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.
4import re
5
6AUTHOR = "Chrome OS Team"
7NAME = "power_Standby"
8TIME = "LONG"
9TEST_CATEGORY = "Benchmark"
10TEST_CLASS = "power"
11TEST_TYPE = "client"
12
13DOC = """
14This test measures the power draw during standby (S3).
15
16Test uses RTC wake to transistion from S3 to S0 every sample_hours for a total
17  standby time of test_hours.  The S3->S0 transistions are added to
18  1. Validate battery use
19  2. Guarantee that S3 was maintained (no external/false wake)
20  3. Create S3->S0->S3 transistions which more closely model user's interaction.
21
22Arguments:
23  sample_hours: float, number of hours between charge use samples.
24  test_hours: float, the number of hours to run the test.
25
26Test must meet the following criteria:
27  Battery must contain ~20% of its charge.
28  Must be run on battery power
29  sample_hours > 0.1
30  test_hours > sample_hours
31"""
32
33opts = {}
34sample_hours = 1.0
35test_hours = 12.0
36max_milliwatts_standby = 500.0
37
38for arg in args:
39    match = re.search("^(\w+)=(.+)", arg)
40    if match:
41        opts[match.group(1)] = match.group(2)
42
43if 'test_hours' in opts:
44    test_hours = float(opts['test_hours'])
45
46if 'sample_hours' in opts:
47    sample_hours = float(opts['sample_hours'])
48
49
50constraints = []
51constraints.append("milliwatts_standby_power <= %.2f" % max_milliwatts_standby)
52
53job.run_test('power_Standby', sample_hours=sample_hours, test_hours=test_hours,
54             constraints=constraints,
55             max_milliwatts_standby=max_milliwatts_standby)
56