@@ -18,7 +18,7 @@ func TestEssentialRequiresRoot(t *testing.T) {
1818 if os .Getuid () == 0 {
1919 t .Skip ("test must run as non-root" )
2020 }
21- err := Essential (slog .Default ())
21+ err := Essential (slog .Default (), 0 )
2222 assert .Error (t , err )
2323}
2424
@@ -31,20 +31,30 @@ func TestWorkspaceReturnsErrorForInvalidMount(t *testing.T) {
3131 assert .Error (t , err )
3232}
3333
34- func TestEssentialMountPoints (t * testing.T ) {
34+ func TestEssentialMounts (t * testing.T ) {
3535 t .Parallel ()
3636
37- // Verify the mount table contains the expected entries.
38- expected := []string {"/proc" , "/sys" , "/dev" , "/dev/pts" , "/tmp" , "/run" }
39- mounts := []mountEntry {
40- {"proc" , "/proc" , "proc" , 0 , "" },
41- {"sysfs" , "/sys" , "sysfs" , 0 , "" },
42- {"devtmpfs" , "/dev" , "devtmpfs" , 0 , "" },
43- {"devpts" , "/dev/pts" , "devpts" , 0 , "newinstance,ptmxmode=0666,mode=0620,gid=5" },
44- {"tmpfs" , "/tmp" , "tmpfs" , 0 , "size=256m" },
45- {"tmpfs" , "/run" , "tmpfs" , 0 , "size=64m" },
46- }
47- for i , m := range mounts {
48- assert .Equal (t , expected [i ], m .target )
49- }
37+ t .Run ("default targets" , func (t * testing.T ) {
38+ t .Parallel ()
39+ mounts := EssentialMountsForTest (0 )
40+ expected := []string {"/proc" , "/sys" , "/dev" , "/dev/pts" , "/tmp" , "/run" }
41+ targets := make ([]string , len (mounts ))
42+ for i , m := range mounts {
43+ targets [i ] = m .target
44+ }
45+ assert .Equal (t , expected , targets )
46+ })
47+
48+ t .Run ("zero uses default tmp size" , func (t * testing.T ) {
49+ t .Parallel ()
50+ mounts := EssentialMountsForTest (0 )
51+ // /tmp is the 5th entry.
52+ assert .Equal (t , "size=256m" , mounts [4 ].data )
53+ })
54+
55+ t .Run ("custom tmp size flows through" , func (t * testing.T ) {
56+ t .Parallel ()
57+ mounts := EssentialMountsForTest (512 )
58+ assert .Equal (t , "size=512m" , mounts [4 ].data )
59+ })
5060}
0 commit comments