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