• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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='UiBench 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='UiBenchJankTests#testResizeHWLayer',
45                    help='which test to run')
46
47parser.add_argument('--iterations', dest='iterations', action='store',
48                    default=10, type=int,
49                    help='Number of times to repeat the tests per run (default 10)')
50
51parser.add_argument('--serial', dest='serial', action='store',
52                    help='Serial number of device to test')
53
54parser.add_argument('--all', dest='run_all', action='store_true',
55                    help='Run all tests')
56
57parser.add_argument('--reinstall', dest='reinstall', action='store_true',
58                    help='Rebuild and reinstall test apks')
59
60parser.add_argument('--reimage', dest='reimage', action='store',
61                    default='',
62                    help='Flag to reimage target device (kernel-update kernel image | all-update complete android image)')
63
64parser.add_argument('--kernel_path', dest='kernel_path', action='store',
65                    default='',
66                    help='Path to kernel source directory. Required if reimage option is used')
67
68args = parser.parse_args()
69
70def make_dir(outdir):
71    try:
72        shutil.rmtree(outdir)
73    except:
74        print "couldn't remove " + outdir
75        pass
76    os.makedirs(outdir)
77
78def experiment():
79    def run_test(outdir, test_name):
80        te._log.info("Running test {}".format(test_name))
81        wload.run(outdir, test_name=test_name, iterations=args.iterations, collect=args.collect)
82
83    if args.reimage:
84        System.reimage(te, args.kernel_path, args.reimage)
85
86    # Get workload
87    wload = Workload.getInstance(te, 'UiBench', args.reinstall)
88
89    outdir=te.res_dir + '_' + args.out_prefix
90    make_dir(outdir)
91
92    # Run UiBench
93    if args.run_all:
94        te._log.info("Running all tests: {}".format(wload.test_list))
95        for test in wload.get_test_list():
96            test_outdir = os.path.join(outdir, test)
97            make_dir(test_outdir)
98            run_test(test_outdir, test)
99    else:
100        test_outdir = os.path.join(outdir, args.test_name)
101        make_dir(test_outdir)
102        run_test(test_outdir, args.test_name)
103
104    # Dump platform descriptor
105    te.platform_dump(te.res_dir)
106
107    te._log.info('RESULTS are in out directory: {}'.format(outdir))
108
109# Setup target configuration
110my_conf = {
111
112    # Target platform and board
113    "platform"     : 'android',
114
115    # Useful for reading names of little/big cluster
116    # and energy model info, its device specific and use
117    # only if needed for analysis
118    # "board"        : 'pixel',
119
120    # Device
121    # By default the device connected is detected, but if more than 1
122    # device, override the following to get a specific device.
123    # "device"       : "HT6880200489",
124
125    # Folder where all the results will be collected
126    "results_dir" : "UiBench",
127
128    # Define devlib modules to load
129    "modules"     : [
130        'cpufreq',      # enable CPUFreq support
131        'cpuidle',      # enable cpuidle support
132        # 'cgroups'     # Enable for cgroup support
133    ],
134
135    "emeter" : {
136        'instrument': 'monsoon',
137        'conf': { }
138    },
139
140    # Tools required by the experiments
141    "tools"   : [ 'taskset'],
142
143    "skip_nrg_model" : True,
144}
145
146if args.serial:
147    my_conf["device"] = args.serial
148
149# Initialize a test environment using:
150te = TestEnv(my_conf, wipe=False)
151target = te.target
152
153results = experiment()
154