diff --git a/android/pylib/device/battery_utils.py b/android/pylib/device/battery_utils.py index 1be42037d..aa9b657b0 100644 --- a/android/pylib/device/battery_utils.py +++ b/android/pylib/device/battery_utils.py @@ -455,7 +455,7 @@ class BatteryUtils(object): logging.info('Current battery temperature: %s', temp) return int(temp) <= target_temp - logging.info('Waiting for the device to cool down to %s degrees.', + logging.info('Waiting for the device to cool down to %s (0.1 C)', target_temp) timeout_retry.WaitFor(cool_device, wait_period=wait_period) diff --git a/android/pylib/perf/test_options.py b/android/pylib/perf/test_options.py index 0a0ace080..e6ef5602d 100644 --- a/android/pylib/perf/test_options.py +++ b/android/pylib/perf/test_options.py @@ -17,4 +17,5 @@ PerfOptions = collections.namedtuple('PerfOptions', [ 'single_step', 'collect_chartjson_data', 'output_chartjson_data', + 'max_battery_temp', ]) diff --git a/android/pylib/perf/test_runner.py b/android/pylib/perf/test_runner.py index 0f464c3cd..31eb0e9e9 100644 --- a/android/pylib/perf/test_runner.py +++ b/android/pylib/perf/test_runner.py @@ -273,6 +273,10 @@ class TestRunner(base_test_runner.BaseTestRunner): logging.info( 'temperature: %s (0.1 C)', str(self._device_battery.GetBatteryInfo().get('temperature'))) + if self._options.max_battery_temp: + self._device_battery.LetBatteryCoolToTemperature( + self._options.max_battery_temp) + logging.info('%s : %s', test_name, cmd) start_time = datetime.datetime.now() diff --git a/android/test_runner.py b/android/test_runner.py index 43387cb7e..d508ef8d7 100755 --- a/android/test_runner.py +++ b/android/test_runner.py @@ -606,6 +606,11 @@ def AddPerfTestOptions(parser): group.add_argument( '--dry-run', action='store_true', help='Just print the steps without executing.') + # Uses 0.1 degrees C because that's what Android does. + group.add_argument( + '--max-battery-temp', type=int, + help='Only start tests when the battery is at or below the given ' + 'temperature (0.1 C)') group.add_argument('single_step_command', nargs='*', action=SingleStepAction, help='If --single-step is specified, the command to run.') AddCommonOptions(parser) @@ -630,7 +635,7 @@ def ProcessPerfTestOptions(args): args.steps, args.flaky_steps, args.output_json_list, args.print_step, args.no_timeout, args.test_filter, args.dry_run, args.single_step, args.collect_chartjson_data, - args.output_chartjson_data) + args.output_chartjson_data, args.max_battery_temp) def AddPythonTestOptions(parser):