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