Home | History | Annotate | Download | only in power_ServodWrapper
      1 # Copyright 2018 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 from autotest_lib.server import utils
      6 
      7 AUTHOR = "mqg"
      8 NAME = "power_ServodWrapper"
      9 PURPOSE = "Measure power with servod while running a client test."
     10 CRITERIA = "This test is a wrapper for a client test."
     11 TIME = "LONG"
     12 TEST_CATEGORY = "Benchmark"
     13 TEST_CLASS = "power"
     14 TEST_TYPE = "server"
     15 DEPENDENCIES = "servo"
     16 
     17 DOC = """
     18 This wrapper test automates the process of power measurement with servod while
     19 running a client test. Please check the client test's control file for any
     20 hardware requirement, e.g. no AC power, no Ethernet.
     21 
     22 This test makes the following assumptions:
     23 1. Servod is already running, and its host and port are provided to this
     24 autotest.
     25 
     26 2. The workstation (or where the autotest is kicked off from) should be in same
     27 timezone with the DUT.
     28 
     29 Sample usage:
     30 test_that <ip address of DUT> power_ServodWrapper --args \
     31 'test=power_LoadTest.fast servo_host=localhost servo_port=9999 \
     32 ina_rate=20 vbat_rate=60'
     33 
     34 What are the parameters:
     35 test: the client test to run in wrapper test; DUT power is measured during this
     36       client test; required.
     37 servo_host: host of servod instance; required.
     38 servo_port: port that the servod instance is on; required.
     39 ina_rate: power measurement from INAs are logged every ina_rate seconds;
     40           optional.
     41 vbat_rate: power measurement from EC is logged every vbat_rate seconds;
     42            optional.
     43 note: User supplied note to tag the specific test; optional.
     44 """
     45 
     46 # Workaround to make it compatible with moblab autotest UI.
     47 global args_dict
     48 try:
     49     args_dict
     50 except NameError:
     51     args_dict = utils.args_to_dict(args)
     52 servo_args = hosts.CrosHost.get_servo_arguments(args_dict)
     53 
     54 def run(machine):
     55     host = hosts.create_host(machine, servo_args=servo_args)
     56     job.run_test("power_ServodWrapper", host=host, config=args_dict)
     57 
     58 parallel_simple(run, machines)
     59