1# Copyright (c) 2012 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 5AUTHOR = "Chrome OS Team" 6NAME = "Power Requirements tests" 7ATTRIBUTES = "suite:power_requirements" 8TIME = "LONG" 9TEST_CATEGORY = "Functional" 10TEST_CLASS = "suite" 11TEST_TYPE = "server" 12DEPENDENCIES = "rpm" 13 14DOC = """ 15This test suite runs automated power tests that should all pass. These tests 16take a long time (several hours) to run and are intended to ensure that the DUT 17complies with the power subsection of our CrOS Requirements doc. 18 19Current tests with runtimes are: 20 power_BatteryCharge : <= 3 hours 21 power_Standby : 12 hours 22 23""" 24# TODO(tbroch) Deprecate this control file when SUITES= mechanism detailed @ 25# https://sites.google.com/a/chromium.org/dev/chromium-os/testing/test-suites 26# has ability to assure power states pre/post conditions. 27from autotest_lib.server import site_host_attributes 28from autotest_lib.client.common_lib import error 29 30def _run_client_test(machine): 31 client = hosts.create_host(machine) 32 client_attributes = site_host_attributes.HostAttributes(client.hostname) 33 client_at = autotest.Autotest(client) 34 if client.has_power(): 35 client.power_on() 36 else: 37 raise error.TestNAError("No power switch configured") 38 39 # TODO(tbroch): Add power_Standby here once there's a mechanism to postpone 40 # autotest server from checking that DUT is still alive via network 41 42 # Run the full 60/20/10/10 load test, draining a full battery 43 client_at.run_test('power_BatteryCharge', percent_target_charge=100, 44 max_run_time=60*60*6, tag='CHARGE_100') 45 try: 46 client.power_off() 47 if hasattr(client_attributes, 'wifi'): 48 ap, sec, pw = client_attributes.wifi.split(',') 49 client_at.run_test('power_LoadTest', loop_count=12, loop_time=3600, 50 force_wifi=True, wifi_ap=ap, wifi_sec=sec, 51 wifi_pw=pw, tag='WIFI_full') 52 else: 53 client_at.run_test('power_LoadTest', loop_count=12, loop_time=3600, 54 check_network=False, tag='WIRED_full') 55 finally: 56 client.power_on() 57 58 # From client/site_tests/suite_HWQual/control.battery_charge_time 59 max_hours = 3 60 percent_charge_delta = 94.0 61 time_limit = max_hours * 60 * 60 * percent_charge_delta / 100.0 62 # battery must be at least 80% of design capacity 63 percent_battery_wear_allowed = .20 64 65 client_at.run_test('power_BatteryCharge', tag='full', 66 max_run_time=time_limit, 67 percent_charge_to_add=100, 68 percent_initial_charge_max=5, 69 use_design_charge_capacity=False, 70 constraints=[ 71 '1.0 - ah_charge_full / ah_charge_full_design <= %f' % 72 percent_battery_wear_allowed, 73 'percent_final_charge - percent_initial_charge >= %f' % 74 percent_charge_delta, 75 ]) 76 77job.parallel_on_machines(_run_client_test, machines) 78