Joel Fernandes | 687487f | 2017-08-22 22:03:27 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
Connor O'Brien | 6e3604a | 2017-10-10 11:49:19 -0700 | [diff] [blame] | 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # |
| 4 | # Copyright (C) 2017, ARM Limited, Google, and contributors. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # |
Joel Fernandes | 687487f | 2017-08-22 22:03:27 -0700 | [diff] [blame] | 18 | |
| 19 | import logging |
| 20 | |
| 21 | from conf import LisaLogging |
| 22 | LisaLogging.setup() |
| 23 | import json |
| 24 | import os |
| 25 | import devlib |
| 26 | from env import TestEnv |
| 27 | from android import Screen, Workload, System |
| 28 | from trace import Trace |
| 29 | import trappy |
| 30 | import pandas as pd |
| 31 | import sqlite3 |
| 32 | import argparse |
| 33 | import shutil |
| 34 | |
| 35 | parser = argparse.ArgumentParser(description='SystemUi tests') |
| 36 | |
| 37 | parser.add_argument('--out_prefix', dest='out_prefix', action='store', default='default', |
| 38 | help='prefix for out directory') |
| 39 | |
| 40 | parser.add_argument('--collect', dest='collect', action='store', default='systrace', |
| 41 | help='what to collect (default systrace)') |
| 42 | |
| 43 | parser.add_argument('--test', dest='test_name', action='store', |
| 44 | default='SystemUiJankTests#testNotificationListPull', |
| 45 | help='which test to run') |
| 46 | |
| 47 | parser.add_argument('--duration', dest='duration_s', action='store', |
| 48 | default=30, type=int, |
| 49 | help='Duration of test (default 30s)') |
| 50 | |
| 51 | parser.add_argument('--iterations', dest='iterations', action='store', |
| 52 | default=5, type=int, |
| 53 | help='Duration of test (default 5s)') |
| 54 | |
| 55 | parser.add_argument('--serial', dest='serial', action='store', |
| 56 | help='Serial number of device to test') |
| 57 | |
| 58 | parser.add_argument('--all', dest='run_all', action='store_true', |
| 59 | help='Run all tests') |
| 60 | |
| 61 | args = parser.parse_args() |
| 62 | |
| 63 | def make_dir(outdir): |
| 64 | try: |
| 65 | shutil.rmtree(outdir) |
| 66 | except: |
| 67 | print "coulnd't remove " + outdir |
| 68 | pass |
| 69 | os.makedirs(outdir) |
| 70 | |
| 71 | def experiment(): |
| 72 | def run_test(outdir, test_name): |
| 73 | te._log.info("Running test {}".format(test_name)) |
| 74 | wload.run(outdir, test_name=test_name, iterations=args.iterations, collect=args.collect) |
| 75 | |
| 76 | # Get workload |
| 77 | wload = Workload.getInstance(te, 'SystemUi') |
| 78 | |
| 79 | outdir=te.res_dir + '_' + args.out_prefix |
| 80 | make_dir(outdir) |
| 81 | |
| 82 | # Run SysUiBench |
| 83 | if args.run_all: |
| 84 | te._log.info("Running all tests: {}".format(wload.test_list)) |
| 85 | for test in wload.get_test_list(): |
| 86 | test_outdir = os.path.join(outdir, test) |
| 87 | make_dir(test_outdir) |
| 88 | run_test(test_outdir, test) |
| 89 | else: |
| 90 | run_test(outdir, args.test_name) |
| 91 | |
| 92 | |
| 93 | # Dump platform descriptor |
| 94 | te.platform_dump(te.res_dir) |
| 95 | |
| 96 | te._log.info('RESULTS are in out directory: {}'.format(outdir)) |
| 97 | |
| 98 | # Setup target configuration |
| 99 | my_conf = { |
| 100 | |
| 101 | # Target platform and board |
| 102 | "platform" : 'android', |
| 103 | |
| 104 | # Useful for reading names of little/big cluster |
| 105 | # and energy model info, its device specific and use |
| 106 | # only if needed for analysis |
| 107 | # "board" : 'pixel', |
| 108 | |
| 109 | # Device |
| 110 | # By default the device connected is detected, but if more than 1 |
| 111 | # device, override the following to get a specific device. |
| 112 | # "device" : "HT6880200489", |
| 113 | |
| 114 | # Folder where all the results will be collected |
| 115 | "results_dir" : "SysUiBench", |
| 116 | |
| 117 | # Define devlib modules to load |
| 118 | "modules" : [ |
| 119 | 'cpufreq', # enable CPUFreq support |
| 120 | 'cpuidle', # enable cpuidle support |
| 121 | # 'cgroups' # Enable for cgroup support |
| 122 | ], |
| 123 | |
| 124 | "emeter" : { |
| 125 | 'instrument': 'monsoon', |
| 126 | 'conf': { } |
| 127 | }, |
| 128 | |
| 129 | # Tools required by the experiments |
| 130 | "tools" : [ 'taskset'], |
| 131 | |
| 132 | "systrace": { |
| 133 | "extra_events" : [ 'sched_boost_task', 'sched_boost_cpu' ] |
Joel Fernandes | c63d542 | 2017-08-22 22:13:49 -0700 | [diff] [blame] | 134 | }, |
| 135 | |
| 136 | "skip_nrg_model" : True, |
Joel Fernandes | 687487f | 2017-08-22 22:03:27 -0700 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | if args.serial: |
| 140 | my_conf["device"] = args.serial |
| 141 | |
| 142 | # Initialize a test environment using: |
| 143 | te = TestEnv(my_conf, wipe=False) |
| 144 | target = te.target |
| 145 | |
| 146 | results = experiment() |