1# Copyright (c) 2013 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 5import json 6 7from autotest_lib.server import test 8from autotest_lib.server.cros import telemetry_runner 9from autotest_lib.server.cros.crosperf import device_setup_utils 10 11 12class telemetry_Benchmarks(test.test): 13 """Run a telemetry benchmark.""" 14 version = 1 15 16 17 def run_once(self, host=None, benchmark=None, args={}): 18 """Run a telemetry benchmark. 19 20 @param host: hostname(ip address) to run the telemetry benchmark on. 21 @param benchmark: telemetry benchmark test to run. 22 """ 23 local = args.get("local") == "True" 24 optional = {} 25 telemetry_on_dut = args.get("telemetry_on_dut") 26 if telemetry_on_dut: 27 optional["telemetry_on_dut"] = telemetry_on_dut == "True" 28 29 dut_config_str = args.get("dut_config", "{}") 30 dut_config = json.loads(dut_config_str) 31 if dut_config: 32 device_setup_utils.setup_device(host, dut_config) 33 34 telemetry = telemetry_runner.TelemetryRunner(host, local, **optional) 35 perf_value_writer = self 36 extra_args = args.get("extra_args", []) 37 repeat = args.get("pageset_repeat") 38 if repeat is not None: 39 extra_args.append('--pageset-repeat=%s' % repeat) 40 41 telemetry.run_telemetry_benchmark(benchmark, perf_value_writer, 42 *extra_args) 43