| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Set of utilities to add commands to a buildbot factory (BuildFactory). | 6 """Set of utilities to add commands to a buildbot factory (BuildFactory). |
| 7 | 7 |
| 8 All the utility functions to add steps to a build factory here are not | 8 All the utility functions to add steps to a build factory here are not |
| 9 project-specific. See the other *_commands.py for project-specific commands. | 9 project-specific. See the other *_commands.py for project-specific commands. |
| 10 """ | 10 """ |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 def GetTestCommand(self, executable, arg_list=None): | 144 def GetTestCommand(self, executable, arg_list=None): |
| 145 cmd = [self._python, self._test_tool, | 145 cmd = [self._python, self._test_tool, |
| 146 '--target', self._target, | 146 '--target', self._target, |
| 147 '--build-dir', self._build_dir, | 147 '--build-dir', self._build_dir, |
| 148 self.GetExecutableName(executable)] | 148 self.GetExecutableName(executable)] |
| 149 | 149 |
| 150 if arg_list is not None: | 150 if arg_list is not None: |
| 151 cmd.extend(arg_list) | 151 cmd.extend(arg_list) |
| 152 return cmd | 152 return cmd |
| 153 | 153 |
| 154 @staticmethod | |
| 155 def DoStepFilterTest(bStep): | |
| 156 """Examines the 'testfilters' property of the build and determines if | |
| 157 the step should run; True for yes.""" | |
| 158 try: | |
| 159 filters = bStep.getProperty('testfilters') | |
| 160 except: | |
| 161 return True | |
| 162 | |
| 163 for filter in filters: | |
| 164 if filter == bStep.name: | |
| 165 return True | |
| 166 if filter.startswith(("%s:" % bStep.name)): | |
| 167 # TODO(vandebo): We cannot modiby bStep after is it generated from the | |
| 168 # factory unless a copy is made. | |
| 169 #bStep.command.append("--gtest_filter=%s" % filter.split(':',1)[1]) | |
| 170 return True | |
| 171 return False | |
| 172 | |
| 173 def AddTestStep(self, command_class, test_name, test_command, | 154 def AddTestStep(self, command_class, test_name, test_command, |
| 174 test_description='', timeout=600, workdir=None, env=None, | 155 test_description='', timeout=600, workdir=None, env=None, |
| 175 locks=None, halt_on_failure=False): | 156 locks=None, halt_on_failure=False, do_step_if=True): |
| 176 """Adds a step to the factory to run a test. | 157 """Adds a step to the factory to run a test. |
| 177 | 158 |
| 178 Args: | 159 Args: |
| 179 command_class: the command type to run, such as shell.ShellCommand or | 160 command_class: the command type to run, such as shell.ShellCommand or |
| 180 gtest_command.GTestCommand | 161 gtest_command.GTestCommand |
| 181 test_name: a string describing the test, used to build its logfile name | 162 test_name: a string describing the test, used to build its logfile name |
| 182 and its descriptions in the waterfall display | 163 and its descriptions in the waterfall display |
| 183 timeout: the buildbot timeout for the test, in seconds. If it doesn't | 164 timeout: the buildbot timeout for the test, in seconds. If it doesn't |
| 184 produce any output to stdout or stderr for this many seconds, | 165 produce any output to stdout or stderr for this many seconds, |
| 185 buildbot will cancel it and call it a failure. | 166 buildbot will cancel it and call it a failure. |
| 186 test_command: the command list to run | 167 test_command: the command list to run |
| 187 test_description: an auxiliary description to be appended to the | 168 test_description: an auxiliary description to be appended to the |
| 188 test_name in the buildbot display; for example, ' (single process)' | 169 test_name in the buildbot display; for example, ' (single process)' |
| 189 workdir: directory where the test executable will be launched. If None, | 170 workdir: directory where the test executable will be launched. If None, |
| 190 step will use default directory. | 171 step will use default directory. |
| 191 env: dictionary with environmental variable key value pairs that will be | 172 env: dictionary with environmental variable key value pairs that will be |
| 192 set or overridden before launching the test executable. Does not do | 173 set or overridden before launching the test executable. Does not do |
| 193 anything if 'env' is None. | 174 anything if 'env' is None. |
| 194 locks: any locks to acquire for this test | 175 locks: any locks to acquire for this test |
| 195 halt_on_failure: whether the current build should halt if this step fails | 176 halt_on_failure: whether the current build should halt if this step fails |
| 196 """ | 177 """ |
| 197 doStepCondition = True | |
| 198 if command_class == gtest_command.GTestCommand: | |
| 199 doStepCondition = self.DoStepFilterTest | |
| 200 | |
| 201 self._factory.addStep( | 178 self._factory.addStep( |
| 202 command_class, | 179 command_class, |
| 203 name=test_name, | 180 name=test_name, |
| 204 timeout=timeout, | 181 timeout=timeout, |
| 205 doStepIf=doStepCondition, | 182 doStepIf=do_step_if, |
| 206 workdir=workdir, | 183 workdir=workdir, |
| 207 env=env, | 184 env=env, |
| 208 # TODO(bradnelson): FIXME | 185 # TODO(bradnelson): FIXME |
| 209 #locks=locks, | 186 #locks=locks, |
| 210 description='running %s%s' % (test_name, test_description), | 187 description='running %s%s' % (test_name, test_description), |
| 211 descriptionDone='%s%s' % (test_name, test_description), | 188 descriptionDone='%s%s' % (test_name, test_description), |
| 212 haltOnFailure=halt_on_failure, | 189 haltOnFailure=halt_on_failure, |
| 213 command=test_command) | 190 command=test_command) |
| 214 | 191 |
| 192 @staticmethod |
| 193 def GTestStepFilter(bStep): |
| 194 """Examines the 'testfilters' property of the build and determines if |
| 195 the step should run; True for yes.""" |
| 196 bStep.setProperty('gtest_filter', None, "Factory") |
| 197 filters = bStep.build.getProperties().getProperty('testfilters') |
| 198 if not filters: |
| 199 return True |
| 200 |
| 201 for filter in filters: |
| 202 if filter == bStep.name: |
| 203 return True |
| 204 if filter.startswith("%s:" % bStep.name): |
| 205 bStep.setProperty('gtest_filter', "--gtest_filter=%s" % |
| 206 filter.split(':',1)[1], "Scheduler") |
| 207 return True |
| 208 return False |
| 209 |
| 215 def AddBasicGTestTestStep(self, test_name, factory_properties=None, | 210 def AddBasicGTestTestStep(self, test_name, factory_properties=None, |
| 216 description='', arg_list=None, total_shards=None, | 211 description='', arg_list=None, total_shards=None, |
| 217 shard_index=None): | 212 shard_index=None): |
| 218 """Adds a step to the factory to run the gtest tests. | 213 """Adds a step to the factory to run the gtest tests. |
| 219 | 214 |
| 220 Args: | 215 Args: |
| 221 total_shards: Number of shards to split this test into. | 216 total_shards: Number of shards to split this test into. |
| 222 shard_index: Shard to run. Must be between 1 and ui_total_shards. | 217 shard_index: Shard to run. Must be between 1 and ui_total_shards. |
| 223 generate_gtest_json: generate JSON results file after running the tests. | 218 generate_gtest_json: generate JSON results file after running the tests. |
| 224 """ | 219 """ |
| (...skipping 18 matching lines...) Expand all Loading... |
| 243 '--build-number', WithProperties("%(buildnumber)s"), | 238 '--build-number', WithProperties("%(buildnumber)s"), |
| 244 '--builder-name', WithProperties("%(buildername)s"),]) | 239 '--builder-name', WithProperties("%(buildername)s"),]) |
| 245 | 240 |
| 246 if total_shards and shard_index: | 241 if total_shards and shard_index: |
| 247 cmd.extend(['--total-shards', str(total_shards), | 242 cmd.extend(['--total-shards', str(total_shards), |
| 248 '--shard-index', str(shard_index)]) | 243 '--shard-index', str(shard_index)]) |
| 249 | 244 |
| 250 cmd.append(self.GetExecutableName(test_name)) | 245 cmd.append(self.GetExecutableName(test_name)) |
| 251 | 246 |
| 252 arg_list.append('--gtest_print_time') | 247 arg_list.append('--gtest_print_time') |
| 248 arg_list.append(WithProperties("%(gtest_filter)s")) |
| 253 cmd.extend(arg_list) | 249 cmd.extend(arg_list) |
| 254 | 250 |
| 255 self.AddTestStep(gtest_command.GTestCommand, test_name, cmd, description) | 251 self.AddTestStep(gtest_command.GTestCommand, test_name, ListProperties(cmd), |
| 252 description, do_step_if=self.GTestStepFilter) |
| 256 | 253 |
| 257 def AddBasicShellStep(self, test_name, timeout=600, arg_list=None): | 254 def AddBasicShellStep(self, test_name, timeout=600, arg_list=None): |
| 258 """Adds a step to the factory to run a simple shell test with standard | 255 """Adds a step to the factory to run a simple shell test with standard |
| 259 defaults. | 256 defaults. |
| 260 """ | 257 """ |
| 261 self.AddTestStep(shell.ShellCommand, test_name, timeout=timeout, | 258 self.AddTestStep(shell.ShellCommand, test_name, timeout=timeout, |
| 262 test_command=self.GetTestCommand(test_name, | 259 test_command=self.GetTestCommand(test_name, |
| 263 arg_list=arg_list)) | 260 arg_list=arg_list)) |
| 264 | 261 |
| 265 | 262 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 raise Exception, ('There is no mapping for identifier %s in %s' % | 482 raise Exception, ('There is no mapping for identifier %s in %s' % |
| 486 (perf_id, self._target)) | 483 (perf_id, self._target)) |
| 487 report_link = '%s/%s/%s/%s' % (self.PERF_BASE_URL, perf_name, test_name, | 484 report_link = '%s/%s/%s/%s' % (self.PERF_BASE_URL, perf_name, test_name, |
| 488 self.PERF_REPORT_URL_SUFFIX) | 485 self.PERF_REPORT_URL_SUFFIX) |
| 489 output_dir = '%s/%s/%s' % (self.PERF_OUTPUT_DIR, perf_name, test_name) | 486 output_dir = '%s/%s/%s' % (self.PERF_OUTPUT_DIR, perf_name, test_name) |
| 490 | 487 |
| 491 return self._CreatePerformanceStepClass(log_processor_class, | 488 return self._CreatePerformanceStepClass(log_processor_class, |
| 492 report_link=report_link, output_dir=output_dir, | 489 report_link=report_link, output_dir=output_dir, |
| 493 factory_properties=factory_properties, perf_name=perf_name, | 490 factory_properties=factory_properties, perf_name=perf_name, |
| 494 test_name=test_name) | 491 test_name=test_name) |
| OLD | NEW |