|
1 | 1 | package osversion |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "fmt" |
4 | 5 | "testing" |
5 | 6 | ) |
6 | 7 |
|
7 | | -// Test the platform compatibility of the different |
8 | | -// OS Versions considering two ltsc container image |
9 | | -// versions (ltsc2019, ltsc2022) |
| 8 | +// Test the platform compatibility of the different OS Versions |
10 | 9 | func Test_PlatformCompat(t *testing.T) { |
11 | | - for testName, tc := range map[string]struct { |
12 | | - hostOs uint16 |
13 | | - ctrOs uint16 |
| 10 | + for _, tc := range []struct { |
| 11 | + hostOS uint16 |
| 12 | + ctrOS uint16 |
14 | 13 | shouldRun bool |
15 | 14 | }{ |
16 | | - "RS5Host_ltsc2019": { |
17 | | - hostOs: RS5, |
18 | | - ctrOs: RS5, |
| 15 | + { |
| 16 | + hostOS: LTSC2019, |
| 17 | + ctrOS: LTSC2019, |
19 | 18 | shouldRun: true, |
20 | 19 | }, |
21 | | - "RS5Host_ltsc2022": { |
22 | | - hostOs: RS5, |
23 | | - ctrOs: V21H2Server, |
| 20 | + { |
| 21 | + hostOS: LTSC2019, |
| 22 | + ctrOS: LTSC2022, |
24 | 23 | shouldRun: false, |
25 | 24 | }, |
26 | | - "WS2022Host_ltsc2019": { |
27 | | - hostOs: V21H2Server, |
28 | | - ctrOs: RS5, |
| 25 | + { |
| 26 | + hostOS: LTSC2022, |
| 27 | + ctrOS: LTSC2019, |
29 | 28 | shouldRun: false, |
30 | 29 | }, |
31 | | - "WS2022Host_ltsc2022": { |
32 | | - hostOs: V21H2Server, |
33 | | - ctrOs: V21H2Server, |
| 30 | + { |
| 31 | + hostOS: LTSC2022, |
| 32 | + ctrOS: LTSC2022, |
34 | 33 | shouldRun: true, |
35 | 34 | }, |
36 | | - "Wind11Host_ltsc2019": { |
37 | | - hostOs: V22H2Win11, |
38 | | - ctrOs: RS5, |
| 35 | + { |
| 36 | + hostOS: V22H2Win11, |
| 37 | + ctrOS: LTSC2019, |
39 | 38 | shouldRun: false, |
40 | 39 | }, |
41 | | - "Wind11Host_ltsc2022": { |
42 | | - hostOs: V22H2Win11, |
43 | | - ctrOs: V21H2Server, |
| 40 | + { |
| 41 | + hostOS: V22H2Win11, |
| 42 | + ctrOS: LTSC2022, |
| 43 | + shouldRun: true, |
| 44 | + }, |
| 45 | + { |
| 46 | + hostOS: LTSC2025, |
| 47 | + ctrOS: LTSC2022, |
| 48 | + shouldRun: true, |
| 49 | + }, |
| 50 | + { |
| 51 | + hostOS: LTSC2022, |
| 52 | + ctrOS: LTSC2025, |
| 53 | + shouldRun: false, |
| 54 | + }, |
| 55 | + { |
| 56 | + hostOS: LTSC2022, |
| 57 | + ctrOS: V22H2Win11, |
| 58 | + shouldRun: false, |
| 59 | + }, |
| 60 | + { |
| 61 | + hostOS: LTSC2025, |
| 62 | + ctrOS: V22H2Win11, |
44 | 63 | shouldRun: true, |
45 | 64 | }, |
46 | 65 | } { |
47 | | - // Check if ltsc2019/ltsc2022 guest images are compatible on |
48 | | - // the given host OS versions |
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" |
| 66 | + t.Run(fmt.Sprintf("Host_%d_Ctr_%d", tc.hostOS, tc.ctrOS), func(t *testing.T) { |
| 67 | + hostOSVersion := OSVersion{ |
| 68 | + MajorVersion: 10, |
| 69 | + MinorVersion: 0, |
| 70 | + Build: tc.hostOS, |
| 71 | + } |
| 72 | + ctrOSVersion := OSVersion{ |
| 73 | + MajorVersion: 10, |
| 74 | + MinorVersion: 0, |
| 75 | + Build: tc.ctrOS, |
| 76 | + } |
| 77 | + if CheckHostAndContainerCompat(hostOSVersion, ctrOSVersion) != tc.shouldRun { |
| 78 | + var expectedResultStr string |
| 79 | + if !tc.shouldRun { |
| 80 | + expectedResultStr = " NOT" |
| 81 | + } |
| 82 | + t.Fatalf("host %v should%s be able to run guest %v", tc.hostOS, expectedResultStr, tc.ctrOS) |
64 | 83 | } |
65 | | - t.Fatalf("Failed %v: host %v should%s be able to run guest %v", testName, tc.hostOs, expectedResultStr, tc.ctrOs) |
66 | | - } |
| 84 | + }) |
67 | 85 | } |
68 | 86 | } |
0 commit comments