Jamie Madill | cf4f8c7 | 2021-05-20 19:24:23 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Avi Drissman | dfd88085 | 2022-09-15 20:11:09 | [diff] [blame] | 2 | # Copyright 2020 The Chromium Authors |
Brian Sheedy | a31578e | 2020-05-18 20:24:36 | [diff] [blame] | 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | import unittest |
| 7 | |
Brian Sheedy | fe2702e | 2024-12-13 21:48:20 | [diff] [blame] | 8 | # //testing/buildbot imports. |
Brian Sheedy | a31578e | 2020-05-18 20:24:36 | [diff] [blame] | 9 | import buildbot_json_magic_substitutions as magic_substitutions |
| 10 | |
| 11 | |
Ben Pastene | 2ea8ba5 | 2020-10-16 21:43:25 | [diff] [blame] | 12 | def CreateConfigWithPool(pool, device_type=None): |
| 13 | dims = { |
Brian Sheedy | 9517d1c | 2022-04-08 01:17:01 | [diff] [blame] | 14 | 'name': 'test_name', |
| 15 | 'swarming': { |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 16 | 'dimensions': { |
| 17 | 'pool': pool, |
| 18 | }, |
Brian Sheedy | 9517d1c | 2022-04-08 01:17:01 | [diff] [blame] | 19 | }, |
Brian Sheedy | a31578e | 2020-05-18 20:24:36 | [diff] [blame] | 20 | } |
Ben Pastene | 2ea8ba5 | 2020-10-16 21:43:25 | [diff] [blame] | 21 | if device_type: |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 22 | dims['swarming']['dimensions']['device_type'] = device_type |
Ben Pastene | 2ea8ba5 | 2020-10-16 21:43:25 | [diff] [blame] | 23 | return dims |
Brian Sheedy | a31578e | 2020-05-18 20:24:36 | [diff] [blame] | 24 | |
| 25 | |
| 26 | class ChromeOSTelemetryRemoteTest(unittest.TestCase): |
| 27 | |
| 28 | def testVirtualMachineSubstitutions(self): |
| 29 | test_config = CreateConfigWithPool('chromium.tests.cros.vm') |
Brian Sheedy | 5f173bb | 2021-11-24 00:45:54 | [diff] [blame] | 30 | self.assertEqual( |
Brian Sheedy | b6491ba | 2022-09-26 20:49:49 | [diff] [blame] | 31 | magic_substitutions.ChromeOSTelemetryRemote(test_config, None, {}), [ |
Brian Sheedy | 5f173bb | 2021-11-24 00:45:54 | [diff] [blame] | 32 | '--remote=127.0.0.1', |
| 33 | '--remote-ssh-port=9222', |
| 34 | ]) |
Brian Sheedy | a31578e | 2020-05-18 20:24:36 | [diff] [blame] | 35 | |
| 36 | def testPhysicalHardwareSubstitutions(self): |
Ben Pastene | 2ea8ba5 | 2020-10-16 21:43:25 | [diff] [blame] | 37 | test_config = CreateConfigWithPool('chromium.tests', device_type='eve') |
Brian Sheedy | 5f173bb | 2021-11-24 00:45:54 | [diff] [blame] | 38 | self.assertEqual( |
Brian Sheedy | b6491ba | 2022-09-26 20:49:49 | [diff] [blame] | 39 | magic_substitutions.ChromeOSTelemetryRemote(test_config, None, {}), |
Brian Sheedy | 5f173bb | 2021-11-24 00:45:54 | [diff] [blame] | 40 | ['--remote=variable_chromeos_device_hostname']) |
Brian Sheedy | a31578e | 2020-05-18 20:24:36 | [diff] [blame] | 41 | |
Brian Sheedy | b6491ba | 2022-09-26 20:49:49 | [diff] [blame] | 42 | def testSkylabSubstitutions(self): |
| 43 | tester_config = {'browser_config': 'cros-chrome', 'use_swarming': False} |
| 44 | self.assertEqual( |
| 45 | magic_substitutions.ChromeOSTelemetryRemote({}, None, tester_config), |
| 46 | []) |
| 47 | |
Brian Sheedy | a31578e | 2020-05-18 20:24:36 | [diff] [blame] | 48 | def testNoPool(self): |
| 49 | test_config = CreateConfigWithPool(None) |
Brian Sheedy | 5f173bb | 2021-11-24 00:45:54 | [diff] [blame] | 50 | with self.assertRaisesRegex(RuntimeError, 'No pool *'): |
Brian Sheedy | b6491ba | 2022-09-26 20:49:49 | [diff] [blame] | 51 | magic_substitutions.ChromeOSTelemetryRemote(test_config, None, {}) |
Brian Sheedy | a31578e | 2020-05-18 20:24:36 | [diff] [blame] | 52 | |
| 53 | def testUnknownPool(self): |
| 54 | test_config = CreateConfigWithPool('totally-legit-pool') |
Brian Sheedy | 5f173bb | 2021-11-24 00:45:54 | [diff] [blame] | 55 | with self.assertRaisesRegex(RuntimeError, 'Unknown CrOS pool *'): |
Brian Sheedy | b6491ba | 2022-09-26 20:49:49 | [diff] [blame] | 56 | magic_substitutions.ChromeOSTelemetryRemote(test_config, None, {}) |
Brian Sheedy | a31578e | 2020-05-18 20:24:36 | [diff] [blame] | 57 | |
| 58 | |
Brian Sheedy | 9517d1c | 2022-04-08 01:17:01 | [diff] [blame] | 59 | class ChromeOSGtestFilterFileTest(unittest.TestCase): |
| 60 | def testVirtualMachineFile(self): |
| 61 | test_config = CreateConfigWithPool('chromium.tests.cros.vm') |
| 62 | self.assertEqual( |
Brian Sheedy | b6491ba | 2022-09-26 20:49:49 | [diff] [blame] | 63 | magic_substitutions.ChromeOSGtestFilterFile(test_config, None, {}), [ |
Brian Sheedy | 9517d1c | 2022-04-08 01:17:01 | [diff] [blame] | 64 | '--test-launcher-filter-file=../../testing/buildbot/filters/' |
| 65 | 'chromeos.amd64-generic.test_name.filter', |
| 66 | ]) |
| 67 | |
| 68 | def testPhysicalHardwareFile(self): |
| 69 | test_config = CreateConfigWithPool('chromium.tests', device_type='eve') |
| 70 | self.assertEqual( |
Brian Sheedy | b6491ba | 2022-09-26 20:49:49 | [diff] [blame] | 71 | magic_substitutions.ChromeOSGtestFilterFile(test_config, None, {}), [ |
| 72 | '--test-launcher-filter-file=../../testing/buildbot/filters/' |
| 73 | 'chromeos.eve.test_name.filter', |
| 74 | ]) |
| 75 | |
| 76 | def testSkylab(self): |
| 77 | test_config = {'name': 'test_name', 'cros_board': 'eve'} |
| 78 | tester_config = {'browser_config': 'cros-chrome', 'use_swarming': False} |
| 79 | self.assertEqual( |
| 80 | magic_substitutions.ChromeOSGtestFilterFile(test_config, None, |
| 81 | tester_config), |
| 82 | [ |
Brian Sheedy | 9517d1c | 2022-04-08 01:17:01 | [diff] [blame] | 83 | '--test-launcher-filter-file=../../testing/buildbot/filters/' |
| 84 | 'chromeos.eve.test_name.filter', |
| 85 | ]) |
| 86 | |
Brian Sheedy | 67937ad1 | 2024-03-06 22:53:55 | [diff] [blame] | 87 | def testSkylabWithVariant(self): |
| 88 | test_config = { |
| 89 | 'name': 'test_name SOME_VARIANT', |
| 90 | 'cros_board': 'eve', |
| 91 | 'variant_id': 'SOME_VARIANT', |
| 92 | } |
| 93 | tester_config = {'browser_config': 'cros-chrome', 'use_swarming': False} |
| 94 | self.assertEqual( |
| 95 | magic_substitutions.ChromeOSGtestFilterFile(test_config, None, |
| 96 | tester_config), |
| 97 | [ |
| 98 | '--test-launcher-filter-file=../../testing/buildbot/filters/' |
| 99 | 'chromeos.eve.test_name.filter', |
| 100 | ]) |
| 101 | |
Brian Sheedy | 9517d1c | 2022-04-08 01:17:01 | [diff] [blame] | 102 | def testNoPool(self): |
| 103 | test_config = CreateConfigWithPool(None) |
| 104 | with self.assertRaisesRegex(RuntimeError, 'No pool *'): |
Brian Sheedy | b6491ba | 2022-09-26 20:49:49 | [diff] [blame] | 105 | magic_substitutions.ChromeOSGtestFilterFile(test_config, None, {}) |
Brian Sheedy | 9517d1c | 2022-04-08 01:17:01 | [diff] [blame] | 106 | |
| 107 | def testUnknownPool(self): |
| 108 | test_config = CreateConfigWithPool('totally-legit-pool') |
| 109 | with self.assertRaisesRegex(RuntimeError, 'Unknown CrOS pool *'): |
Brian Sheedy | b6491ba | 2022-09-26 20:49:49 | [diff] [blame] | 110 | magic_substitutions.ChromeOSGtestFilterFile(test_config, None, {}) |
Brian Sheedy | 9517d1c | 2022-04-08 01:17:01 | [diff] [blame] | 111 | |
| 112 | |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 113 | def CreateConfigWithGpu(gpu): |
Brian Sheedy | b18cb76 | 2020-06-30 00:09:29 | [diff] [blame] | 114 | return { |
| 115 | 'swarming': { |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 116 | 'dimensions': { |
| 117 | 'gpu': gpu, |
| 118 | }, |
Brian Sheedy | b18cb76 | 2020-06-30 00:09:29 | [diff] [blame] | 119 | }, |
| 120 | } |
| 121 | |
| 122 | |
Brian Sheedy | 0b46d6b | 2023-11-27 21:33:02 | [diff] [blame] | 123 | class GPUExpectedVendorId(unittest.TestCase): |
| 124 | def testSingleGpuSingleDimension(self): |
| 125 | test_config = CreateConfigWithGpu('vendor:device1-driver') |
| 126 | self.assertEqual( |
| 127 | magic_substitutions.GPUExpectedVendorId(test_config, None, {}), |
| 128 | ['--expected-vendor-id', 'vendor']) |
| 129 | |
| 130 | def testDoubleGpuSingleDimension(self): |
| 131 | test_config = CreateConfigWithGpu( |
| 132 | 'vendor:device1-driver|vendor:device2-driver') |
| 133 | self.assertEqual( |
| 134 | magic_substitutions.GPUExpectedVendorId(test_config, None, {}), |
| 135 | ['--expected-vendor-id', 'vendor']) |
| 136 | |
| 137 | def testDoubleGpuSingleDimensionDifferentVendors(self): |
| 138 | test_config = CreateConfigWithGpu( |
| 139 | 'vendor:device1-driver|vendor2:device2-driver') |
| 140 | with self.assertRaises(AssertionError): |
| 141 | magic_substitutions.GPUExpectedVendorId(test_config, None, {}) |
| 142 | |
| 143 | def testAppleSilicon(self): |
| 144 | test_config = CreateConfigWithGpu('apple:m1') |
| 145 | self.assertEqual( |
| 146 | magic_substitutions.GPUExpectedVendorId(test_config, None, {}), |
| 147 | ['--expected-vendor-id', '106b']) |
| 148 | |
| 149 | def testNoGpu(self): |
| 150 | test_config = { |
| 151 | 'swarming': { |
| 152 | 'dimensions': {}, |
| 153 | }, |
| 154 | } |
| 155 | self.assertEqual( |
| 156 | magic_substitutions.GPUExpectedVendorId(test_config, None, {}), |
| 157 | ['--expected-vendor-id', '0']) |
| 158 | |
| 159 | def testNoDimensions(self): |
| 160 | with self.assertRaises(AssertionError): |
| 161 | magic_substitutions.GPUExpectedVendorId({}, None, {}) |
| 162 | |
| 163 | def testSkylabKnownBoard(self): |
| 164 | test_config = { |
| 165 | 'name': 'test_name', |
| 166 | 'cros_board': 'volteer', |
| 167 | } |
| 168 | tester_config = { |
| 169 | 'browser_config': 'cros-chrome', |
| 170 | 'use_swarming': False, |
| 171 | } |
| 172 | self.assertEqual( |
| 173 | magic_substitutions.GPUExpectedVendorId(test_config, None, |
| 174 | tester_config), |
| 175 | ['--expected-vendor-id', '8086']) |
| 176 | |
| 177 | def testSkylabUnknownBoard(self): |
| 178 | test_config = { |
| 179 | 'name': 'test_name', |
| 180 | 'cros_board': 'fancy_new_board', |
| 181 | } |
| 182 | tester_config = { |
| 183 | 'browser_config': 'cros-chrome', |
| 184 | 'use_swarming': False, |
| 185 | } |
| 186 | self.assertEqual( |
| 187 | magic_substitutions.GPUExpectedVendorId(test_config, None, |
| 188 | tester_config), |
| 189 | ['--expected-vendor-id', '0']) |
| 190 | |
| 191 | |
Brian Sheedy | b18cb76 | 2020-06-30 00:09:29 | [diff] [blame] | 192 | class GPUExpectedDeviceId(unittest.TestCase): |
| 193 | def assertDeviceIdCorrectness(self, retval, device_ids): |
| 194 | self.assertEqual(len(retval), 2 * len(device_ids)) |
Jamie Madill | cf4f8c7 | 2021-05-20 19:24:23 | [diff] [blame] | 195 | for i in range(0, len(retval), 2): |
Brian Sheedy | b18cb76 | 2020-06-30 00:09:29 | [diff] [blame] | 196 | self.assertEqual(retval[i], '--expected-device-id') |
| 197 | for d in device_ids: |
| 198 | self.assertIn(d, retval) |
| 199 | |
| 200 | def testSingleGpuSingleDimension(self): |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 201 | test_config = CreateConfigWithGpu('vendor:device1-driver') |
Brian Sheedy | b18cb76 | 2020-06-30 00:09:29 | [diff] [blame] | 202 | self.assertDeviceIdCorrectness( |
Brian Sheedy | b6491ba | 2022-09-26 20:49:49 | [diff] [blame] | 203 | magic_substitutions.GPUExpectedDeviceId(test_config, None, {}), |
| 204 | ['device1']) |
Brian Sheedy | b18cb76 | 2020-06-30 00:09:29 | [diff] [blame] | 205 | |
Brian Sheedy | b18cb76 | 2020-06-30 00:09:29 | [diff] [blame] | 206 | def testDoubleGpuSingleDimension(self): |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 207 | test_config = CreateConfigWithGpu( |
| 208 | 'vendor:device1-driver|vendor:device2-driver') |
Brian Sheedy | b18cb76 | 2020-06-30 00:09:29 | [diff] [blame] | 209 | self.assertDeviceIdCorrectness( |
Brian Sheedy | b6491ba | 2022-09-26 20:49:49 | [diff] [blame] | 210 | magic_substitutions.GPUExpectedDeviceId(test_config, None, {}), |
Brian Sheedy | b18cb76 | 2020-06-30 00:09:29 | [diff] [blame] | 211 | ['device1', 'device2']) |
| 212 | |
Brian Sheedy | 0b46d6b | 2023-11-27 21:33:02 | [diff] [blame] | 213 | def testAppleSilicon(self): |
| 214 | test_config = CreateConfigWithGpu('apple:m1') |
| 215 | self.assertDeviceIdCorrectness( |
| 216 | magic_substitutions.GPUExpectedDeviceId(test_config, None, {}), ['0']) |
| 217 | |
Brian Sheedy | b18cb76 | 2020-06-30 00:09:29 | [diff] [blame] | 218 | def testNoGpu(self): |
| 219 | self.assertDeviceIdCorrectness( |
| 220 | magic_substitutions.GPUExpectedDeviceId( |
| 221 | {'swarming': { |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 222 | 'dimensions': {} |
Brian Sheedy | b6491ba | 2022-09-26 20:49:49 | [diff] [blame] | 223 | }}, None, {}), ['0']) |
Brian Sheedy | b18cb76 | 2020-06-30 00:09:29 | [diff] [blame] | 224 | |
| 225 | def testNoDimensions(self): |
| 226 | with self.assertRaises(AssertionError): |
Brian Sheedy | b6491ba | 2022-09-26 20:49:49 | [diff] [blame] | 227 | magic_substitutions.GPUExpectedDeviceId({}, None, {}) |
Brian Sheedy | 5f173bb | 2021-11-24 00:45:54 | [diff] [blame] | 228 | |
Brian Sheedy | 0b46d6b | 2023-11-27 21:33:02 | [diff] [blame] | 229 | def testSkylabKnownBoard(self): |
| 230 | test_config = { |
| 231 | 'name': 'test_name', |
| 232 | 'cros_board': 'volteer', |
| 233 | } |
| 234 | tester_config = { |
| 235 | 'browser_config': 'cros-chrome', |
| 236 | 'use_swarming': False, |
| 237 | } |
| 238 | self.assertDeviceIdCorrectness( |
| 239 | magic_substitutions.GPUExpectedDeviceId(test_config, None, |
| 240 | tester_config), ['9a49']) |
| 241 | |
| 242 | def testSkylabUnknownBoard(self): |
| 243 | test_config = { |
| 244 | 'name': 'test_name', |
| 245 | 'cros_board': 'fancy_new_board', |
| 246 | } |
| 247 | tester_config = { |
| 248 | 'browser_config': 'cros-chrome', |
| 249 | 'use_swarming': False, |
| 250 | } |
| 251 | self.assertDeviceIdCorrectness( |
| 252 | magic_substitutions.GPUExpectedDeviceId(test_config, None, |
| 253 | tester_config), ['0']) |
| 254 | |
Brian Sheedy | 5f173bb | 2021-11-24 00:45:54 | [diff] [blame] | 255 | |
Brian Sheedy | 910cda8 | 2022-07-19 11:58:34 | [diff] [blame] | 256 | class GPUParallelJobs(unittest.TestCase): |
| 257 | def testNoOsType(self): |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 258 | test_config = CreateConfigWithGpu('vendor:device1-driver') |
Brian Sheedy | 910cda8 | 2022-07-19 11:58:34 | [diff] [blame] | 259 | with self.assertRaises(AssertionError): |
Brian Sheedy | d544b66 | 2023-07-06 20:14:38 | [diff] [blame] | 260 | magic_substitutions.GPUParallelJobs(test_config, 'name', {}) |
Brian Sheedy | 910cda8 | 2022-07-19 11:58:34 | [diff] [blame] | 261 | |
| 262 | def testParallelJobs(self): |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 263 | test_config = CreateConfigWithGpu('vendor:device1-driver') |
Brian Sheedy | 910cda8 | 2022-07-19 11:58:34 | [diff] [blame] | 264 | for os_type in ['lacros', 'linux', 'mac', 'win']: |
Brian Sheedy | d544b66 | 2023-07-06 20:14:38 | [diff] [blame] | 265 | retval = magic_substitutions.GPUParallelJobs(test_config, 'name', |
Brian Sheedy | 910cda8 | 2022-07-19 11:58:34 | [diff] [blame] | 266 | {'os_type': os_type}) |
| 267 | self.assertEqual(retval, ['--jobs=4']) |
| 268 | |
| 269 | def testSerialJobs(self): |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 270 | test_config = CreateConfigWithGpu('vendor:device1-driver') |
Brian Sheedy | 910cda8 | 2022-07-19 11:58:34 | [diff] [blame] | 271 | for os_type in ['android', 'chromeos', 'fuchsia']: |
Brian Sheedy | d544b66 | 2023-07-06 20:14:38 | [diff] [blame] | 272 | retval = magic_substitutions.GPUParallelJobs(test_config, 'name', |
Brian Sheedy | 910cda8 | 2022-07-19 11:58:34 | [diff] [blame] | 273 | {'os_type': os_type}) |
| 274 | self.assertEqual(retval, ['--jobs=1']) |
| 275 | |
Austin Eng | 479701f | 2022-08-19 13:32:50 | [diff] [blame] | 276 | def testWebGPUCTSWindowsIntelSerialJobs(self): |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 277 | intel_config = CreateConfigWithGpu('8086:device1-driver') |
| 278 | amd_config = CreateConfigWithGpu('1002:device1-driver') |
Austin Eng | 479701f | 2022-08-19 13:32:50 | [diff] [blame] | 279 | |
Brian Sheedy | f9871703 | 2023-03-20 18:30:19 | [diff] [blame] | 280 | for gpu_config in [intel_config, amd_config]: |
Austin Eng | 479701f | 2022-08-19 13:32:50 | [diff] [blame] | 281 | for name, telemetry_test_name in [('webgpu_cts', None), |
| 282 | (None, 'webgpu_cts')]: |
| 283 | is_intel = intel_config == gpu_config |
| 284 | c = gpu_config.copy() |
| 285 | if name: |
| 286 | c['name'] = name |
| 287 | if telemetry_test_name: |
| 288 | c['telemetry_test_name'] = telemetry_test_name |
| 289 | for os_type in ['lacros', 'linux', 'mac', 'win']: |
Brian Sheedy | d544b66 | 2023-07-06 20:14:38 | [diff] [blame] | 290 | retval = magic_substitutions.GPUParallelJobs(c, 'name', |
Austin Eng | 479701f | 2022-08-19 13:32:50 | [diff] [blame] | 291 | {'os_type': os_type}) |
| 292 | if is_intel and os_type == 'win': |
| 293 | self.assertEqual(retval, ['--jobs=1']) |
| 294 | else: |
| 295 | self.assertEqual(retval, ['--jobs=4']) |
| 296 | |
Brian Sheedy | 7ac3595 | 2022-10-20 20:31:04 | [diff] [blame] | 297 | def testWebGLWindowsIntelParallelJobs(self): |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 298 | intel_config = CreateConfigWithGpu('8086:device1-driver') |
| 299 | amd_config = CreateConfigWithGpu('1002:device1-driver') |
Brian Sheedy | 7ac3595 | 2022-10-20 20:31:04 | [diff] [blame] | 300 | for gpu_config in [intel_config, amd_config]: |
| 301 | for name, telemetry_test_name in [('webgl_conformance', None), |
Yuly Novikov | 0aba6f7e | 2022-11-22 21:24:33 | [diff] [blame] | 302 | ('webgl1_conformance', None), |
| 303 | ('webgl2_conformance', None), |
| 304 | (None, 'webgl1_conformance'), |
| 305 | (None, 'webgl2_conformance')]: |
Brian Sheedy | 7ac3595 | 2022-10-20 20:31:04 | [diff] [blame] | 306 | is_intel = intel_config == gpu_config |
| 307 | c = gpu_config.copy() |
| 308 | if name: |
| 309 | c['name'] = name |
| 310 | if telemetry_test_name: |
| 311 | c['telemetry_test_name'] = telemetry_test_name |
| 312 | for os_type in ['lacros', 'linux', 'mac', 'win']: |
Brian Sheedy | d544b66 | 2023-07-06 20:14:38 | [diff] [blame] | 313 | retval = magic_substitutions.GPUParallelJobs(c, 'name', |
Brian Sheedy | 7ac3595 | 2022-10-20 20:31:04 | [diff] [blame] | 314 | {'os_type': os_type}) |
| 315 | if is_intel and os_type == 'win': |
| 316 | self.assertEqual(retval, ['--jobs=2']) |
| 317 | else: |
| 318 | self.assertEqual(retval, ['--jobs=4']) |
| 319 | |
Brian Sheedy | f9871703 | 2023-03-20 18:30:19 | [diff] [blame] | 320 | def testWebGLMacNvidiaParallelJobs(self): |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 321 | amd_config = CreateConfigWithGpu('1002:device1-driver') |
| 322 | nvidia_config = CreateConfigWithGpu('10de:device1-driver') |
Brian Sheedy | f9871703 | 2023-03-20 18:30:19 | [diff] [blame] | 323 | |
| 324 | for gpu_config in [nvidia_config, amd_config]: |
Brian Sheedy | d544b66 | 2023-07-06 20:14:38 | [diff] [blame] | 325 | for name, telemetry_test_name in [('webgl1_conformance', None), |
| 326 | (None, 'webgl1_conformance')]: |
Brian Sheedy | f9871703 | 2023-03-20 18:30:19 | [diff] [blame] | 327 | is_nvidia = gpu_config == nvidia_config |
| 328 | c = gpu_config.copy() |
| 329 | if name: |
| 330 | c['name'] = name |
| 331 | if telemetry_test_name: |
| 332 | c['telemetry_test_name'] = telemetry_test_name |
| 333 | for os_type in ['lacros', 'linux', 'mac', 'win']: |
Brian Sheedy | d544b66 | 2023-07-06 20:14:38 | [diff] [blame] | 334 | retval = magic_substitutions.GPUParallelJobs(c, 'name', |
Brian Sheedy | f9871703 | 2023-03-20 18:30:19 | [diff] [blame] | 335 | {'os_type': os_type}) |
| 336 | if is_nvidia and os_type == 'mac': |
| 337 | self.assertEqual(retval, ['--jobs=3']) |
| 338 | else: |
| 339 | self.assertEqual(retval, ['--jobs=4']) |
| 340 | |
Brian Sheedy | d544b66 | 2023-07-06 20:14:38 | [diff] [blame] | 341 | def testPixelMacDebugParallelJobs(self): |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 342 | gpu_config = CreateConfigWithGpu('1002:device1-driver') |
Brian Sheedy | d544b66 | 2023-07-06 20:14:38 | [diff] [blame] | 343 | for name, telemetry_test_name in [('pixel_skia_gold_test', None), |
| 344 | (None, 'pixel')]: |
| 345 | c = gpu_config.copy() |
| 346 | if name: |
| 347 | c['name'] = name |
| 348 | if telemetry_test_name: |
| 349 | c['telemetry_test_name'] = telemetry_test_name |
| 350 | for os_type in ['lacros', 'linux', 'mac', 'win']: |
| 351 | for tester_name in ('Name Debug', 'Name Dbg', 'name debug', 'name dbg'): |
| 352 | retval = magic_substitutions.GPUParallelJobs(c, tester_name, |
| 353 | {'os_type': os_type}) |
| 354 | if os_type == 'mac': |
| 355 | self.assertEqual(retval, ['--jobs=1']) |
| 356 | else: |
| 357 | self.assertEqual(retval, ['--jobs=4']) |
| 358 | # Double check that non-debug Mac pixel tests still get parallelized. |
| 359 | retval = magic_substitutions.GPUParallelJobs(c, 'name release', |
| 360 | {'os_type': 'mac'}) |
| 361 | self.assertEqual(retval, ['--jobs=4']) |
| 362 | |
| 363 | def testPixelMacNvidiaParallelJobs(self): |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 364 | gpu_config = CreateConfigWithGpu('10de:device1-driver') |
Brian Sheedy | d544b66 | 2023-07-06 20:14:38 | [diff] [blame] | 365 | for name, telemetry_test_name in [('pixel_skia_gold_test', None), |
| 366 | (None, 'pixel')]: |
| 367 | c = gpu_config.copy() |
| 368 | if name: |
| 369 | c['name'] = name |
| 370 | if telemetry_test_name: |
| 371 | c['telemetry_test_name'] = telemetry_test_name |
| 372 | for os_type in ['lacros', 'linux', 'mac', 'win']: |
| 373 | retval = magic_substitutions.GPUParallelJobs(c, 'name', |
| 374 | {'os_type': os_type}) |
| 375 | if os_type == 'mac': |
| 376 | self.assertEqual(retval, ['--jobs=1']) |
| 377 | else: |
| 378 | self.assertEqual(retval, ['--jobs=4']) |
| 379 | |
Brian Sheedy | 910cda8 | 2022-07-19 11:58:34 | [diff] [blame] | 380 | |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 381 | def CreateConfigWithDeviceType(device_type): |
Brian Sheedy | ba13cf52 | 2022-09-13 21:00:09 | [diff] [blame] | 382 | return { |
| 383 | 'swarming': { |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 384 | 'dimensions': { |
| 385 | 'device_type': device_type, |
| 386 | }, |
Brian Sheedy | ba13cf52 | 2022-09-13 21:00:09 | [diff] [blame] | 387 | }, |
| 388 | } |
| 389 | |
| 390 | |
| 391 | class GPUTelemetryNoRootForUnrootedDevices(unittest.TestCase): |
| 392 | def testNoOsType(self): |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 393 | test_config = CreateConfigWithDeviceType('a13') |
Brian Sheedy | ba13cf52 | 2022-09-13 21:00:09 | [diff] [blame] | 394 | with self.assertRaises(AssertionError): |
| 395 | magic_substitutions.GPUTelemetryNoRootForUnrootedDevices( |
| 396 | test_config, None, {}) |
| 397 | |
| 398 | def testNonAndroidOs(self): |
| 399 | retval = magic_substitutions.GPUTelemetryNoRootForUnrootedDevices( |
| 400 | {}, None, {'os_type': 'linux'}) |
| 401 | self.assertEqual(retval, []) |
| 402 | |
| 403 | def testUnrootedDevices(self): |
Brian Sheedy | 9c404d6 | 2024-12-16 16:26:09 | [diff] [blame^] | 404 | devices = ('a13', 'a13ve', 'a23', 'dm1q', 'devonn') |
Brian Sheedy | ba13cf52 | 2022-09-13 21:00:09 | [diff] [blame] | 405 | for d in devices: |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 406 | test_config = CreateConfigWithDeviceType(d) |
Brian Sheedy | ba13cf52 | 2022-09-13 21:00:09 | [diff] [blame] | 407 | retval = magic_substitutions.GPUTelemetryNoRootForUnrootedDevices( |
| 408 | test_config, None, {'os_type': 'android'}) |
| 409 | self.assertEqual(retval, |
| 410 | ['--compatibility-mode=dont-require-rooted-device']) |
| 411 | |
Brian Sheedy | ba13cf52 | 2022-09-13 21:00:09 | [diff] [blame] | 412 | def testRootedDevices(self): |
Garrett Beaty | ade673d | 2023-08-04 22:00:25 | [diff] [blame] | 413 | test_config = CreateConfigWithDeviceType('hammerhead') |
Brian Sheedy | ba13cf52 | 2022-09-13 21:00:09 | [diff] [blame] | 414 | retval = magic_substitutions.GPUTelemetryNoRootForUnrootedDevices( |
| 415 | test_config, None, {'os_type': 'android'}) |
| 416 | self.assertEqual(retval, []) |
| 417 | |
| 418 | |
Brian Sheedy | 55140f7 | 2023-06-02 17:32:23 | [diff] [blame] | 419 | class GPUWebGLRuntimeFile(unittest.TestCase): |
| 420 | def testNoOsType(self): |
| 421 | test_config = {'telemetry_test_name': 'webgl1_conformance'} |
| 422 | with self.assertRaises(AssertionError): |
| 423 | magic_substitutions.GPUWebGLRuntimeFile(test_config, None, {}) |
| 424 | |
| 425 | def testNoSuite(self): |
| 426 | tester_config = {'os_type': 'linux'} |
| 427 | with self.assertRaises(AssertionError): |
| 428 | magic_substitutions.GPUWebGLRuntimeFile({}, None, tester_config) |
| 429 | |
| 430 | def testUnknownSuite(self): |
| 431 | test_config = {'telemetry_test_name': 'foo'} |
| 432 | tester_config = {'os_type': 'linux'} |
| 433 | with self.assertRaises(AssertionError): |
| 434 | magic_substitutions.GPUWebGLRuntimeFile(test_config, None, tester_config) |
| 435 | |
| 436 | def testKnownOsTypes(self): |
| 437 | for os_type in ('android', 'linux', 'mac', 'win'): |
| 438 | for suite in ('webgl1_conformance', 'webgl2_conformance'): |
| 439 | retval = magic_substitutions.GPUWebGLRuntimeFile( |
| 440 | {'telemetry_test_name': suite}, None, {'os_type': os_type}) |
| 441 | self.assertEqual(retval, [ |
| 442 | '--read-abbreviated-json-results-from=../../content/test/data/gpu/' |
| 443 | f'{suite}_{os_type}_runtimes.json' |
| 444 | ]) |
| 445 | |
| 446 | def testUnknownOsType(self): |
| 447 | for suite in ('webgl1_conformance', 'webgl2_conformance'): |
| 448 | retval = magic_substitutions.GPUWebGLRuntimeFile( |
| 449 | {'telemetry_test_name': suite}, None, {'os_type': 'foo'}) |
| 450 | self.assertEqual(retval, [ |
| 451 | '--read-abbreviated-json-results-from=../../content/test/data/gpu/' |
| 452 | f'{suite}_linux_runtimes.json' |
| 453 | ]) |
| 454 | |
| 455 | |
Brian Sheedy | a31578e | 2020-05-18 20:24:36 | [diff] [blame] | 456 | if __name__ == '__main__': |
| 457 | unittest.main() |