Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Base classes for a test and validator which upload results | 5 """Base classes for a test and validator which upload results |
| 6 (reference images, error images) to cloud storage.""" | 6 (reference images, error images) to cloud storage.""" |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import tempfile | 10 import tempfile |
| 11 | 11 |
| 12 from catapult_base import cloud_storage | 12 from catapult_base import cloud_storage |
| 13 from telemetry.page import page_test | 13 from telemetry.page import page_test |
| 14 from telemetry.util import image_util | 14 from telemetry.util import image_util |
| 15 from telemetry.util import rgba_color | 15 from telemetry.util import rgba_color |
| 16 | 16 |
| 17 import gpu_test_base | 17 from gpu_tests import gpu_test_base |
| 18 | 18 |
| 19 test_data_dir = os.path.abspath(os.path.join( | 19 test_data_dir = os.path.abspath(os.path.join( |
| 20 os.path.dirname(__file__), '..', '..', 'data', 'gpu')) | 20 os.path.dirname(__file__), '..', '..', 'data', 'gpu')) |
| 21 | 21 |
| 22 default_generated_data_dir = os.path.join(test_data_dir, 'generated') | 22 default_generated_data_dir = os.path.join(test_data_dir, 'generated') |
| 23 | 23 |
| 24 error_image_cloud_storage_bucket = 'chromium-browser-gpu-tests' | 24 error_image_cloud_storage_bucket = 'chromium-browser-gpu-tests' |
| 25 | 25 |
| 26 def _CompareScreenshotSamples(screenshot, expectations, device_pixel_ratio): | 26 def _CompareScreenshotSamples(screenshot, expectations, device_pixel_ratio): |
| 27 for expectation in expectations: | 27 for expectation in expectations: |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 49 if not actual_color.IsEqual(expected_color, expectation["tolerance"]): | 49 if not actual_color.IsEqual(expected_color, expectation["tolerance"]): |
| 50 raise page_test.Failure('Expected pixel at ' + str(location) + | 50 raise page_test.Failure('Expected pixel at ' + str(location) + |
| 51 ' to be ' + | 51 ' to be ' + |
| 52 str(expectation["color"]) + " but got [" + | 52 str(expectation["color"]) + " but got [" + |
| 53 str(actual_color.r) + ", " + | 53 str(actual_color.r) + ", " + |
| 54 str(actual_color.g) + ", " + | 54 str(actual_color.g) + ", " + |
| 55 str(actual_color.b) + "]") | 55 str(actual_color.b) + "]") |
| 56 | 56 |
| 57 class ValidatorBase(gpu_test_base.ValidatorBase): | 57 class ValidatorBase(gpu_test_base.ValidatorBase): |
| 58 def __init__(self): | 58 def __init__(self): |
| 59 super(ValidatorBase, self).__init__() | 59 gpu_test_base.ValidatorBase.__init__(self) |
|
Ken Russell (switch to Gerrit)
2015/10/21 22:12:08
It's undesirable to name the superclass explicitly
Corentin Wallez
2015/10/21 23:07:25
I was having a pylint error related to using super
| |
| 60 # Parameters for cloud storage reference images. | 60 # Parameters for cloud storage reference images. |
| 61 self.vendor_id = None | 61 self.vendor_id = None |
| 62 self.device_id = None | 62 self.device_id = None |
| 63 self.vendor_string = None | 63 self.vendor_string = None |
| 64 self.device_string = None | 64 self.device_string = None |
| 65 self.msaa = False | 65 self.msaa = False |
| 66 | 66 |
| 67 ### | 67 ### |
| 68 ### Routines working with the local disk (only used for local | 68 ### Routines working with the local disk (only used for local |
| 69 ### testing without a cloud storage account -- the bots do not use | 69 ### testing without a cloud storage account -- the bots do not use |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 cloud_storage.Get(self.options.refimg_cloud_storage_bucket, | 185 cloud_storage.Get(self.options.refimg_cloud_storage_bucket, |
| 186 self._FormatReferenceImageName(img_name, page, tab), | 186 self._FormatReferenceImageName(img_name, page, tab), |
| 187 temp_file) | 187 temp_file) |
| 188 return image_util.FromPngFile(temp_file) | 188 return image_util.FromPngFile(temp_file) |
| 189 | 189 |
| 190 def _UploadErrorImagesToCloudStorage(self, image_name, screenshot, ref_img): | 190 def _UploadErrorImagesToCloudStorage(self, image_name, screenshot, ref_img): |
| 191 """For a failing run, uploads the failing image, reference image (if | 191 """For a failing run, uploads the failing image, reference image (if |
| 192 supplied), and diff image (if reference image was supplied) to cloud | 192 supplied), and diff image (if reference image was supplied) to cloud |
| 193 storage. This subsumes the functionality of the | 193 storage. This subsumes the functionality of the |
| 194 archive_gpu_pixel_test_results.py script.""" | 194 archive_gpu_pixel_test_results.py script.""" |
| 195 machine_name = re.sub('\W+', '_', self.options.test_machine_name) | 195 machine_name = re.sub(r'\W+', '_', self.options.test_machine_name) |
| 196 upload_dir = '%s_%s_telemetry' % (self.options.build_revision, machine_name) | 196 upload_dir = '%s_%s_telemetry' % (self.options.build_revision, machine_name) |
| 197 base_bucket = '%s/runs/%s' % (error_image_cloud_storage_bucket, upload_dir) | 197 base_bucket = '%s/runs/%s' % (error_image_cloud_storage_bucket, upload_dir) |
| 198 image_name_with_revision = '%s_%s.png' % ( | 198 image_name_with_revision = '%s_%s.png' % ( |
| 199 image_name, self.options.build_revision) | 199 image_name, self.options.build_revision) |
| 200 self._UploadBitmapToCloudStorage( | 200 self._UploadBitmapToCloudStorage( |
| 201 base_bucket + '/gen', image_name_with_revision, screenshot, | 201 base_bucket + '/gen', image_name_with_revision, screenshot, |
| 202 public=True) | 202 public=True) |
| 203 if ref_img is not None: | 203 if ref_img is not None: |
| 204 self._UploadBitmapToCloudStorage( | 204 self._UploadBitmapToCloudStorage( |
| 205 base_bucket + '/ref', image_name_with_revision, ref_img, public=True) | 205 base_bucket + '/ref', image_name_with_revision, ref_img, public=True) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 default='') | 258 default='') |
| 259 group.add_option('--test-machine-name', | 259 group.add_option('--test-machine-name', |
| 260 help='Name of the test machine. Specifying this argument causes this ' | 260 help='Name of the test machine. Specifying this argument causes this ' |
| 261 'script to upload failure images and diffs to cloud storage directly, ' | 261 'script to upload failure images and diffs to cloud storage directly, ' |
| 262 'instead of relying on the archive_gpu_pixel_test_results.py script.', | 262 'instead of relying on the archive_gpu_pixel_test_results.py script.', |
| 263 default='') | 263 default='') |
| 264 group.add_option('--generated-dir', | 264 group.add_option('--generated-dir', |
| 265 help='Overrides the default on-disk location for generated test images ' | 265 help='Overrides the default on-disk location for generated test images ' |
| 266 '(only used for local testing without a cloud storage account)', | 266 '(only used for local testing without a cloud storage account)', |
| 267 default=default_generated_data_dir) | 267 default=default_generated_data_dir) |
| OLD | NEW |