1# Copyright 2018 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5"""Wrapper test measures DUT power with Sweetberry via powerlog tool.""" 6 7from autotest_lib.server.cros.power import power_base_wrapper 8from autotest_lib.server.cros.power import power_telemetry_logger 9from autotest_lib.server.cros.power import servo_charger 10 11 12class power_PowerlogWrapper(power_base_wrapper.PowerBaseWrapper): 13 """Wrapper test around a client test. 14 15 This wrapper test runs 1 client test given by user, and measures DUT power 16 with Sweetberry via powerlog tool. 17 """ 18 version = 1 19 20 def warmup(self, host, charge_control=False): 21 """Disconnect DUT from AC power. 22 23 Many power autotests require that DUT is on battery, thus disconnect DUT 24 from AC power as preparation. 25 """ 26 super(power_PowerlogWrapper, self).warmup(host) 27 if charge_control: 28 self._charge_manager = servo_charger.ServoV4ChargeManager( 29 host, host.servo) 30 self._charge_manager.stop_charging() 31 32 def cleanup(self, charge_control=False): 33 """Connect DUT to AC power. 34 35 This allows DUT to charge between tests, and complies with moblab 36 requirement. 37 """ 38 if charge_control: 39 self._charge_manager.start_charging() 40 super(power_PowerlogWrapper, self).cleanup() 41 42 def _get_power_telemetry_logger(self, host, config, resultsdir): 43 """Return powerlog telemetry logger. 44 45 @param host: CrosHost object representing the DUT. 46 @param config: the args argument from test_that in a dict. Settings for 47 power telemetry devices. 48 required data: {'test': 'test_TestName.tag'} 49 @param resultsdir: path to directory where current autotest results are 50 stored, e.g. /tmp/test_that_results/ 51 results-1-test_TestName.tag/test_TestName.tag/ 52 results/ 53 """ 54 return power_telemetry_logger.PowerlogTelemetryLogger(config, 55 resultsdir, 56 host) 57