• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 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 utils
6
7AUTHOR = "coconutruben"
8NAME = "power_Monitoring"
9PURPOSE = "Continuously measure power with servod while running client tests."
10CRITERIA = "This test is a wrapper for ServodWrapper wrapped test(s)."
11TIME = "LONG"
12TEST_CATEGORY = "Benchmark"
13TEST_CLASS = "power"
14TEST_TYPE = "server"
15DEPENDENCIES = "servo_state:WORKING"
16
17DOC = """
18This wrapper test runs the tests specified under a given suite in a continuous
19loop for a given amount of time. If the DUT runs out of power, the test charges
20it before continuing the test suite.
21
22So this test is designed to collect all relevant power tests for many loops.
23This has three main advantages and use cases:
24- There is a wider spread of battery charge percentages that tests run under
25  as tests don't recharge at the end individually.
26- This runs as a one stop test and requires less configuration and scheduling.
27- As this runs as one test this allows to collect multiple samples of the same
28  client test under the same OS image in environments where a new test triggers
29  an image update.
30
31Based on the above this test might be a good fit for your use case or not.
32
33This test makes the following assumptions:
341. The DUT is attached to a servo device that supports charging and
35discharging (currently only v4).
36
372. Servod is already running, and its host and port are provided to this
38autotest.
39
403. The workstation (or where the autotest is kicked off from) should be in same
41timezone with the DUT.
42
43Sample usage:
44test_that <ip address of DUT> power_Monitoring --args \
45'suite=power_monitoring runtime_hr=20 servo_host=localhost servo_port=9999'
46
47What are the parameters (all optional with defaults):
48suite: the test suite to run.
49runtime_hr: desired runtime in hours.
50start_charging_level: battery charge percent when charging triggers.
51stop_charging_level: battery charge percent when charging stops.
52servo_host: host of servod instance.
53servo_port: port that the servod instance is on.
54pdash_note: User supplied note to tag the specific test; optional.
55"""
56# Workaround to make it compatible with moblab autotest UI.
57global args_dict
58try:
59    args_dict
60except NameError:
61    args_dict = utils.args_to_dict(args)
62servo_args = hosts.CrosHost.get_servo_arguments(args_dict)
63
64def run(machine):
65    host = hosts.create_host(machine, servo_args=servo_args)
66    job.run_test('power_Monitoring', host=host, config=args_dict,
67                 disable_sysinfo=True)
68parallel_simple(run, machines)
69