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='DisplayImage 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='energy', 41 help='What to collect (default energy). Also supports option ' 42 'display-energy which suspends the cpu to help prevent extra ' 43 'energy consumption by the cpu.') 44 45parser.add_argument('--image', dest='image', action='store', default='image.png', 46 type=str, 47 help='name of image located in LISA_HOME/experiments/data'\ 48 ' (default image.png)') 49 50parser.add_argument('--brightness', dest='brightness', action='store', default=100, 51 type=int, 52 help='Brightness of screen (default 100)') 53 54parser.add_argument('--duration', dest='duration_s', action='store', 55 default=15, type=int, 56 help='Duration of test (default 15s)') 57 58parser.add_argument('--serial', dest='serial', action='store', 59 help='Serial number of device to test') 60 61args = parser.parse_args() 62 63def experiment(): 64 # Get workload 65 wload = Workload.getInstance(te, 'DisplayImage') 66 67 outdir=te.res_dir + '_' + args.out_prefix 68 try: 69 shutil.rmtree(outdir) 70 except: 71 print "couldn't remove " + outdir 72 pass 73 os.makedirs(outdir) 74 75 # Run DisplayImage 76 wload.run(outdir, duration_s=args.duration_s, brightness=args.brightness, 77 filepath=os.path.join(os.environ["LISA_HOME"], 78 'experiments/data', args.image), collect=args.collect) 79 80 # Dump platform descriptor 81 te.platform_dump(te.res_dir) 82 83 te._log.info('RESULTS are in out directory: {}'.format(outdir)) 84 85# Setup target configuration 86my_conf = { 87 88 # Target platform and board 89 "platform" : 'android', 90 91 # Useful for reading names of little/big cluster 92 # and energy model info, its device specific and use 93 # only if needed for analysis 94 # "board" : 'pixel', 95 96 # Device 97 # By default the device connected is detected, but if more than 1 98 # device, override the following to get a specific device. 99 # "device" : "HT6880200489", 100 101 # Folder where all the results will be collected 102 "results_dir" : "DisplayImage", 103 104 # Define devlib modules to load 105 "modules" : [ 106 'cpufreq', # enable CPUFreq support 107 ], 108 109 "emeter" : { 110 'instrument': 'monsoon', 111 'conf': { } 112 }, 113 114 # Tools required by the experiments 115 "tools" : [ ], 116 117 "skip_nrg_model" : True, 118} 119 120if args.serial: 121 my_conf["device"] = args.serial 122 123# Initialize a test environment using: 124te = TestEnv(my_conf, wipe=False) 125target = te.target 126 127results = experiment() 128