@@ -19,6 +19,7 @@ import (
1919 "encoding/base64"
2020 "encoding/json"
2121 "runtime"
22+ "strings"
2223 "testing"
2324
2425 "github.com/moby/buildkit/client/llb"
@@ -249,7 +250,7 @@ func TestPackSetAnnotations(t *testing.T) {
249250 type testInfo struct {
250251 name string
251252 version string
252- cmd string
253+ cmd [] string
253254 kPath string
254255 rPath string
255256 rType string
@@ -259,21 +260,21 @@ func TestPackSetAnnotations(t *testing.T) {
259260 tests := []testInfo {
260261 {
261262 name : "Valid without version and rootfs" ,
262- cmd : "cli" ,
263+ cmd : [] string { "cli" } ,
263264 kPath : "kernel" ,
264265 expectError : false ,
265266 },
266267 {
267268 name : "Valid with version but without rootfs" ,
268269 version : "v0.1.1" ,
269- cmd : "cli" ,
270+ cmd : [] string { "cli" } ,
270271 kPath : "kernel" ,
271272 expectError : false ,
272273 },
273274 {
274275 name : "Valid with version and initrd rootfs" ,
275276 version : "v0.1.1" ,
276- cmd : "cli" ,
277+ cmd : [] string { "cli" } ,
277278 kPath : "kernel" ,
278279 rPath : "kernel" ,
279280 rType : "initrd" ,
@@ -282,15 +283,15 @@ func TestPackSetAnnotations(t *testing.T) {
282283 {
283284 name : "Valid with version and raw rootfs" ,
284285 version : "v0.1.1" ,
285- cmd : "cli" ,
286+ cmd : [] string { "cli" } ,
286287 kPath : "kernel" ,
287288 rType : "raw" ,
288289 expectError : false ,
289290 },
290291 {
291292 name : "Invalid rootfs type" ,
292293 version : "v0.1.1" ,
293- cmd : "cli" ,
294+ cmd : [] string { "cli" } ,
294295 kPath : "kernel" ,
295296 rType : "foo" ,
296297 expectError : true ,
@@ -317,7 +318,7 @@ func TestPackSetAnnotations(t *testing.T) {
317318 require .Equal (t , p .Framework , i .Annots ["com.urunc.unikernel.unikernelType" ])
318319 require .Equal (t , p .Monitor , i .Annots ["com.urunc.unikernel.hypervisor" ])
319320 require .Equal (t , p .Version , i .Annots ["com.urunc.unikernel.unikernelVersion" ])
320- require .Equal (t , tc .cmd , i .Annots ["com.urunc.unikernel.cmdline" ])
321+ require .Equal (t , strings . Join ( tc .cmd , " " ) , i .Annots ["com.urunc.unikernel.cmdline" ])
321322 require .Equal (t , tc .kPath , i .Annots ["com.urunc.unikernel.binary" ])
322323 if tc .rType == "raw" {
323324 require .Equal (t , "true" , i .Annots ["com.urunc.unikernel.mountRootfs" ])
@@ -628,15 +629,15 @@ func TestPackToPack(t *testing.T) {
628629 From : "local" ,
629630 Path : "kernel" ,
630631 },
631- Cmd : "cmd" ,
632+ Cmd : [] string { "cmd" } ,
632633 }
633634 i , err := ToPack (hops , "context" )
634635 require .NoError (t , err )
635636 require .NotNil (t , i )
636637 require .Equal (t , "false" , i .Annots ["com.urunc.unikernel.mountRootfs" ])
637638 require .Equal (t , hops .Platform .Framework , i .Annots ["com.urunc.unikernel.unikernelType" ])
638639 require .Equal (t , hops .Platform .Monitor , i .Annots ["com.urunc.unikernel.hypervisor" ])
639- require .Equal (t , hops .Cmd , i .Annots ["com.urunc.unikernel.cmdline" ])
640+ require .Equal (t , strings . Join ( hops .Cmd , " " ) , i .Annots ["com.urunc.unikernel.cmdline" ])
640641 require .Equal (t , DefaultKernelPath , i .Annots ["com.urunc.unikernel.binary" ])
641642 require .Empty (t , i .Annots ["com.urunc.unikernel.initrd" ])
642643 require .Empty (t , i .Annots ["com.urunc.unikernel.unikernelVersion" ])
@@ -668,15 +669,15 @@ func TestPackToPack(t *testing.T) {
668669 From : "harbor.nbfc.io/foo" ,
669670 Path : "/kernel" ,
670671 },
671- Cmd : "cmd" ,
672+ Cmd : [] string { "cmd" } ,
672673 }
673674 i , err := ToPack (hops , "foo" )
674675 require .NoError (t , err )
675676 require .NotNil (t , i )
676677 require .Equal (t , "false" , i .Annots ["com.urunc.unikernel.mountRootfs" ])
677678 require .Equal (t , hops .Platform .Framework , i .Annots ["com.urunc.unikernel.unikernelType" ])
678679 require .Equal (t , hops .Platform .Monitor , i .Annots ["com.urunc.unikernel.hypervisor" ])
679- require .Equal (t , hops .Cmd , i .Annots ["com.urunc.unikernel.cmdline" ])
680+ require .Equal (t , strings . Join ( hops .Cmd , " " ) , i .Annots ["com.urunc.unikernel.cmdline" ])
680681 require .Equal (t , hops .Kernel .Path , i .Annots ["com.urunc.unikernel.binary" ])
681682 require .Empty (t , i .Annots ["com.urunc.unikernel.initrd" ])
682683 require .Empty (t , i .Annots ["com.urunc.unikernel.unikernelVersion" ])
@@ -705,15 +706,15 @@ func TestPackToPack(t *testing.T) {
705706 From : "local" ,
706707 Path : "rootfs" ,
707708 },
708- Cmd : "cmd" ,
709+ Cmd : [] string { "cmd" } ,
709710 }
710711 i , err := ToPack (hops , "context" )
711712 require .NoError (t , err )
712713 require .NotNil (t , i )
713714 require .Equal (t , "false" , i .Annots ["com.urunc.unikernel.mountRootfs" ])
714715 require .Equal (t , hops .Platform .Framework , i .Annots ["com.urunc.unikernel.unikernelType" ])
715716 require .Equal (t , hops .Platform .Monitor , i .Annots ["com.urunc.unikernel.hypervisor" ])
716- require .Equal (t , hops .Cmd , i .Annots ["com.urunc.unikernel.cmdline" ])
717+ require .Equal (t , strings . Join ( hops .Cmd , " " ) , i .Annots ["com.urunc.unikernel.cmdline" ])
717718 require .Equal (t , DefaultKernelPath , i .Annots ["com.urunc.unikernel.binary" ])
718719 require .Equal (t , DefaultRootfsPath , i .Annots ["com.urunc.unikernel.initrd" ])
719720 require .Empty (t , i .Annots ["com.urunc.unikernel.unikernelVersion" ])
@@ -759,7 +760,7 @@ func TestPackToPack(t *testing.T) {
759760 Path : "rootfs" ,
760761 Type : "initrd" ,
761762 },
762- Cmd : "cmd" ,
763+ Cmd : [] string { "cmd" } ,
763764 }
764765 i , err := ToPack (hops , "context" )
765766 require .NoError (t , err )
@@ -768,7 +769,7 @@ func TestPackToPack(t *testing.T) {
768769 require .Equal (t , hops .Platform .Framework , i .Annots ["com.urunc.unikernel.unikernelType" ])
769770 require .Equal (t , hops .Platform .Monitor , i .Annots ["com.urunc.unikernel.hypervisor" ])
770771 require .Equal (t , hops .Platform .Version , i .Annots ["com.urunc.unikernel.unikernelVersion" ])
771- require .Equal (t , hops .Cmd , i .Annots ["com.urunc.unikernel.cmdline" ])
772+ require .Equal (t , strings . Join ( hops .Cmd , " " ) , i .Annots ["com.urunc.unikernel.cmdline" ])
772773 require .Equal (t , DefaultKernelPath , i .Annots ["com.urunc.unikernel.binary" ])
773774 require .Equal (t , DefaultRootfsPath , i .Annots ["com.urunc.unikernel.initrd" ])
774775 require .Empty (t , i .Annots ["com.urunc.unikernel.blkMntPoint" ])
@@ -813,15 +814,15 @@ func TestPackToPack(t *testing.T) {
813814 Path : "rootfs" ,
814815 Type : "initrd" ,
815816 },
816- Cmd : "cmd" ,
817+ Cmd : [] string { "cmd" } ,
817818 }
818819 i , err := ToPack (hops , "context" )
819820 require .NoError (t , err )
820821 require .NotNil (t , i )
821822 require .Equal (t , "false" , i .Annots ["com.urunc.unikernel.mountRootfs" ])
822823 require .Equal (t , hops .Platform .Framework , i .Annots ["com.urunc.unikernel.unikernelType" ])
823824 require .Equal (t , hops .Platform .Monitor , i .Annots ["com.urunc.unikernel.hypervisor" ])
824- require .Equal (t , hops .Cmd , i .Annots ["com.urunc.unikernel.cmdline" ])
825+ require .Equal (t , strings . Join ( hops .Cmd , " " ) , i .Annots ["com.urunc.unikernel.cmdline" ])
825826 require .Equal (t , DefaultKernelPath , i .Annots ["com.urunc.unikernel.binary" ])
826827 require .Equal (t , hops .Rootfs .Path , i .Annots ["com.urunc.unikernel.initrd" ])
827828 require .Empty (t , i .Annots ["com.urunc.unikernel.unikernelVersion" ])
@@ -858,15 +859,15 @@ func TestPackToPack(t *testing.T) {
858859 Rootfs : Rootfs {
859860 From : "harbor.nbfc.io/foo" ,
860861 },
861- Cmd : "cmd" ,
862+ Cmd : [] string { "cmd" } ,
862863 }
863864 i , err := ToPack (hops , "context" )
864865 require .NoError (t , err )
865866 require .NotNil (t , i )
866867 require .Equal (t , "true" , i .Annots ["com.urunc.unikernel.mountRootfs" ])
867868 require .Equal (t , hops .Platform .Framework , i .Annots ["com.urunc.unikernel.unikernelType" ])
868869 require .Equal (t , hops .Platform .Monitor , i .Annots ["com.urunc.unikernel.hypervisor" ])
869- require .Equal (t , hops .Cmd , i .Annots ["com.urunc.unikernel.cmdline" ])
870+ require .Equal (t , strings . Join ( hops .Cmd , " " ) , i .Annots ["com.urunc.unikernel.cmdline" ])
870871 require .Equal (t , DefaultKernelPath , i .Annots ["com.urunc.unikernel.binary" ])
871872 require .Empty (t , i .Annots ["com.urunc.unikernel.initrd" ])
872873 require .Empty (t , i .Annots ["com.urunc.unikernel.unikernelVersion" ])
@@ -903,15 +904,15 @@ func TestPackToPack(t *testing.T) {
903904 From : "scratch" ,
904905 Includes : []string {"foo:bar" },
905906 },
906- Cmd : "cmd" ,
907+ Cmd : [] string { "cmd" } ,
907908 }
908909 i , err := ToPack (hops , "context" )
909910 require .NoError (t , err )
910911 require .NotNil (t , i )
911912 require .Equal (t , "false" , i .Annots ["com.urunc.unikernel.mountRootfs" ])
912913 require .Equal (t , hops .Platform .Framework , i .Annots ["com.urunc.unikernel.unikernelType" ])
913914 require .Equal (t , hops .Platform .Monitor , i .Annots ["com.urunc.unikernel.hypervisor" ])
914- require .Equal (t , hops .Cmd , i .Annots ["com.urunc.unikernel.cmdline" ])
915+ require .Equal (t , strings . Join ( hops .Cmd , " " ) , i .Annots ["com.urunc.unikernel.cmdline" ])
915916 require .Equal (t , DefaultKernelPath , i .Annots ["com.urunc.unikernel.binary" ])
916917 require .Equal (t , DefaultRootfsPath , i .Annots ["com.urunc.unikernel.initrd" ])
917918 require .Empty (t , i .Annots ["com.urunc.unikernel.unikernelVersion" ])
@@ -960,15 +961,15 @@ func TestPackToPack(t *testing.T) {
960961 From : "scratch" ,
961962 Includes : []string {"foo:bar" },
962963 },
963- Cmd : "cmd" ,
964+ Cmd : [] string { "cmd" } ,
964965 }
965966 i , err := ToPack (hops , "context" )
966967 require .NoError (t , err )
967968 require .NotNil (t , i )
968969 require .Equal (t , "true" , i .Annots ["com.urunc.unikernel.mountRootfs" ])
969970 require .Equal (t , hops .Platform .Framework , i .Annots ["com.urunc.unikernel.unikernelType" ])
970971 require .Equal (t , hops .Platform .Monitor , i .Annots ["com.urunc.unikernel.hypervisor" ])
971- require .Equal (t , hops .Cmd , i .Annots ["com.urunc.unikernel.cmdline" ])
972+ require .Equal (t , strings . Join ( hops .Cmd , " " ) , i .Annots ["com.urunc.unikernel.cmdline" ])
972973 require .Equal (t , DefaultKernelPath , i .Annots ["com.urunc.unikernel.binary" ])
973974 require .Empty (t , i .Annots ["com.urunc.unikernel.initrd" ])
974975 require .Empty (t , i .Annots ["com.urunc.unikernel.unikernelVersion" ])
@@ -1008,15 +1009,15 @@ func TestPackToPack(t *testing.T) {
10081009 From : "local" ,
10091010 Path : "rootfs" ,
10101011 },
1011- Cmd : "cmd" ,
1012+ Cmd : [] string { "cmd" } ,
10121013 }
10131014 i , err := ToPack (hops , "context" )
10141015 require .NoError (t , err )
10151016 require .NotNil (t , i )
10161017 require .Equal (t , "false" , i .Annots ["com.urunc.unikernel.mountRootfs" ])
10171018 require .Equal (t , hops .Platform .Framework , i .Annots ["com.urunc.unikernel.unikernelType" ])
10181019 require .Equal (t , hops .Platform .Monitor , i .Annots ["com.urunc.unikernel.hypervisor" ])
1019- require .Equal (t , hops .Cmd , i .Annots ["com.urunc.unikernel.cmdline" ])
1020+ require .Equal (t , strings . Join ( hops .Cmd , " " ) , i .Annots ["com.urunc.unikernel.cmdline" ])
10201021 require .Equal (t , hops .Kernel .Path , i .Annots ["com.urunc.unikernel.binary" ])
10211022 require .Equal (t , DefaultRootfsPath , i .Annots ["com.urunc.unikernel.initrd" ])
10221023 require .Empty (t , i .Annots ["com.urunc.unikernel.unikernelVersion" ])
@@ -1055,15 +1056,15 @@ func TestPackToPack(t *testing.T) {
10551056 Path : "rootfs" ,
10561057 Type : "initrd" ,
10571058 },
1058- Cmd : "cmd" ,
1059+ Cmd : [] string { "cmd" } ,
10591060 }
10601061 i , err := ToPack (hops , "context" )
10611062 require .NoError (t , err )
10621063 require .NotNil (t , i )
10631064 require .Equal (t , "false" , i .Annots ["com.urunc.unikernel.mountRootfs" ])
10641065 require .Equal (t , hops .Platform .Framework , i .Annots ["com.urunc.unikernel.unikernelType" ])
10651066 require .Equal (t , hops .Platform .Monitor , i .Annots ["com.urunc.unikernel.hypervisor" ])
1066- require .Equal (t , hops .Cmd , i .Annots ["com.urunc.unikernel.cmdline" ])
1067+ require .Equal (t , strings . Join ( hops .Cmd , " " ) , i .Annots ["com.urunc.unikernel.cmdline" ])
10671068 require .Equal (t , DefaultKernelPath , i .Annots ["com.urunc.unikernel.binary" ])
10681069 require .Equal (t , hops .Rootfs .Path , i .Annots ["com.urunc.unikernel.initrd" ])
10691070 require .Empty (t , i .Annots ["com.urunc.unikernel.unikernelVersion" ])
@@ -1100,15 +1101,15 @@ func TestPackToPack(t *testing.T) {
11001101 Rootfs : Rootfs {
11011102 From : "harbor.nbfc.io/foo" ,
11021103 },
1103- Cmd : "cmd" ,
1104+ Cmd : [] string { "cmd" } ,
11041105 }
11051106 i , err := ToPack (hops , "context" )
11061107 require .NoError (t , err )
11071108 require .NotNil (t , i )
11081109 require .Equal (t , "true" , i .Annots ["com.urunc.unikernel.mountRootfs" ])
11091110 require .Equal (t , hops .Platform .Framework , i .Annots ["com.urunc.unikernel.unikernelType" ])
11101111 require .Equal (t , hops .Platform .Monitor , i .Annots ["com.urunc.unikernel.hypervisor" ])
1111- require .Equal (t , hops .Cmd , i .Annots ["com.urunc.unikernel.cmdline" ])
1112+ require .Equal (t , strings . Join ( hops .Cmd , " " ) , i .Annots ["com.urunc.unikernel.cmdline" ])
11121113 require .Equal (t , DefaultKernelPath , i .Annots ["com.urunc.unikernel.binary" ])
11131114 require .Empty (t , i .Annots ["com.urunc.unikernel.initrd" ])
11141115 require .Empty (t , i .Annots ["com.urunc.unikernel.unikernelVersion" ])
@@ -1145,15 +1146,15 @@ func TestPackToPack(t *testing.T) {
11451146 From : "scratch" ,
11461147 Includes : []string {"foo:bar" },
11471148 },
1148- Cmd : "cmd" ,
1149+ Cmd : [] string { "cmd" } ,
11491150 }
11501151 i , err := ToPack (hops , "context" )
11511152 require .NoError (t , err )
11521153 require .NotNil (t , i )
11531154 require .Equal (t , "false" , i .Annots ["com.urunc.unikernel.mountRootfs" ])
11541155 require .Equal (t , hops .Platform .Framework , i .Annots ["com.urunc.unikernel.unikernelType" ])
11551156 require .Equal (t , hops .Platform .Monitor , i .Annots ["com.urunc.unikernel.hypervisor" ])
1156- require .Equal (t , hops .Cmd , i .Annots ["com.urunc.unikernel.cmdline" ])
1157+ require .Equal (t , strings . Join ( hops .Cmd , " " ) , i .Annots ["com.urunc.unikernel.cmdline" ])
11571158 require .Equal (t , hops .Kernel .Path , i .Annots ["com.urunc.unikernel.binary" ])
11581159 require .Equal (t , DefaultRootfsPath , i .Annots ["com.urunc.unikernel.initrd" ])
11591160 require .Empty (t , i .Annots ["com.urunc.unikernel.unikernelVersion" ])
@@ -1196,7 +1197,7 @@ func TestPackToPack(t *testing.T) {
11961197 Path : "kernel" ,
11971198 Type : "foo" ,
11981199 },
1199- Cmd : "cmd" ,
1200+ Cmd : [] string { "cmd" } ,
12001201 }
12011202 i , err := ToPack (hops , "context" )
12021203 require .ErrorContains (t , err , "Error handling rootfs entry" )
@@ -1217,7 +1218,7 @@ func TestPackToPack(t *testing.T) {
12171218 // Rootfs: Rootfs{
12181219 // From: "harbor.nbfc.io/foo",
12191220 // },
1220- // Cmd: "cmd",
1221+ // Cmd: []string{ "cmd"} ,
12211222 // }
12221223 // i, err := ToPack(hops, "context")
12231224 // require.ErrorContains(t, err, "unikraft does not support raw rootfs")
@@ -1237,7 +1238,7 @@ func TestPackToPack(t *testing.T) {
12371238 From : "scratch" ,
12381239 Includes : []string {":bar" },
12391240 },
1240- Cmd : "cmd" ,
1241+ Cmd : [] string { "cmd" } ,
12411242 }
12421243 i , err := ToPack (hops , "context" )
12431244 require .ErrorContains (t , err , "Error handling rootfs entry" )
@@ -1251,7 +1252,7 @@ func TestPackToPack(t *testing.T) {
12511252 },
12521253 Kernel : Kernel {},
12531254 Rootfs : Rootfs {},
1254- Cmd : "cmd" ,
1255+ Cmd : [] string { "cmd" } ,
12551256 }
12561257 i , err := ToPack (hops , "context" )
12571258 require .ErrorContains (t , err , "Error choosing base state" )
0 commit comments