run_sysui.py revision 6e3604a24925c2ca67f6cf4b3415c0d6c8b80e75
1#!/usr/bin/env python 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# 18 19import logging 20 21from conf import LisaLogging 22LisaLogging.setup() 23import json 24import os 25import devlib 26from env import TestEnv 27from android import Screen, Workload, System 28from trace import Trace 29import trappy 30import pandas as pd 31import sqlite3 32import argparse 33import shutil 34 35parser = argparse.ArgumentParser(description='SystemUi tests') 36 37parser.add_argument('--out_prefix', dest='out_prefix', action='store', default='default', 38 help='prefix for out directory') 39 40parser.add_argument('--collect', dest='collect', action='store', default='systrace', 41 help='what to collect (default systrace)') 42 43parser.add_argument('--test', dest='test_name', action='store', 44 default='SystemUiJankTests#testNotificationListPull', 45 help='which test to run') 46 47parser.add_argument('--duration', dest='duration_s', action='store', 48 default=30, type=int, 49 help='Duration of test (default 30s)') 50 51parser.add_argument('--iterations', dest='iterations', action='store', 52 default=5, type=int, 53 help='Duration of test (default 5s)') 54 55parser.add_argument('--serial', dest='serial', action='store', 56 help='Serial number of device to test') 57 58parser.add_argument('--all', dest='run_all', action='store_true', 59 help='Run all tests') 60 61args = parser.parse_args() 62 63def make_dir(outdir): 64 try: 65 shutil.rmtree(outdir) 66 except: 67 print "coulnd't remove " + outdir 68 pass 69 os.makedirs(outdir) 70 71def 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 99my_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' ] 134 }, 135 136 "skip_nrg_model" : True, 137} 138 139if args.serial: 140 my_conf["device"] = args.serial 141 142# Initialize a test environment using: 143te = TestEnv(my_conf, wipe=False) 144target = te.target 145 146results = experiment() 147