@@ -156,6 +156,7 @@ func TestJail(t *testing.T) {
156156 jailerCfg JailerConfig
157157 expectedArgs []string
158158 netns string
159+ socketPath string
159160 expectedSockPath string
160161 }{
161162 {
@@ -183,6 +184,8 @@ func TestJail(t *testing.T) {
183184 "--" ,
184185 "--seccomp-level" ,
185186 "0" ,
187+ "--api-sock" ,
188+ "/run/firecracker.socket" ,
186189 },
187190 expectedSockPath : filepath .Join (
188191 defaultJailerPath ,
@@ -218,6 +221,8 @@ func TestJail(t *testing.T) {
218221 "--" ,
219222 "--seccomp-level" ,
220223 "0" ,
224+ "--api-sock" ,
225+ "/run/firecracker.socket" ,
221226 },
222227 expectedSockPath : filepath .Join (
223228 defaultJailerPath ,
@@ -259,6 +264,8 @@ func TestJail(t *testing.T) {
259264 "--" ,
260265 "--seccomp-level" ,
261266 "0" ,
267+ "--api-sock" ,
268+ "/run/firecracker.socket" ,
262269 },
263270 expectedSockPath : filepath .Join (
264271 "/tmp" ,
@@ -268,6 +275,42 @@ func TestJail(t *testing.T) {
268275 "run" ,
269276 "firecracker.socket" ),
270277 },
278+ {
279+ name : "custom socket path" ,
280+ socketPath : "api.sock" ,
281+ jailerCfg : JailerConfig {
282+ ID : "my-test-id" ,
283+ UID : Int (123 ),
284+ GID : Int (100 ),
285+ NumaNode : Int (0 ),
286+ ChrootStrategy : NewNaiveChrootStrategy ("path" , "kernel-image-path" ),
287+ ExecFile : "/path/to/firecracker" ,
288+ },
289+ expectedArgs : []string {
290+ defaultJailerBin ,
291+ "--id" ,
292+ "my-test-id" ,
293+ "--uid" ,
294+ "123" ,
295+ "--gid" ,
296+ "100" ,
297+ "--exec-file" ,
298+ "/path/to/firecracker" ,
299+ "--node" ,
300+ "0" ,
301+ "--" ,
302+ "--seccomp-level" ,
303+ "0" ,
304+ "--api-sock" ,
305+ "api.sock" ,
306+ },
307+ expectedSockPath : filepath .Join (
308+ defaultJailerPath ,
309+ "firecracker" ,
310+ "my-test-id" ,
311+ rootfsFolderName ,
312+ "api.sock" ),
313+ },
271314 }
272315 for _ , c := range testCases {
273316 t .Run (c .name , func (t * testing.T ) {
@@ -277,8 +320,9 @@ func TestJail(t *testing.T) {
277320 },
278321 }
279322 cfg := & Config {
280- JailerCfg : & c .jailerCfg ,
281- NetNS : c .netns ,
323+ JailerCfg : & c .jailerCfg ,
324+ NetNS : c .netns ,
325+ SocketPath : c .socketPath ,
282326 }
283327 jail (context .Background (), m , cfg )
284328
0 commit comments