From 99ac96511bed17f48d908db3d00a1f48579ba011 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Tue, 12 Aug 2025 04:38:45 +0900 Subject: hst/fs: interface filesystem config This allows mount points to be represented by different underlying structs. Signed-off-by: Ophestra --- hst/fsephemeral_test.go | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 hst/fsephemeral_test.go (limited to 'hst/fsephemeral_test.go') diff --git a/hst/fsephemeral_test.go b/hst/fsephemeral_test.go new file mode 100644 index 00000000..f003a928 --- /dev/null +++ b/hst/fsephemeral_test.go @@ -0,0 +1,50 @@ +package hst_test + +import ( + "syscall" + "testing" + + "hakurei.app/container" + "hakurei.app/hst" +) + +func TestFSEphemeral(t *testing.T) { + checkFs(t, "ephemeral", []fsTestCase{ + {"nil", (*hst.FSEphemeral)(nil), nil, nil, nil, ""}, + + {"full", &hst.FSEphemeral{ + Dst: m("/run/user/65534"), + Write: true, + Size: 1 << 10, + Perm: 0700, + }, container.Ops{&container.MountTmpfsOp{ + FSName: "ephemeral", + Path: m("/run/user/65534"), + Flags: syscall.MS_NOSUID | syscall.MS_NODEV, + Size: 1 << 10, + Perm: 0700, + }}, m("/run/user/65534"), nil, + "w+ephemeral(-rwx------):/run/user/65534"}, + + {"cover ro", &hst.FSEphemeral{Dst: m("/run/nscd")}, + container.Ops{&container.MountTmpfsOp{ + FSName: "readonly", + Path: m("/run/nscd"), + Flags: syscall.MS_NOSUID | syscall.MS_NODEV | syscall.MS_RDONLY, + Perm: 0755, + }}, m("/run/nscd"), nil, + "+ephemeral(-rwxr-xr-x):/run/nscd"}, + + {"negative size", &hst.FSEphemeral{ + Dst: hst.AbsTmp, + Write: true, + Size: -1, + }, container.Ops{&container.MountTmpfsOp{ + FSName: "ephemeral", + Path: hst.AbsTmp, + Flags: syscall.MS_NOSUID | syscall.MS_NODEV, + Perm: 0755, + }}, hst.AbsTmp, nil, + "w+ephemeral(-rwxr-xr-x):/.hakurei"}, + }) +} -- cgit v1.3.1