@@ -33,9 +33,10 @@ import (
33
33
"github.com/firecracker-microvm/firecracker-containerd/internal"
34
34
)
35
35
36
- func TestBuildJailedRootHandler_Isolated (t * testing.T ) {
37
- internal .RequiresIsolation (t )
36
+ func TestBuildJailedRootHandler (t * testing.T ) {
37
+ internal .RequiresRoot (t )
38
38
dir := t .TempDir ()
39
+ ctx := context .Background ()
39
40
40
41
kernelImagePath := filepath .Join (dir , "kernel-image" )
41
42
kernelImageFd , err := os .OpenFile (kernelImagePath , os .O_CREATE , 0600 )
@@ -61,7 +62,7 @@ func TestBuildJailedRootHandler_Isolated(t *testing.T) {
61
62
GID : 456 ,
62
63
}
63
64
vmID := "foo"
64
- jailer , err := newRuncJailer (context . Background () , l , vmID , runcConfig , []* proto.FirecrackerDriveMount {})
65
+ jailer , err := newRuncJailer (ctx , l , vmID , runcConfig , []* proto.FirecrackerDriveMount {})
65
66
require .NoError (t , err , "failed to create runc jailer" )
66
67
67
68
cfg := config.Config {
@@ -85,7 +86,7 @@ func TestBuildJailedRootHandler_Isolated(t *testing.T) {
85
86
machine := firecracker.Machine {
86
87
Cfg : machineConfig ,
87
88
}
88
- err = handler .Fn (context . Background () , & machine )
89
+ err = handler .Fn (ctx , & machine )
89
90
assert .NoError (t , err , "jailed handler failed to run" )
90
91
91
92
_ , err = os .Stat (filepath .Join (dir , "config.json" ))
@@ -101,9 +102,9 @@ func TestBuildJailedRootHandler_Isolated(t *testing.T) {
101
102
assert .NoError (t , err , "failed to create root drive" )
102
103
}
103
104
104
- func TestMkdirAllWithPermissions_Isolated (t * testing.T ) {
105
+ func TestMkdirAllWithPermissions (t * testing.T ) {
105
106
// requires isolation so we can change uid/gid of files
106
- internal .RequiresIsolation (t )
107
+ internal .RequiresRoot (t )
107
108
108
109
tmpdir := t .TempDir ()
109
110
@@ -132,9 +133,9 @@ func TestMkdirAllWithPermissions_Isolated(t *testing.T) {
132
133
assert .Equal (t , newgid , newlyCreatedPathStat .Sys ().(* syscall.Stat_t ).Gid )
133
134
}
134
135
135
- func TestBindMountToJail_Isolated (t * testing.T ) {
136
+ func TestBindMountToJail (t * testing.T ) {
136
137
// The user must be root to call chown.
137
- internal .RequiresIsolation (t )
138
+ internal .RequiresRoot (t )
138
139
139
140
dir := t .TempDir ()
140
141
@@ -167,9 +168,10 @@ func TestBindMountToJail_Isolated(t *testing.T) {
167
168
require .Error (t , err )
168
169
}
169
170
170
- func TestFifoHandler_Isolated (t * testing.T ) {
171
+ func TestFifoHandler (t * testing.T ) {
171
172
// Because of chown(2).
172
- internal .RequiresIsolation (t )
173
+ internal .RequiresRoot (t )
174
+ ctx := context .Background ()
173
175
174
176
testcases := []struct {
175
177
name string
@@ -215,15 +217,8 @@ func TestFifoHandler_Isolated(t *testing.T) {
215
217
require .NoError (t , err )
216
218
217
219
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 )
227
222
require .NoError (t , err )
228
223
})
229
224
}
0 commit comments