Add a Windows section for Linux oci on LCOW
When creating a default OCI spec on Windows that is targeting the LCOW platform it needs to contain a Windows section as well. This adds the Windows section by default. It also protects against this case for all OCI creation that doesnt use the OCI package in the runhcs-shim. Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
This commit is contained in:
@@ -73,6 +73,44 @@ func TestGenerateSpec(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateSpecWithPlatform(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx := namespaces.WithNamespace(context.Background(), "testing")
|
||||
platforms := []string{"windows/amd64", "linux/amd64"}
|
||||
for _, p := range platforms {
|
||||
t.Logf("Testing platform: %s", p)
|
||||
s, err := GenerateSpecWithPlatform(ctx, nil, p, &containers.Container{ID: t.Name()})
|
||||
if err != nil {
|
||||
t.Fatalf("failed to generate spec: %v", err)
|
||||
}
|
||||
|
||||
if s.Root == nil {
|
||||
t.Fatal("expected non nil Root section.")
|
||||
}
|
||||
if s.Process == nil {
|
||||
t.Fatal("expected non nil Process section.")
|
||||
}
|
||||
if p == "windows/amd64" {
|
||||
if s.Linux != nil {
|
||||
t.Fatal("expected nil Linux section")
|
||||
}
|
||||
if s.Windows == nil {
|
||||
t.Fatal("expected non nil Windows section")
|
||||
}
|
||||
} else {
|
||||
if s.Linux == nil {
|
||||
t.Fatal("expected non nil Linux section")
|
||||
}
|
||||
if runtime.GOOS == "windows" && s.Windows == nil {
|
||||
t.Fatal("expected non nil Windows section for LCOW")
|
||||
} else if runtime.GOOS != "windows" && s.Windows != nil {
|
||||
t.Fatal("expected nil Windows section")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSpecWithTTY(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user