1# Copyright (c) 2014 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 5from autotest_lib.server import autotest, test 6 7 8class power_RPMTest(test.test): 9 """Test RPM functionality.""" 10 version = 1 11 12 13 def initialize(self, host, verify=True): 14 """ 15 @param host: The host to run the test on 16 @param verify: True to test both on and off for the AC power and to 17 check with the host whether it sees the same state 18 """ 19 self._host = host 20 self._host_at = autotest.Autotest(host) 21 self._verify = verify 22 23 24 def _set_power(self, power_on): 25 if power_on: 26 self._host.power_on() 27 else: 28 self._host.power_off() 29 30 if self._verify: 31 self._host_at.run_test('power_CheckAC', check_client_result=True, 32 power_on=power_on) 33 34 35 def run_once(self, power_sequence=[True]): 36 """Run the test.i 37 38 @param power_sequence: Sequence of values to set the power state to in 39 order 40 """ 41 42 for val in power_sequence: 43 self._set_power(val) 44