aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuren Baghdasaryan <surenb@google.com>2017-08-31 13:20:47 -0700
committerSuren Baghdasaryan <surenb@google.com>2017-09-29 14:27:08 -0700
commitf5e6c7dd1f499f557e7ad53a1da59fec2c8ab066 (patch)
treec545e280e2e9538e205493ef2436bffc6499deec
parentb10c8551a7c692a39ed3e04326560912e9e5168a (diff)
downloadlisa-f5e6c7dd1f499f557e7ad53a1da59fec2c8ab066.tar.gz
experiments/uibench: Add command-line options to reimage target device
Add --reimage and --kernel_path command-line option to allow user to rebuild kernel and android images and reflash the target device. Change-Id: I4a76c43e8901242dcb1ce7b27670bc54fa4f8508 Signed-off-by: Suren Baghdasaryan <surenb@google.com>
-rwxr-xr-xexperiments/run_uibench.py13
-rw-r--r--libs/utils/android/system.py65
-rw-r--r--libs/utils/android/workload.py11
3 files changed, 88 insertions, 1 deletions
diff --git a/experiments/run_uibench.py b/experiments/run_uibench.py
index 3d122da..abff931 100755
--- a/experiments/run_uibench.py
+++ b/experiments/run_uibench.py
@@ -41,13 +41,21 @@ parser.add_argument('--all', dest='run_all', action='store_true',
parser.add_argument('--reinstall', dest='reinstall', action='store_true',
help='Rebuild and reinstall test apks')
+parser.add_argument('--reimage', dest='reimage', action='store',
+ default='',
+ help='Flag to reimage target device (kernel-update kernel image | all-update complete android image)')
+
+parser.add_argument('--kernel_path', dest='kernel_path', action='store',
+ default='',
+ help='Path to kernel source directory. Required if reimage option is used')
+
args = parser.parse_args()
def make_dir(outdir):
try:
shutil.rmtree(outdir)
except:
- print "coulnd't remove " + outdir
+ print "couldn't remove " + outdir
pass
os.makedirs(outdir)
@@ -56,6 +64,9 @@ def experiment():
te._log.info("Running test {}".format(test_name))
wload.run(outdir, test_name=test_name, iterations=args.iterations, collect=args.collect)
+ if args.reimage:
+ System.reimage(te, args.kernel_path, args.reimage)
+
# Get workload
wload = Workload.getInstance(te, 'UiBench', args.reinstall)
diff --git a/libs/utils/android/system.py b/libs/utils/android/system.py
index be7b0b3..6caef69 100644
--- a/libs/utils/android/system.py
+++ b/libs/utils/android/system.py
@@ -19,13 +19,17 @@ import logging
from devlib.utils.android import adb_command
from devlib import TargetError
+from devlib.utils.android_build import Build
+from time import sleep
import os
import re
import time
+import json
import pexpect as pe
GET_FRAMESTATS_CMD = 'shell dumpsys gfxinfo {} > {}'
ADB_INSTALL_CMD = 'install -g -r {}'
+BOARD_CONFIG_FILE = 'board.json'
class System(object):
"""
@@ -676,4 +680,65 @@ class System(object):
"""
target.execute('pm reset-permissions {}'.format(package))
+ @staticmethod
+ def find_config_file(test_env):
+ # Try device-specific config file first
+ board_cfg_file = os.path.join(test_env.DEVICE_LISA_HOME, BOARD_CONFIG_FILE)
+
+ if not os.path.exists(board_cfg_file):
+ # Try local config file $LISA_HOME/libs/utils/platforms/$TARGET_PRODUCT.json
+ board_cfg_file = 'libs/utils/platforms/{}.json'.format(test_env.TARGET_PRODUCT)
+ board_cfg_file = os.path.join(test_env.LISA_HOME, board_cfg_file)
+ if not os.path.exists(board_cfg_file):
+ return None
+ return board_cfg_file
+
+ @staticmethod
+ def read_config_file(board_cfg_file):
+ with open(board_cfg_file, "r") as fh:
+ board_config = json.load(fh)
+ return board_config
+
+ @staticmethod
+ def reimage(test_env, kernel_path='', update_cfg=''):
+ """
+ Get a reference to the specified Android workload
+
+ :param test_env: target test environment
+ :type test_env: TestEnv
+
+ :param kernel_path: path to kernel sources, required if reimage option is used
+ :type kernel_path: str
+
+ :param update_cfg: update configuration name from board_cfg.json
+ :type update_cfg: str
+
+ """
+ # Find board config file from device-specific or local directory
+ board_cfg_file = System.find_config_file(test_env)
+ if board_cfg_file == None:
+ raise RuntimeError('Board config file is not found')
+
+ # Read build config file
+ board_config = System.read_config_file(board_cfg_file)
+ if board_config == None:
+ raise RuntimeError('Board config file {} is invalid'.format(board_cfg_file))
+
+ # Read update-config section and execute appropriate scripts
+ update_config = board_config['update-config'][update_cfg]
+ if update_config == None:
+ raise RuntimeError('Update config \'{}\' is not found'.format(update_cfg))
+
+ board_cfg_dir = os.path.dirname(os.path.realpath(board_cfg_file))
+ build_script = update_config['build-script']
+ flash_script = update_config['flash-script']
+ build_script = os.path.join(board_cfg_dir, build_script)
+ flash_script = os.path.join(board_cfg_dir, flash_script)
+
+ cmd_prefix = "LOCAL_KERNEL_HOME='{}' ".format(kernel_path)
+ bld = Build(test_env)
+ bld.exec_cmd(cmd_prefix + build_script)
+ bld.exec_cmd(cmd_prefix + flash_script)
+
+
# vim :set tabstop=4 shiftwidth=4 expandtab
diff --git a/libs/utils/android/workload.py b/libs/utils/android/workload.py
index 0c96ad1..87267e6 100644
--- a/libs/utils/android/workload.py
+++ b/libs/utils/android/workload.py
@@ -112,6 +112,16 @@ class Workload(object):
def getInstance(cls, test_env, name, reinstall=False):
"""
Get a reference to the specified Android workload
+
+ :param test_env: target test environment
+ :type test_env: TestEnv
+
+ :param name: workload name
+ :type name: str
+
+ :param reinstall: flag to reinstall workload applications
+ :type reinstall: boolean
+
"""
# Initialize list of available workloads
@@ -123,6 +133,7 @@ class Workload(object):
raise ValueError(msg)
sc = cls._availables[name.lower()]
+
if (reinstall or not cls._packages_installed(sc, False)):
if (not cls._build_packages(sc, test_env) or
not cls._install_packages(sc, test_env)):