aboutsummaryrefslogtreecommitdiffhomepage
path: root/hst/fsephemeral_test.go
blob: f003a9287665ca86c0560a9d91d92e643375e9b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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, "<invalid>"},

		{"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"},
	})
}