1#!/usr/bin/env python 2 3import logging 4 5from conf import LisaLogging 6LisaLogging.setup() 7import json 8import os 9import devlib 10from env import TestEnv 11from android import Screen, Workload, System 12from trace import Trace 13import trappy 14import pandas as pd 15import sqlite3 16import argparse 17import shutil 18 19# Description: This experiments tests suspend/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 24parser = argparse.ArgumentParser(description='SuspendResume tests') 25 26parser.add_argument('--out_prefix', dest='out_prefix', action='store', default='default', 27 help='prefix for out directory') 28 29parser.add_argument('--collect', dest='collect', action='store', default='systrace', 30 help='what to collect (default systrace)') 31 32parser.add_argument('--duration', dest='duration_s', action='store', 33 default=15, type=int, 34 help='Duration of test (default 15s)') 35 36parser.add_argument('--serial', dest='serial', action='store', 37 help='Serial number of device to test') 38 39args = parser.parse_args() 40 41def experiment(): 42 # Get workload 43 wload = Workload.getInstance(te, 'SuspendResume') 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 SuspendResume 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 62my_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" : "SuspendResume", 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 96if args.serial: 97 my_conf["device"] = args.serial 98 99# Initialize a test environment using: 100te = TestEnv(my_conf, wipe=False) 101target = te.target 102 103results = experiment() 104