Home | History | Annotate | Download | only in sequences
      1 # Copyright (c) 2010 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 AUTHOR = "Chrome OS Team"
      6 NAME = "Power"
      7 TIME = "LONG"
      8 TEST_CATEGORY = "Functional"
      9 TEST_CLASS = "suite"
     10 TEST_TYPE = "server"
     11 DEPENDENCIES = "rpm"
     12 
     13 DOC = """
     14 This test suite runs automated power tests that should all pass and that
     15 require the power to be connected with a remote power manager.
     16 """
     17 
     18 from autotest_lib.server import site_host_attributes
     19 from autotest_lib.client.common_lib import error
     20 
     21 # Run power tests that don't take a long time
     22 TESTS = [
     23   'power_Backlight',
     24   'power_CPUFreq',
     25   'power_CPUIdle',
     26   'power_Draw',
     27   'power_Idle',
     28   'power_StatsCPUFreq',
     29   'power_StatsCPUIdle',
     30   'power_StatsUSB',
     31   'power_x86Settings'
     32 ]
     33 
     34 
     35 def run_client_test(machine):
     36   client = hosts.create_host(machine)
     37   client_attributes = site_host_attributes.HostAttributes(machine)
     38   client_at = autotest.Autotest(client)
     39 
     40   if client.has_power():
     41     client.power_on()
     42   else:
     43     raise error.TestNAError("No power switch configured")
     44 
     45   # Run power_x86Settings test with AC power connected
     46   client_at.run_test('power_x86Settings', tag='AC_ONLINE')
     47 
     48   # Charge battery to at least 50% first
     49   client_at.run_test('power_BatteryCharge', percent_target_charge=50,
     50                      max_run_time=60*60*4, tag='CHARGE_50')
     51 
     52   client.power_off()
     53   try:
     54     for test in TESTS:
     55         client_at.run_test(test)
     56 
     57     if not client_attributes.has_resume_bug:
     58         client_at.run_test('power_Resume')
     59 
     60   finally:
     61     client.power_on()
     62 
     63   # Run the 60/20/10/10 load test
     64   # Charge the battery to at least 99% in preparation for the load
     65   # test. Charging the battery from empty to full can take up to 4 hours.
     66   client_at.run_test('power_BatteryCharge', percent_target_charge=99,
     67                      max_run_time=60*60*5, tag='CHARGE_99')
     68 
     69   # Turn off power and run power_LoadTest. The power_LoadTest can take
     70   # up to 9 hours to run to completion
     71   # TODO (snanda):
     72   # 1. Make the test run over wifi instead of ethernet
     73   # 2. Make the test login automatically to facebook and gmail
     74   # 3. Add audiovideo_V4L2 webcam test
     75   client.power_off()
     76 
     77   try:
     78     if hasattr(client_attributes, 'wifi'):
     79       wifi_ap, wifi_sec, wifi_pw = client_attributes.wifi.split(',')
     80 
     81       client_at.run_test('power_LoadTest', loop_count=9, loop_time=3600,
     82                          force_wifi=True, wifi_ap=wifi_ap, wifi_sec=wifi_sec,
     83                          wifi_pw=wifi_pw, tag='WIFI')
     84     else:
     85       client_at.run_test('power_LoadTest', loop_count=9, loop_time=3600,
     86                          check_network=False, tag='WIRED')
     87   finally:
     88     client.power_on()
     89 
     90 
     91 job.parallel_on_machines(run_client_test, machines)
     92