...
1 package osversion
2
3 import (
4 "testing"
5 )
6
7
8
9
10 func Test_PlatformCompat(t *testing.T) {
11 for testName, tc := range map[string]struct {
12 hostOs uint16
13 ctrOs uint16
14 shouldRun bool
15 }{
16 "RS5Host_ltsc2019": {
17 hostOs: RS5,
18 ctrOs: RS5,
19 shouldRun: true,
20 },
21 "RS5Host_ltsc2022": {
22 hostOs: RS5,
23 ctrOs: V21H2Server,
24 shouldRun: false,
25 },
26 "WS2022Host_ltsc2019": {
27 hostOs: V21H2Server,
28 ctrOs: RS5,
29 shouldRun: false,
30 },
31 "WS2022Host_ltsc2022": {
32 hostOs: V21H2Server,
33 ctrOs: V21H2Server,
34 shouldRun: true,
35 },
36 "Wind11Host_ltsc2019": {
37 hostOs: V22H2Win11,
38 ctrOs: RS5,
39 shouldRun: false,
40 },
41 "Wind11Host_ltsc2022": {
42 hostOs: V22H2Win11,
43 ctrOs: V21H2Server,
44 shouldRun: true,
45 },
46 } {
47
48
49
50 hostOSVersion := OSVersion{
51 MajorVersion: 10,
52 MinorVersion: 0,
53 Build: tc.hostOs,
54 }
55 ctrOSVersion := OSVersion{
56 MajorVersion: 10,
57 MinorVersion: 0,
58 Build: tc.ctrOs,
59 }
60 if CheckHostAndContainerCompat(hostOSVersion, ctrOSVersion) != tc.shouldRun {
61 var expectedResultStr string
62 if !tc.shouldRun {
63 expectedResultStr = " NOT"
64 }
65 t.Fatalf("Failed %v: host %v should%s be able to run guest %v", testName, tc.hostOs, expectedResultStr, tc.ctrOs)
66 }
67 }
68 }
69
View as plain text