1 #!/usr/bin/env python 2 3 import logging 4 5 from conf import LisaLogging 6 LisaLogging.setup() 7 import json 8 import os 9 import devlib 10 from env import TestEnv 11 from android import Screen, Workload, System 12 from trace import Trace 13 import trappy 14 import pandas as pd 15 import sqlite3 16 import argparse 17 import shutil 18 19 # Description: This experiments tests idle/resume by turning off 20 # the screen and cutting off USB 21 # REQUIRES DEVICE TO BE CONNECTED THROUGH MONSOON SO THAT PASSTHROUGH 22 # CAN BE TURNED OFF. By default energy will be measured in this test. 23 24 parser = argparse.ArgumentParser(description='IdleResume tests') 25 26 parser.add_argument('--out_prefix', dest='out_prefix', action='store', default='default', 27 help='prefix for out directory') 28 29 parser.add_argument('--collect', dest='collect', action='store', default='systrace', 30 help='what to collect (default systrace)') 31 32 parser.add_argument('--duration', dest='duration_s', action='store', 33 default=15, type=int, 34 help='Duration of test (default 15s)') 35 36 parser.add_argument('--serial', dest='serial', action='store', 37 help='Serial number of device to test') 38 39 args = parser.parse_args() 40 41 def experiment(): 42 # Get workload 43 wload = Workload.getInstance(te, 'IdleResume') 44 45 outdir=te.res_dir + '_' + args.out_prefix 46 try: 47 shutil.rmtree(outdir) 48 except: 49 print "couldn't remove " + outdir 50 pass 51 os.makedirs(outdir) 52 53 # Run IdleResume 54 wload.run(outdir, duration_s=args.duration_s, collect=args.collect) 55 56 # Dump platform descriptor 57 te.platform_dump(te.res_dir) 58 59 te._log.info('RESULTS are in out directory: {}'.format(outdir)) 60 61 # Setup target configuration 62 my_conf = { 63 64 # Target platform and board 65 "platform" : 'android', 66 67 # Useful for reading names of little/big cluster 68 # and energy model info, its device specific and use 69 # only if needed for analysis 70 # "board" : 'pixel', 71 72 # Device 73 # By default the device connected is detected, but if more than 1 74 # device, override the following to get a specific device. 75 # "device" : "HT6880200489", 76 77 # Folder where all the results will be collected 78 "results_dir" : "IdleResume", 79 80 # Define devlib modules to load 81 "modules" : [ 82 'cpufreq', # enable CPUFreq support 83 'cpuidle', # enable cpuidle support 84 # 'cgroups' # Enable for cgroup support 85 ], 86 87 "emeter" : { 88 'instrument': 'monsoon', 89 'conf': { } 90 }, 91 92 # Tools required by the experiments 93 "tools" : [ 'taskset'], 94 } 95 96 if args.serial: 97 my_conf["device"] = args.serial 98 99 # Initialize a test environment using: 100 te = TestEnv(my_conf, wipe=False) 101 target = te.target 102 103 results = experiment() 104