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 that controls charging / discharging DUT with Servo v4.""" 6 7from autotest_lib.server import test 8from autotest_lib.server.cros.power import servo_charger 9from autotest_lib.server.cros.power import wrapper_test_runner 10 11 12class power_ChargeControlWrapper(test.test): 13 """Base class for a wrapper test around a client test. 14 15 This wrapper test runs 1 client test given by user, and controls charging / 16 discharging the DUT with Servo v4. 17 """ 18 version = 1 19 20 def run_once(self, host, config): 21 """Measure power while running the client side test. 22 23 @param host: CrosHost object representing the DUT. 24 @param config: the args argument from test_that in a dict. 25 required data: {'test': 'test_TestName.tag'} 26 """ 27 test_runner = wrapper_test_runner.WrapperTestRunner( 28 config, self.autodir) 29 test_runner.run_test(host) 30 31 def warmup(self, host): 32 """Disconnect DUT from AC power. 33 34 Many power autotests require that DUT is on battery, thus disconnect DUT 35 from AC power as preparation. 36 """ 37 super(power_ChargeControlWrapper, self).warmup(host) 38 self._charge_manager = servo_charger.ServoV4ChargeManager(host, 39 host.servo) 40 self._charge_manager.stop_charging() 41 42 def cleanup(self): 43 """Connect DUT to AC power. 44 45 This allows DUT to charge between tests, and complies with moblab 46 requirement. 47 """ 48 self._charge_manager.start_charging() 49 super(power_ChargeControlWrapper, self).cleanup() 50