| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 """ Prepare runtime resources that are needed by Test builders but not | |
| 7 Bench builders. """ | |
| 8 | |
| 9 from build_step import BuildStep | |
| 10 import build_step | |
| 11 # builder_name_schema must be imported after build_step so the PYTHONPATH will | |
| 12 # be set properly to import it. | |
| 13 import builder_name_schema | |
| 14 import os | |
| 15 import sys | |
| 16 | |
| 17 | |
| 18 class PreRender(BuildStep): | |
| 19 | |
| 20 def _RunBeforeGenerateGMs(self): | |
| 21 # Prepare directory to hold GM expectations. | |
| 22 self._flavor_utils.CreateCleanDeviceDirectory( | |
| 23 self._device_dirs.GMExpectedDir()) | |
| 24 | |
| 25 # Push the GM expectations JSON file to the device. | |
| 26 device_gm_expectations_path = self._flavor_utils.DevicePathJoin( | |
| 27 self._device_dirs.GMExpectedDir(), build_step.GM_EXPECTATIONS_FILENAME) | |
| 28 repo_gm_expectations_path = os.path.join( | |
| 29 self._gm_expected_dir, build_step.GM_EXPECTATIONS_FILENAME) | |
| 30 if os.path.exists(repo_gm_expectations_path): | |
| 31 print 'Pushing GM expectations from %s on host to %s on device...' % ( | |
| 32 repo_gm_expectations_path, device_gm_expectations_path) | |
| 33 self._flavor_utils.PushFileToDevice(repo_gm_expectations_path, | |
| 34 device_gm_expectations_path) | |
| 35 else: | |
| 36 print('Missing GM expectations file %s' % repo_gm_expectations_path) | |
| 37 | |
| 38 # Push GM's ignore_failures_file to the device. | |
| 39 device_ignore_failures_path = self._flavor_utils.DevicePathJoin( | |
| 40 self._device_dirs.GMExpectedDir(), build_step.GM_IGNORE_FAILURES_FILE) | |
| 41 repo_ignore_failures_path = os.path.join( | |
| 42 self._gm_expected_dir, os.pardir, build_step.GM_IGNORE_FAILURES_FILE) | |
| 43 if os.path.exists(repo_ignore_failures_path): | |
| 44 print ('Pushing ignore_failures_file from %s on host to %s on device...' | |
| 45 % (repo_ignore_failures_path, device_ignore_failures_path)) | |
| 46 self._flavor_utils.PushFileToDevice(repo_ignore_failures_path, | |
| 47 device_ignore_failures_path) | |
| 48 else: | |
| 49 print('Missing ignore_failures_file %s' % repo_ignore_failures_path) | |
| 50 | |
| 51 # Prepare directory to hold GM actuals. | |
| 52 self._flavor_utils.CreateCleanHostDirectory(self._gm_actual_dir) | |
| 53 self._flavor_utils.CreateCleanDeviceDirectory( | |
| 54 self._flavor_utils.DevicePathJoin(self._device_dirs.GMActualDir(), | |
| 55 self._builder_name)) | |
| 56 # DM too. | |
| 57 self._flavor_utils.CreateCleanDeviceDirectory(self._device_dirs.DMDir()) | |
| 58 | |
| 59 def _RunBeforeRunDecodingTests(self): | |
| 60 # Copy expectations file and images to decode in skimage to device. | |
| 61 self._flavor_utils.CreateCleanDeviceDirectory( | |
| 62 self._device_dirs.SKImageExpectedDir()) | |
| 63 skimage_subdir = builder_name_schema.GetWaterfallBot(self._builder_name) | |
| 64 skimage_expected_filename = build_step.GM_EXPECTATIONS_FILENAME | |
| 65 | |
| 66 skimage_host_expectations = os.path.join(self._skimage_expected_dir, | |
| 67 skimage_subdir, | |
| 68 skimage_expected_filename) | |
| 69 | |
| 70 if os.path.exists(skimage_host_expectations): | |
| 71 skimage_device_subdir = self._flavor_utils.DevicePathJoin( | |
| 72 self._device_dirs.SKImageExpectedDir(), | |
| 73 skimage_subdir) | |
| 74 skimage_device_expectations = self._flavor_utils.DevicePathJoin( | |
| 75 skimage_device_subdir, skimage_expected_filename) | |
| 76 self._flavor_utils.CreateCleanDeviceDirectory(skimage_device_subdir) | |
| 77 self._flavor_utils.PushFileToDevice(skimage_host_expectations, | |
| 78 skimage_device_expectations) | |
| 79 | |
| 80 self._flavor_utils.CopyDirectoryContentsToDevice( | |
| 81 self._skimage_in_dir, self._device_dirs.SKImageInDir()) | |
| 82 | |
| 83 # Create a directory for the output of skimage | |
| 84 self._flavor_utils.CreateCleanHostDirectory(self._skimage_out_dir) | |
| 85 self._flavor_utils.CreateCleanDeviceDirectory( | |
| 86 self._device_dirs.SKImageOutDir()) | |
| 87 | |
| 88 def _RunBeforeRenderSKPs(self): | |
| 89 # SKP files have already been installed by DownloadSKPs, so we don't need | |
| 90 # to do that here. | |
| 91 | |
| 92 # Install JSON summaries of image expectations. | |
| 93 if not os.path.isdir(self.playback_expected_summaries_dir): | |
| 94 os.makedirs(self.playback_expected_summaries_dir) | |
| 95 self._flavor_utils.CopyDirectoryContentsToDevice( | |
| 96 self.playback_expected_summaries_dir, | |
| 97 self._device_dirs.PlaybackExpectedSummariesDir()) | |
| 98 | |
| 99 # Prepare directory to hold actually-generated images. | |
| 100 self._flavor_utils.CreateCleanHostDirectory( | |
| 101 self.playback_actual_images_dir) | |
| 102 self._flavor_utils.CreateCleanDeviceDirectory( | |
| 103 self._device_dirs.PlaybackActualImagesDir()) | |
| 104 | |
| 105 # Prepare directory to hold JSON summaries of actually-generated images. | |
| 106 self._flavor_utils.CreateCleanHostDirectory( | |
| 107 self.playback_actual_summaries_dir) | |
| 108 self._flavor_utils.CreateCleanDeviceDirectory( | |
| 109 self._device_dirs.PlaybackActualSummariesDir()) | |
| 110 | |
| 111 def _Run(self): | |
| 112 self._RunBeforeGenerateGMs() | |
| 113 self._RunBeforeRunDecodingTests() | |
| 114 self._RunBeforeRenderSKPs() | |
| 115 | |
| 116 | |
| 117 if '__main__' == __name__: | |
| 118 sys.exit(BuildStep.RunBuildStep(PreRender)) | |
| OLD | NEW |