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
5from autotest_lib.client.common_lib import utils
6
7AUTHOR = "llozano@chromium.org c-compiler-chrome@google.com"
8NAME = "telemetry_AFDOGenerate"
9PURPOSE = "Produce profile (AFDO format) of normal browsing for optimization."
10ATTRIBUTES = "suite:AFDO_record"
11SUITE = "AFDO_record"
12TIME = "LONG"
13TEST_CATEGORY = "Benchmark"
14TEST_CLASS = "telemetry"
15TEST_TYPE = "server"
16# The test uses gsutil to do upload, which is not supported in container.
17REQUIRE_SSP = False
18
19DOC = """
20Run a pre-defined set of benchmarks on the DUT and create a sampled profile
21of the chrome execution. The profile is generated in AFDO format.
22See go/afdo for more information about AFDO.
23For now, this test is only designed to run on lumpy and parrot boards.
24It will fail if run on other boards.
25
26Example invocation:
27/usr/bin/test_that --debug --board=lumpy <DUT IP>
28  --args="ignore_failures=True local=True gs_test_location=True"
29  telemetry_PGOGenerate
30"""
31
32args_dict = utils.args_to_dict(args)
33
34profiler = 'custom_perf'
35# These are arguments to the linux "perf" tool.
36# The -e value is processor specific and comes from the Intel SDM vol 3b
37profiler_args = 'record -a -e r20c4 -c 500000 -b '
38
39job.default_profile_only = True
40job.profilers.add(profiler, profiler_args)
41
42def run_telemetry_AFDOGenerate(machine):
43    run_host = hosts.create_host(machine)
44
45    # TODO (llozano):
46    # Pass "disable_sysinfo=True" to run_test since it would be nice
47    # to avoid copying all the logs back to the server. However, we
48    # cannot do this because of crosbug 308646
49    job.run_test('telemetry_AFDOGenerate', host=run_host,
50                  args=args_dict)
51
52job.parallel_simple(run_telemetry_AFDOGenerate, machines)
53
54if profiler:
55    job.profilers.delete(profiler)
56