def _LaunchPerfTest(self, test_name): """Runs a perf test. Args: test_name: the name of the test to be executed. Returns: A tuple containing (Output, base_test_result.ResultType) """ cmd = ('%s --device %s --keep_test_server_ports' % (self._tests[test_name], self.device)) logging.info('%s : %s', test_name, cmd) start_time = datetime.datetime.now() timeout = 1800 if self._options.no_timeout: timeout = None full_cmd = cmd if self._options.dry_run: full_cmd = 'echo %s' % cmd output, exit_code = pexpect.run( full_cmd, cwd=os.path.abspath(constants.DIR_SOURCE_ROOT), withexitstatus=True, logfile=sys.stdout, timeout=timeout, env=os.environ) end_time = datetime.datetime.now() if exit_code is None: exit_code = -1 logging.info('%s : exit_code=%d in %d secs at %s', test_name, exit_code, (end_time - start_time).seconds, self.device) result_type = base_test_result.ResultType.FAIL if exit_code == 0: result_type = base_test_result.ResultType.PASS if test_name in self._flaky_tests: # The exit_code is used at the second stage when printing the # test output. If the test is flaky, force to "0" to get that step green # whilst still gathering data to the perf dashboards. # The result_type is used by the test_dispatcher to retry the test. exit_code = 0 persisted_result = { 'name': test_name, 'output': output, 'exit_code': exit_code, 'result_type': result_type, 'total_time': (end_time - start_time).seconds, 'device': self.device, 'cmd': cmd, } self._SaveResult(persisted_result) return (output, result_type)
def _LaunchPerfTest(self, test_name): """Runs a perf test. Args: test_name: the name of the test to be executed. Returns: A tuple containing (Output, base_test_result.ResultType) """ try: logging.warning('Unmapping device ports') forwarder.Forwarder.UnmapAllDevicePorts(self.adb) self.adb.RestartAdbdOnDevice() except Exception as e: logging.error('Exception when tearing down device %s', e) cmd = ('%s --device %s' % (self._tests[test_name], self.device)) logging.info('%s : %s', test_name, cmd) start_time = datetime.datetime.now() timeout = 5400 if self._options.no_timeout: timeout = None full_cmd = cmd if self._options.dry_run: full_cmd = 'echo %s' % cmd logfile = sys.stdout if self._options.single_step: # Just print a heart-beat so that the outer buildbot functions won't timeout # without response. logfile = _HeartBeatLogger() cwd = os.path.abspath(constants.DIR_SOURCE_ROOT) if full_cmd.startswith('src/'): cwd = os.path.abspath( os.path.join(constants.DIR_SOURCE_ROOT, os.pardir)) output, exit_code = pexpect.run(full_cmd, cwd=cwd, withexitstatus=True, logfile=logfile, timeout=timeout, env=os.environ) if self._options.single_step: # Stop the logger. logfile.stop() end_time = datetime.datetime.now() if exit_code is None: exit_code = -1 logging.info('%s : exit_code=%d in %d secs at %s', test_name, exit_code, (end_time - start_time).seconds, self.device) result_type = base_test_result.ResultType.FAIL if exit_code == 0: result_type = base_test_result.ResultType.PASS actual_exit_code = exit_code if test_name in self._flaky_tests: # The exit_code is used at the second stage when printing the # test output. If the test is flaky, force to "0" to get that step green # whilst still gathering data to the perf dashboards. # The result_type is used by the test_dispatcher to retry the test. exit_code = 0 persisted_result = { 'name': test_name, 'output': output, 'exit_code': exit_code, 'actual_exit_code': actual_exit_code, 'result_type': result_type, 'total_time': (end_time - start_time).seconds, 'device': self.device, 'cmd': cmd, } self._SaveResult(persisted_result) return (output, result_type)
def _LaunchPerfTest(self, test_name): """Runs a perf test. Args: test_name: the name of the test to be executed. Returns: A tuple containing (Output, base_test_result.ResultType) """ try: logging.warning('Unmapping device ports') forwarder.Forwarder.UnmapAllDevicePorts(self.device) self.device.old_interface.RestartAdbdOnDevice() except Exception as e: logging.error('Exception when tearing down device %s', e) cmd = ('%s --device %s' % (self._tests[test_name], self.device.old_interface.GetDevice())) logging.info('%s : %s', test_name, cmd) start_time = datetime.datetime.now() timeout = 5400 if self._options.no_timeout: timeout = None full_cmd = cmd if self._options.dry_run: full_cmd = 'echo %s' % cmd logfile = sys.stdout if self._options.single_step: # Just print a heart-beat so that the outer buildbot scripts won't timeout # without response. logfile = _HeartBeatLogger() cwd = os.path.abspath(constants.DIR_SOURCE_ROOT) if full_cmd.startswith('src/'): cwd = os.path.abspath(os.path.join(constants.DIR_SOURCE_ROOT, os.pardir)) output, exit_code = pexpect.run( full_cmd, cwd=cwd, withexitstatus=True, logfile=logfile, timeout=timeout, env=os.environ) if self._options.single_step: # Stop the logger. logfile.stop() end_time = datetime.datetime.now() if exit_code is None: exit_code = -1 logging.info('%s : exit_code=%d in %d secs at %s', test_name, exit_code, (end_time - start_time).seconds, self.device.old_interface.GetDevice()) result_type = base_test_result.ResultType.FAIL if exit_code == 0: result_type = base_test_result.ResultType.PASS actual_exit_code = exit_code if test_name in self._flaky_tests: # The exit_code is used at the second stage when printing the # test output. If the test is flaky, force to "0" to get that step green # whilst still gathering data to the perf dashboards. # The result_type is used by the test_dispatcher to retry the test. exit_code = 0 persisted_result = { 'name': test_name, 'output': output, 'exit_code': exit_code, 'actual_exit_code': actual_exit_code, 'result_type': result_type, 'total_time': (end_time - start_time).seconds, 'device': self.device.old_interface.GetDevice(), 'cmd': cmd, } self._SaveResult(persisted_result) return (output, result_type)