@@ -33,9 +33,10 @@ import (
3333 "github.com/firecracker-microvm/firecracker-containerd/internal"
3434)
3535
36- func TestBuildJailedRootHandler_Isolated (t * testing.T ) {
37- internal .RequiresIsolation (t )
36+ func TestBuildJailedRootHandler (t * testing.T ) {
37+ internal .RequiresRoot (t )
3838 dir := t .TempDir ()
39+ ctx := context .Background ()
3940
4041 kernelImagePath := filepath .Join (dir , "kernel-image" )
4142 kernelImageFd , err := os .OpenFile (kernelImagePath , os .O_CREATE , 0600 )
@@ -61,7 +62,7 @@ func TestBuildJailedRootHandler_Isolated(t *testing.T) {
6162 GID : 456 ,
6263 }
6364 vmID := "foo"
64- jailer , err := newRuncJailer (context . Background () , l , vmID , runcConfig , []* proto.FirecrackerDriveMount {})
65+ jailer , err := newRuncJailer (ctx , l , vmID , runcConfig , []* proto.FirecrackerDriveMount {})
6566 require .NoError (t , err , "failed to create runc jailer" )
6667
6768 cfg := config.Config {
@@ -85,7 +86,7 @@ func TestBuildJailedRootHandler_Isolated(t *testing.T) {
8586 machine := firecracker.Machine {
8687 Cfg : machineConfig ,
8788 }
88- err = handler .Fn (context . Background () , & machine )
89+ err = handler .Fn (ctx , & machine )
8990 assert .NoError (t , err , "jailed handler failed to run" )
9091
9192 _ , err = os .Stat (filepath .Join (dir , "config.json" ))
@@ -101,9 +102,9 @@ func TestBuildJailedRootHandler_Isolated(t *testing.T) {
101102 assert .NoError (t , err , "failed to create root drive" )
102103}
103104
104- func TestMkdirAllWithPermissions_Isolated (t * testing.T ) {
105+ func TestMkdirAllWithPermissions (t * testing.T ) {
105106 // requires isolation so we can change uid/gid of files
106- internal .RequiresIsolation (t )
107+ internal .RequiresRoot (t )
107108
108109 tmpdir := t .TempDir ()
109110
@@ -132,9 +133,9 @@ func TestMkdirAllWithPermissions_Isolated(t *testing.T) {
132133 assert .Equal (t , newgid , newlyCreatedPathStat .Sys ().(* syscall.Stat_t ).Gid )
133134}
134135
135- func TestBindMountToJail_Isolated (t * testing.T ) {
136+ func TestBindMountToJail (t * testing.T ) {
136137 // The user must be root to call chown.
137- internal .RequiresIsolation (t )
138+ internal .RequiresRoot (t )
138139
139140 dir := t .TempDir ()
140141
@@ -167,9 +168,10 @@ func TestBindMountToJail_Isolated(t *testing.T) {
167168 require .Error (t , err )
168169}
169170
170- func TestFifoHandler_Isolated (t * testing.T ) {
171+ func TestFifoHandler (t * testing.T ) {
171172 // Because of chown(2).
172- internal .RequiresIsolation (t )
173+ internal .RequiresRoot (t )
174+ ctx := context .Background ()
173175
174176 testcases := []struct {
175177 name string
@@ -215,15 +217,8 @@ func TestFifoHandler_Isolated(t *testing.T) {
215217 require .NoError (t , err )
216218
217219 handler := j .BuildLinkFifoHandler ()
218- err = handler .Fn (
219- context .Background (),
220- & firecracker.Machine {
221- Cfg : firecracker.Config {
222- LogPath : logPath ,
223- MetricsPath : metricsPath ,
224- },
225- },
226- )
220+ machine := firecracker.Machine {Cfg : firecracker.Config {LogPath : logPath , MetricsPath : metricsPath }}
221+ err = handler .Fn (ctx , & machine )
227222 require .NoError (t , err )
228223 })
229224 }
0 commit comments