aboutsummaryrefslogtreecommitdiff
path: root/build/lib.linux-x86_64-2.7
diff options
context:
space:
mode:
authorYongqin Liu <yongqin.liu@linaro.org>2015-01-03 17:46:21 +0800
committerYongqin Liu <yongqin.liu@linaro.org>2015-01-03 17:46:21 +0800
commitcf7013d6e23f0a0da3bcae5fb9d8e20639b1d21f (patch)
tree4888505a53fc2070d376945391ae48bbee333166 /build/lib.linux-x86_64-2.7
downloadlava-android-test-cf7013d6e23f0a0da3bcae5fb9d8e20639b1d21f.tar.gz
first commit
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
Diffstat (limited to 'build/lib.linux-x86_64-2.7')
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/__init__.py16
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/adb.py401
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/api.py44
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/commands.py935
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/config.py51
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/hwprofile.py174
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/main.py63
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/provider.py276
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/repository.py83
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/swprofile.py95
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/0xbench.py89
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/__init__.py0
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/android-0xbenchmark/ZeroxBench_Preference.xml5
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_kill.py69
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_modify_path.py121
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_wait.py54
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/bctest.py52
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/big_LITTLE.py51
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/blackbox.py494
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/bluetooth.py47
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/busybox.py57
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/busybox/busybox_test.sh35
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cache_coherency.py47
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/__init__.py30
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/bionic_libc_tests.py29
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/example.py31
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/linaro_android_kernel_test.py30
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/tjunittest.py30
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts.py70
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_list_result_wrapper.sh26
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_prepare.sh131
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_redirect.sh24
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_run_wrapper.sh25
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_wrapper.py346
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/ctshelper.jarbin0 -> 1738 bytes
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/gatortest.py52
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/gatortest/daemoncheck.py20
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/gatortest/modulecheck.py20
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/glmark2.py52
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/glmark2/glmark2.sh35
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/glmark2/glmark2_wait.py51
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/helloworld.py46
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/__init__.py31
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/connect-lab-wifi.sh170
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/example.sh62
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/install-overlay.sh79
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/sdcard-mounted.sh65
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/workload.sh146
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/ime.py57
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/ime/ime_test.sh13
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/install_prep_4bench.py46
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/instruments/__init__.py28
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/instruments/example.py32
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/iozone.py118
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/memtester.py45
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/methanol.py65
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/methanol/methanol.sh327
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/methanol/methanol_merge_results.py86
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/methanol/start_server.py62
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/mmtest.py63
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey.py57
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey/monkey.sh6
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey_long_run.py78
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey_long_run/juice_package_black_list6
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey_long_run/monkey_long_run.sh13
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey_long_run/package_black_list2
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/pm_qa.py58
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/pm_qa/pm-qa.sh63
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/sched_tests.py49
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/__init__.py33
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/binder.sh13
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/custom.sh14
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/dalvik-vm-unit-tests.sh12
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/example.sh4
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/skia.py89
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/sleep.py48
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/task_placement.py49
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/tjbench.py140
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/usbhardware.py56
-rwxr-xr-xbuild/lib.linux-x86_64-2.7/lava_android_test/test_definitions/usbhardware/usbhardware.sh13
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/v8.py53
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/testdef.py771
-rw-r--r--build/lib.linux-x86_64-2.7/lava_android_test/utils.py202
83 files changed, 7631 insertions, 0 deletions
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/__init__.py b/build/lib.linux-x86_64-2.7/lava_android_test/__init__.py
new file mode 100644
index 0000000..7074800
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/__init__.py
@@ -0,0 +1,16 @@
+# Copyright (c) 2010, 2011 Linaro
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+__version__ = (0, 16, 3, "final", 0)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/adb.py b/build/lib.linux-x86_64-2.7/lava_android_test/adb.py
new file mode 100644
index 0000000..5bedb8c
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/adb.py
@@ -0,0 +1,401 @@
+# Copyright (c) 2011 - 2012 Linaro
+#
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import re
+import subprocess
+import tempfile
+import threading
+import time
+
+from Queue import Queue
+from lava_android_test.config import get_config
+
+config = get_config()
+
+
+class ADB(object):
+ ERR_CHMOD = 260
+ ERR_WRAPPER = 300
+ ERR_SHELL = 350
+ ERR_PUSH = 400
+ ERR_INSTALL = 450
+ ERR_UNINSTALL = 450
+ adb = 'adb'
+ serial = None
+
+ target_dir = config.tempdir_android
+
+ def __init__(self, serial=None, quiet=True):
+ self.cmdExecutor = CommandExecutor(quiet)
+ if serial is not None:
+ self.serial = serial
+ self.adb = 'adb -s %s' % serial
+ else:
+ self.serial = self.get_serial()
+
+ def get_serial(self):
+ if not self.serial:
+ serial_ary = self.run_cmd_host('adb get-serialno')[1]
+ serial = serial_ary[0].strip()
+ if not serial or serial == 'unknown':
+ return ''
+ else:
+ return serial
+ else:
+ return self.serial
+
+ def push(self, source=None, target=None):
+ if source is None:
+ return (-1, None)
+
+ target_dir = self.target_dir
+ if target is None:
+ target = os.path.join(self.target_dir, os.path.basename(source))
+ else:
+ target_dir = os.path.dirname(target)
+
+ self.cmdExecutor.run('%s shell mkdir %s' % (self.adb, target_dir))
+ s = self.cmdExecutor.run('%s push %s %s' % (self.adb, source, target))
+ ret = s.returncode
+ return (ret, target)
+
+ def pull(self, source=None, target=None):
+ if source is None:
+ return -1
+
+ if target is None:
+ cmd = '%s pull %s' % (self.adb, source)
+ else:
+ cmd = '%s pull %s %s' % (self.adb, source, target)
+ s = self.cmdExecutor.run(cmd)
+ return s.returncode
+
+ def shell(self, command=None, stdout=None, stderr=None):
+ if command is None:
+ return 0
+ tmpdir = config.tempdir_host
+ if not os.path.exists(tmpdir):
+ os.mkdir(tmpdir)
+ (tmpshell, tmpshell_name) = tempfile.mkstemp(suffix='.sh',
+ prefix='lava-android-test',
+ dir=tmpdir)
+ tmpfile_path = os.path.join(tmpdir, tmpshell_name)
+ os.write(tmpshell, '#/system/bin/sh\n')
+ os.write(tmpshell, 'base=/system\n')
+ os.write(tmpshell, ("export PATH=/sbin:/vendor/bin:/system/sbin:"
+ "/system/bin:/system/xbin\n"))
+ org_cmd = command
+ if stdout is not None:
+ command = '%s 1>>%s' % (command, stdout)
+ if stderr is not None:
+ command = '%s 2>>%s' % (command, stderr)
+
+ os.write(tmpshell, command + '\n')
+ os.write(tmpshell, 'RET_CODE=$?\n')
+ if stdout is not None:
+ os.write(tmpshell,
+ 'echo ANDROID_TEST_COMMAND="%s">>%s\n' % (org_cmd, stdout))
+ os.write(tmpshell,
+ 'echo ANDROID_TEST_RET_CODE=${RET_CODE} >>%s\n' % (stdout))
+
+ os.write(tmpshell, 'echo RET_CODE=${RET_CODE}\n')
+ os.close(tmpshell)
+
+ (ret_code, target_path) = self.push(tmpfile_path)
+ os.remove(tmpfile_path)
+ if ret_code != 0:
+ return self.ERR_PUSH
+
+ s = self.cmdExecutor.run(
+ '%s shell chmod 777 %s' % (self.adb, target_path))
+ ret_code = s.returncode
+ if ret_code != 0:
+ return self.ERR_CHMOD + ret_code
+ #check the whether the output is empty
+ if len(s.stdout) != 0:
+ return self.ERR_CHMOD
+
+ self.cmdExecutor.say('Begin to execute shell command: %s' % command)
+ s = self.cmdExecutor.run('%s shell %s' % (self.adb, target_path))
+ ret_code = s.returncode
+ if ret_code != 0:
+ return self.ERR_SHELL + ret_code
+ output = s.stdout
+ ret_code_line = output[len(output) - 1]
+ self.cmdExecutor.run('%s shell rm %s' % (self.adb, target_path))
+
+ ret_code_pattern = "^RET_CODE=(?P<ret_code>\d+)\s*$"
+ pat = re.compile(ret_code_pattern)
+ match = pat.search(ret_code_line)
+ if not match:
+ return self.ERR_SHELL
+ else:
+ data = match.groupdict()
+ return int(data['ret_code'], 10)
+
+ def exists(self, path):
+ ret_code = self.shell("ls %s" % path)
+ return ret_code == 0
+
+ def installapk(self, apkpath):
+ cmd = '%s install %s' % (self.adb, apkpath)
+ s = self.cmdExecutor.run(cmd)
+ ret_code = s.returncode
+ if ret_code != 0:
+ return self.ERR_INSTALL + ret_code
+ return 0
+
+ def uninstallapk(self, package):
+ cmd = '%s uninstall %s' % (self.adb, package)
+ s = self.cmdExecutor.run(cmd)
+ ret_code = s.returncode
+ if ret_code != 0:
+ return self.ERR_UNINSTALL + ret_code
+ return 0
+
+ def makedirs(self, path):
+ parent_path = os.path.dirname(path)
+ if parent_path == '/' or self.exists(parent_path):
+ return self.shell("mkdir %s" % path)
+ else:
+ ret = self.makedirs(parent_path)
+ if ret == 0:
+ return self.shell("mkdir %s" % path)
+ else:
+ return ret
+
+ def rmtree(self, dirpath):
+ ret_code = self.shell("rm -r %s" % dirpath)
+ return ret_code
+
+ def move(self, srcdir, destdir):
+ if srcdir is None:
+ return 0
+ if destdir is None:
+ return 0
+ ret_code = self.shell("mv %s %s" % (srcdir, destdir))
+ return ret_code
+
+ def copy(self, source_file, target_file):
+ if source_file is None:
+ return 0
+ if target_file is None:
+ return 0
+ if not self.exists(source_file):
+ return 0
+
+ ret_code = self.shell("dd if=%s of=%s" % (source_file, target_file))
+ return ret_code
+
+ def listdir(self, dirpath):
+ if self.exists(dirpath):
+ (ret_code, output) = self.run_cmd_host(
+ '%s shell ls %s ' % (self.adb, dirpath))
+ return (ret_code, output)
+ else:
+ return (1, None)
+
+ def read_file(self, filepath):
+ tmpfile_name = tempfile.mkstemp(
+ prefix='read_file_', dir=config.tempdir_host)[1]
+ ret_code = self.pull(filepath, tmpfile_name)
+ if ret_code != 0:
+ return None
+ data = None
+ try:
+ with open(tmpfile_name) as fd:
+ data = fd.read()
+ finally:
+ os.remove(tmpfile_name)
+ return data
+
+ def get_shellcmdoutput(self, cmd=None, quiet=True):
+ return self.get_shellcmdoutput_with_stderr(cmd=cmd, quiet=True)[0:2]
+
+ def run_adb_cmd(self, cmd, quiet=True):
+ return self.run_adb_cmd_with_stderr(cmd=cmd, quiet=quiet)[0:2]
+
+ def run_cmd_host(self, cmd, quiet=True):
+ return self.run_cmd_host_with_stderr(cmd, quiet=quiet)[0:2]
+
+ def get_shellcmdoutput_with_stderr(self, cmd=None, quiet=True):
+ if cmd is None:
+ return None
+ return self.run_adb_cmd_with_stderr(cmd='shell %s' % cmd, quiet=quiet)
+
+ def run_adb_cmd_with_stderr(self, cmd, quiet=True):
+ if not self.isDeviceConnected():
+ print ("Reconnect adb connection of device(%s) "
+ "for running command[%s]") % (self.get_serial(), cmd)
+ if not self.reconnect():
+ raise Exception('Failed to connect the device(%s)' % (
+ self.get_serial()))
+ return self.run_cmd_host_with_stderr(cmd='%s %s' % (self.adb, cmd),
+ quiet=quiet)
+
+ def run_cmd_host_with_stderr(self, cmd, quiet=True):
+ result = self.cmdExecutor.run(cmd, quiet=quiet)
+ return (result.returncode, result.stdout, result.stderr)
+
+ def run_adb_shell_for_test(self, cmd, stdoutlog=None,
+ stderrlog=None, quiet=False):
+ (ret_code, stdout, stderr) = self.get_shellcmdoutput_with_stderr(
+ cmd=cmd,
+ quiet=quiet)
+ if ret_code != 0:
+ return ret_code
+ self.push_stream_to_device(stdout, stdoutlog)
+ self.push_stream_to_device(stderr, stderrlog)
+ return ret_code
+
+ def push_stream_to_device(self, stream_lines, path):
+ if self.serial:
+ android_info = 'android(%s)' % self.serial
+ else:
+ android_info = 'android'
+
+ if not self.isDeviceConnected():
+ if not self.reconnect():
+ raise Exception('Failed to pull file(%s) to %s, '
+ 'because the device is not connected' % (
+ path, android_info))
+ basename = os.path.basename(path)
+ tmp_path = os.path.join(config.tempdir_host, basename)
+ if self.exists(path):
+ retcode = self.pull(path, tmp_path)
+ if retcode != 0:
+ raise Exception(
+ 'Failed to pull file(%s) to %s' % (path, android_info))
+
+ with open(tmp_path, 'a') as tmp_fd:
+ tmp_fd.writelines(stream_lines)
+ tmp_fd.close()
+
+ if self.push(tmp_path, path)[1] is None:
+ raise Exception(
+ 'Failed to pull file(%s) to %s' % (path, android_info))
+ os.remove(tmp_path)
+
+ def devices(self):
+ return self.run_cmd_host('%s devices' % self.adb)
+
+ def isDeviceConnected(self):
+ lines = self.run_cmd_host('%s get-state' % self.adb)[1]
+ for line in lines:
+ if 'device' in line:
+ return True
+ return False
+
+ def connect(self):
+ if self.serial:
+ self.run_cmd_host('adb connect %s' % self.serial, quiet=False)
+ return self.isDeviceConnected()
+ return False
+
+ def disconnect(self):
+ if self.serial:
+ self.run_cmd_host('adb disconnect %s' % self.serial, quiet=False)
+ return not self.isDeviceConnected()
+ return False
+
+ def reconnect(self):
+ for i in range(1, 5):
+ print "LAVA: try to reconnect the device(%s) %i/5 times" % (
+ self.serial, i)
+ if self.disconnect():
+ time.sleep(2)
+ if self.connect():
+ return True
+ time.sleep(5)
+ return False
+
+
+class CommandExecutor(object):
+ def __init__(self, quiet=True):
+ self._queue = Queue()
+ self.quiet = quiet
+ self.stdout = []
+ self.stderr = []
+
+ def say(self, text, *args, **kwargs):
+ if not self.quiet:
+ print "LAVA:", text.format(*args, **kwargs)
+
+ def display_subprocess_output(self, stream_name, line):
+ if stream_name == 'stdout':
+ self.say('(stdout) {0}', line.rstrip())
+ elif stream_name == 'stderr':
+ self.say('(stderr) {0}', line.rstrip())
+
+ def _drain_queue(self):
+ while True:
+ args = self._queue.get()
+ if args is None:
+ break
+ self.display_subprocess_output(*args)
+
+ def _read_stream(self, stream, stream_name):
+ if stream is None:
+ return
+ for line in iter(stream.readline, ''):
+ output_line = (stream_name, line)
+ self._queue.put(output_line)
+ if stream_name == 'stdout':
+ self.stdout.append(line)
+ elif stream_name == 'stderr':
+ self.stderr.append(line)
+
+ def run(self, cmd, quiet=True):
+ self.quiet = quiet
+ self.stdout = []
+ self.stderr = []
+ self.say("Begin to execute command: %s" %
+ cmd.replace('{', '{{').replace('}', '}}'))
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ shell=True)
+
+ stdout_reader = threading.Thread(
+ target=self._read_stream, args=(proc.stdout, "stdout"))
+ stderr_reader = threading.Thread(
+ target=self._read_stream, args=(proc.stderr, "stderr"))
+ ui_printer = threading.Thread(
+ target=self._drain_queue)
+
+ ui_printer.start()
+ stdout_reader.start()
+ stderr_reader.start()
+ try:
+ proc.wait()
+ except KeyboardInterrupt:
+ proc.kill()
+ finally:
+ stdout_reader.join()
+ stderr_reader.join()
+ self._queue.put(None)
+ ui_printer.join()
+ return CommandResult(proc.returncode, self.stdout, self.stderr)
+
+
+class CommandResult(object):
+ def __init__(self, returncode, stdout=[], stderr=[]):
+ self.returncode = returncode
+ self.stdout = stdout
+ self.stderr = stderr
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/api.py b/build/lib.linux-x86_64-2.7/lava_android_test/api.py
new file mode 100644
index 0000000..624422e
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/api.py
@@ -0,0 +1,44 @@
+"""
+Public API for extending Abrek
+"""
+from abc import abstractmethod
+
+
+class ITest(object):
+ """
+ Abrek test.
+
+ Something that can be installed and invoked by abre.
+ """
+
+ @abstractmethod
+ def install(self):
+ """
+ Install the test suite.
+
+ This creates an install directory under the user's XDG_DATA_HOME
+ directory to mark that the test is installed. The installer's
+ install() method is then called from this directory to complete any
+ test specific install that may be needed.
+ """
+
+ @abstractmethod
+ def uninstall(self):
+ """
+ Uninstall the test suite.
+
+ Uninstalling just recursively removes the test specific directory under
+ the user's XDG_DATA_HOME directory. This will both mark the test as
+ removed, and clean up any files that were downloaded or installed under
+ that directory. Dependencies are intentionally not removed by this.
+ """
+
+ @abstractmethod
+ def run(self, quiet=False):
+ # TODO: Document me
+ pass
+
+ @abstractmethod
+ def parse(self, resultname):
+ # TODO: Document me
+ pass
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/commands.py b/build/lib.linux-x86_64-2.7/lava_android_test/commands.py
new file mode 100644
index 0000000..eb46c78
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/commands.py
@@ -0,0 +1,935 @@
+# Copyright (c) 2011, 2012 Linaro
+#
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import base64
+import os
+import re
+import urlparse
+import versiontools
+import zipfile
+
+from tempfile import mkdtemp
+from uuid import uuid4
+
+from lava_tool.interface import Command as LAVACommand
+from lava_tool.interface import LavaCommandError
+from linaro_dashboard_bundle.io import DocumentIO
+
+from lava_android_test.adb import ADB
+from lava_android_test.config import get_config
+from lava_android_test.provider import TestProvider
+from lava_android_test.repository import GitRepository
+from lava_android_test.testdef import AndroidTest
+from lava_android_test.testdef import AndroidTestRunner, \
+ AndroidTestInstaller, \
+ AndroidTestParser
+from lava_android_test import utils
+
+
+class Command(LAVACommand):
+
+ def __init__(self, parser, args):
+ super(Command, self).__init__(parser, args)
+ self.config = get_config()
+# self._test_loader = TestLoader(self._config)
+
+ @classmethod
+ def register_arguments(cls, parser):
+ parser.add_argument(
+ "-q", "--quiet",
+ action="store_true",
+ default=False,
+ help="Be less verbose about undertaken actions")
+ parser.add_argument(
+ "-Q", "--quiet-subcommands",
+ action="store_true",
+ default=False,
+ help="Hide the output of all sub-commands (including tests)")
+
+ def say(self, text, *args, **kwargs):
+ print "LAVA:", text.format(*args, **kwargs)
+
+ def say_begin(self, text, *args, **kwargs):
+ print "LAVA: --Start Operation: ", text.format(*args, **kwargs)
+
+ def say_end(self, text, *args, **kwargs):
+ print "LAVA: --End Operation: ", text.format(*args, **kwargs),
+
+ def display_subprocess_output(self, stream_name, line):
+ if self.args.quiet_subcommands:
+ return
+ if stream_name == 'stdout':
+ self.say('(stdout) {0}', line.rstrip())
+ elif stream_name == 'stderr':
+ self.say('(stderr) {0}', line.rstrip())
+
+
+class extract_attachments(Command):
+ """
+ Extract the attachment files from the result bundle file
+ generated by the -o option of run command
+ or from the output of parse command
+ """
+ @classmethod
+ def register_arguments(self, parser):
+ super(extract_attachments, self).register_arguments(parser)
+ parser.add_argument("result_file",
+ help="The result bundle json file")
+ group = parser.add_argument_group("specify the output directory")
+ group.add_argument("-d", "--directory",
+ default=None,
+ metavar="directory",
+ help=("specify the directory where all the "
+ "attachment files will be put"))
+
+ def invoke(self):
+
+ if not os.path.exists(self.args.result_file):
+ raise LavaCommandError("The specified result file(%s) "
+ "does not exist." % self.args.result_file)
+ msg = "extract attachment file from result bundle file(%s)" % (
+ self.args.result_file)
+ self.say_begin(msg)
+ badchars = "[^a-zA-Z0-9\._-]"
+ with open(self.args.result_file) as stream:
+ jobdata = stream.read()
+ result_data = DocumentIO.loads(jobdata)[1]
+ test_runs = result_data.get('test_runs')
+ if not self.args.directory:
+ attachment_dir = mkdtemp(prefix='attachments-',
+ dir=os.path.curdir)
+ elif not os.path.exists(self.args.directory):
+ os.makedirs(self.args.directory)
+ attachment_dir = self.args.directory
+ elif not os.path.isdir(self.args.directory):
+ raise LavaCommandError(
+ "The specified path(%s) is not a directory."
+ % self.args.directory)
+ else:
+ attachment_dir = self.args.directory
+
+ for test in test_runs:
+ test_id = test.get('test_id').replace(" ", "_")
+ test_id = re.sub(badchars, "_", test_id)
+ target_dir = mkdtemp(prefix='%s' % test_id, dir=attachment_dir)
+ print "The test id is: %s" % test_id
+ attachments = test.get('attachments', [])
+ for attach in attachments:
+ pathname = attach.get('pathname')
+ file_name = os.path.basename(pathname)
+ content_decoded = base64.standard_b64decode(
+ attach.get("content"))
+ with open(os.path.join(target_dir, file_name), 'w') as fd:
+ fd.write(content_decoded)
+ self.say("All attachment files are put under directory(%s)" %
+ (attachment_dir))
+ self.say_end(msg)
+
+
+class list_devices(Command):
+ """
+ List available devices
+ program::lava-android-test list-devices
+ """
+
+ def invoke(self):
+
+ self.adb = ADB()
+ try:
+ output = self.adb.devices()[1]
+ if output is not None:
+ for line in output:
+ print line.strip()
+ else:
+ print "No device attached"
+ except OSError:
+ print "No device attached"
+
+
+class list_tests(Command):
+ """
+ List available tests
+ program:: lava-android-test list-tests
+ """
+
+ def invoke(self):
+ self.say("Known tests:")
+ for provider in TestProvider().get_test_provider_list():
+ for test in provider().list_test():
+ self.say(" - {test_id}", test_id=test)
+
+
+class version(Command):
+ """
+ Show LAVA Test version
+ """
+
+ def invoke(self):
+ self.say("version details:")
+ for framework in self._get_frameworks():
+ self.say(" - {framework}: {version}",
+ framework=framework.__name__,
+ version=versiontools.format_version(
+ framework.__version__, framework))
+
+ def _get_frameworks(self):
+ import lava_tool
+ import lava_android_test
+ import linaro_dashboard_bundle
+ return [
+ lava_android_test,
+ lava_tool,
+ linaro_dashboard_bundle]
+
+
+class AndroidCommand(Command):
+
+ @classmethod
+ def register_arguments(self, parser):
+ super(AndroidCommand, self).register_arguments(parser)
+ group = parser.add_argument_group("specify device serial number")
+ group.add_argument("-s", "--serial",
+ default=None,
+ metavar="serial",
+ help=("specify the device with serial number"
+ "that this command will be run on"))
+
+ def test_installed(self, test_id):
+ if self.adb is None:
+ self.adb = ADB()
+ test_dir = os.path.join(self.config.installdir_android, test_id)
+ return self.adb.exists(test_dir)
+
+ def get_device_serial(self):
+ return ADB(self.args.serial).get_serial()
+
+ def assertDeviceIsConnected(self):
+ if not self.adb.isDeviceConnected():
+ if self.adb.serial:
+ raise Exception("Device '%s' is not connected" %
+ self.adb.serial)
+ else:
+ raise Exception("No device found")
+
+ def invoke(self):
+ serial = self.get_device_serial()
+ if not serial:
+ raise LavaCommandError("No device attached")
+ self.serial = serial
+ self.adb = ADB(self.serial)
+
+ try:
+ self.assertDeviceIsConnected()
+ except Exception as err:
+ raise LavaCommandError(err)
+
+ self.invoke_sub()
+
+ def invoke_sub(self):
+ raise NotImplementedError
+
+
+class AndroidTestCommand(AndroidCommand):
+ @classmethod
+ def register_arguments(self, parser):
+ super(AndroidTestCommand, self).register_arguments(parser)
+ parser.add_argument("test_id",
+ help="Test identifier")
+
+ def get_tip_msg(self, text):
+ if self.args.serial:
+ tip_msg = "%s (%s) on device(%s)" % (text,
+ self.args.test_id,
+ self.args.serial)
+ else:
+ tip_msg = "%s (%s)" % (text, self.args.test_id)
+ return tip_msg
+
+
+class AndroidResultCommand(AndroidCommand):
+ @classmethod
+ def register_arguments(self, parser):
+ super(AndroidResultCommand, self).register_arguments(parser)
+ parser.add_argument("result_id",
+ help="Test result identifier")
+
+
+class AndroidResultsCommand(AndroidCommand):
+ @classmethod
+ def register_arguments(self, parser):
+ super(AndroidResultsCommand, self).register_arguments(parser)
+ parser.add_argument("result_id", nargs="+",
+ help="One or more result identifiers")
+
+
+class list_installed(AndroidCommand):
+ """
+ List installed tests for specified device.
+ program:: lava-android-test list-tests
+ program:: lava-android-test list-tests -s device_serial
+ """
+ def invoke_sub(self):
+
+ self.say("Installed tests:")
+ try:
+ output = self.adb.listdir(self.config.installdir_android)[1]
+ if output is not None:
+ for dir_name in output:
+ self.say(" - {test_id}", test_id=dir_name.strip())
+ else:
+ self.say("No tests installed")
+ except OSError:
+ self.say("No tests installed")
+
+
+class list_results(AndroidCommand):
+ """
+ List results of tests that has been run on the specified device.
+ program:: lava-android-test list-results
+ program:: lava-android-test list-results -s device_serial
+ """
+ def invoke_sub(self):
+ self.say("Saved results:")
+ try:
+ (ret_code, output) = self.adb.listdir(
+ self.config.resultsdir_android)
+ if ret_code != 0:
+ raise OSError()
+ for dir_name in output:
+ self.say(" - {result_id}", result_id=dir_name.strip())
+ except OSError:
+ self.say("No results found")
+
+
+class install(AndroidTestCommand):
+ """
+ Install test to the specified device.
+ program:: lava-android-test install test-id
+ program:: lava-android-test install test-id -s device_serial
+ """
+
+ @classmethod
+ def register_arguments(cls, parser):
+ super(cls, install).register_arguments(parser)
+ parser.add_argument('-o', '--install-option')
+
+ def invoke_sub(self):
+ tip_msg = self.get_tip_msg("Install test")
+ self.say_begin(tip_msg)
+
+ if self.test_installed(self.args.test_id):
+ raise LavaCommandError("The test (%s) has already installed." %
+ self.args.test_id)
+ test = TestProvider().load_test(self.args.test_id, self.args.serial)
+ try:
+ test.install(self.args.install_option)
+ except Exception as strerror:
+ raise LavaCommandError("Test installation error: %s" % strerror)
+
+ self.say_end(tip_msg)
+
+
+class uninstall(AndroidTestCommand):
+ """
+ Unistall test of the specified device.
+ program:: lava-android-test uninstall test-id
+ program:: lava-android-test uninstall test-id -s device_serial
+ """
+ def invoke_sub(self):
+ tip_msg = self.get_tip_msg("Uninstall test")
+ self.say_begin(tip_msg)
+
+ test = TestProvider().load_test(self.args.test_id, self.args.serial)
+ try:
+ test.uninstall()
+ except Exception as strerror:
+ raise LavaCommandError("Test uninstall error: %s" % strerror)
+ self.say_end(tip_msg)
+
+
+class run(AndroidTestCommand):
+ """
+ Run a previously installed test program on the specified device
+ program:: lava-android-test run test-id
+ program:: lava-android-test run test-id -s device_serial
+ program:: lava-android-test run test-id -s device_serial -o outputfile
+ """
+
+ @classmethod
+ def register_arguments(cls, parser):
+ super(run, cls).register_arguments(parser)
+ parser.add_argument('-O', '--run-option',
+ help=("Specified in the job file for using in "
+ "the real test action, so that we can customize"
+ " some test when need"))
+ group = parser.add_argument_group("specify the bundle output file")
+ group.add_argument("-o", "--output",
+ default=None,
+ metavar="FILE",
+ help=("After running the test parse the result"
+ " artefacts, fuse them with the initial"
+ " bundle and finally save the complete bundle"
+ " to the specified FILE."))
+
+ def invoke_sub(self):
+ tip_msg = self.get_tip_msg("Run test")
+ self.say_begin(tip_msg)
+
+ if not self.test_installed(self.args.test_id):
+ raise LavaCommandError(
+ "The test (%s) has not been installed yet." %
+ self.args.test_id)
+ test = TestProvider().load_test(self.args.test_id, self.args.serial)
+
+ if not self.test_installed(test.testname):
+ raise LavaCommandError(
+ "The test (%s) has not been installed yet."
+ % self.args.test_id)
+
+ try:
+ result_id = test.run(quiet=self.args.quiet,
+ run_options=self.args.run_option)
+ if self.args.output:
+ output_dir = os.path.dirname(self.args.output)
+ if output_dir and (not os.path.exists(output_dir)):
+ os.makedirs(output_dir)
+ bundle = generate_bundle(self.args.serial, result_id)
+ with open(self.args.output, "wt") as stream:
+ DocumentIO.dump(stream, bundle)
+
+ except Exception as strerror:
+ raise LavaCommandError("Test execution error: %s" % strerror)
+
+ self.say_end(tip_msg)
+
+
+class run_custom(AndroidCommand):
+ """
+ Run the command(s) that specified by the -c option in the command line
+ program:: lava-android-test run-custom -c 'cm1' -c 'cmd2' -p 'parse-regex1'
+ program:: lava-android-test run test-id -s device_serial
+ program:: lava-android-test run test-id -s device_serial -o outputfile
+ """
+
+ @classmethod
+ def register_arguments(cls, parser):
+ super(run_custom, cls).register_arguments(parser)
+ group = parser.add_mutually_exclusive_group(required=True)
+ group.add_argument('-c', '--android-command', action='append',
+ help=("Specified in the job file for using"
+ " in the real test action, so that "
+ "we can customize some test when need"))
+ group.add_argument('-f', '--command-file',
+ help=("Specified the command file that will be "
+ "pushed into android and run."))
+ parser.add_argument('-p', '--parse-regex',
+ help=("Specified the regular expression used"
+ " for analyzing command output"))
+ group = parser.add_argument_group("specify the bundle output file")
+ group.add_argument("-o", "--output",
+ default=None,
+ metavar="FILE",
+ help=("After running the test parse the result"
+ " artefacts, fuse them with the initial"
+ " bundle and finally save the complete bundle"
+ " to the specified FILE."))
+
+ def invoke_sub(self):
+
+ test_name = 'custom'
+ ADB_SHELL_STEPS = []
+ STEPS_HOST_PRE = []
+ STEPS_ADB_PRE = []
+ file_name = None
+ if self.args.android_command:
+ ADB_SHELL_STEPS = self.args.android_command
+ cmds_str = ','.join(ADB_SHELL_STEPS)
+ if len(cmds_str) > 40:
+ cmds_str = '%s...' % (cmds_str[:40])
+ test_name_suffix = 'command=[%s]' % (cmds_str)
+ elif self.args.command_file:
+ file_url = self.args.command_file
+ urlpath = urlparse.urlsplit(file_url).path
+ file_name = os.path.basename(urlpath)
+ target_path = os.path.join(self.config.installdir_android,
+ test_name, file_name)
+ STEPS_HOST_PRE = ["wget %s -O %s" % (file_url, file_name)]
+ STEPS_ADB_PRE = ["push %s %s" % (file_name, target_path)]
+ ADB_SHELL_STEPS = ["chmod 777 %s" % target_path,
+ target_path]
+ file_name_str = file_name
+ if len(file_name_str) > 40:
+ file_name_str = '%s...' % (cmds_str[:40])
+ test_name_suffix = 'command_file=%s' % (file_name_str)
+
+ PATTERN = None
+ if self.args.parse_regex:
+ PATTERN = self.args.parse_regex
+
+ tip_msg = ''
+ if self.args.serial:
+ tip_msg = ("Run following custom test(s) on device(%s):"
+ "\n\tcommands=%s"
+ "\n\tcommand-file=%s\n") % (
+ self.args.serial,
+ '\n\t\t'.join(ADB_SHELL_STEPS),
+ file_name)
+ else:
+ tip_msg = ("Run following custom test(s):"
+ "\n\t\tcommands=%s"
+ "\n\tcommand-file=%s\n") % (
+ '\n\t\t'.join(ADB_SHELL_STEPS),
+ file_name)
+
+ self.say_begin(tip_msg)
+
+ inst = AndroidTestInstaller()
+
+ run = AndroidTestRunner(steps_host_pre=STEPS_HOST_PRE,
+ steps_adb_pre=STEPS_ADB_PRE,
+ adbshell_steps=ADB_SHELL_STEPS)
+ parser = AndroidTestParser(pattern=PATTERN)
+ test = AndroidTest(testname=test_name,
+ installer=inst, runner=run, parser=parser)
+ test.parser.results = {'test_results': []}
+ test.setadb(self.adb)
+
+ if not self.test_installed(test.testname):
+ test.install()
+
+ try:
+ result_id = test.run(quiet=self.args.quiet)
+ if self.args.output:
+ output_dir = os.path.dirname(self.args.output)
+ if output_dir and (not os.path.exists(output_dir)):
+ os.makedirs(output_dir)
+ bundle = generate_bundle(self.args.serial,
+ result_id, test=test,
+ test_id='%s(%s)' % (test_name, test_name_suffix))
+ with open(self.args.output, "wt") as stream:
+ DocumentIO.dump(stream, bundle)
+
+ except Exception as strerror:
+ raise LavaCommandError("Test execution error: %s" % strerror)
+ self.say_end(tip_msg)
+
+
+class run_monkeyrunner(AndroidCommand):
+ """
+ Run the monkeyrunner scripts that stored in the specified git repository
+ program:: lava-android-test run-monkeyrunner -g giturl -r resultfilelist
+ """
+
+ @classmethod
+ def register_arguments(cls, parser):
+ super(run_monkeyrunner, cls).register_arguments(parser)
+ parser.add_argument("url",
+ help="The repository url of the test scripts")
+ parser.add_argument('-t', '--repo-type',
+ default='git',
+ help=("Specify the type of the repository"))
+ group = parser.add_argument_group("specify the bundle output file")
+ group.add_argument("-o", "--output",
+ default=None,
+ metavar="FILE",
+ help=("After running the test parse the result"
+ " artefacts, fuse them with the initial"
+ " bundle and finally save the complete bundle"
+ " to the specified FILE."))
+
+ def invoke_sub(self):
+
+ if not utils.check_command_exist('monkeyrunner'):
+ raise LavaCommandError('The command monkeyrunner can not be found')
+
+ if self.args.repo_type == 'git':
+ target_dir = mkdtemp(prefix='git_repo',
+ dir=self.config.tempdir_host)
+ os.chmod(target_dir, 0755)
+ GitRepository(self.args.url).checkout(target_dir)
+ else:
+ raise LavaCommandError("The repository type(%s) is not supported"
+ % self.args.repo_type)
+
+ script_list = utils.find_files(target_dir, '.py')
+
+ test_id = self.args.url
+ if len(test_id) > 40:
+ test_id = '%s...' % (test_id[:40])
+ test_id = 'monkeyrunner_%s' % test_id
+
+ tip_msg = ("Run monkeyrunner scripts in following url on device(%s):"
+ "\n\turl=%s") % (
+ self.serial,
+ self.args.url)
+
+ self.say_begin(tip_msg)
+ bundles = []
+ for script in script_list:
+ if "monkeycommon.py" == os.path.basename(script):
+ continue
+ sub_bundle = {}
+ from datetime import datetime
+ starttime = datetime.utcnow()
+ test_case_id = script.replace('%s/' % target_dir, '')
+ if len(test_case_id) > 50:
+ test_case_id = '%s...' % (test_case_id[:50])
+ try:
+ sub_bundle = self.run_monkeyrunner_test(script, self.serial,
+ test_case_id)
+ test_result = {"test_case_id": test_case_id,
+ "result": 'pass'}
+ if sub_bundle:
+ sub_bundle['test_runs'][0]['test_results'].append(
+ test_result)
+ except Exception as strerror:
+ self.say('Failed to run script(%s) with error:\n%s' % (
+ script,
+ strerror))
+
+ test_result = {"test_case_id": test_case_id,
+ "result": 'fail'}
+ TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'
+ sub_bundle['test_runs'] = [{'test_results': [test_result],
+ 'test_id': 'monkeyrunner(%s)' % test_case_id,
+ 'time_check_performed': False,
+ 'analyzer_assigned_uuid': str(uuid4()),
+ 'analyzer_assigned_date': starttime.strftime(TIMEFORMAT)}]
+ if sub_bundle:
+ bundles.append(sub_bundle)
+
+ if self.args.output:
+ output_dir = os.path.dirname(self.args.output)
+ if output_dir and (not os.path.exists(output_dir)):
+ os.makedirs(output_dir)
+ with open(self.args.output, "wt") as stream:
+ DocumentIO.dump(stream, merge_bundles(bundles))
+
+ self.say_end(tip_msg)
+
+ def run_monkeyrunner_test(self, script, serial, test_case_id=None):
+
+ inst = AndroidTestInstaller()
+ run = AndroidTestRunner(steps_host_pre=[
+ 'monkeyrunner %s %s' % (script, serial)])
+ parser = MonkeyrunnerTestParser()
+ parser.monkeyrunner_result = os.path.join(os.path.dirname(script),
+ 'results.txt')
+ test = AndroidTest(testname='monkeyrunner',
+ installer=inst, runner=run, parser=parser)
+ test.parser.results = {'test_results': []}
+ test.setadb(self.adb)
+
+ ##By calling the install function, we will create the directory
+ ##on the target, and the the output file and error file
+ ##will be pushed there
+ if not self.test_installed(test.testname):
+ test.install()
+
+ ##The png files here are generated to the host by the monkeyrunner
+ ##monkeyrunner is run on host, not on the target
+ bundle = {}
+ org_png_file_list = utils.find_files(self.config.tempdir_host,
+ '.%s' % 'png')
+ result_id = test.run(quiet=self.args.quiet)
+ if self.args.output:
+ cur_all_png_list = utils.find_files(self.config.tempdir_host,
+ '.%s' % 'png')
+ new_png_list = set(cur_all_png_list).difference(org_png_file_list)
+ test_id = 'monkeyrunner(%s)' % (test_case_id)
+ bundle = generate_bundle(self.args.serial,
+ result_id, test=test,
+ test_id=test_id,
+ attachments=list(new_png_list))
+ utils.delete_files(new_png_list)
+
+ return bundle
+
+
+class MonkeyrunnerTestParser(AndroidTestParser):
+ '''
+ Before this method is called, self.monkeyrunner_result must be set
+ to the right value
+ '''
+
+
+ def real_parse(self, result_filename=None, output_filename=None,
+ test_name=''):
+ self.res_pattern = ("^\s*(?P<test_case_id>.*?)\s*="
+ "\s*(?P<result>(true|false))\s*$")
+ self.measurement_pattern = ("^\s*(?P<test_case_id>.*?)\s*="
+ "\s*(?P<measurement>[\.\d]+)\s*$")
+ self.measurement_units_pattern = ("^\s*(?P<test_case_id>.*?)\s*="
+ "\s*(?P<measurement>[\.\d]+)\s+(?P<units>\S+)\s*$")
+
+ res_pat = re.compile(self.res_pattern)
+ measurement_pat = re.compile(self.measurement_pattern)
+ measurement_units_pat = re.compile(self.measurement_units_pattern)
+
+
+ if not os.path.exists(self.monkeyrunner_result):
+ return
+ with open(self.monkeyrunner_result) as stream:
+ for lineno, line in enumerate(stream, 1):
+ match = res_pat.search(line)
+ if not match:
+ match = measurement_pat.search(line)
+ if not match:
+ match = measurement_units_pat.search(line)
+ if not match:
+ continue
+ data = match.groupdict()
+ data["log_filename"] = result_filename
+ data["log_lineno"] = lineno
+ if data.get('result') is None:
+ data['result'] = 'pass'
+
+ self.results['test_results'].append(data)
+
+
+class parse(AndroidResultsCommand):
+ """
+ Parse the results of previous test that run on the specified device
+ program:: lava-android-test parse test-result-id
+ """
+ def invoke_sub(self):
+ bundle = generate_combined_bundle(self.args.serial,
+ self.args.result_id)
+ try:
+ print DocumentIO.dumps(bundle)
+ except IOError:
+ pass
+
+
+class parse_custom(AndroidResultsCommand):
+ """
+ Parse the results of previous test that run with run-custom command
+ on the specified device
+ program:: lava-android-test parse-custom test-result-id -P
+ """
+ @classmethod
+ def register_arguments(cls, parser):
+ super(parse_custom, cls).register_arguments(parser)
+ parser.add_argument('-p', '--parse-regex',
+ help=("Specified the regular expression used"
+ " for analyzing command output"))
+
+ def invoke_sub(self):
+ PATTERN = None
+ if self.args.parse_regex:
+ PATTERN = self.args.parse_regex
+ test_name = 'custom'
+ inst = AndroidTestInstaller()
+ run = AndroidTestRunner()
+ parser = AndroidTestParser(pattern=PATTERN)
+ test = AndroidTest(testname=test_name, installer=inst,
+ runner=run, parser=parser)
+ test.parser.results = {'test_results': []}
+ test.setadb(self.adb)
+
+ bundle = generate_combined_bundle(self.args.serial,
+ self.args.result_id, test=test)
+ try:
+ print DocumentIO.dumps(bundle)
+ except IOError:
+ pass
+
+
+def generate_combined_bundle(serial=None, result_ids=None, test=None,
+ test_id=None):
+ if result_ids is None:
+ return {}
+
+ bundle = None
+
+ for rid in result_ids:
+ b = generate_bundle(serial, rid, test, test_id)
+ if rid == result_ids[0]:
+ bundle = b
+ else:
+ bundle['test_runs'].append(b['test_runs'][0])
+
+ return bundle
+
+
+def merge_bundles(bundles=[]):
+ config = get_config()
+ merged_bundles = {"format": config.bundle_format,
+ 'test_runs': []}
+ for bundle in bundles:
+ if bundle['test_runs']:
+ merged_bundles['test_runs'].append(bundle['test_runs'][0])
+ return merged_bundles
+
+
+def generate_bundle(serial=None, result_id=None, test=None,
+ test_id=None, attachments=[]):
+ if result_id is None:
+ return {}
+ config = get_config()
+ adb = ADB(serial)
+ resultdir = os.path.join(config.resultsdir_android, result_id)
+ if not adb.exists(resultdir):
+ raise Exception("The result (%s) is not existed." % result_id)
+
+ bundle_text = adb.read_file(os.path.join(resultdir, "testdata.json"))
+ bundle = DocumentIO.loads(bundle_text)[1]
+ test_tmp = None
+ if test:
+ test_tmp = test
+ else:
+ test_tmp = TestProvider().load_test(bundle['test_runs'][0]['test_id'],
+ serial)
+ if test_id:
+ bundle['test_runs'][0]['test_id'] = test_id
+ else:
+ attrs = bundle['test_runs'][0].get('attributes')
+ if attrs:
+ run_options = attrs.get('run_options')
+ if run_options:
+ test_id = '%s(%s)' % (bundle['test_runs'][0]['test_id'],
+ run_options)
+ bundle['test_runs'][0]['test_id'] = test_id
+
+ test_tmp.parse(result_id)
+ stdout_text = adb.read_file(os.path.join(resultdir,
+ os.path.basename(test_tmp.org_ouput_file)))
+ if stdout_text is None:
+ stdout_text = ''
+ stderr_text = adb.read_file(os.path.join(resultdir, 'stderr.log'))
+ if stderr_text is None:
+ stderr_text = ''
+ bundle['test_runs'][0]["test_results"] = test_tmp.parser.results[
+ "test_results"]
+
+ ## following part is used for generating the attachment for normal test
+ attachment_bundles = []
+ for attachment in test_tmp.attachments:
+ data_bundle = attachment.generate_bundle(adb=adb, resultsdir=resultdir)
+ if data_bundle:
+ attachment_bundles.append(data_bundle)
+
+ bundle['test_runs'][0]["attachments"] = attachment_bundles
+
+ ##following used for the attachment for monkeyrunner test
+ for attach in attachments:
+ if os.path.exists(attach):
+ with open(attach, 'rb') as stream:
+ data = stream.read()
+ if data:
+ bundle['test_runs'][0]["attachments"].append({
+ "pathname": os.path.basename(attach),
+ "mime_type": 'image/png',
+ "content": base64.standard_b64encode(data)})
+ return bundle
+
+class show(AndroidResultCommand):
+ """
+ Display the output from a previous test that run on the specified device
+ program:: lava-android-test show result-id
+ program:: lava-android-test show result-id -s device_serial
+ """
+ def invoke_sub(self):
+ resultsdir = os.path.join(self.config.resultsdir_android,
+ self.args.result_id)
+ if not self.adb.exists(resultsdir):
+ raise LavaCommandError(
+ "The result (%s) is not existed." % self.args.result_id)
+
+ stdout = os.path.join(resultsdir, "stdout.log")
+ if not self.adb.exists(stdout):
+ self.say("No result found for '%s'" % self.args.result_id)
+ return
+ try:
+ output = self.adb.get_shellcmdoutput('cat %s' % stdout)[1]
+ if output is not None:
+ for line in output:
+ self.display_subprocess_output('stdout', line)
+ except IOError:
+ pass
+
+ stderr = os.path.join(resultsdir, "stderr.log")
+ if not self.adb.exists(stderr):
+ return
+ try:
+ output = self.adb.get_shellcmdoutput('cat %s' % stderr)[1]
+ if output is not None:
+ for line in output:
+ self.display_subprocess_output('stderr', line)
+ except IOError:
+ pass
+
+
+class rename(AndroidResultCommand):
+ """
+ Rename the result's id of a previous test that run on the specified device
+ program:: lava-android-test rename result-id result-id-new
+ program:: lava-android-test remove result-id result-id-new -s device_serial
+ """
+
+ @classmethod
+ def register_arguments(self, parser):
+ super(rename, self).register_arguments(parser)
+ parser.add_argument("result_id_new",
+ help="New test result identifier")
+
+ def invoke_sub(self):
+ srcdir = os.path.join(self.config.resultsdir_android,
+ self.args.result_id)
+ destdir = os.path.join(self.config.resultsdir_android,
+ self.args.result_id_new)
+
+ if not self.adb.exists(srcdir):
+ self.say("Result (%s) not found" % self.args.result_id)
+ return
+ if self.adb.exists(destdir):
+ self.say("Destination result name already exists")
+ self.adb.move(srcdir, destdir)
+
+
+class remove(AndroidResultsCommand):
+ """
+ Remove the result of a previous test that run on the specified device
+ program:: lava-android-test remove result-id
+ program:: lava-android-test remove result-id0 result-id1
+ program:: lava-android-test remove result-id -s device_serial
+ """
+
+ @classmethod
+ def register_arguments(self, parser):
+ super(remove, self).register_arguments(parser)
+ group = parser.add_argument_group("force to remove")
+ group.add_argument("-f", "--force",
+ action="store_true",
+ help=("give an interactive question about remove"))
+
+ def remove(self, rid):
+ resultsdir = os.path.join(self.config.resultsdir_android, rid)
+ if not self.adb.exists(resultsdir):
+ self.say("No result found for '%s'" % rid)
+ return
+ if not self.args.force:
+ self.say("Remove result '%s' for good? [Y/N]" % rid)
+ response = raw_input()
+ if response[0].upper() != 'Y':
+ return
+ self.adb.rmtree(resultsdir)
+
+ def invoke_sub(self):
+ for rid in self.args.result_id:
+ self.remove(rid)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/config.py b/build/lib.linux-x86_64-2.7/lava_android_test/config.py
new file mode 100644
index 0000000..64bf278
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/config.py
@@ -0,0 +1,51 @@
+# Copyright (c) 2010-2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+
+
+class LavaAndroidTestConfig(object):
+ def __init__(self):
+ home = os.environ.get('ANDROID_TEST_HOME', '/data/local/tmp/lava-android-test/')
+ config = os.environ.get('ANDROID_TEST_CONFIG_HOME',
+ os.path.join(home, '.config'))
+ basedata = os.environ.get('ANDROID_TEST_DATA_HOME',
+ os.path.join(home, 'share'))
+ self.configdir = config
+ self.installdir_android = os.path.join(basedata, 'installed-tests')
+ self.resultsdir_android = os.path.join(basedata, 'results')
+ self.tempdir_android = os.path.join(home, 'temp')
+ self.tempdir_host = os.environ.get('ANDROID_TEST_TEMP_HOST',
+ '/tmp/lava-android-test')
+ self.bundle_format = "Dashboard Bundle Format 1.3"
+
+
+_config = None
+
+
+def get_config():
+ global _config
+ if _config is not None:
+ return _config
+ return LavaAndroidTestConfig()
+
+
+def set_config(config):
+ global _config
+ _config = config
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/hwprofile.py b/build/lib.linux-x86_64-2.7/lava_android_test/hwprofile.py
new file mode 100644
index 0000000..1ac7b50
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/hwprofile.py
@@ -0,0 +1,174 @@
+# Copyright (c) 2010 Linaro
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import re
+import sys
+from lava_android_test.adb import ADB
+
+ARM_KEYMAP = {
+ 'Processor': 'cpu_model_name',
+ 'Features': 'cpu_features',
+ 'CPU implementer': 'cpu_implementer',
+ 'CPU architecture': 'cpu_architecture',
+ 'CPU variant': 'cpu_variant',
+ 'CPU part': 'cpu_part',
+ 'CPU revision': 'cpu_revision',
+}
+
+ARM_VALMAP = {
+ 'CPU implementer': lambda value: int(value, 16),
+ 'CPU architecture': int,
+ 'CPU variant': lambda value: int(value, 16),
+ 'CPU part': lambda value: int(value, 16),
+ 'CPU revision': int,
+}
+
+
+def _translate_cpuinfo(keymap, valmap, key, value):
+ """
+ Translate a key and value using keymap and valmap passed in
+ """
+ newkey = keymap.get(key, key)
+ newval = valmap.get(key, lambda x: x)(value)
+ return newkey, newval
+
+
+def get_cpu_devs(adb=ADB()):
+ """
+ Return a list of CPU devices
+ """
+
+ pattern = re.compile('^(?P<key>.+?)\s*:\s*(?P<value>.*)$')
+ cpunum = 0
+ devices = []
+ cpudevs = []
+ cpudevs.append({})
+
+ # TODO maybe there is other types
+ keymap, valmap = ARM_KEYMAP, ARM_VALMAP
+
+ try:
+ (retcode, cpuinfo) = adb.get_shellcmdoutput("cat /proc/cpuinfo")
+ if retcode != 0 or cpuinfo is None:
+ raise IOError("Faile to get content of file(%s)" % "/proc/cpuinfo")
+ for line in cpuinfo:
+ match = pattern.match(line)
+ if match:
+ key, value = match.groups()
+ key = key.strip()
+ value = value.strip()
+ try:
+ key, value = _translate_cpuinfo(keymap, valmap, key, value)
+ except ValueError:
+ pass
+ if cpudevs[cpunum].get(key):
+ cpunum += 1
+ cpudevs.append({})
+ cpudevs[cpunum][key] = value
+ for c in range(len(cpudevs)):
+ device = {}
+ device['device_type'] = 'device.cpu'
+ device['description'] = 'Processor #{0}'.format(c)
+ device['attributes'] = cpudevs[c]
+ devices.append(device)
+ except IOError:
+ print >> sys.stderr, "WARNING: Could not read cpu information"
+ return devices
+
+
+def get_board_devs(adb=ADB()):
+ """
+ Return a list of board devices
+ """
+ devices = []
+ attributes = {}
+ device = {}
+
+ try:
+ (retcode, cpuinfo) = adb.get_shellcmdoutput("cat /proc/cpuinfo")
+ if retcode != 0 or cpuinfo is None:
+ raise IOError("Faile to get content of file(%s)" % "/proc/cpuinfo")
+ pattern = re.compile("^Hardware\s*:\s*(?P<description>.+)$", re.M)
+ found = False
+ for line in cpuinfo:
+ match = pattern.search(line)
+ if match:
+ found = True
+ device['description'] = match.group('description').strip()
+ if not found:
+ return devices
+ except IOError:
+ print >> sys.stderr, "WARNING: Could not read board information"
+ return devices
+ if attributes:
+ device['attributes'] = attributes
+ device['device_type'] = 'device.board'
+ devices.append(device)
+ return devices
+
+
+def get_mem_devs(adb=ADB()):
+ """ Return a list of memory devices
+
+ This returns up to two items, one for physical RAM and another for swap
+ """
+ devices = []
+
+ pattern = re.compile('^(?P<key>.+?)\s*:\s*(?P<value>.+) kB$', re.M)
+
+ try:
+ (retcode, meminfo) = adb.get_shellcmdoutput("cat /proc/meminfo")
+ if retcode != 0 or meminfo is None:
+ raise IOError("Faile to get content of file(%s)" % "/proc/meminfo")
+ for line in meminfo:
+ match = pattern.search(line)
+ if not match:
+ continue
+ key, value = match.groups()
+ key = key.strip()
+ value = value.strip()
+ if key not in ('MemTotal', 'SwapTotal'):
+ continue
+ #Kernel reports in 2^10 units
+ capacity = int(value) << 10
+ if capacity == 0:
+ continue
+ if key == 'MemTotal':
+ kind = 'RAM'
+ else:
+ kind = 'swap'
+ description = "{capacity}MiB of {kind}".format(
+ capacity=capacity >> 20, kind=kind)
+ device = {}
+ device['description'] = description
+ device['attributes'] = {'capacity': str(capacity), 'kind': kind}
+ device['device_type'] = "device.mem"
+ devices.append(device)
+ except IOError:
+ print >> sys.stderr, "WARNING: Could not read memory information"
+ return devices
+
+
+def get_hardware_context(adb=ADB()):
+ """
+ Return a dict with all of the hardware profile information gathered
+ """
+ hardware_context = {}
+ devices = []
+ devices.extend(get_cpu_devs(adb))
+ devices.extend(get_board_devs(adb))
+ devices.extend(get_mem_devs(adb))
+ hardware_context['devices'] = devices
+ return hardware_context
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/main.py b/build/lib.linux-x86_64-2.7/lava_android_test/main.py
new file mode 100644
index 0000000..cb39a72
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/main.py
@@ -0,0 +1,63 @@
+# Copyright (c) 2010-2012 Linaro
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import os
+import sys
+import shutil
+from tempfile import mkdtemp
+from lava_android_test import utils
+from lava_android_test.config import get_config, set_config
+from lava_tool.dispatcher import LavaDispatcher, run_with_dispatcher_class
+
+
+class LAVAAndroidTestDispatcher(LavaDispatcher):
+ toolname = 'lava_android_test'
+ description = """
+ LAVA Android Test wrapper framework
+ """
+ epilog = """
+ Please report all bugs using the Launchpad bug tracker:
+ http://bugs.launchpad.net/lava-android-test/+filebug
+ """
+
+
+def check_adb_installed():
+ return utils.check_command_exist('adb')
+
+
+def main():
+ if not check_adb_installed():
+ print >> sys.stderr, "Can't find the command adb."
+ print >> sys.stderr, ("Please add the path of adb"
+ " command to PATH environment.")
+ sys.exit(1)
+
+ config = get_config()
+ try:
+ if not os.path.exists(config.tempdir_host):
+ os.makedirs(config.tempdir_host)
+ #make every user can write/read this directory
+ os.chmod(config.tempdir_host, 0777)
+ config.tempdir_host = mkdtemp(dir=config.tempdir_host)
+ set_config(config)
+ os.chmod(config.tempdir_host, 0755)
+ run_with_dispatcher_class(LAVAAndroidTestDispatcher)
+ finally:
+ #can't remove the parent directory, because there may be other
+ #instance using the parent directory
+ shutil.rmtree(config.tempdir_host)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/provider.py b/build/lib.linux-x86_64-2.7/lava_android_test/provider.py
new file mode 100644
index 0000000..4ded272
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/provider.py
@@ -0,0 +1,276 @@
+# Copyright (c) 2012 Linaro
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import traceback
+
+from pkgutil import walk_packages
+
+from lava_android_test import testdef
+from lava_android_test import test_definitions
+from lava_android_test.test_definitions import commands, instruments
+from lava_android_test.adb import ADB
+from lava_android_test.config import get_config
+from lava_android_test.utils import find_files
+
+
+class UnfoundTest(Exception):
+ """
+ Raise this for unfound test errors
+ """
+
+
+class TestProvider(object):
+
+ test_prefix = ''
+
+ def list_test(self):
+ """
+ Return the list of this type
+ """
+ raise NotImplementedError()
+
+ def import_mod(self, importpath):
+ try:
+ mod = __import__(importpath)
+ except ImportError:
+ raise UnfoundTest('The module(%s) is not found!' % importpath)
+ for i in importpath.split('.')[1:]:
+ mod = getattr(mod, i)
+ return mod
+
+ def list_mod(self, pkg_path):
+ test_list = []
+ for importer, mod, ispkg in walk_packages(pkg_path):
+ test_list.append(mod)
+ return test_list
+
+ def gen_testobj(self, testname=None, installer=None, runner=None,
+ parser=None, adb=ADB()):
+
+ if installer is None:
+ installer = testdef.AndroidTestInstaller()
+ if runner is None:
+ runner = testdef.AndroidTestRunner()
+ if parser is None:
+ parser = testdef.AndroidTestParser()
+
+ testobj = testdef.AndroidTest(testname=testname,
+ installer=installer, runner=runner, parser=parser)
+
+ testobj.parser.results = {'test_results': []}
+ testobj.setadb(adb)
+ return testobj
+
+ def get_test_provider_list(self):
+ providers_hash = {}
+# module = imp.load_source("module", os.path.realpath(__file__))
+ module = self.import_mod('lava_android_test.provider')
+ for name, cls in module.__dict__.iteritems():
+ if name.endswith('TestProvider') \
+ and name != 'TestProvider':
+ providers_hash[name] = cls
+ names = providers_hash.keys()
+ names.sort()
+ providers_list = []
+ common_test_provider = None
+ for name in names:
+ if name != 'CommonTestProvider':
+ providers_list.append(providers_hash.get(name))
+ else:
+ common_test_provider = providers_hash.get(name)
+ if common_test_provider is not None:
+ providers_list.append(common_test_provider)
+ return providers_list
+
+ def load_test(self, test_name=None, serial=''):
+ providers = self.get_test_provider_list()
+ err_msg = ''
+ for provider in providers:
+ try:
+ testobj = provider().load_test(test_name=test_name,
+ serial=serial)
+ if testobj is not None:
+ return testobj
+ except:
+ err_msg = err_msg + traceback.format_exc()
+ raise UnfoundTest('The test(%s) is not found! + Exception:\n%s' % (
+ test_name, err_msg))
+
+
+class CommonTestProvider(TestProvider):
+
+ def list_test(self):
+ return self.list_mod(test_definitions.__path__)
+
+ def load_test(self, test_name=None, serial=None):
+ importpath = "lava_android_test.test_definitions.%s" % test_name
+ mod = self.import_mod(importpath)
+
+ base = mod.testobj
+ base.parser.results = {'test_results': []}
+ base.setadb(ADB(serial))
+ return base
+
+
+class CommandTestProvider(TestProvider):
+
+ test_prefix = 'command'
+
+ def list_test(self):
+ test_list = self.list_mod(commands.__path__)
+ ret_list = []
+ for test_id in test_list:
+ ret_list.append('%s-%s' % (self.test_prefix, test_id))
+ return ret_list
+
+ def load_test(self, test_name=None, serial=None):
+ if not test_name.startswith('%s-' % self.test_prefix):
+ raise UnfoundTest('The test(%s) is not found!' % test_name)
+ mod_name = test_name.replace('%s-' % self.test_prefix, '', 1)
+ importpath = "lava_android_test.test_definitions.%ss.%s" % (
+ self.test_prefix, mod_name)
+ mod = self.import_mod(importpath)
+ if not mod.RUN_ADB_SHELL_STEPS:
+ raise UnfoundTest(("RUN_ADB_SHELL_STEPS not"
+ " defined in the test(%s).") % test_name)
+ if not mod.PATTERN:
+ raise UnfoundTest(("PATTERN not"
+ " defined in the test(%s).") % test_name)
+ testobj = self.gen_testobj(
+ testname=test_name,
+ runner=testdef.AndroidTestRunner(
+ adbshell_steps=mod.RUN_ADB_SHELL_STEPS),
+ parser=testdef.AndroidTestParser(pattern=mod.PATTERN),
+ adb=ADB(serial))
+ return testobj
+
+
+class InstrumentTestProvider(TestProvider):
+
+ test_prefix = 'instrument'
+
+ def list_test(self):
+ test_list = self.list_mod(instruments.__path__)
+ ret_list = []
+ for test_id in test_list:
+ ret_list.append('%s-%s' % (self.test_prefix, test_id))
+ return ret_list
+
+ def load_test(self, test_name=None, serial=None):
+ if not test_name.startswith('%s-' % self.test_prefix):
+ raise UnfoundTest('The test(%s) is not found!' % test_name)
+ mod_name = test_name.replace('%s-' % self.test_prefix, '', 1)
+ importpath = "lava_android_test.test_definitions.%ss.%s" % (
+ self.test_prefix, mod_name)
+ mod = self.import_mod(importpath)
+ if not mod.RUN_ADB_SHELL_STEPS:
+ raise UnfoundTest(("RUN_ADB_SHELL_STEPS not"
+ " defined in the test(%s).") % test_name)
+
+ testobj = self.gen_testobj(
+ testname=test_name,
+ runner=testdef.AndroidTestRunner(
+ adbshell_steps=mod.RUN_ADB_SHELL_STEPS),
+ parser=testdef.AndroidInstrumentTestParser(),
+ adb=ADB(serial))
+ return testobj
+
+
+class ShellTestProvider(TestProvider):
+
+ test_prefix = 'shell'
+ config = get_config()
+ dotext = '.sh'
+
+ def list_test(self):
+ dotext = '.sh'
+ mod = self.import_mod("lava_android_test.test_definitions.shells")
+ sh_files = find_files(mod.curdir, dotext)
+ test_list = []
+ for f in sh_files:
+ ##Assume that the file name only has one '.sh'
+ f_name_no_dotext = os.path.basename(f).replace(dotext, '')
+ test_list.append('%s-%s' % (self.test_prefix, f_name_no_dotext))
+ return test_list
+
+ def load_test(self, test_name=None, serial=None):
+ if not test_name.startswith('%s-' % self.test_prefix):
+ raise UnfoundTest('The test(%s) is not found!' % test_name)
+ f_name_no_dotext = test_name.replace('%s-' % self.test_prefix, '', 1)
+
+ mod = self.import_mod("lava_android_test.test_definitions.%ss" %
+ self.test_prefix)
+ f_name = '%s%s' % (f_name_no_dotext, self.dotext)
+ sh_file = '%s/%s' % (mod.curdir, f_name)
+
+ test_sh_android_path = os.path.join(self.config.installdir_android,
+ test_name, f_name)
+
+ INSTALL_STEPS_ADB_PRE = [
+ 'push %s %s ' % (sh_file, test_sh_android_path),
+ 'shell chmod 777 %s' % test_sh_android_path]
+
+ ADB_SHELL_STEPS = ['%s $(OPTIONS)' % test_sh_android_path]
+
+ testobj = self.gen_testobj(
+ testname=test_name,
+ installer=testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE),
+ runner=testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS),
+ parser=testdef.AndroidSimpleTestParser(),
+ adb=ADB(serial))
+ return testobj
+
+
+class HostShellTestProvider(TestProvider):
+
+ test_prefix = 'hostshell'
+ config = get_config()
+ dotext = '.sh'
+
+ def list_test(self):
+ dotext = '.sh'
+ mod = self.import_mod("lava_android_test.test_definitions.hostshells")
+ sh_files = find_files(mod.curdir, dotext)
+ test_list = []
+ for f in sh_files:
+ ##Assume that the file name only has one '.sh'
+ f_name_no_dotext = os.path.basename(f).replace(dotext, '')
+ test_list.append('%s-%s' % (self.test_prefix, f_name_no_dotext))
+ return test_list
+
+ def load_test(self, test_name=None, serial=None):
+ if not test_name.startswith('%s-' % self.test_prefix):
+ raise UnfoundTest('The test(%s) is not found!' % test_name)
+ f_name_no_prefix = test_name.replace('%s-' % self.test_prefix, '', 1)
+
+ mod = self.import_mod("lava_android_test.test_definitions.%ss" %
+ self.test_prefix)
+ f_name = '%s%s' % (f_name_no_prefix, self.dotext)
+ test_sh_path = '%s/%s' % (mod.curdir, f_name)
+
+ HOST_SHELL_STEPS = ['bash %s -s $(SERIAL) $(OPTIONS)' % test_sh_path]
+
+ testobj = self.gen_testobj(
+ testname=test_name,
+ installer=testdef.AndroidTestInstaller(),
+ runner=testdef.AndroidTestRunner(
+ steps_host_pre=HOST_SHELL_STEPS),
+ parser=testdef.AndroidSimpleTestParser(),
+ adb=ADB(serial))
+ return testobj
+
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/repository.py b/build/lib.linux-x86_64-2.7/lava_android_test/repository.py
new file mode 100644
index 0000000..ce57470
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/repository.py
@@ -0,0 +1,83 @@
+# Copyright (C) 2012 Linaro Limited
+#
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import os
+import subprocess
+
+from lava_android_test import utils
+
+
+class RepositoryError(Exception):
+ """
+ Raise this for repository related errors
+ """
+
+
+class Repository(object):
+ '''
+ Base class for all repository class used to checkout files.
+ This class and sub classes are base the repository command.
+ '''
+
+ def __init__(self, url, repo_type, cmds=[]):
+ self.url = url
+ self.repo_type = repo_type
+ self.check_cmds_exist(cmds)
+
+ def checkout(self, target_dir=None):
+ """
+ Checkout this repository to the specified the target_dir directory
+ """
+ raise NotImplementedError()
+
+ def check_cmds_exist(self, cmds=[]):
+ """
+ check whether the necessary commands are existing.
+ """
+ for cmd in cmds:
+ if not utils.check_command_exist(cmd):
+ raise RepositoryError(("The necessary command(%) does not"
+ " exist, Or can't be seen from path")
+ % cmd)
+
+
+class GitRepository(Repository):
+
+ git_cmd = 'git'
+
+ def __init__(self, url):
+ super(GitRepository, self).__init__(url, 'git', [self.git_cmd])
+
+ def checkout(self, target_dir=None):
+ """
+ Checkout this git repository to the specified the target_dir directory
+ """
+ cmds = []
+ if not target_dir:
+ cmds = [self.git_cmd, 'clone', self.url]
+
+ else:
+ if not os.path.exists(target_dir):
+ os.makedirs(target_dir)
+ cmds = [self.git_cmd, 'clone', self.url, target_dir]
+
+ rc = subprocess.call(cmds)
+ if rc != 0:
+ raise RepositoryError(("Failed to clone the specified "
+ "repository() with exist staus=%d")
+ % (self.url, rc))
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/swprofile.py b/build/lib.linux-x86_64-2.7/lava_android_test/swprofile.py
new file mode 100644
index 0000000..1a74e67
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/swprofile.py
@@ -0,0 +1,95 @@
+# Copyright (c) 2010 Linaro
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import re
+import sys
+from datetime import datetime
+from lava_android_test.adb import ADB
+
+
+def get_properties(adb=ADB()):
+ if adb is None:
+ return {}
+
+ properties = {}
+ try:
+ propinfo = adb.get_shellcmdoutput("getprop")[1]
+ if propinfo is None:
+ return properties
+ pattern = re.compile(
+ '^\[(?P<key>[^\]]+?)]\s*:\s*\[(?P<value>[^\]]+)\]\s*$',
+ re.M)
+ for line in propinfo:
+ match = pattern.search(line)
+ if match:
+ key, value = match.groups()
+ properties[key] = value
+ except IOError:
+ print >> sys.stderr, "WARNING: Could not read board information"
+ return properties
+ return properties
+
+
+def get_image_name_from_properties(adb=ADB()):
+ props = get_properties(adb)
+ return props.get('ro.build.display.id', '')
+
+
+def get_source_info(adb=ADB()):
+
+ TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'
+ source = []
+ example = {'project_name': '',
+ 'branch_vcs': 'git',
+ 'branch_url': '',
+ 'branch_revision': '',
+ 'commit_timestamp': datetime.utcnow().strftime(TIMEFORMAT)}
+ source.append(example)
+ return source
+
+
+def get_package_info(adb=ADB()):
+
+ packages_info = []
+ pkginfo = adb.get_shellcmdoutput('/system/bin/pm list packages -v')[1]
+ if pkginfo is None:
+ return packages_info
+ pattern = re.compile(
+ ("^\s*package:\s*(?P<package_name>[^:]+?)\s*:"
+ "\s*(?P<version>[^\s].+)\s*$"), re.M)
+ for line in pkginfo:
+ match = pattern.search(line)
+ if match:
+ package_name, version = match.groups()
+ package = {'name': package_name.strip(),
+ 'version': version.strip()}
+ packages_info.append(package)
+ return packages_info
+
+
+def get_software_context(adb=ADB()):
+ """ Return dict used for storing software_context information
+
+ image - the image information of the android system
+ sources - the source information about the android system
+ packages - the apk packages information in the android system
+ """
+ if adb is None:
+ return {}
+
+ software_context = {'image': {'name': get_image_name_from_properties(adb)},
+ 'sources': get_source_info(adb),
+ 'packages': get_package_info(adb)
+ }
+ return software_context
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/0xbench.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/0xbench.py
new file mode 100644
index 0000000..8327629
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/0xbench.py
@@ -0,0 +1,89 @@
+# Copyright (c) 2011 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+0xbench integrates several popular benchmarks into a single Android
+app that can be run to get benchmark reports for a given device.
+Here by default we will run the math/2d/3d test on the target device.
+
+**URL:** http://code.google.com/p/0xbench/
+
+**Default options:** "--ez math true --ez 2d true --ez 3d true --ez vm true"
+"""
+
+import os
+import json
+
+import lava_android_test.testdef
+
+curdir = os.path.realpath(os.path.dirname(__file__))
+
+# "-timeout timeout" must be specified with at least one test
+# can not only specified the "-timeout timeout" as option
+DEFAULT_OPTIONS = '--ez math true --ez 2d true --ez 3d true --ez vm true'
+INSTALL_STEPS_HOST_POST = [
+ ("python %s/android-0xbenchmark/android_0xbenchmark_modify_path.py"
+ " $(SERIAL)") % curdir]
+
+RUN_STEPS_HOST_PRE = [
+ ("python %s/android-0xbenchmark/android_0xbenchmark_kill.py"
+ " $(SERIAL)") % curdir]
+RUN_STEPS_ADB_SHELL = ['logcat -c',
+ ("am start -n org.zeroxlab.zeroxbenchmark/"
+ "org.zeroxlab.zeroxbenchmark.Benchmark --ez autorun true $(OPTIONS)")]
+RUN_STEPS_HOST_POST = [
+ 'python %s/android-0xbenchmark/android_0xbenchmark_wait.py '
+ '$(SERIAL) $(OPTIONS)' % curdir]
+
+
+class ZeroXBenchmarkTestParser(lava_android_test.testdef.AndroidTestParser):
+
+ def parse(self, result_filename=None, output_filename='0xBenchmark.bundle',
+ test_name=''):
+ """Parse test output to gather results
+ Use the pattern specified when the class was instantiated to look
+ through the results line-by-line and find lines that match it.
+ Results are then stored in self.results. If a fixupdict was supplied
+ it is used to convert test result strings to a standard format.
+ """
+ with open(output_filename) as stream:
+ test_results_data = stream.read()
+ test_results_json = json.loads(test_results_data)
+ self.results['test_results'] = test_results_json[
+ 'test_runs'][0]['test_results']
+ if self.fixupdict:
+ self.fixresults(self.fixupdict)
+ if self.appendall:
+ self.appendtoall(self.appendall)
+ self.fixmeasurements()
+ self.fixids()
+
+save_dir = '/data/data/org.zeroxlab.zeroxbenchmark/files'
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_host_post=INSTALL_STEPS_HOST_POST)
+run = lava_android_test.testdef.AndroidTestRunner(
+ steps_host_pre=RUN_STEPS_HOST_PRE,
+ adbshell_steps=RUN_STEPS_ADB_SHELL,
+ steps_host_post=RUN_STEPS_HOST_POST)
+parser = ZeroXBenchmarkTestParser()
+testobj = lava_android_test.testdef.AndroidTest(testname="0xbench",
+ installer=inst, runner=run, parser=parser,
+ org_ouput_file=os.path.join(save_dir, '0xBenchmark.bundle'),
+ default_options=DEFAULT_OPTIONS)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/__init__.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/__init__.py
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/android-0xbenchmark/ZeroxBench_Preference.xml b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/android-0xbenchmark/ZeroxBench_Preference.xml
new file mode 100644
index 0000000..6f07a12
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/android-0xbenchmark/ZeroxBench_Preference.xml
@@ -0,0 +1,5 @@
+<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
+<map>
+<string name="KEY_RESULT_CUSTOM_DIR">/data/data/org.zeroxlab.zeroxbenchmark/files</string>
+<int name="KEY_RESULT_SELECTION" value="1" />
+</map>
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_kill.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_kill.py
new file mode 100755
index 0000000..17a4fd7
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_kill.py
@@ -0,0 +1,69 @@
+#!/usr/bin/python
+
+# Copyright (c) 2011 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import re
+import sys
+import time
+from commands import getstatusoutput
+
+if len(sys.argv) == 1:
+ adb_cmd = "adb"
+else:
+ adb_cmd = "adb -s %s" % (sys.argv[1])
+
+
+def back():
+ back_cmd = '%s shell input keyevent 4' % (adb_cmd)
+ rc, output = getstatusoutput(back_cmd)
+ if rc != 0:
+ print 'Failed to execute command %s:%s' % (back_cmd, output)
+ sys.exit(1)
+back()
+back()
+back()
+
+##app_76 861 80 165896 28848 ffffffff afd0eb18 S
+## org.zeroxlab.zeroxbenchmark
+pattern = re.compile(
+ '^\S+\s+(?P<pid>\d+?)\s+.*org\.zeroxlab\.zeroxbenchmark\s*$')
+while True:
+ pscmd = '%s shell ps' % (adb_cmd)
+ rc, output = getstatusoutput(pscmd)
+ if rc != 0:
+ print ("Failed to get process information about "
+ "org.zeroxlab.zeroxbenchmark:%s") % output
+ sys.exit(1)
+ pid = None
+ for line in output.splitlines():
+ match = pattern.match(line)
+ if match:
+ pid = match.group('pid')
+ break
+
+ if pid is None:
+ sys.exit(0)
+
+ killcmd = '%s shell kill %s' % (adb_cmd, pid)
+ rc, output = getstatusoutput(killcmd)
+ if rc != 0:
+ print 'Failed to kill process(%s):%s' % (pid, output)
+ sys.exit(1)
+ time.sleep(2)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_modify_path.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_modify_path.py
new file mode 100644
index 0000000..0b0d309
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_modify_path.py
@@ -0,0 +1,121 @@
+#!/usr/bin/python
+
+# Copyright (c) 2011 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import sys
+import re
+import os
+from commands import getstatusoutput
+
+curdir = os.path.realpath(os.path.dirname(__file__))
+source = '%s/ZeroxBench_Preference.xml' % curdir
+target = ("/data/data/org.zeroxlab.zeroxbenchmark/shared_prefs/"
+ "ZeroxBench_Preference.xml")
+
+if len(sys.argv) == 1:
+ adbcmd = 'adb'
+else:
+ adbcmd = 'adb -s %s' % (sys.argv[1])
+
+target_dir = '/data/data'
+lscmd = '%s shell ls -l %s' % (adbcmd, target_dir)
+rc, output = getstatusoutput(lscmd)
+if rc != 0:
+ print 'Failed to get group and owner of directory(%s) : %s' % (target_dir,
+ output)
+ sys.exit(1)
+group = None
+owner = None
+##drwxr-x--x app_76 app_76 2011-10-21 14:40
+## org.zeroxlab.zeroxbenchmark
+pattern = re.compile(
+ ("^d\S+\s+(?P<group>\S+?)\s+(?P<owner>\S+?)\s+"
+ "\S+\s+\S+\s+org\.zeroxlab\.zeroxbenchmark\s*$"))
+for line in output.splitlines():
+ match = pattern.match(line)
+ if match:
+ group, owner = match.groups()
+ break
+if (group is None) or (owner is None):
+ print 'Failed to get group and owner of directory(%s): %s' % (target_dir,
+ output)
+ sys.exit(1)
+
+target_dir = '/data/data/org.zeroxlab.zeroxbenchmark/shared_prefs'
+mkdircmd = '%s shell mkdir %s' % (adbcmd, target_dir)
+rc, output = getstatusoutput(mkdircmd)
+if rc != 0:
+ print 'Failed to create directory(%s): %s' % (source, target, output)
+ sys.exit(1)
+
+chowncmd = '%s shell chown %s.%s %s' % (adbcmd, owner, group, target_dir)
+rc, output = getstatusoutput(chowncmd)
+if rc != 0:
+ print 'Failed to change group(%s) and owner(%s) of file(%s): %s' % (group,
+ owner, target_dir, output)
+ sys.exit(1)
+
+chmodcmd = '%s shell chmod 771 %s' % (adbcmd, target_dir)
+rc, output = getstatusoutput(chmodcmd)
+if rc != 0:
+ print 'Failed to change chmod to 771 for file(%s): %s' % (target_dir,
+ output)
+ sys.exit(1)
+
+pushcmd = '%s push %s %s' % (adbcmd, source, target)
+rc, output = getstatusoutput(pushcmd)
+if rc != 0:
+ print 'Failed to push file(%s) to file(%s): %s' % (source, target,
+ output)
+ sys.exit(1)
+
+chowncmd = '%s shell chown %s.%s %s' % (adbcmd, owner, group, target)
+rc, output = getstatusoutput(chowncmd)
+if rc != 0:
+ print 'Failed to change group(%s) and owner(%s) of file(%s): %s' % (group,
+ owner, target, output)
+ sys.exit(1)
+
+chmodcmd = '%s shell chmod 660 %s' % (adbcmd, target)
+rc, output = getstatusoutput(chmodcmd)
+if rc != 0:
+ print 'Failed to change chmod to 771 for file(%s): %s' % (target, output)
+ sys.exit(1)
+
+target_dir = '/data/data/org.zeroxlab.zeroxbenchmark/files'
+mkdircmd = '%s shell mkdir %s' % (adbcmd, target_dir)
+rc, output = getstatusoutput(mkdircmd)
+if rc != 0:
+ print 'Failed to create directory(%s): %s' % (target_dir, output)
+ sys.exit(1)
+
+chowncmd = '%s shell chown %s.%s %s' % (adbcmd, owner, group, target_dir)
+rc, output = getstatusoutput(chowncmd)
+if rc != 0:
+ print 'Failed to change group(%s) and owner(%s) of file(%s): %s' % (group,
+ owner, target_dir, output)
+ sys.exit(1)
+
+chmodcmd = '%s shell chmod 771 %s' % (adbcmd, target_dir)
+rc, output = getstatusoutput(chmodcmd)
+if rc != 0:
+ print 'Failed to change chmod to 771 for file(%s): %s' % (target_dir,
+ output)
+ sys.exit(1)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_wait.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_wait.py
new file mode 100755
index 0000000..dcfdbfc
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_wait.py
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+
+# Copyright (c) 2011 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import sys
+import time
+
+from lava_android_test.utils import stop_at_pattern
+
+adb_cmd = "adb"
+# here assumes that there is no serial number will start with '-'
+# and the options passed are start with '-' as first option
+if len(sys.argv) > 1 and (not sys.argv[1].startswith('-')):
+ adb_cmd = "adb -s %s" % (sys.argv[1])
+
+timeout = 2400
+for index in range(1, len(sys.argv)):
+ arg = sys.argv[index]
+ if arg == '-timeout' and \
+ (index + 1 < len(sys.argv)) and \
+ sys.argv[index + 1]:
+ try:
+ timeout = int(sys.argv[index + 1])
+ except ValueError:
+ pass
+ finally:
+ break
+
+logcat_cmd = '%s logcat' % (adb_cmd)
+pattern = "Displayed org.zeroxlab.zeroxbenchmark/.Report"
+
+if not stop_at_pattern(command=logcat_cmd, pattern=pattern, timeout=timeout):
+ print "0xbench Test: TIMEOUT Fail"
+ sys.exit(1)
+
+time.sleep(3)
+sys.exit(0)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/bctest.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/bctest.py
new file mode 100644
index 0000000..5609277
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/bctest.py
@@ -0,0 +1,52 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Android Team <linaro-android@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+bctest test covers testing of a couple of binder IOCTLS.
+We can think of it as a subset of "shell-binder" test,
+which is much more exhaustive and is the main binder test to go for.
+binder test "bctest" that is pre-intalled on Juice Android builds.
+
+**URL:** http://android.git.linaro.org/gitweb?p=platform/frameworks/base.git;a=blob;f=cmds/servicemanager/bctest.c
+
+**Default options:** "publish 1"
+"""
+
+import lava_android_test.config
+import lava_android_test.testdef
+
+test_name = 'bctest'
+
+DEFAULT_OPTIONS = 'publish 1'
+
+INSTALL_STEPS_ADB_PRE = []
+ADB_SHELL_STEPS = ['bctest $(OPTIONS)']
+PATTERN = "(?P<test_case_id>.*ioctl)\s(?P<result>(PASS|FAIL)?).*"
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN)
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser,
+ default_options=DEFAULT_OPTIONS)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/big_LITTLE.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/big_LITTLE.py
new file mode 100644
index 0000000..7aa6b1f
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/big_LITTLE.py
@@ -0,0 +1,51 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Drives big.LITTLE test scripts that are pre-intalled on Linaro Android
+builds of big.LITTLE.
+By default will run all the tests on the target including tests on:
+basic module and switcher/cache-coherency/data-corruption/disk-io/governor/memory/perf/switcher/vfp-ffmpeg
+
+**URL:** https://linaro-private.git.linaro.org/gitweb?p=bL_tests/bL_iks_tests.git;a=summary
+
+**Default options:** "-a"
+"""
+
+import lava_android_test.testdef
+
+test_name = 'big_LITTLE'
+
+DEFAULT_OPTIONS='-a'
+
+INSTALL_STEPS_ADB_PRE = []
+ADB_SHELL_STEPS = ['run_stress_switcher_tests.sh $(OPTIONS)']
+PATTERN = "(?P<test_case_id>.*-*)\s+:\s+(?P<result>(PASS|FAIL))"
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN)
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser,
+ default_options=DEFAULT_OPTIONS)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/blackbox.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/blackbox.py
new file mode 100644
index 0000000..790569b
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/blackbox.py
@@ -0,0 +1,494 @@
+# Copyright (c) 2012 Linaro Limited
+
+# Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Bridge for the black-box testing implemented by lava-blackbox.
+It covers all the available tests in AOSP.
+The list is available here from APMTest to ZipFileROTest
+
+**Sample Result URL:** http://validation.linaro.org/lava-server/dashboard/image-reports/linaro-android-member-ti_panda-linaro
+
+**URL:** https://github.com/zyga/lava-blackbox
+
+**Default options:** None
+"""
+
+import datetime
+import functools
+import logging
+import os
+import pdb
+import shutil
+import subprocess
+import tempfile
+
+from linaro_dashboard_bundle.evolution import DocumentEvolution
+from linaro_dashboard_bundle.io import DocumentIO
+
+from lava_android_test.config import get_config
+
+
+def debuggable_real(func):
+ """
+ Helper for debugging functions that otherwise have their exceptions
+ consumed by the caller. Any exception raised from such a function will
+ trigger a pdb session when 'DEBUG_DEBUGGABLE' environment is set.
+ """
+ @functools.wraps(func)
+ def debuggable_decorator(*args, **kwargs):
+ try:
+ return func(*args, **kwargs)
+ except:
+ logging.exception("exception in @debuggable function")
+ pdb.post_mortem()
+ return debuggable_decorator
+
+
+def debuggable_noop(func):
+ return func
+
+
+if os.getenv("DEBUG_DEBUGGABLE"):
+ debuggable = debuggable_real
+else:
+ debuggable = debuggable_noop
+
+
+class SuperAdb(object):
+ """
+ Class that implements certain parts of ADB()-like API differently.
+ """
+
+ def __init__(self, stock_adb):
+ # Name of the adb executable with any required arguments,
+ # such as -s 'serial'
+ self._adb_cmd = stock_adb.adb.split()
+
+ def __call__(self, command, *args, **kwargs):
+ """
+ Invoke adb command.
+
+ This call is somewhat special that it wraps two subprocess helper
+ functions: check_call and check_output. They are called depending
+ on the keyword argument 'stdout', if passed as None then output
+ is _not_ saved and is instantly streamed to the stdout of the running
+ program. In any other case stdout is buffered and saved, then returned
+ """
+ cmd = self._adb_cmd + command
+ if "stdout" in kwargs and kwargs['stdout'] is None:
+ del kwargs['stdout']
+ return subprocess.check_call(cmd, *args, **kwargs)
+ else:
+ return subprocess.check_output(cmd, *args, **kwargs)
+
+ def listdir(self, dirname):
+ """
+ List directory entries on the android device.
+
+ Similar to adb.listdir() as implemented in ADB() but generates
+ subsequent lines instead of returning a big lump of text for the
+ developer to parse. Also, instead of using 'ls' on the target it
+ uses the special 'ls' command built into adb.
+
+ The two special entries, . and .., are omitted
+ """
+ for line in self(['ls', dirname]).splitlines():
+ # a, b and c are various pieces of stat data
+ # but we don't need that here.
+ a, b, c, pathname = line.split(' ', 3)
+ if pathname not in ('.', '..'):
+ yield pathname
+
+
+class AdbMixIn(object):
+ """
+ Mix-in class that assists in setting up ADB.
+
+ lava-android-test uses the setadb()/getadb() methods to pass the ADB object
+ (which encapsulates connection data for the specific device we will be
+ talking to).
+
+ Since the ADB object has fixed API and changes there are beyond the scope
+ of this test any extra stuff we want from ADB will be provided by the
+ SuperAdb class.
+
+ This mix-in class that has methods expected by lava-android-test and
+ exposes two properties, adb and super_adb.
+ """
+
+ adb = None
+
+ def setadb(self, adb=None):
+ if self.adb is None and adb is not None:
+ self.adb = adb
+ else:
+ self.adb = adb
+ self.super_adb = SuperAdb(adb)
+
+ def getadb(self):
+ return self.adb
+
+
+class Sponge(object):
+ """
+ A simple namespace-like object that anyone can assign and read freely.
+
+ To get some understanding of what is going on both reads and writes are
+ logged.
+ """
+
+ def __getattr__(self, attr):
+ return super(Sponge, self).__getattr__(attr)
+
+ def __setattr__(self, attr, value):
+ super(Sponge, self).__setattr__(attr, value)
+
+
+class FutureFormatDetected(Exception):
+ """
+ Exception raised when the code detects a new, unsupported
+ format that was created after this library was written.
+
+ Since formats do not have partial ordering we can only detect
+ a future format when the document format is already at the "latest"
+ value, as determined by DocumentEvolution.is_latest(), but the actual
+ format is not known to us.
+
+ Typically this won't happen often as document upgrades are not performed
+ unless necessary. The only case when this may happen is where the bundle
+ loaded from the device was already using a future format to begin with.
+ """
+
+ def __init__(self, format):
+ self.format = format
+
+ def __str__(self):
+ "Unsupported, future format: %s" % self.format
+
+ def __repr__(self):
+ return "FutureFormatDetected(%r)" % self.format
+
+
+class BlackBoxTestBridge(AdbMixIn):
+ """
+ Bridge for interacting with black box tests implemented as something that
+ looks like android test definition.
+ """
+
+ # NOTE: none of the tests will actually carry this ID, it is simply used
+ # here so that it's not a magic value.
+ testname = 'blackbox'
+
+ def __init__(self):
+ """
+ Initialize black-box test bridge
+ """
+ # The sponge object is just a requirement from the API, it is not
+ # actually used by us in any way. The framework assigns a skeleton
+ # test result there but we don't really need it. The Sponge object
+ # is a simple 'bag' or namespace that will happily accept and record
+ # any values.
+ self.parser = Sponge()
+
+ def install(self, install_options=None):
+ """
+ "Install" blackbox on the test device.
+
+ Black box tests cannot be installed, they must be pre-baked into the
+ image. To conform to the 'protocol' used by lava-android-test we will
+ perform a fake 'installation' of the black box tests by creating a
+ directory that lava-android-test is checking for. We do that only if
+ the lava-blackbox executable, which is the entry point to black box
+ tests exists in the image.
+
+ ..note::
+ This method is part of the lava-android-test framework API.
+ """
+ if not self.adb.exists(self._blackbox_pathname):
+ # Sadly lava-android-test has no exception hierarchy that we can
+ # use so all problems are reported as RuntimeError
+ raise RuntimeError(
+ 'blackbox test cannot be "installed" as they must be built'
+ ' into the image.'
+ ' See https://github.com/zyga/android-lava-wrapper'
+ ' for details.')
+ else:
+ self.adb.makedirs(self._fake_install_path)
+
+ def uninstall(self):
+ """
+ Conformance method to keep up with the API required by
+ lava-android-test. It un-does what install() did by removing the
+ _fake_install_path directory from the device.
+
+ ..note::
+ This method is part of the lava-android-test framework API.
+ """
+ if self.adb.exists(self._fake_install_path):
+ self.adb.rmtree(self._fake_install_path)
+
+ @debuggable
+ def run(self, quiet=False, run_options=None):
+ """
+ Run the black-box test on the target device.
+
+ Use ADB to run the black-box executable on the device. Keep the results
+ in the place that lava-android-test expects us to use.
+
+ ..note::
+ This method is part of the lava-android-test framework API.
+ """
+ # The blackbox test runner will create a directory each time it is
+ # started. All of those directories will be created relative to a so
+ # called spool directory. Instead of using the default spool directory
+ # (which can also change) we will use the directory where
+ # lava-android-test keeps all of the results.
+ spool_dir = get_config().resultsdir_android
+ logging.debug("Using spool directory for black-box testing: %r", spool_dir)
+ stuff_before = frozenset(self.super_adb.listdir(spool_dir))
+ blackbox_command = [
+ 'shell', self._blackbox_pathname,
+ '--spool', spool_dir,
+ '--run-all-tests']
+ # Let's run the blackbox executable via ADB
+ logging.debug("Starting black-box tests...")
+ self.super_adb(blackbox_command, stdout=None)
+ logging.debug("Black-box tests have finished!")
+ stuff_after = frozenset(self.super_adb.listdir(spool_dir))
+ # Check what got added to the spool directory
+ new_entries = stuff_after - stuff_before
+ if len(new_entries) == 0:
+ raise RuntimeError("Nothing got added to the spool directory")
+ elif len(new_entries) > 1:
+ raise RuntimeError("Multiple items added to the spool directory")
+ result_id = list(new_entries)[0]
+ print "The blackbox test have finished running, the result id is %r" % result_id
+ return result_id
+
+ def parse(self, result_id):
+ """
+ UNIMPLEMENTED METHOD
+
+ Sadly this method is never called as lava-android-test crashes before
+ it gets to realize it is processing blackbox results and load this
+ class. This crash _may_ be avoided by hiding the real results of
+ blackbox and instead populating the results directory with dummy test
+ results that only let LAVA figure out that blackbox is the test to
+ load. Then we could monkey patch other parts and it could be
+ implemented.
+
+ ONCE THIS IS FIXED THE FOLLOWING DESCRIPTION SHOULD APPLY
+
+ Parse and save results of previous test run.
+
+ The result_id is a name of a directory on the Android device (
+ relative to the resultsdir_android configuration option).
+
+ ..note::
+ This method is part of the lava-android-test framework API.
+ """
+ # Sadly since the goal is integration with lava lab I don't have the
+ # time to do it. In the lab we use lava-android-test run -o anyway.
+ raise NotImplementedError()
+
+ def _get_combined_bundle(self, result_id):
+ """
+ Compute the combined bundle of a past run and return it
+ """
+ config = get_config()
+ temp_dir = tempfile.mkdtemp()
+ remote_bundle_dir = os.path.join(config.resultsdir_android, result_id)
+ try:
+ self._copy_all_bundles(remote_bundle_dir, temp_dir)
+ bundle = self._combine_bundles(temp_dir)
+ finally:
+ shutil.rmtree(temp_dir)
+ return bundle
+
+ # Desired format name, used in a few methods below
+ _desired_format = "Dashboard Bundle Format 1.3"
+
+ def _copy_all_bundles(self, android_src, host_dest):
+ """
+ Use adb pull to copy all the files from android_src (android
+ fileystem) to host_dest (host filesystem).
+ """
+ logging.debug("Saving bundles from %s to %s", android_src, host_dest)
+ for name in self.super_adb.listdir(android_src):
+ logging.debug("Considering file %s", name)
+ # NOTE: We employ simple filtering for '.json' files. This prevents
+ # spurious JSON parsing errors if the result directory has
+ # additional files of any kind.
+ #
+ # We _might_ want to lessen that eventually restriction but at this
+ # time blackbox is really designed to be self-sufficient so there
+ # is no point of additional files.
+ if not name.endswith('.json'):
+ continue
+ remote_pathname = os.path.join(android_src, name)
+ local_pathname = os.path.join(host_dest, name)
+ try:
+ logging.debug(
+ "Copying %s to %s", remote_pathname, local_pathname)
+ self.adb.pull(remote_pathname, local_pathname)
+ except:
+ logging.exception("Unable to copy bundle %s", name)
+
+ def _combine_bundles(self, dirname):
+ """
+ Combine all bundles from a previous test run into one bundle.
+
+ Returns the aggregated bundle object
+
+ Load, parse and validate each bundle from the specified directory and
+ combine them into one larger bundle. This is somewhat tricky. Each
+ bundle we coalesce may be generated by a different, separate programs
+ and may, thus, use different formats.
+
+ To combine them all correctly we need to take two precautions:
+ 1) All bundles must be updated to a single, common format
+ 2) No bundle may be upgraded beyond the latest format known
+ to this code. Since the hypothetical 2.0 format may be widely
+ different that we cannot reliably interpret anything beyond
+ the format field. To prevent this we use the evolution API
+ to carefully upgrade only to the "sentinel" format, 1.3
+ (at this time)
+ """
+ # Use DocumentIO.loads() to preserve the order of entries.
+ # This is a very small touch but it makes reading the results
+ # far more pleasant.
+ aggregated_bundle = DocumentIO.loads(
+ '{\n'
+ '"format": "' + self._desired_format + '",\n'
+ '"test_runs": []\n'
+ '}\n')[1]
+ # Iterate over all files there
+ for name in os.listdir(dirname):
+ bundle_pathname = os.path.join(dirname, name)
+ # Process bundle one by one
+ try:
+ format, bundle = self._load_bundle(bundle_pathname)
+ self._convert_to_common_format(format, bundle)
+ self._combine_with_aggregated(aggregated_bundle, bundle)
+ except:
+ logging.exception("Unable to process bundle %s", name)
+ # Return the aggregated bundle
+ return aggregated_bundle
+
+ def _load_bundle(self, local_pathname):
+ """
+ Load the bundle from local_pathname.
+
+ There are various problems that can happen here but
+ they should all be treated equally, the bundle not
+ being used. This also transparently does schema validation
+ so the chance of getting wrong data is lower.
+ """
+ with open(local_pathname, 'rt') as stream:
+ format, bundle = DocumentIO.load(stream)
+ return format, bundle
+
+ def _convert_to_common_format(self, format, bundle):
+ """
+ Convert the bundle to the common format.
+
+ This is a careful and possibly fragile process that may
+ raise FutureFormatDetected exception. If that happens
+ then desired_format (encoded in the function itself) must be
+ changed and the code reviewed for any possible changes
+ required to support the more recent format.
+ """
+ while True:
+ # Break conditions, encoded separately for clarity
+ if format == self._desired_format:
+ # This is our desired break condition, when format
+ # becomes (or starts as) the desired format
+ break
+ if DocumentEvolution.is_latest(bundle):
+ # This is a less desired break condition, if we
+ # got here then the only possible explanation is
+ # that some program started with format > desired_format
+ # and the DocumentEvolution API is updated to understand
+ # it but we are not. In that case let's raise an exception
+ raise FutureFormatDetected(format)
+ # As long as the document format is old keep upgrading it
+ # step-by-step. Evolution is done in place
+ DocumentEvolution.evolve_document(bundle, one_step=True)
+
+ def _combine_with_aggregated(self, aggregated_bundle, bundle):
+ """
+ Combine the bundle with the contents of aggregated_bundle.
+
+ This method simply transplants all the test runs as that is what
+ the bundle format was designed to be - a simple container for test
+ runs.
+ """
+ assert bundle["format"] == self._desired_format
+ assert aggregated_bundle["format"] == self._desired_format
+ aggregated_bundle["test_runs"].extend(bundle.get("test_runs", []))
+
+ @property
+ def _blackbox_pathname(self):
+ """
+ The path to the blackbox bridge on the device.
+ """
+ return "/system/bin/lava-blackbox"
+
+ @property
+ def _fake_install_path(self):
+ """
+ The path that we create on the android system to
+ indicate that the black box test is installed.
+
+ This is used by uninstall() and install()
+ """
+ config = get_config()
+ return os.path.join(config.installdir_android, self.testname)
+
+ def _monkey_patch_lava(self):
+ """
+ Monkey patch the implementation of lava_android_test.commands.generate_bundle
+
+ This change is irreversible but given the one-off nature of
+ lava-android-test this is okay. It should be safe to do this since
+ LAVA will only load the blackbox test module if we explicitly request
+ to run it. At that time no other tests will run in the same process.
+
+ This method should not be used once lava-android-test grows a better
+ API to allow us to control how bundles are generated.
+ """
+ from lava_android_test import commands
+ def _phony_generate_bundle(serial=None, result_id=None,
+ test=None, test_id=None, attachments=[]):
+ if result_id is None:
+ raise NotImplementedError
+ return self._get_combined_bundle(result_id)
+ commands.generate_bundle = _phony_generate_bundle
+ logging.warning(
+ "The 'blackbox' test definition has monkey-patched the function"
+ " lava_android_test.commands.generate_bundle() if you are _not_"
+ " running the blackbox test or are experiencing odd problems/crashes"
+ " below please look at this method first")
+
+
+# initialize the blackbox test definition object
+testobj = BlackBoxTestBridge()
+
+# Then monkey patch lava-android-test so that parse keeps working
+testobj._monkey_patch_lava()
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/bluetooth.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/bluetooth.py
new file mode 100644
index 0000000..2ca1d8c
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/bluetooth.py
@@ -0,0 +1,47 @@
+# copyright (C) 2012 Linaro Limited
+#
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+This test helps validating basic bluetooth functionality by executing the
+Android BluetoothTestRunner tests.
+
+**URL:** http://android.git.linaro.org/gitweb?p=platform/frameworks/base.git;a=blob;f=core/tests/bluetoothtests/src/android/bluetooth/BluetoothTestRunner.java
+
+**Default options:** None
+"""
+
+import lava_android_test.testdef
+
+test_name = 'bluetooth'
+
+cmd = ("am instrument -r -e enable_iterations 2 -e discoverable_iterations 2"
+ " -e scan_iterations 2 -e enable_pan_iterations 2 -e pair_iterations 1 "
+ " -e device_address $(OPTIONS) "
+ " -w com.android.bluetooth.tests/android.bluetooth.BluetoothTestRunner")
+RUN_ADB_SHELL_STEPS = [cmd]
+
+inst = lava_android_test.testdef.AndroidTestInstaller()
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=RUN_ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidInstrumentTestParser()
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/busybox.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/busybox.py
new file mode 100644
index 0000000..cc32fcc
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/busybox.py
@@ -0,0 +1,57 @@
+# Copyright (c) 2011 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+This is a simple test to ensure busybox is installed on an Android build and
+can execute some basic busybox commands
+
+**URL:** http://www.busybox.net/
+
+**Default Options:** None
+"""
+
+import os
+import lava_android_test.testdef
+from lava_android_test.config import get_config
+
+test_name = 'busybox'
+config = get_config()
+curdir = os.path.realpath(os.path.dirname(__file__))
+test_sh_name = 'busybox_test.sh'
+test_sh_path = os.path.join(curdir, test_name, test_sh_name)
+test_sh_android_path = os.path.join(config.installdir_android,
+ test_name, test_sh_name)
+
+INSTALL_STEPS_ADB_PRE = ['push %s %s ' % (test_sh_path,
+ test_sh_android_path),
+ 'shell chmod 777 %s' % test_sh_android_path]
+
+ADB_SHELL_STEPS = [test_sh_android_path]
+#PATTERN = "^(?P<test_case_id>\w+):\W+(?P<measurement>\d+\.\d+)"
+PATTERN = "^\s*(?P<test_case_id>\w+)=(?P<result>\w+)\s*$"
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN)
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/busybox/busybox_test.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/busybox/busybox_test.sh
new file mode 100755
index 0000000..455a75e
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/busybox/busybox_test.sh
@@ -0,0 +1,35 @@
+#!/system/bin/sh
+
+test_func(){
+ if [ ! -f /system/bin/busybox ]; then
+ echo "busybox=unexist"
+ exit
+ fi
+
+ if /system/bin/busybox [ $# -lt 1 ]; then
+ return 0
+ fi
+ test_cmd=$1
+ /system/bin/busybox "$@" 1>/dev/null 2>/dev/null
+ if /system/bin/busybox [ $? -ne 0 ]; then
+ echo "${test_cmd}=fail"
+ else
+ echo "${test_cmd}=pass"
+ fi
+}
+
+rm -r /data/local/tmp/busybox 1>/dev/null 2>/dev/null
+
+test_func mkdir /data/local/tmp/busybox
+test_func touch /data/local/tmp/busybox/test.txt
+test_func ls /data/local/tmp/busybox/test.txt
+test_func ps
+test_func whoami
+test_func which busybox
+test_func basename /data/local/tmp/busybox/test.txt
+test_func cp /data/local/tmp/busybox/test.txt /data/local/tmp/busybox/test2.txt
+test_func rm /data/local/tmp/busybox/test2.txt
+test_func dmesg
+test_func grep service /init.rc
+
+rm -r /data/busybox 1>/dev/null 2>/dev/null
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cache_coherency.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cache_coherency.py
new file mode 100644
index 0000000..72f1709
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cache_coherency.py
@@ -0,0 +1,47 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Stressapptest tries to maximize randomized traffic to memory from processor
+and I/O, with the intent of creating a realistic high load situation
+in order to test the existing hardware devices in a computer.
+Used for cache-coherency testing on big.LITTLE here.
+
+**URL:** http://android.git.linaro.org/gitweb?p=platform/external/stressapptest.git;a=summary
+
+**Default options:** None
+"""
+import lava_android_test.testdef
+
+test_name = 'cache_coherency'
+
+INSTALL_STEPS_ADB_PRE = []
+ADB_SHELL_STEPS = ['stressapptest -M 16 --cc_test -s 10']
+PATTERN = "^\s*(?P<test_case_id>Status?):\s+(?P<result>(PASS|FAIL)?)\s+-\s+"
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN)
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/__init__.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/__init__.py
new file mode 100644
index 0000000..075f164
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/__init__.py
@@ -0,0 +1,30 @@
+# copyright (C) 2012 Linaro Limited
+#
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+This directory contains the test that only needs to run an android command and
+specify the output pattern that to parse the command ouptu to get result.
+Please see the example.py for a reference.
+Please note this is not a test that can be run.
+
+**URL:** None
+
+**Default options:** None
+"""
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/bionic_libc_tests.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/bionic_libc_tests.py
new file mode 100644
index 0000000..4beaac3
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/bionic_libc_tests.py
@@ -0,0 +1,29 @@
+# Copyright (c) 2013 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+Runs the stock bionic tests.
+
+**URL:** http://android.git.linaro.org/gitweb?p=platform/system/extras.git;a=tree;f=tests/bionic/libc
+
+**Default Options:** None
+"""
+
+RUN_ADB_SHELL_STEPS = ['run-bionic-tests.sh']
+PATTERN = "(?P<test_case_id>.*-*)\s+:\s+(?P<result>(PASS|FAIL))"
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/example.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/example.py
new file mode 100644
index 0000000..2a175da
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/example.py
@@ -0,0 +1,31 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Example for how to add tests that only need to run an android command
+and specify the output pattern to parse the command ouput to get result.
+
+**URL:** None
+
+**Default options:** None
+"""
+RUN_ADB_SHELL_STEPS = ['tjunittest']
+PATTERN = ("^\s*(?P<test_case_id>.+)\s+\.\.\.\s+(?P<result>\w+)\."
+ "\s+(?P<measurement>[\d\.]+)\s+(?P<units>\w+)\s*$")
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/linaro_android_kernel_test.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/linaro_android_kernel_test.py
new file mode 100644
index 0000000..39fd33c
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/linaro_android_kernel_test.py
@@ -0,0 +1,30 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+Runs the linaro kernel unit tests including:
+ ashmem/ashmem_expanded/alarmdev/logger/binder/sync
+
+**URL:** https://linaro-private.git.linaro.org/gitweb?p=android/linaro-android-kernel-test.git;a=summary
+
+**Default Options:** None
+"""
+
+RUN_ADB_SHELL_STEPS = ['linaro-android-kernel-tests.sh']
+PATTERN = "\s*\[(?P<test_case_id>\w+)\]:\s\w+\s(?P<result>\w+)"
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/tjunittest.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/tjunittest.py
new file mode 100644
index 0000000..e377fc4
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/commands/tjunittest.py
@@ -0,0 +1,30 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Tests the various code paths in the TurboJPEG C Wrapper
+
+**URL:** https://git.linaro.org/gitweb?p=people/tomgall/libjpeg-turbo/libjpeg-turbo.git;a=blob_plain;f=tjunittest.c
+
+**Default options:** None
+"""
+ADB_SHELL_STEPS = ['tjunittest']
+PATTERN = ("^\s*(?P<test_case_id>.+)\s+\.\.\.\s+(?P<result>\w+)\."
+ "\s+(?P<measurement>[\d\.]+)\s+(?P<units>\w+)\s*$")
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts.py
new file mode 100644
index 0000000..6e0eec7
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts.py
@@ -0,0 +1,70 @@
+# Copyright (C) 2012 Linaro Limited
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+This test executes the Android Compatibility Test Suite (CTS) to verify if
+a given build meets all the criteria.
+
+**URL:** http://source.android.com/compatibility/cts-intro.html
+
+**Default Options:** None
+"""
+
+import os
+
+from lava_android_test.testdef import (Attachment,
+ AndroidTest,
+ AndroidTestInstaller,
+ AndroidTestRunner,
+ AndroidTestParser)
+
+test_name = 'cts'
+
+curdir = os.path.realpath(os.path.dirname(__file__))
+
+RUN_STEPS_HOST_PRE = ['python %s/cts/cts_wrapper.py $(SERIAL) $(OPTIONS)' % (
+ curdir)]
+
+inst = AndroidTestInstaller()
+run = AndroidTestRunner(steps_host_pre=RUN_STEPS_HOST_PRE)
+
+# cts-tf > [2K06-17 14:24:02 I/10.254.21.142:5555: android.acceleration.
+# cts.HardwareAccelerationTest#testIsHardwareAccelerated PASS
+pattern = ("^cts-tf.*\s*[\d-]+\s+[\d:]+\s+I\/\S+\:\s+(?P<test_case_id>\S+#\S+)"
+ "\s+(?P<result>\S+)\s*$")
+parser = AndroidTestParser(pattern=pattern,
+ fixupdict={'PASS': 'pass', 'FAIL': 'fail'})
+
+attachments = [
+ Attachment(pathname="/data/local/tmp/logcat.log",
+ mime_type="text/plain"),
+ Attachment(pathname="/data/local/tmp/kmsg.log",
+ mime_type="text/plain"),
+ Attachment(pathname="/data/local/tmp/cts-results.zip",
+ mime_type="application/zip"),
+ Attachment(pathname="/data/local/tmp/device_logcat.zip",
+ mime_type="application/zip"),
+ Attachment(pathname="/data/local/tmp/host_log.zip",
+ mime_type="application/zip")
+ ]
+testobj = AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser,
+ attachments=attachments)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_list_result_wrapper.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_list_result_wrapper.sh
new file mode 100755
index 0000000..b6ef869
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_list_result_wrapper.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+# Copyright (C) 2012 Linaro Limited
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#http://source.android.com/compatibility/downloads.html
+
+echo "./android-cts/tools/cts-tradefed l r"
+./android-cts/tools/cts-tradefed l r |tee cts_list_results.log
+
+exit 0 \ No newline at end of file
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_prepare.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_prepare.sh
new file mode 100755
index 0000000..6b677a6
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_prepare.sh
@@ -0,0 +1,131 @@
+#!/bin/bash
+# Copyright (C) 2012 Linaro Limited
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#http://source.android.com/compatibility/downloads.html
+if [ -z "$cts_pkg" ]; then
+cts_pkg="android-cts-linux_x86-arm-latest.zip"
+fi
+media_pkg="android-cts-media-latest.zip"
+site_url="http://testdata.validation.linaro.org/cts/"
+#site_url="http://192.168.1.127/images/cts/"
+#export http_proxy=http://localhost:3128
+
+cts_pkg_url="${site_url}${cts_pkg}"
+media_pkg_url="${site_url}${media_pkg}"
+
+ADB_OPTION=""
+SERIAL=""
+if [ "x${1}" != "x" ]; then
+ ADB_OPTION="-s ${1}"
+ SERIAL="${1}"
+fi
+ADB_CMD="adb ${ADB_OPTION}"
+
+
+function download_unzip(){
+ if [ -z "$1" ] || [ -z "$2" ]; then
+ return
+ fi
+ url="${1}"
+ pkg="${2}"
+
+ echo "wget --connect-timeout=30 -S --progress=dot -e dotbytes=2M ${url} -O ${pkg}"
+ wget -c -t 20 --connect-timeout=30 -S --progress=dot -e dotbytes=2M "${url}" -O ${pkg}
+ if [ $? -ne 0 ]; then
+ echo "Failed to get the package ${url}"
+ exit 1
+ fi
+ echo "unzip ${pkg}"
+ unzip ${pkg}
+ if [ $? -ne 0 ]; then
+ echo "Faild to unzip the package "
+ exit 1
+ fi
+}
+
+function main(){
+ rm -fr ${cts_pkg} ${media_pkg} android-cts
+ download_unzip "${cts_pkg_url}" ${cts_pkg}
+
+ #1. Your phone should be running a user build (Android 4.0 and later) from source.android.com
+ #2. Please refer to this link on the Android developer site and set up your device accordingly.
+ #3. Make sure that your device has been flashed with a user build (Android 4.0and later) before you run CTS.
+ ####Step 1~3 is done by deployment
+
+ #4. You need to ensure the Text To Speech files are installed on the device.
+ # You can check via Settings > Speech synthesis > Install voice data
+ # before running CTS tests.
+ # (Note that this assumes you have Android Market installed on the device,
+ # if not you will need to install the files manually via adb)
+ ##TODO don't know how to do this yet
+
+ #5. Make sure the device has a SD card plugged in and the card is empty.
+ # Warning: CTS may modify/erase data on the SD card plugged in to the device.
+ #6. Do a factory data reset on the device (Settings > SD Card & phone storage >Factory data reset).
+ # Warning: This will erase all user data from the phone.
+ #7. Make sure no lock pattern is set on the device (Settings > Security > Screen Lock should be 'None').
+ #8. Make sure the "USB Debugging" development option is checked (Settings >Developer options > USB debugging).
+ #9. Make sure Settings > Developer options > Stay Awake is checked
+ #10. Make sure Settings > Developer options > Allow mock locations is checked
+ ####Step 5~10 is done by deployment
+
+ #11. Make sure device is connected to a functioning Wi-Fi network (Settings > WiFi)
+ ${ADB_CMD} shell am start -a android.intent.action.MAIN -n com.android.settings/.Settings
+ ${ADB_CMD} shell service call wifi 13 i32 1
+ sleep 5
+
+ #12. Make sure the device is at the home screen at the start of CTS (Press the home button).
+ ${ADB_CMD} shell input keyevent 3
+ sleep 3
+
+ #13. While a device is running tests, it must not be used for any other tasks.
+ #14. Do not press any keys on the device while CTS is running.
+ # Pressing keys or touching the screen of a test device will interfere with the running tests and may lead to test failures.
+ #####Steps 13~14 should be the ok because nobody will operation the test target.
+
+ #15. Set up accessibility tests:
+ echo "${ADB_CMD} install -r android-cts/repository/testcases/CtsDelegatingAccessibilityService.apk"
+ ${ADB_CMD} install -r android-cts/repository/testcases/CtsDelegatingAccessibilityService.apk
+ if [ $? -ne 0 ]; then
+ echo "Faild to install CtsDelegatingAccessibilityService.apk"
+ exit 1
+ fi
+ ## On the device, enable Settings > Accessibility > DelegatingAccessibility Service
+ ${ADB_CMD} push $2 /data/local/tmp/
+ ${ADB_CMD} shell am start -a android.intent.action.VIEW -n com.android.settings/.Settings
+ ${ADB_CMD} shell uiautomator runtest ctshelper.jar -c com.linaro.ctshelper#AccessibilityHelper
+
+
+ #16. Set up device administration tests:
+ echo "${ADB_CMD} install -r android-cts/repository/testcases/CtsDeviceAdmin.apk"
+ ${ADB_CMD} install -r android-cts/repository/testcases/CtsDeviceAdmin.apk
+ if [ $? -ne 0 ]; then
+ echo "Faild to install CtsDeviceAdmin.apk"
+ exit 1
+ fi
+ ## On the device, enable Settings > Security > Device Administrators >android.deviceadmin.cts.CtsDeviceAdmin* settings
+ ${ADB_CMD} shell am start -a android.intent.action.VIEW -n com.android.settings/.Settings
+ ${ADB_CMD} shell uiautomator runtest ctshelper.jar -c com.linaro.ctshelper#SecurityHelper
+ ${ADB_CMD} shell am start -a android.intent.action.VIEW -n com.android.launcher/com.android.launcher2.Launcher
+
+ exit 0
+}
+
+main "$@"
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_redirect.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_redirect.sh
new file mode 100755
index 0000000..b23b3a5
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_redirect.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+# Copyright (C) 2012 Linaro Limited
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+output_file=${1} && shift
+eval "$@" &> ${output_file} &
+echo $!
+exit 0
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_run_wrapper.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_run_wrapper.sh
new file mode 100755
index 0000000..6e4e5ba
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_run_wrapper.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+# Copyright (C) 2012 Linaro Limited
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#http://source.android.com/compatibility/downloads.html
+
+echo ./android-cts/tools/cts-tradefed "$@" --disable-reboot
+./android-cts/tools/cts-tradefed "$@" --disable-reboot > ./cts_output.log 2>&1
+exit 0
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_wrapper.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_wrapper.py
new file mode 100755
index 0000000..deca63c
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/cts_wrapper.py
@@ -0,0 +1,346 @@
+#!/usr/bin/python
+
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import re
+import sys
+import pexpect
+import time
+import xml.dom.minidom
+from zipfile import ZipFile
+
+from lava_android_test.adb import ADB
+from lava_android_test.utils import stop_at_pattern
+from lava_android_test.utils import find_files
+
+adb = ADB(sys.argv[1])
+curdir = os.path.realpath(os.path.dirname(__file__))
+
+
+def stop_at_cts_pattern(command=None, pattern=None, timeout=-1):
+ if not command:
+ return
+
+ if not pattern:
+ response = [pexpect.EOF]
+ else:
+ response = [pattern, pexpect.EOF]
+
+ result = True
+ proc_cts = pexpect.spawn(command, logfile=sys.stdout)
+ time.sleep(200)
+ try:
+ match_id = proc_cts.expect(response, timeout=timeout)
+ if match_id == 0:
+ time.sleep(5)
+ except pexpect.TIMEOUT:
+ result = False
+ finally:
+ proc_cts.sendcontrol('C')
+ proc_cts.sendline('')
+ target_dir = os.path.join(os.getcwd(),
+ './android-cts/repository/results/')
+ for zip_f in find_files(target_dir, '.zip'):
+ ret_code = adb.push(zip_f, '/data/local/tmp/cts-results.zip')[0]
+ if ret_code != 0:
+ print "Failed to push file %s to device(%s)" % (zip_f,
+ adb.get_serial())
+ log_target_dir = os.path.join(os.getcwd(),
+ './android-cts/repository/logs/')
+ for zip_f in find_files(log_target_dir, '.zip'):
+ base_name = os.path.basename(zip_f)
+ if base_name.startswith('device_logcat_'):
+ base_name = 'device_logcat.zip'
+ if base_name.startswith('host_log_'):
+ base_name = 'host_log.zip'
+
+ ret_code = adb.push(zip_f, '/data/local/tmp/%s' % base_name)[0]
+ if ret_code != 0:
+ print "Failed to push file %s to device(%s)" % (zip_f,
+ adb.get_serial())
+ with ZipFile(zip_f) as log_fd:
+ print '=========Log file [%s] starts=========>>>>>' % (
+ base_name)
+ f_name = base_name.replace('.zip', '.txt')
+ for line in log_fd.open(f_name).readlines():
+ print line.rstrip()
+ print '<<<<<=========Log file [%s] ends=========' % base_name
+ return result
+
+
+def get_not_executed():
+ list_result_path = os.path.join(curdir, 'cts_list_result_wrapper.sh')
+ list_result_cmd = "bash %s" % list_result_path
+
+ pattern = 'CTS unknown'
+ if not stop_at_pattern(command=list_result_cmd,
+ pattern=pattern, timeout=5):
+ print "Failed to list the cts result for device(%s)" % adb.get_serial()
+
+ with open('cts_list_results.log') as fd:
+ #0 17237 126 0 2012.06.23_03.31.49 CTS unknown
+ pattern = ("\s*\d+\s+\d+\s+\d+\s+(?P<no_executed>\d+)"
+ "\s+.+CTS\s+unknown\s*$")
+ pat = re.compile(pattern)
+ for line in fd.readlines():
+ match = pat.search(line)
+ if not match:
+ continue
+ return match.groupdict()['no_executed']
+ return 0
+
+
+def prepare_cts():
+ cts_prepare_path = os.path.join(curdir, 'cts_prepare.sh')
+ cts_helper_jar_path = os.path.join(curdir, 'ctshelper.jar')
+ cts_prepare_cmd = "bash %s" % cts_prepare_path
+ if not stop_at_pattern(command="%s %s %s" % (cts_prepare_cmd,
+ adb.get_serial(), cts_helper_jar_path),
+ timeout=18000):
+ print "Preapration for CTS test times out"
+ return False
+ return True
+
+
+def run_cts_with_plan(cts_cmd=None, plan='CTS', timeout=36000):
+ pattern = "Time:"
+ plan_command = '--plan %s' % plan
+ if cts_cmd:
+ plan_command = "%s %s --disable-reboot" % (cts_cmd, plan_command)
+ if not stop_at_cts_pattern(command=plan_command, pattern=pattern,
+ timeout=timeout):
+ print "CTS test times out"
+ return False
+
+ return True
+
+
+def run_cts_with_package(cts_cmd=None, package=None, timeout=36000):
+ if not package:
+ return True
+ pattern = "Time:"
+ plan_command = '--package %s' % package
+ if cts_cmd:
+ plan_command = "%s %s --disable-reboot" % (cts_cmd, plan_command)
+ if not stop_at_cts_pattern(command=plan_command, pattern=pattern,
+ timeout=timeout):
+ print "CTS test times out"
+ return False
+
+ return True
+
+
+def run_cts_with_class(cts_cmd=None, cls=None, method=None, timeout=36000):
+ if not cls:
+ return True
+ pattern = "Time:"
+ cmd = '--class %s' % cls
+ if method:
+ cmd = '%s --method %s' % (cmd, method)
+
+ if cts_cmd:
+ cmd = "%s %s --disable-reboot" % (cts_cmd, cmd)
+ if not stop_at_cts_pattern(command=cmd, pattern=pattern,
+ timeout=timeout):
+ print "CTS test times out"
+ return False
+
+ return True
+
+
+def run_cts_continue(cts_cmd=None):
+ pattern = "Time:"
+ continue_command = '--continue-session 0'
+ if cts_cmd:
+ continue_command = "%s %s" % (cts_cmd, continue_command)
+
+ while True:
+ number_of_not_executed = get_not_executed()
+ if number_of_not_executed and int(number_of_not_executed) > 0:
+ print ('Reconnect the adb connection before continuing '
+ 'the CTS on device(%s)') % adb.get_serial()
+ if not adb.reconnect():
+ print "Faile to reconnect the adb connection of device(%s)" % (
+ adb.get_serial())
+ break
+
+ print "Continue the uncompleted CTS test on device(%s)" % (
+ adb.get_serial())
+
+ if not stop_at_cts_pattern(command=continue_command,
+ pattern=pattern,
+ timeout=36000):
+ print "CTS test times out"
+ else:
+ break
+
+
+def collect_log(command=None, output_file=None):
+ if command and output_file:
+ print 'Redirect the output of command[%s] to file[%s]' % (command,
+ output_file)
+ cmd = 'bash %s %s "%s"' % (os.path.join(curdir, 'cts_redirect.sh'),
+ output_file, command)
+ stdout = adb.run_cmd_host(cmd)[1]
+ if stdout:
+ return stdout[0].strip()
+
+ return None
+
+
+def collect_logs():
+
+ kmsg = {'command':
+ 'adb -s %s shell cat /proc/kmsg' % (adb.get_serial()),
+ 'output_file': 'kmsg.log'}
+
+ logcat = {'command':
+ 'adb -s %s logcat -c; adb -s %s logcat -v time' % (
+ adb.get_serial(), adb.get_serial()),
+ 'output_file': 'logcat.log'}
+
+ ## define all the logs need to be collected
+ logs = [kmsg, logcat]
+ for log in logs:
+ pid = collect_log(command=log.get('command'),
+ output_file=log.get('output_file'))
+ if pid:
+ log['pid'] = pid
+ return logs
+
+
+def push_log(logs=[]):
+ for log in logs:
+ log_file = log.get('output_file')
+ base_name = os.path.basename(log_file)
+ if log_file:
+ ret_code = adb.push(log_file, '/data/local/tmp/%s' % base_name)[0]
+ if ret_code != 0:
+ print "Failed to push file %s to device(%s)" % (log_file,
+ adb.get_serial())
+ with open(log_file) as log_fd:
+ print '=========Log file [%s] starts=========>>>>>' % (
+ log_file)
+ for line in log_fd.readlines():
+ print line.rstrip()
+ print '<<<<<=========Log file [%s] ends=========' % log_file
+
+
+def get_all_packages(plan_file=None):
+ if not plan_file:
+ return []
+ if not os.path.exists(plan_file):
+ print "file(%s) does not exist" % plan_file
+ return []
+
+ package_list = []
+ try:
+ dom = xml.dom.minidom.parse(plan_file)
+ test_plan = dom.getElementsByTagName("TestPlan")[0]
+ for entry in test_plan.getElementsByTagName("Entry"):
+ package_list.append(entry.attributes.get('uri').value)
+ except Exception as e:
+ print "Has exception to parse the xml file"
+ print "Exception: %s" % e
+ finally:
+ return package_list
+
+
+def get_value_from_paras(paras=[], option=None, default=None):
+ if not option:
+ return default
+
+ if not option in paras:
+ return default
+
+ index = paras.index(option)
+ if len(paras) > index + 1:
+ return paras[index + 1]
+
+ return default
+
+
+def main():
+
+ package_name = None
+ plan_name = 'CTS'
+ class_name = None
+ method_name = None
+ timeout = 36000
+ #--cts_pkg cts_package_file --package package_name --timeout 36000
+ #--cts_pkg cts_package_file --plan plan_name --timeout 36000
+ if len(sys.argv) > 2:
+ paras = sys.argv[2:]
+ cts_pkg = get_value_from_paras(paras=paras, option='--cts-pkg')
+ if cts_pkg:
+ os.environ["cts_pkg"] = cts_pkg
+
+ java_home = get_value_from_paras(paras=paras, option='--java-home')
+ if java_home:
+ os.environ["PATH"] = java_home + "/bin" + os.pathsep + java_home \
+ + "/jre/bin" + os.pathsep + os.environ["PATH"]
+ os.environ["JAVA_HOME"] = java_home
+
+ package_name = get_value_from_paras(paras=paras, option='--package')
+ plan_name = get_value_from_paras(paras=paras,
+ option='--plan',
+ default='CTS')
+ timeout = get_value_from_paras(paras=paras, option='--timeout',
+ default=36000)
+ if timeout:
+ timeout = int(timeout)
+
+ class_name = get_value_from_paras(paras=paras, option='--class')
+ method_name = get_value_from_paras(paras=paras, option='--method')
+
+ run_wrapper_path = os.path.join('./android-cts/tools/cts-tradefed ')
+ run_wrapper_cmd = "%s" % run_wrapper_path
+ run_wrapper_cmd = '%s run cts --serial %s' % (run_wrapper_cmd,
+ adb.get_serial())
+
+ logs = collect_logs()
+ if not prepare_cts():
+ sys.exit(1)
+
+ try:
+ if package_name:
+ run_cts_with_package(cts_cmd=run_wrapper_cmd, package=package_name,
+ timeout=timeout)
+ elif class_name:
+ run_cts_with_class(cts_cmd=run_wrapper_cmd, cls=class_name,
+ method=method_name, timeout=timeout)
+ else:
+ run_cts_with_plan(cts_cmd=run_wrapper_cmd, plan=plan_name,
+ timeout=timeout)
+
+ finally:
+ for log in logs:
+ pid = log.get('pid')
+ if pid:
+ adb.run_cmd_host('kill -9 %s' % pid)
+
+ push_log(logs)
+
+ sys.exit(0)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/ctshelper.jar b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/ctshelper.jar
new file mode 100644
index 0000000..0c253ae
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/cts/ctshelper.jar
Binary files differ
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/gatortest.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/gatortest.py
new file mode 100644
index 0000000..a04ad6c
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/gatortest.py
@@ -0,0 +1,52 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Ensures the gator daemon required by DS5 is up and running on the Android
+device.
+
+**URL:** https://wiki.linaro.org/Platform/Android/DebugAndroidUsingDS-5
+
+**Default Options:** None
+"""
+
+import os
+
+import lava_android_test.testdef
+
+curdir = os.path.realpath(os.path.dirname(__file__))
+test_name = "gatortest"
+
+RUN_STEPS_HOST_POST = ['python %s/gatortest/daemoncheck.py $(SERIAL)' % curdir,
+ 'python %s/gatortest/modulecheck.py $(SERIAL)' % curdir]
+
+PATTERN = "^\s*(?P<test_case_id>\w+)\s*=\s*(?P<result>\w+)\s*$"
+
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN)
+
+run = lava_android_test.testdef.AndroidTestRunner(
+ steps_host_post=RUN_STEPS_HOST_POST)
+# dummy installer
+inst = lava_android_test.testdef.AndroidTestInstaller()
+
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ runner=run,
+ installer=inst,
+ parser=parser)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/gatortest/daemoncheck.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/gatortest/daemoncheck.py
new file mode 100644
index 0000000..a1fa1b9
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/gatortest/daemoncheck.py
@@ -0,0 +1,20 @@
+import sys
+from commands import getstatusoutput
+
+if len(sys.argv) == 1:
+ adbcmd = 'adb'
+else:
+ adbcmd = 'adb -s %s' % (sys.argv[1])
+
+cmd = '%s shell ps' % (adbcmd)
+rc, output = getstatusoutput(cmd)
+if rc != 0:
+ print 'Failed to run command %s : %s' % (cmd, output)
+ sys.exit(1)
+
+# parse output
+
+if output.find("gator") != -1:
+ print "gator_daemon_check=pass"
+else:
+ print "gator_daemon_check=fail"
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/gatortest/modulecheck.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/gatortest/modulecheck.py
new file mode 100644
index 0000000..23f0ba6
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/gatortest/modulecheck.py
@@ -0,0 +1,20 @@
+import sys
+from commands import getstatusoutput
+
+if len(sys.argv) == 1:
+ adbcmd = 'adb'
+else:
+ adbcmd = 'adb -s %s' % (sys.argv[1])
+
+cmd = '%s shell lsmod' % (adbcmd)
+rc, output = getstatusoutput(cmd)
+if rc != 0:
+ print 'Failed to run command %s : %s' % (cmd, output)
+ sys.exit(1)
+
+# parse output
+
+if output.find("gator") != -1:
+ print "gator_module_check=pass"
+else:
+ print "gator_module_check=fail"
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/glmark2.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/glmark2.py
new file mode 100644
index 0000000..f111c90
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/glmark2.py
@@ -0,0 +1,52 @@
+# Copyright (C) 2010-2012 Linaro Limited
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Executes the glmark2 benchmark.
+
+**URL:** https://launchpad.net/glmark2
+
+**Default Options:** None
+"""
+
+import os
+import lava_android_test.testdef
+from lava_android_test.config import get_config
+
+test_name = 'glmark2'
+config = get_config()
+curdir = os.path.realpath(os.path.dirname(__file__))
+test_sh_name = 'glmark2.sh'
+test_sh_path = os.path.join(curdir, test_name, test_sh_name)
+RUN_STEPS_HOST_PRE = ['/bin/bash %s $(SERIAL)' % test_sh_path]
+
+#I/glmark2 ( 1818): [texture] texture-filter=nearest: FPS: 8 FrameTime: 125.000 ms
+PATTERN = ("^\s*I/glmark2\s*\(.+\):\s+(?P<test_case_id>\[\w+\]\s+\S+)"
+ "\s+FPS:\s+(?P<measurement>\d+)")
+
+inst = lava_android_test.testdef.AndroidTestInstaller()
+run = lava_android_test.testdef.AndroidTestRunner(
+ steps_host_pre=RUN_STEPS_HOST_PRE)
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN,
+ appendall={'units': 'FPS'})
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/glmark2/glmark2.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/glmark2/glmark2.sh
new file mode 100755
index 0000000..2a9b410
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/glmark2/glmark2.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+# Copyright (C) 2012 Linaro Limited
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ADB_CMD="adb"
+prog_dir=`dirname $0`
+
+function main(){
+ if [ "x${1}" != "x" ]; then
+ ADB_CMD="${ADB_CMD} -s ${1}"
+ fi
+ ${ADB_CMD} logcat -c
+ ${ADB_CMD} shell am start -W org.linaro.glmark2/.Glmark2Activity
+ python ${prog_dir}/glmark2_wait.py ${1}
+ #${ADB_CMD} logcat -d glmark2:I *:S
+ ${ADB_CMD} logcat -d
+}
+
+main "$@"
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/glmark2/glmark2_wait.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/glmark2/glmark2_wait.py
new file mode 100755
index 0000000..5c680ce
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/glmark2/glmark2_wait.py
@@ -0,0 +1,51 @@
+#!/usr/bin/python
+
+# Copyright (C) 2012 Linaro Limited
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import pexpect
+import sys
+import time
+
+if len(sys.argv) == 1:
+ adb_cmd = "adb"
+else:
+ adb_cmd = "adb -s %s" % (sys.argv[1])
+
+logcat_cmd = '%s logcat -v time' % (adb_cmd)
+pattern1 = "glmark2 Score:"
+#pattern1 = "\[loop\] fragment-steps=5:fragment-uniform=true:
+#vertex-steps=5: FPS:"
+pattern2 = "Process org.linaro.glmark2.+has died"
+pattern3 = ("No suitable EGLConfig for GLES2.0 found."
+ " Please check that proper GLES2.0 drivers are installed.")
+
+try:
+ proc = pexpect.spawn(logcat_cmd, logfile=sys.stdout)
+ match_id = proc.expect([pattern1, pattern2, pattern3, pexpect.EOF],
+ timeout=1000)
+ print "in glmark2_wait.py match_id = %s\n" % match_id
+ if (match_id == 0) or (match_id == 1) or (match_id == 2):
+ proc.sendcontrol('C')
+except pexpect.TIMEOUT:
+ print "glmark2 Test: TIMEOUT Fail\n"
+ sys.exit(1)
+finally:
+ proc.sendcontrol('C')
+
+time.sleep(3)
+sys.exit(0)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/helloworld.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/helloworld.py
new file mode 100644
index 0000000..40ad04e
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/helloworld.py
@@ -0,0 +1,46 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Example for how to add test wrapper for lava-android-test
+
+**URL:** None
+
+**Default options:** None
+"""
+
+import lava_android_test.config
+import lava_android_test.testdef
+
+test_name = 'helloworld'
+
+INSTALL_STEPS_ADB_PRE = []
+ADB_SHELL_STEPS = ['echo helloworld: PASS']
+PATTERN = "^\s*(?P<test_case_id>[^:]+?):\s+(?P<result>(PASS|FAIL)?)\s*$"
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN)
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/__init__.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/__init__.py
new file mode 100644
index 0000000..dcb0716
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/__init__.py
@@ -0,0 +1,31 @@
+# copyright (C) 2012 Linaro Limited
+#
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+This directory contains the tests that only need to run a host command.
+Please see the example.sh for a reference.
+Please note this is not a test that can be run.
+
+**URL:** None
+
+**Default options:** None
+"""
+
+import os
+curdir = os.path.dirname(os.path.realpath(__file__))
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/connect-lab-wifi.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/connect-lab-wifi.sh
new file mode 100755
index 0000000..d04233d
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/connect-lab-wifi.sh
@@ -0,0 +1,170 @@
+#!/bin/bash
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+function generate_wpa_conf(){
+ conf=$1 && ssid=$2 passwd=$3
+ if [ -z "${conf}" ];then
+ return
+ fi
+
+ if [ -z "${ssid}" ]; then
+ cat >wpa_supplicant.conf <<__EOF__
+ctrl_interface=wlan0
+update_config=1
+device_type=0-00000000-0
+
+__EOF__
+
+ elif [ -z "${passwd}" ]; then
+ cat >wpa_supplicant.conf <<__EOF__
+ctrl_interface=wlan0
+update_config=1
+device_type=0-00000000-0
+
+network={
+ ssid="${ssid}"
+ key_mgmt=NONE
+ priority=2
+}
+
+__EOF__
+
+ else
+ cat >wpa_supplicant.conf <<__EOF__
+ctrl_interface=wlan0
+update_config=1
+device_type=0-00000000-0
+
+network={
+ ssid="${ssid}"
+ psk="${passwd}"
+ key_mgmt=WPA-PSK
+ priority=2
+}
+
+__EOF__
+
+ fi
+}
+
+function enable_wifi(){
+ conf=$1 && ssid=$2 && serial=$3
+ if [ -z "${conf}" ]; then
+ return
+ fi
+ ADB_OPTION=""
+ if [ -n "${serial}" ]; then
+ ADB_OPTION="-s ${serial}"
+ fi
+
+ adb ${ADB_OPTION} shell am start -a android.intent.action.MAIN -n com.android.settings/.Settings
+ sleep 3
+ adb ${ADB_OPTION} shell service call wifi 13 i32 0
+ sleep 5
+ adb ${ADB_OPTION} push "${conf}" /data/misc/wifi/wpa_supplicant.conf
+ adb ${ADB_OPTION} shell chown wifi.wifi /data/misc/wifi/wpa_supplicant.conf
+ adb ${ADB_OPTION} shell chmod 660 /data/misc/wifi/wpa_supplicant.conf
+ adb ${ADB_OPTION} shell ls -l /data/misc/wifi/wpa_supplicant.conf
+ adb ${ADB_OPTION} shell service call wifi 13 i32 1
+ #extend the wait time because the time to turn wifi on some devices(like
+ #Origen) will take a little longer
+ sleep 60
+ for i in {1..30}; do
+ adb ${ADB_OPTION} shell wpa_cli list_networks|grep -E "^\s*[[:digit:]]+\s+${ssid}\s+any\s+\[CURRENT\]"
+ if [ $? -eq 0 ];then
+ break
+ fi
+ sleep 5
+ done
+
+ if [ $i -eq 30 ]; then
+ echo "connect-lava-wifi-${ssid}=fail"
+ return 1
+ else
+ echo "connect-lava-wifi-${ssid}=pass"
+ return 0
+ fi
+}
+
+function parse_argv() {
+ # Parse command line arguments
+ # Sets: VERBOSE, dev
+ while test -n "$1"; do
+ case "$1" in
+ --serial|-s)
+ SERIAL="$2"
+ shift 2
+ ;;
+ --passwd|-p)
+ PASSWD="$2"
+ shift 2
+ ;;
+ *)
+ if [ -n "${SSID}" ]; then
+ show_usage
+ exit 1
+ else
+ SSID="$1"
+ shift
+ fi
+ ;;
+ esac
+ done
+}
+
+function show_usage(){
+ # Display the usage line
+ echo "Usage 1, Specify the ssid and pawword via command line:"
+ echo " $0 [--passwd|-p passwd] [--serial|-s serial] ssid"
+ echo "Usage 2, Specify the ssid and pawword via configuration file:"
+ echo " Specify the file path via 'WIFI_DEV_CONF' environment variable,"
+ echo " /etc/lava/devices/wifi.conf is the default value if not specified"
+ echo " The content of this file like this:"
+ echo " SSID=the ssid of wifi"
+ echo " PASSWD=the password of the specified wifi via SSID"
+}
+
+function main(){
+ if [ -z "${WIFI_DEV_CONF}" ]; then
+ wifi_dev_conf="/etc/lava/devices/wifi.conf"
+ else
+ wifi_dev_conf="${WIFI_DEV_CONF}"
+ fi
+
+ echo "Will use ${wifi_dev_conf} as the configuration file for wifi if exists"
+ if [ -f "${wifi_dev_conf}" ]; then
+ . "${wifi_dev_conf}"
+ fi
+ parse_argv "$@"
+
+ if [ -z "${SSID}" ]; then
+ show_usage
+ exit 1
+ fi
+
+ wifi_conf="wpa_supplicant.conf"
+ generate_wpa_conf "${wifi_conf}" "${SSID}" "${PASSWD}"
+ enable_wifi "${wifi_conf}" "${SSID}" "${SERIAL}"
+ RET=$?
+ rm -f "${wifi_conf}"
+ exit $RET
+}
+
+main "$@"
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/example.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/example.sh
new file mode 100755
index 0000000..50c81b7
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/example.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+function parse_argv() {
+ # Parse command line arguments
+ while test -n "$1"; do
+ case "$1" in
+ --serial|-s)
+ SERIAL="$2"
+ if [ -n "${SERIAL}" ]; then
+ shift 2
+ else
+ show_usage
+ exit 1
+ fi
+ ;;
+ --help|-h)
+ show_usage
+ exit 1
+ ;;
+ *)
+ if [ -n "${OPTIONS}" ]; then
+ OPTIONS="${OPTIONS} $1"
+ else
+ OPTIONS="$1"
+ fi
+ shift
+ ;;
+ esac
+ done
+}
+
+function show_usage(){
+ # Display the usage line
+ echo "Usage $(basename $0) [--serial <serial>|-s <serial>] <other-option>"
+ echo "Usage $(basename $0) [--help|-h]"
+}
+
+function main(){
+ parse_argv "$@"
+ echo "hostshells-example-fail=fail"
+ echo "hostshells-example-pass=pass"
+}
+
+main "$@"
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/install-overlay.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/install-overlay.sh
new file mode 100755
index 0000000..996bcbb
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/install-overlay.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+function parse_argv() {
+ # Parse command line arguments
+ while test -n "$1"; do
+ case "$1" in
+ --serial|-s)
+ SERIAL="$2"
+ if [ -n "${SERIAL}" ]; then
+ shift 2
+ else
+ show_usage
+ exit 1
+ fi
+ ;;
+ --url|-u)
+ URL="$2"
+ if [ -n "${URL}" ]; then
+ shift 2
+ else
+ show_usage
+ exit 1
+ fi
+ ;;
+ --help|-h)
+ show_usage
+ exit 1
+ ;;
+ *)
+ if [ -n "${OPTIONS}" ]; then
+ OPTIONS="${OPTIONS} $1"
+ else
+ OPTIONS="$1"
+ fi
+ shift
+ ;;
+ esac
+ done
+}
+
+function show_usage(){
+ # Display the usage line
+ echo "Usage $(basename $0) [--serial <serial>|-s <serial>] <other-option>"
+ echo "Usage $(basename $0) [--help|-h]"
+}
+
+function main(){
+ parse_argv "$@"
+ # Fetch the overlay and extract it.
+ wget $URL overlay.tar.bz2
+ tar -xvf overlay.tar.bz2
+
+ # Push the overlay
+ adb -s ${SERIAL} remount
+ adb -s ${SERIAL} push overlay/ /
+ adb -s ${SERIAL} shell sync
+ adb -s ${SERIAL} shell stop
+ adb -s ${SERIAL} shell start
+}
+
+main "$@"
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/sdcard-mounted.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/sdcard-mounted.sh
new file mode 100755
index 0000000..4257850
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/sdcard-mounted.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+function parse_argv() {
+ # Parse command line arguments
+ while test -n "$1"; do
+ case "$1" in
+ --serial|-s)
+ SERIAL="$2"
+ if [ -n "${SERIAL}" ]; then
+ shift 2
+ else
+ show_usage
+ exit 1
+ fi
+ ;;
+ --help|-h)
+ show_usage
+ exit 1
+ ;;
+ *)
+ shift
+ ;;
+ esac
+ done
+}
+
+function show_usage(){
+ # Display the usage line
+ echo "Usage $(basename $0) [--serial <serial>|-s <serial>]"
+ echo "Usage $(basename $0) [--help|-h]"
+}
+
+function main(){
+ parse_argv "$@"
+ ADB_OPTION=''
+ if [ -n "${SERIAL}" ]; then
+ ADB_OPTION="-s ${SERIAL}"
+ fi
+ adb ${ADB_OPTION} shell mount |grep -e '/sdcard' -e 'emulated'
+ if [ $? -eq 0 ]; then
+ echo "sdcard-mounted=pass"
+ else
+ echo "sdcard-mounted=fail"
+ fi
+}
+
+main "$@"
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/workload.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/workload.sh
new file mode 100755
index 0000000..a01a4a1
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/hostshells/workload.sh
@@ -0,0 +1,146 @@
+#!/bin/bash
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+function parse_argv() {
+ # Parse command line arguments
+ while test -n "$1"; do
+ case "$1" in
+ --serial|-s)
+ SERIAL="$2"
+ if [ -n "${SERIAL}" ]; then
+ shift 2
+ else
+ show_usage
+ exit 1
+ fi
+ ;;
+ --config|-c)
+ CONFIG="$2"
+ if [ -n "${CONFIG}" ]; then
+ shift 2
+ else
+ show_usage
+ exit 1
+ fi
+ ;;
+ --git|-g)
+ GIT_URL="$2"
+ if [ -n "${GIT_URL}" ]; then
+ shift 2
+ else
+ show_usage
+ exit 1
+ fi
+ ;;
+ --help|-h)
+ show_usage
+ exit 1
+ ;;
+ *)
+ if [ -n "${OPTIONS}" ]; then
+ OPTIONS="${OPTIONS} $1"
+ else
+ OPTIONS="$1"
+ fi
+ shift
+ ;;
+ esac
+ done
+}
+
+function show_usage(){
+ # Display the usage line
+ echo "Usage $(basename $0) [--serial|-s <serial>] [--config|-c <config_file>] [--git|g <git-url>] <other-option>"
+ echo "Usage $(basename $0) [--help|-h]"
+}
+
+function parse_output_result(){
+ result_f=${1}
+ if [ ! -f "${1}" ]; then
+ echo "There is no result file output/results.csv"
+ return
+ fi
+
+ file_tmp=${result_f}.tmp
+ sed 's/ /_/g' ${result_f} > ${file_tmp}
+ keys=`head -n 1 ${file_tmp}`
+ values=`tail -n 1 ${file_tmp}`
+ for ((i=1; i<21; i++)); do
+ key=`echo ${keys}|cut -d , -f ${i}|sed 's/\r//'`
+ value=`echo ${values}|cut -d , -f ${i}|sed 's/\r//'`
+
+ echo ${value}|grep -P '^[.\d]+$' &>/dev/null
+ if [ $? -ne 0 ]; then
+ key="${key}_${value}"
+ value="true"
+ fi
+ echo ${key}=${value}
+ done
+ rm -f ${file_tmp}
+}
+
+function main(){
+ local_git="file:///home/bhoj/workload-automation.git"
+ branch="lava"
+ outputdir="outputdir"
+ result="${outputdir}/result.csv"
+
+ parse_argv "$@"
+
+ config_file="config.csv"
+ if [ -n "${CONFIG}" ]; then
+ config_file="${CONFIG}"
+ fi
+
+ if [ -n "${GIT_URL}" ]; then
+ git_url="${GIT_URL}"
+ else
+ git_url="${local_git}"
+ fi
+
+ git clone "${git_url}" -b ${branch}
+ if [ $? -ne 0 ]; then
+ echo "Failed to clone git repository: ${git_url}"
+ exit 1
+ fi
+ ip=`echo ${SERIAL}|sed 's/:5555//'`
+ cd "workload-automation"
+
+ #update the ip address and patch config.csv file
+ sed -i "s/192.168.1.38/${ip}/g" workload_config.py
+
+ python workload_setup_dependencies.py
+ if [ $? -ne 0 ]; then
+ echo "Failed to run workload_setup_dependencies.py"
+ exit 1
+ fi
+
+ rm -fr ${outputdir}
+ python workload.py ${config_file} ${outputdir}/
+ if [ $? -ne 0 ]; then
+ echo "Failed to run workload.py config.csv outputdir/"
+ exit 1
+ fi
+ cat ${result}
+ parse_output_result ${result}
+}
+
+main "$@"
+
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/ime.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/ime.py
new file mode 100644
index 0000000..aacaef6
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/ime.py
@@ -0,0 +1,57 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Performs testing of Android Input Method Manager by listing the available
+input methods on the system.
+
+**URL:** http://android.git.linaro.org/gitweb?p=platform/frameworks/base.git;a=blob;f=cmds/ime/src/com/android/commands/ime/Ime.java
+
+**Default options:** None
+"""
+
+import os
+import lava_android_test.testdef
+from lava_android_test.config import get_config
+
+test_name = 'ime'
+config = get_config()
+curdir = os.path.realpath(os.path.dirname(__file__))
+test_sh_name = 'ime_test.sh'
+test_sh_path = os.path.join(curdir, test_name, test_sh_name)
+test_sh_android_path = os.path.join(config.installdir_android,
+ test_name, test_sh_name)
+
+INSTALL_STEPS_ADB_PRE = ['push %s %s ' % (test_sh_path,
+ test_sh_android_path),
+ 'shell chmod 777 %s' % test_sh_android_path]
+
+ADB_SHELL_STEPS = [test_sh_android_path]
+PATTERN = "^\s*(?P<test_case_id>ime)=(?P<result>\w+)\s*$"
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN)
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/ime/ime_test.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/ime/ime_test.sh
new file mode 100755
index 0000000..6a6d7a1
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/ime/ime_test.sh
@@ -0,0 +1,13 @@
+#!/system/bin/sh
+
+test_func(){
+ if [ ! -f /system/bin/ime ]; then
+ echo "ime=fail"
+ exit
+ fi
+
+ /system/bin/ime list -a
+ echo "ime=pass"
+}
+
+test_func
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/install_prep_4bench.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/install_prep_4bench.py
new file mode 100644
index 0000000..2687adc
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/install_prep_4bench.py
@@ -0,0 +1,46 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Remove the Linaro wallpaper before start the benchmark test
+
+**URL:** None
+
+**Default options:** None
+"""
+import lava_android_test.config
+import lava_android_test.testdef
+
+test_name = 'install_prep_4bench'
+
+INSTALL_STEPS_ADB_PRE = []
+ADB_SHELL_STEPS = ['rm /data/system/wallpaper_info.xml',
+ "echo install_prep_4bench.wallpaper: PASS"]
+PATTERN = "^\s*(?P<test_case_id>[^:]+?):\s+(?P<result>(PASS|FAIL)?)\s*$"
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN)
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/instruments/__init__.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/instruments/__init__.py
new file mode 100644
index 0000000..43e06ba
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/instruments/__init__.py
@@ -0,0 +1,28 @@
+# copyright (C) 2012 Linaro Limited
+#
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+This directory contains the tests that only need to run the "am instrument -w"
+command on android. Please see the example.py for a reference.
+Please note this is not a test that can be run.
+
+**URL:** None
+
+**Default options:** None
+"""
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/instruments/example.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/instruments/example.py
new file mode 100644
index 0000000..b5c73d0
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/instruments/example.py
@@ -0,0 +1,32 @@
+# copyright (C) 2012 Linaro Limited
+#
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Example for how to add instrument tests into lava-android-test.
+You can try this test with the android emulator which has this test integrated.
+
+**URL:** http://android.git.linaro.org/gitweb?p=platform/development.git;a=blob;f=tools/emulator/test-apps/ConnectivityTest/src/com/android/emulator/connectivity/test/ConnectivityTest.java
+
+**Default options:** None
+"""
+
+cmd = ("am instrument -r -w "
+ "com.android.emulator.connectivity.test/"
+ "android.test.InstrumentationTestRunner")
+RUN_ADB_SHELL_STEPS = [cmd]
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/iozone.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/iozone.py
new file mode 100644
index 0000000..ab9a0b2
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/iozone.py
@@ -0,0 +1,118 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Perform the iozone test on the target device
+
+**URL:** http://android.git.linaro.org/gitweb?p=platform/external/iozone.git;a=summary
+
+**Default options:** None
+"""
+from lava_android_test.config import get_config
+import lava_android_test.testdef
+import os
+import re
+
+
+class IozoneParser(lava_android_test.testdef.AndroidTestParser):
+ '''Custom parser for Iozone. -b with a results file must be specified.
+ The results file is not parsed. However the addition of this parameter
+ causes an organized results report to be printed at the bottom
+ '''
+ #used to find each report
+ PATTERN_REPORT = '(?P<report_name>.*?)report'
+ #used to determined output units
+ PATTERN_UNITS = 'Output is in (?P<units>\S*)'
+
+ def real_parse(self, result_filename='stdout.log',
+ output_filename='stdout.log',
+ test_name=''):
+ '''Parse the results of stdout.
+ This requires the -b option be specified to IOZONE.
+ '''
+ #filename = artifacts.stdout_pathname
+ pat_report = re.compile(self.PATTERN_REPORT)
+ pat_units = re.compile(self.PATTERN_UNITS)
+ units = ''
+ with open(output_filename, 'r') as fd:
+ lines = fd.readlines()
+ for i in range(0, len(lines)):
+ line = lines[i]
+ match_report = pat_report.search(line)
+ match_units = pat_units.search(line)
+ #found report.
+ if match_report:
+ ''' The results are the following format
+ <report name> report
+ reclen 1
+ block_size results 1
+ '''
+ report_name = match_report.groupdict()['report_name'
+ ].replace("\"", "")
+ i += 1
+ rclen_line = lines[i].replace("\"", "")
+ i += 1
+ results_line = lines[i].replace("\"", "")
+ reclen_split = rclen_line.split()
+ results_split = results_line.split()
+ #first value is the block size
+ size = results_split[0]
+ for n in range(0, len(reclen_split)):
+ results = {'test_case_id':
+ "iozone_%sKB_%s_rclen_%s" % (report_name,
+ str(size),
+ str(reclen_split[n])),
+ 'result': 'pass',
+ 'measurement': int(results_split[n + 1]),
+ 'units': units}
+ self.results['test_results'].append(results)
+ elif match_units:
+ units = match_units.groupdict()['units']
+
+
+test_name = 'iozone'
+
+config = get_config()
+curdir = os.path.realpath(os.path.dirname(__file__))
+iozone_sh_name = 'iozone.sh'
+iozone_dir_path = os.path.join(curdir, 'iozone')
+#copy the whole directory over
+#this will alow users to place the crosscompiled izone binary
+#in the folder and modify iozone.sh to remount the root fs.
+iozone_dir_android_path = os.path.join(config.installdir_android,
+ test_name)
+iozone_sh_android_path = os.path.join(iozone_dir_android_path,
+ iozone_sh_name)
+
+INSTALL_STEPS_ADB_PRE = ['push %s %s ' % (iozone_dir_path,
+ iozone_dir_android_path),
+ 'shell chmod -R 777 %s' % iozone_dir_android_path]
+
+ADB_SHELL_STEPS = ["%s %s" % (iozone_sh_android_path, iozone_dir_android_path)]
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = IozoneParser()
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/memtester.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/memtester.py
new file mode 100644
index 0000000..2ddad92
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/memtester.py
@@ -0,0 +1,45 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Perform the memtester test on the target device.
+memtester is a utility for testing the memory subsystem in a computer to determine if it is faulty.
+
+**URL:** http://android.git.linaro.org/gitweb?p=platform/external/memtester.git;a=summary
+
+**Default options:** None
+"""
+import lava_android_test.testdef
+
+test_name = 'memtester'
+
+INSTALL_STEPS_ADB_PRE = []
+ADB_SHELL_STEPS = ['memtester 1M 1']
+PATTERN = "^\s*(?P<test_case_id>.*?)\s*:\s*(?P<result>\w+)\s*$"
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN)
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/methanol.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/methanol.py
new file mode 100644
index 0000000..5785317
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/methanol.py
@@ -0,0 +1,65 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+The Methanol is a page load benchmarking engine.
+The benchmark engine measures the overall page layouting and rendering time of the browser.
+The methanol now includs test for css/canvas/smp/svg test
+
+**URL:** https://github.com/szeged/methanol.git
+
+**Default options:** None
+"""
+
+import os
+import json
+
+import lava_android_test.testdef
+
+from lava_android_test.config import get_config
+
+curdir = os.path.realpath(os.path.dirname(__file__))
+config = get_config()
+
+result_dir = config.resultsdir_android
+RUN_STEPS_HOST_PRE = ["bash %s/methanol/methanol.sh $(SERIAL) $(OPTIONS)" % curdir]
+
+class MethanolTestParser(lava_android_test.testdef.AndroidTestParser):
+
+ def real_parse(self, result_filename=None, output_filename='methanol_result.json',
+ test_name=''):
+ """Parse test output to gather results
+ Use the pattern specified when the class was instantiated to look
+ through the results line-by-line and find lines that match it.
+ Results are then stored in self.results. If a fixupdict was supplied
+ it is used to convert test result strings to a standard format.
+ """
+ with open(output_filename) as stream:
+ test_results_data = stream.read()
+ test_results_json = json.loads(test_results_data)
+ self.results['test_results'] = test_results_json
+
+
+inst = lava_android_test.testdef.AndroidTestInstaller()
+run = lava_android_test.testdef.AndroidTestRunner(steps_host_pre=RUN_STEPS_HOST_PRE)
+parser = MethanolTestParser()
+testobj = lava_android_test.testdef.AndroidTest(testname="methanol",
+ installer=inst, runner=run, parser=parser,
+ org_ouput_file='/data/local/tmp/methanol/methanol_result.json')
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/methanol/methanol.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/methanol/methanol.sh
new file mode 100755
index 0000000..81e2598
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/methanol/methanol.sh
@@ -0,0 +1,327 @@
+#!/bin/bash
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#the default ip or domain used by the client to access the server
+DEFAULT_DOMAIN_IP=`ifconfig | awk -F':' '/inet addr/&&!/127.0.0.1/{split($2,_," ");print _[1]}'`
+DEFAULT_BROWSER='DEFAULT'
+
+########################################################
+###### NOT MODIFY SOURCE OF BELOW #####
+########################################################
+THIS_FILE="$0"
+methanol_git="git://github.com/szeged/methanol.git"
+chrome_apk_url="http://testdata.validation.linaro.org/chrome/Chrome-latest.apk"
+server_settings_file="/etc/lava/web_server/settings.conf"
+result_dir_android="/data/local/tmp/methanol"
+declare -a RESULTS=();
+methanol_url="/"
+report_url="/cgi/save_methanol_data.py"
+report_res_dir="/tmp/methanol"
+target_dir=""
+server_pid=""
+
+ADB_OPTION=""
+domain_ip="${DEFAULT_DOMAIN_IP}"
+browser="${DEFAULT_BROWSER}"
+test_target=""
+
+function parse_arg(){
+ serial=""
+ while test -n "$1"; do
+ case "$1" in
+ --browser|-b)
+ if [ "x$2" = "x" ]; then
+ echo "Error: $1 requires an argument which should be DEFAULT or CHROME"
+ exit 1
+ fi
+ browser="$2"
+ if [ "X${browser}" != "XDEFAULT" ] && [ "X${browser}" != "XCHROME" ]; then
+ echo "Error: $1 requires an argument which should be DEFAULT or CHROME"
+ exit 1
+ fi
+ shift 2
+ ;;
+ --domain|-d)
+ if [ "x$2" = "x" ]; then
+ echo "Error: $1 requires an argument"
+ exit 1
+ fi
+ domain_ip="$2"
+ shift 2
+ ;;
+ --target|-t)
+ if [ "x$2" = "x" ]; then
+ echo "Error: $1 requires an argument"
+ exit 1
+ fi
+ test_target="$2"
+ shift 2
+ ;;
+ --help|-h)
+ show_usage
+ exit 0
+ ;;
+ *)
+ if [ -n "${serial}" ]; then
+ show_usage
+ echo "Too many arguments, see --help for details"
+ exit 1
+ else
+ serial="$1"
+ shift
+ fi
+ ;;
+ esac
+ done
+
+ if [ -n "${serial}" ]; then
+ ADB_OPTION="-s ${serial}"
+ fi
+}
+
+function show_usage(){
+ echo "`basename ${THIS_FILE}` [serial_no] [-b DEFAULT|CHROME] [-d domain_ip]"
+}
+
+function patch_sources(){
+ src_root_dir=${1}
+ if [ -z ${src_root_dir} ]; then
+ return
+ fi
+
+ if [ \! -d ${src_root_dir} ]; then
+ return
+ fi
+
+ ## The following test case cannot be on android browser, so comment them out
+ ## Patch the engine.js
+ sed -i "s% + results;% + results.replace\(new RegExp('/','gm'), '_'\);%" ${src_root_dir}/engine.js
+
+ ##Patch svg.js
+ sed -i s%\"svg/anim/earth.svg\",%\"svg/anim/earth.svg\"/*,% ${src_root_dir}/svg.js
+ sed -i s%\"svg/anim/svg.svg\"%\"svg/anim/svg.svg\"*/% ${src_root_dir}/svg.js
+
+ ##Patch smp.js
+ sed -i s%\"smp/3d-terrain-demo/single/index.html\",%//\"smp/3d-terrain-demo/single/index.html\",% ${src_root_dir}/smp.js
+ sed -i s%\"smp/3d-terrain-demo/worker/index.html\",%//\"smp/3d-terrain-demo/worker/index.html\",% ${src_root_dir}/smp.js
+ sed -i s%\"smp/fire-on-water/worker/index.html\",%//\"smp/fire-on-water/worker/index.html\",% ${src_root_dir}/smp.js
+}
+
+function deploy(){
+
+ if [ "${browser}" = "CHROME" ]; then
+ echo "wget --progress=dot -e dotbytes=1M -np -l 10 --no-check-certificate ${chrome_apk_url} -O ./Chrome-latest.apk"
+ wget --progress=dot -e dotbytes=1M -np -l 10 --no-check-certificate ${chrome_apk_url} -O ./Chrome-latest.apk
+ if [ $? -ne 0 ]; then
+ echo "Failed to download the chrome apk file from ${chrome_apk_url}."
+ cleanup
+ exit 1
+ fi
+
+ adb ${ADB_OPTION} uninstall com.android.chrome
+
+ echo "adb ${ADB_OPTION} install ./Chrome-latest.apk"
+ adb ${ADB_OPTION} install ./Chrome-latest.apk
+ if [ $? -ne 0 ]; then
+ echo "Failed to install the Chrome browser application."
+ cleanup
+ rm -f ./Chrome-latest.apk
+ exit 1
+ fi
+ rm -f ./Chrome-latest.apk
+ adb ${ADB_OPTION} shell am start com.android.chrome/com.google.android.apps.chrome.Main
+ sleep 10
+ f_preferences='/data/data/com.android.chrome/shared_prefs/com.android.chrome_preferences.xml'
+ f_preferences_base=`basename ${f_preferences}`
+ owner_grp=`adb ${ADB_OPTION} shell ls -l ${f_preferences}|cut -d \ -f2`
+ if [ -z "${owner_grp}" ]; then
+ echo "Failed to get the user/group infromation of chrome preferences file."
+ cleanup
+ rm -f ./Chrome-latest.apk
+ exit 1
+ fi
+ adb ${ADB_OPTION} pull ${f_preferences} ./${f_preferences_base}
+ sed -i '/<map>/ a\<boolean name="first_run_flow" value="true" />' ./${f_preferences_base}
+ adb ${ADB_OPTION} push ./${f_preferences_base} ${f_preferences}
+ adb ${ADB_OPTION} shell chown ${owner_grp}:${owner_grp} ${f_preferences}
+ chrome_pid=`adb ${ADB_OPTION} shell ps |grep -P 'chrome\s*$'|tr -s ' '|cut -d \ -f2`
+ if [ -n "${chrome_pid}" ]; then
+ adb ${ADB_OPTION} shell kill ${chrome_pid}
+ fi
+ rm -f ./${f_preferences_base}
+ fi
+
+ cur_path=`pwd`
+ target_dir=`mktemp -u --tmpdir=${cur_path} methanol-XXX`
+ git clone "${methanol_git}" "${target_dir}"
+ if [ $? -ne 0 ];then
+ echo "Failed to clone the methanol source from ${methanol_git}"
+ cleanup
+ exit 1
+ fi
+
+ #patch just because some test can not be run on android
+ patch_sources "${target_dir}"
+
+ url_file=`mktemp -u --tmpdir=${cur_path} url-XXX`
+ nohup python `dirname $0`/start_server.py "${domain_ip}" "${target_dir}" "${url_file}" &>server.log &
+ server_pid=$!
+ sleep 5
+ domain_protocol=`cat ${url_file}`
+ if [ -z "${domain_protocol}" ]; then
+ echo "Cannot get the url of the temporary created server."
+ echo "Failed to deploy the temporary server"
+ cleanup
+ exit 1
+ fi
+}
+
+function check_url(){
+ if [ -n "${report_url}" ]; then
+ wget -q "${domain_protocol}/${report_url}" -O /dev/null
+ if [ $? -ne 0 ]; then
+ echo "The report url(${domain_protocol}/${report_url}) cannot be accessed"
+ echo "Please put the save_methanol_data.py to the cgi-bin directory"
+ echo "of your web server, and make sure it is accessible."
+ cleanup
+ exit 1
+ fi
+ fi
+
+ if [ -n "${methanol_url}" ]; then
+ wget -q "${domain_protocol}/${methanol_url}" -O /dev/null
+ if [ $? -ne 0 ]; then
+ echo "The url(${domain_protocol}/${methanol_url}) cannot be accessed"
+ echo "Please clone the methanol directory to local via following command"
+ echo " git clone ${methanol_git}"
+ echo "and copy the entire directory to some place of your web server"
+ echo "and make sure it is accessible."
+ cleanup
+ exit 1
+ fi
+ else
+ echo "Please speecify the methanol url that will be used for test."
+ cleanup
+ exit 1
+ fi
+}
+
+function wait_result(){
+ if [ -n "$1" ]; then
+ file_path="$1"
+ else
+ return 0
+ fi
+
+ for (( i=1; ; i++ )); do
+ sleep 300
+ if [ -f "${file_path}" ]; then
+ return 0
+ fi
+ done
+ return 1
+}
+
+function test_methanol(){
+ if [ -n "$1" ]; then
+ test_type="-${1}"
+ else
+ test_type=""
+ fi
+
+ result_file=`mktemp -u --tmpdir=${report_res_dir} fire${test_type}-XXX.json`
+ res_basename=`basename ${result_file}`
+ test_url="${domain_protocol}/${methanol_url}/fire${test_type}.html"
+ if [ -n "${report_url}" ]; then
+ test_url="${test_url}?reportToUrl=${report_url}%3Fsave2file=${res_basename}"
+ fi
+
+ component_default="com.android.browser/com.android.browser.BrowserActivity"
+ component_chrome=" com.android.chrome/com.google.android.apps.chrome.Main"
+ if [ "${browser}" = "CHROME" ]; then
+ component=${component_chrome}
+ else
+ component=${component_default}
+ fi
+ echo "adb ${ADB_OPTION} shell am start -a android.intent.action.VIEW -d ${test_url} -n ${component}"
+ adb ${ADB_OPTION} shell "am start -a android.intent.action.VIEW -d ${test_url} -n ${component}"
+ wait_result "${result_file}"
+ if [ $? -eq 0 ]; then
+ cur_path=`pwd`
+ cp -uvf ${result_file} ${cur_path}/${res_basename}
+ echo "result_file=${cur_path}/${res_basename}"
+ RESULTS[${#RESULTS[@]}]="${cur_path}/${res_basename}"
+
+ rm -f ${result_file}
+ else
+ echo "Failed to get the test result of fire${test_type}.html"
+ #cleanup
+ #exit 1
+ fi
+}
+
+function cleanup(){
+ echo "DO CLEAN UP"
+ rm -fr methanol_result.json "${RESULTS[@]}"
+ if [ -n "${server_pid}" ]; then
+ kill -9 ${server_pid}
+ fi
+ if [ -n "${target_dir}" ]; then
+ rm -fr "${target_dir}"
+ fi
+ if [ "${browser}" = "CHROME" ]; then
+ adb ${ADB_OPTION} uninstall com.android.chrome
+ fi
+}
+
+function main(){
+ parse_arg "$@"
+
+ ## delete the test result for last time
+ adb ${ADB_OPTION} shell rm "${result_dir_android}/methanol_result.json"
+
+ trap cleanup EXIT
+
+ deploy
+
+ check_url
+
+ page_suffix='${test_target}'
+ if [ -n "${page_suffix}" ]; then
+ page_suffix="-${test_target}"
+ fi
+ echo `date`: starts to test fire${page_suffix}.html
+ test_methanol "${test_target}"
+ echo `date`: all tests completed
+
+ echo "Merge results of file: ${RESULTS[@]}"
+ `dirname $0`/methanol_merge_results.py methanol_result.json "${RESULTS[@]}"
+ if [ $? -eq 0 ]; then
+ adb ${ADB_OPTION} shell mkdir ${result_dir_android}
+ adb ${ADB_OPTION} push methanol_result.json "${result_dir_android}/methanol_result.json"
+ for f in "${RESULTS[@]}"; do
+ adb ${ADB_OPTION} push "${f}" "${result_dir_android}"
+ done
+ echo "The result is also push to android: ${result_dir_android}/${res_basename}"
+ else
+ echo "Failed to merge the results"
+ fi
+}
+main "$@"
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/methanol/methanol_merge_results.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/methanol/methanol_merge_results.py
new file mode 100755
index 0000000..a57c602
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/methanol/methanol_merge_results.py
@@ -0,0 +1,86 @@
+#!/usr/bin/python
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import re
+import string
+import sys
+
+import simplejson as json
+
+if len(sys.argv) < 3:
+ basename = os.path.basename(sys.argv[0])
+ print 'Please specified the merge target file and source files like:'
+ print '\t %s target-result-file source-file1 source-file2 ...'
+ sys.exit(1)
+
+target_file = sys.argv[1]
+test_results = []
+for f in sys.argv[2:]:
+ if not os.path.exists(f):
+ print "The file(%s) does not exist" % f
+ continue
+
+ with open(f) as stream:
+ f_basename = os.path.basename(f)
+ last_hyphen_index = string.rfind(f_basename, '-')
+ if last_hyphen_index != -1:
+ file_id = f_basename[:last_hyphen_index]
+ else:
+ file_id = ''
+
+ jobdata = stream.read()
+ results_data = json.loads(jobdata)
+ for res in results_data:
+ test_case_id = res.get('test_case_id')
+ average = res.get('average')
+ avg_dev = res.get('average_deviate')
+ units = res.get('units')
+ if file_id and test_case_id == 'summary':
+ test_case_id = '%s-summary' % file_id
+ test_case_id = test_case_id.replace('/', '_')
+ badchars = "[^a-zA-Z0-9\._-]"
+ test_case_id = re.sub(badchars, "", test_case_id.replace(" ", "_"))
+ if not units:
+ units = 'ms'
+ test_results.append({'test_case_id': '%s_avg' % test_case_id,
+ 'result': 'pass',
+ 'measurement': average,
+ 'units': units})
+ if avg_dev:
+ test_results.append({
+ 'test_case_id': '%s_avg_dev' % test_case_id,
+ 'result': 'pass',
+ 'measurement': avg_dev,
+ 'units': '%'})
+
+
+with open(target_file, 'w') as fd:
+ indent = ' ' * 2
+ separators = (', ', ': ')
+ json.dump(test_results, fd,
+ use_decimal=True,
+ indent=indent,
+ separators=separators,
+ sort_keys=False)
+
+print "The result has been merged in file: %s" % target_file
+sys.exit(0)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/methanol/start_server.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/methanol/start_server.py
new file mode 100755
index 0000000..6ca96b5
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/methanol/start_server.py
@@ -0,0 +1,62 @@
+#/usr/bin/python
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import sys
+import CGIHTTPServer
+import BaseHTTPServer
+
+### check parameter
+if len(sys.argv) < 3:
+ print 'Please spsecify the ip and directory like this:'
+ print ' %s domain-or-ip directory-path url-file' % (
+ os.path.basename(__file__))
+ sys.exit(1)
+
+domain = sys.argv[1]
+directory = sys.argv[2]
+if len(sys.argv) == 4:
+ url_file = sys.argv[3]
+else:
+ url_file = ''
+
+## change to that directory
+old_dir = os.getcwd()
+os.chdir(directory)
+
+## set the server configuration before start
+cgi_handler = CGIHTTPServer.CGIHTTPRequestHandler
+cgi_handler.cgi_directories.append('/cgi')
+httpd = BaseHTTPServer.HTTPServer((domain, 0), cgi_handler)
+url = '%s://%s:%s/' % ('http', httpd.socket.getsockname()[0],
+ httpd.socket.getsockname()[1])
+
+## out put the url information to console and file for other script reference
+print "serving at url=", url
+if url_file:
+ with open(url_file, 'w') as stream:
+ stream.write(url)
+ print 'The information of url also have been wirtten into file(%s)' % (
+ url_file)
+
+try:
+ httpd.serve_forever()
+finally:
+ os.chdir(old_dir)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/mmtest.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/mmtest.py
new file mode 100644
index 0000000..985a650
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/mmtest.py
@@ -0,0 +1,63 @@
+# Copyright (C) 2011-2012 Linaro Limited
+#
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Performs a test of multimedia functionality in Android by playing a variety
+of different multimedia formats on Android.
+
+**URL:** http://android.git.linaro.org/gitweb?p=platform/frameworks/base.git;a=tree;f=media/tests/MediaFrameworkTest
+
+**Default options:** None
+"""
+
+import os
+import lava_android_test.testdef
+from lava_android_test.utils import get_local_name
+from lava_android_test.config import get_config
+
+test_name = 'mmtest'
+config = get_config()
+
+site = 'http://samplemedia.linaro.org/'
+local_name = get_local_name(site)
+RUN_STEPS_HOST_PRE = [
+ 'wget --progress=dot -e dotbytes=1M -r -np -l 10 -R csv,txt,css,html,gif,pdf %s -P %s' % (site,
+ local_name),
+ r'find %s -type f -name "index*" -exec rm -f \{\} \;' % local_name,
+ r'find %s -type f -name "README" -exec rm -f \{\} \;' % local_name]
+
+test_files_target_path = os.path.join(config.installdir_android,
+ test_name, local_name)
+RUN_STEPS_ADB_PRE = ['push %s %s' % (local_name, test_files_target_path)]
+RUN_ADB_SHELL_STEPS = ['am instrument -r -e targetDir %s \
+ -w com.android.mediaframeworktest/.MediaFrameworkTestRunner'
+ % test_files_target_path,
+ 'rm -r %s' % (test_files_target_path)]
+
+inst = lava_android_test.testdef.AndroidTestInstaller()
+run = lava_android_test.testdef.AndroidTestRunner(
+ steps_host_pre=RUN_STEPS_HOST_PRE,
+ steps_adb_pre=RUN_STEPS_ADB_PRE,
+ adbshell_steps=RUN_ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidInstrumentTestParser()
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey.py
new file mode 100644
index 0000000..944d8ae
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey.py
@@ -0,0 +1,57 @@
+# Copyright (c) 2011 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+Performs a test of monkey functionality in Android with the monkey command
+
+**URL:** http://android.git.linaro.org/gitweb?p=platform/development.git;a=blob;f=cmds/monkey/monkey
+
+**Default options:** None
+"""
+import os
+import lava_android_test.testdef
+from lava_android_test.config import get_config
+
+test_name = 'monkey'
+config = get_config()
+curdir = os.path.realpath(os.path.dirname(__file__))
+monkey_sh_name = 'monkey.sh'
+monkey_sh_path = os.path.join(curdir, 'monkey', monkey_sh_name)
+monkey_sh_android_path = os.path.join(config.installdir_android,
+ test_name, monkey_sh_name)
+
+INSTALL_STEPS_ADB_PRE = ['push %s %s ' % (monkey_sh_path,
+ monkey_sh_android_path),
+ 'shell chmod 777 %s' % monkey_sh_android_path]
+
+ADB_SHELL_STEPS = [monkey_sh_android_path]
+#PATTERN = "^(?P<test_case_id>\w+):\W+(?P<measurement>\d+\.\d+)"
+PATTERN = "## Network stats: elapsed time=(?P<measurement>\d+)ms"
+FAILURE_PATTERNS = []
+#FAILURE_PATTERNS = ['\*\* Monkey aborted due to error.',
+# '\*\* System appears to have crashed']
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN,
+ appendall={'units': 'ms'}, failure_patterns=FAILURE_PATTERNS)
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst, runner=run, parser=parser)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey/monkey.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey/monkey.sh
new file mode 100755
index 0000000..c774680
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey/monkey.sh
@@ -0,0 +1,6 @@
+#!/system/bin/sh
+#monkey_cmd="monkey -s 1 --pct-touch 10 --pct-motion 20 --pct-nav 20 --pct-majornav 30 --pct-appswitch 20 --throttle 500 2147483647"
+monkey_cmd="monkey -s 1 --pct-touch 10 --pct-motion 20 --pct-nav 20 --pct-majornav 30 --pct-appswitch 20 --throttle 500 500"
+echo execute command=${monkey_cmd}
+${monkey_cmd}
+echo MONKEY_RET_CODE=$?
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey_long_run.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey_long_run.py
new file mode 100644
index 0000000..d3d448d
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey_long_run.py
@@ -0,0 +1,78 @@
+# Copyright (c) 2011 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+Performs a test of monkey functionality in Android with some
+black list packages provided.
+
+**URL:** http://android.git.linaro.org/gitweb?p=platform/development.git;a=blob;f=cmds/monkey/monkey
+
+**Default options:** "generic_target"
+"""
+import os
+import lava_android_test.testdef
+from lava_android_test.config import get_config
+
+test_name = 'monkey_long_run'
+config = get_config()
+curdir = os.path.realpath(os.path.dirname(__file__))
+monkey_sh_name = 'monkey_long_run.sh'
+monkey_sh_path = os.path.join(curdir, test_name, monkey_sh_name)
+monkey_sh_android_path = os.path.join(config.installdir_android,
+ test_name, monkey_sh_name)
+monkey_blacklist_name = 'package_black_list'
+monkey_blacklist_path = os.path.join(curdir, test_name, monkey_blacklist_name)
+monkey_blacklist_android_path = os.path.join(config.installdir_android,
+ test_name, monkey_blacklist_name)
+juice_monkey_blacklist_name = 'juice_package_black_list'
+juice_monkey_blacklist_path = os.path.join(curdir, test_name,
+ juice_monkey_blacklist_name)
+juice_monkey_blacklist_android_path = os.path.join(config.installdir_android,
+ test_name,
+ juice_monkey_blacklist_name)
+
+DEFAULT_OPTIONS = 'generic_target'
+INSTALL_STEPS_ADB_PRE = ['push %s %s ' % (monkey_sh_path,
+ monkey_sh_android_path),
+ 'push %s %s ' % (monkey_blacklist_path,
+ monkey_blacklist_android_path),
+ 'push %s %s ' % (juice_monkey_blacklist_path,
+ juice_monkey_blacklist_android_path),
+ 'shell chmod 777 %s' % monkey_sh_android_path]
+
+ADB_SHELL_STEPS = ['%s $(OPTIONS) %s %s' % (monkey_sh_android_path,
+ juice_monkey_blacklist_android_path,
+ monkey_blacklist_android_path)]
+#PATTERN = "^(?P<test_case_id>\w+):\W+(?P<measurement>\d+\.\d+)"
+PATTERN = "## Network stats: elapsed time=(?P<measurement>\d+)ms"
+FAILURE_PATTERNS = ['\*\* Monkey aborted due to error.',
+ '\*\* System appears to have crashed']
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN,
+ appendall={'units': 'ms'}, failure_patterns=FAILURE_PATTERNS)
+testobj = lava_android_test.testdef.AndroidTest(
+ testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser,
+ default_options=DEFAULT_OPTIONS)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey_long_run/juice_package_black_list b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey_long_run/juice_package_black_list
new file mode 100644
index 0000000..56d6045
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey_long_run/juice_package_black_list
@@ -0,0 +1,6 @@
+com.android.browser
+com.android.development
+com.android.quicksearchbox
+com.android.speechrecorder
+com.android.connectivitymanagertest
+org.linaro.glmark2
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey_long_run/monkey_long_run.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey_long_run/monkey_long_run.sh
new file mode 100755
index 0000000..afdc249
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey_long_run/monkey_long_run.sh
@@ -0,0 +1,13 @@
+#!/system/bin/sh
+#monkey_cmd="monkey -s 1 --pct-touch 10 --pct-motion 20 --pct-nav 20 --pct-majornav 30 --pct-appswitch 20 --throttle 500 2147483647"
+if [ $1 == 'juice' ]; then
+monkey_cmd="monkey -s 1 --pct-touch 10 --pct-motion 20 --pct-nav 20 --pct-majornav 30 --pct-appswitch 20 --throttle 500 --pkg-blacklist-file $2 30000"
+elif [ $1 == 'juno' ]; then
+monkey_cmd="monkey -s 1 --pct-touch 10 --pct-motion 20 --pct-nav 20 --pct-majornav 30 --pct-appswitch 20 --throttle 500 --pkg-blacklist-file /data/juno_monkey_blacklist 30000"
+else
+monkey_cmd="monkey -s 1 --pct-touch 10 --pct-motion 20 --pct-nav 20 --pct-majornav 30 --pct-appswitch 20 --throttle 500 --pkg-blacklist-file $3 25000"
+fi
+
+echo execute command=${monkey_cmd}
+${monkey_cmd}
+echo MONKEY_RET_CODE=$?
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey_long_run/package_black_list b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey_long_run/package_black_list
new file mode 100644
index 0000000..0fc6125
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/monkey_long_run/package_black_list
@@ -0,0 +1,2 @@
+com.android.camera
+com.android.connectivitymanagertest
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/pm_qa.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/pm_qa.py
new file mode 100644
index 0000000..bf2cff8
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/pm_qa.py
@@ -0,0 +1,58 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Linaro PM-QA tests for platforms
+
+**URL:** https://git.linaro.org/gitweb?p=tools/pm-qa.git;a=summary
+
+**Default options:** /data/benchmark/pm-qa
+"""
+
+import os
+import lava_android_test.testdef
+from lava_android_test.config import get_config
+
+DEFAULT_OPTIONS = '/data/benchmark/pm-qa'
+test_name = 'pm_qa'
+config = get_config()
+curdir = os.path.realpath(os.path.dirname(__file__))
+test_sh_name = 'pm-qa.sh'
+test_sh_path = os.path.join(curdir, test_name, test_sh_name)
+test_sh_android_path = os.path.join(config.installdir_android,
+ test_name, test_sh_name)
+
+INSTALL_STEPS_ADB_PRE = ['push %s %s ' % (test_sh_path,
+ test_sh_android_path),
+ 'shell chmod 777 %s' % test_sh_android_path]
+
+ADB_SHELL_STEPS = ["%s $(OPTIONS)" % test_sh_android_path]
+PATTERN = "^\s*(?P<test_case_id>\w+)=(?P<result>\w+)\s*$"
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN)
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser,
+ default_options=DEFAULT_OPTIONS)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/pm_qa/pm-qa.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/pm_qa/pm-qa.sh
new file mode 100755
index 0000000..a570d8e
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/pm_qa/pm-qa.sh
@@ -0,0 +1,63 @@
+#!/system/bin/sh
+
+scripts_dir=$1 && shift
+if [ -z "${scripts_dir}" ];then
+ scripts_dir="/data/benchmark/pm-qa"
+fi
+test_func(){
+ if [ ! -d "${scripts_dir}" ]; then
+ echo "pm_qa=fail"
+ exit
+ fi
+
+ mkdir /data/bin/
+ cd /data/bin
+
+ busybox ln -s -f /system/bin/busybox awk
+ busybox ln -s -f /system/bin/busybox basename
+ busybox ln -s -f /system/bin/busybox chmod
+ busybox ln -s -f /system/bin/busybox chown
+ busybox ln -s -f /system/bin/busybox cp
+ busybox ln -s -f /system/bin/busybox diff
+ busybox ln -s -f /system/bin/busybox find
+ busybox ln -s -f /system/bin/busybox grep
+ busybox ln -s -f /system/bin/busybox rm
+ busybox ln -s -f /system/bin/busybox seq
+ busybox ln -s -f /system/bin/busybox taskset
+ busybox ln -s -f /system/bin/busybox tee
+ busybox ln -s -f /system/bin/busybox printf
+ busybox ln -s -f /system/bin/busybox wc
+
+ busybox ln -s -f /system/bin/fake_command command
+ busybox ln -s -f /system/bin/fake_sudo sudo
+ busybox ln -s -f /system/bin/fake_udevadm udevadm
+
+ export PATH=/data/bin:$PATH
+
+ cd "${scripts_dir}"
+
+ pwd_dir=$PWD
+ echo $pwd
+ tests_dirs="cpuidle cpufreq cpuhotplug sched_mc suspend thermal utils"
+
+ for dir in $tests_dirs; do
+ subDir=${pwd_dir}/$dir
+ if [ -d $subDir ]; then
+ cd $subDir
+ else
+ continue
+ fi
+
+ echo `pwd`
+ for file in `find . -name "*.sh"`; do
+ path=$file
+ echo $path
+ /system/bin/sh $path
+ done
+ cd ..
+ done
+
+ echo "pm_qa=pass"
+}
+
+test_func
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/sched_tests.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/sched_tests.py
new file mode 100644
index 0000000..df91439
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/sched_tests.py
@@ -0,0 +1,49 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Drives scheduler test scripts that are pre-intalled on Linaro Android
+builds of big.LITTLE
+
+**URL:** https://linaro-private.git.linaro.org/gitweb?p=bL_tests/sched_tests.git
+
+**Default options:** None
+"""
+
+import lava_android_test.testdef
+
+test_name = 'sched_tests'
+
+DEFAULT_OPTIONS='output all'
+
+INSTALL_STEPS_ADB_PRE = []
+ADB_SHELL_STEPS = ['run_sched_test $(OPTIONS)']
+PATTERN = "(?P<test_case_id>.*-*)\s+:\s+(?P<result>(SUCCESS|FAILED))"
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN)
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser,
+ default_options=DEFAULT_OPTIONS)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/__init__.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/__init__.py
new file mode 100644
index 0000000..7c13426
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/__init__.py
@@ -0,0 +1,33 @@
+# copyright (C) 2012 Linaro Limited
+#
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+This directory contains the tests that only need to run the android shell
+scripts that stored under this directory.
+Please see the example.sh for a reference.
+Please note this is not a test that can be run.
+
+**URL:** None
+
+**Default options:** None
+"""
+
+
+import os
+curdir = os.path.dirname(os.path.realpath(__file__))
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/binder.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/binder.sh
new file mode 100755
index 0000000..d3fb43d
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/binder.sh
@@ -0,0 +1,13 @@
+#!/system/bin/sh
+
+chmod 777 /data/nativebenchmark/binderAddInts
+if [ -z "$1" ]; then
+ /data/nativebenchmark/binderAddInts -n 10
+else
+ /data/nativebenchmark/binderAddInts -n $1
+fi
+if [ $? -eq 0 ]; then
+ echo "binder=pass";
+else
+ echo "binder=fail";
+fi
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/custom.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/custom.sh
new file mode 100755
index 0000000..4b78632
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/custom.sh
@@ -0,0 +1,14 @@
+#!/system/bin/sh
+
+echo "The custom shell will be run is:"
+echo " $@"
+echo "Shell starts:"
+$@
+echo "Shell ends:"
+RET=$?
+echo "The exit status is: $RET"
+if [ $? -ne 0 ]; then
+ echo "custom=fail"
+else
+ echo "custom=pass"
+fi
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/dalvik-vm-unit-tests.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/dalvik-vm-unit-tests.sh
new file mode 100755
index 0000000..65ca818
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/dalvik-vm-unit-tests.sh
@@ -0,0 +1,12 @@
+#!/system/bin/sh
+#
+# Dalvik-VM unit tests.
+#
+
+chmod 777 /data/nativetest/dalvik-vm-unit-tests/dalvik-vm-unit-tests
+/data/nativetest/dalvik-vm-unit-tests/dalvik-vm-unit-tests
+if [ $? -eq 0 ]; then
+ echo "dalvik-vm-unit-tests=pass"
+else
+ echo "dalvik-vm-unit-tests=fail"
+fi
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/example.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/example.sh
new file mode 100755
index 0000000..7e7e858
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/shells/example.sh
@@ -0,0 +1,4 @@
+#!/system/bin/sh
+
+echo "test_case_fail=fail"
+echo "test_case_pass=pass" \ No newline at end of file
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/skia.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/skia.py
new file mode 100644
index 0000000..8edbaee
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/skia.py
@@ -0,0 +1,89 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Runs the skia benchmark to test 2D graphics performance.
+
+**URL:** https://sites.google.com/site/skiadocs/
+
+**Default options:** None
+"""
+
+import re
+import lava_android_test.testdef
+
+test_name = 'skia'
+
+DEFAULT_OPTIONS = '1000'
+
+INSTALL_STEPS_ADB_PRE = []
+# Skia can do many more benchmarks, but it becomes almost too much data
+# to make a nice chart for. The -match limits the ones we run
+ADB_SHELL_STEPS = ['logcat -c',
+ 'skia_bench -repeat $(OPTIONS) -timers w -config 565 -match bitmap',
+ 'skia_bench -repeat $(OPTIONS) -timers w -config 565 -match rects',
+ 'skia_bench -repeat $(OPTIONS) -timers w -config 565 -match repeat',
+ 'logcat -d -s "skia:*"']
+
+
+class SkiaTestParser(lava_android_test.testdef.AndroidTestParser):
+
+ def parse(self, result_filename=None, output_filename=None,
+ test_name=test_name):
+ pat_test = re.compile(r'running bench \[.*?\]\W+(?P<test>\w+)\W+$')
+ pat_type = re.compile(
+ r'\d+\):\W+(?P<type>\w+):\W+msecs =\W+(?P<time>\d+.\d+)')
+
+ test = None
+ with open(output_filename, 'r') as stream:
+ for lineno, line in enumerate(stream, 1):
+ match = pat_test.search(line)
+ if match:
+ test = match.group('test')
+ else:
+ match = pat_type.search(line)
+ if match:
+ data = {}
+ data['test_case_id'] = "%s_%s" % (test,
+ match.group('type'))
+ data['measurement'] = match.group('time')
+ data['result'] = 'pass'
+ data['units'] = 'ms'
+ data['log_filename'] = result_filename
+ data['log_lineno'] = lineno
+ self.results['test_results'].append(data)
+
+ if self.fixupdict:
+ self.fixresults(self.fixupdict)
+ if self.appendall:
+ self.appendtoall(self.appendall)
+ self.fixmeasurements()
+ self.fixids()
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = SkiaTestParser()
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser,
+ default_options=DEFAULT_OPTIONS)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/sleep.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/sleep.py
new file mode 100644
index 0000000..faf39ad
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/sleep.py
@@ -0,0 +1,48 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Action for sleeping some time between test actions
+
+**URL:** None
+
+**Default options:** None
+"""
+import lava_android_test.config
+import lava_android_test.testdef
+
+test_name = 'sleep'
+
+DEFAULT_OPTIONS = '10'
+
+INSTALL_STEPS_ADB_PRE = []
+ADB_SHELL_STEPS = ['sleep $(OPTIONS); echo sleep_$(OPTIONS): PASS']
+PATTERN = "^\s*(?P<test_case_id>[^:]+?):\s+(?P<result>(PASS|FAIL)?)\s*$"
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN)
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser,
+ default_options=DEFAULT_OPTIONS)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/task_placement.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/task_placement.py
new file mode 100644
index 0000000..04fe252
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/task_placement.py
@@ -0,0 +1,49 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Drives task placement scripts that are pre-intalled on Linaro Android
+builds of big.LITTLE
+
+**URL:** https://linaro-private.git.linaro.org/gitweb?p=bL_tests/task-placement-tests.git
+
+**Default options:** None
+"""
+
+import lava_android_test.testdef
+
+test_name = 'task_placement'
+
+DEFAULT_OPTIONS=''
+
+INSTALL_STEPS_ADB_PRE = []
+ADB_SHELL_STEPS = ['run_all_task_placement_tests.sh $(OPTIONS)']
+PATTERN = "(?P<test_case_id>.*-*)\s+:\s+(?P<result>(PASS|FAIL))"
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN)
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser,
+ default_options=DEFAULT_OPTIONS)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/tjbench.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/tjbench.py
new file mode 100644
index 0000000..f86f3d6
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/tjbench.py
@@ -0,0 +1,140 @@
+# Copyright (c) 2011-2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Tests the performance of libjpegturbo
+
+**URL:** http://sourceforge.net/projects/libjpeg-turbo/
+
+**Default options:** None
+"""
+
+import os
+import re
+import lava_android_test.testdef
+from lava_android_test.config import get_config
+
+test_name = 'tjbench'
+config = get_config()
+curdir = os.path.realpath(os.path.dirname(__file__))
+ppm_file_name = 'nightshot_iso_100.ppm'
+ppm_url = ("http://testdata.validation.linaro.org/tjbench/"
+ "nightshot_iso_100.ppm")
+ppm_temp_path = os.path.join(config.tempdir_host, ppm_file_name)
+ppm_android_path = os.path.join(config.tempdir_android, test_name,
+ ppm_file_name)
+ppm_tmpfs_path = os.path.join('/data/local/tmp/mytmpfs', ppm_file_name)
+INSTALL_STEPS_HOST_PRE = ['wget --no-check-certificate -q "%s" -O ./%s' % (
+ ppm_url, ppm_file_name)]
+INSTALL_STEPS_ADB_PRE = ['push %s %s' % (ppm_temp_path, ppm_android_path)]
+
+RUN_STEPS_ADB_SHELL = ['mkdir /data/local/tmp/mytmpfs',
+ 'mount -t tmpfs -o mode=777 tmpfs /data/local/tmp/mytmpfs',
+ 'dd if=%s of=%s' % (ppm_android_path, ppm_tmpfs_path),
+ 'tjbench %s 95 -rgb -quiet scale 1/2' % ppm_tmpfs_path,
+ 'tjbench %s 95 -rgb -quiet' % ppm_tmpfs_path,
+ 'umount /data/local/tmp/mytmpfs',
+ 'rmdir /data/local/tmp/mytmpfs']
+
+
+class TjbenchTestParser(lava_android_test.testdef.AndroidTestParser):
+
+ def parse(self, result_filename='stdout.log', output_filename='stdout.log',
+ test_name=''):
+ """Parse test output to gather results
+ Use the pattern specified when the class was instantiated to look
+ through the results line-by-line and find lines that match it.
+ Results are then stored in self.results. If a fixupdict was supplied
+ it is used to convert test result strings to a standard format.
+ """
+ try:
+ unit_pat = re.compile(
+ r'^\s*All performance values in (?P<units>\S+)\s*$')
+ measure_pat = re.compile(
+ ('^\s*(?P<format>\S+)\s+\S+\s+(?P<subsamp>\S+)\s+'
+ '(?P<qual>\d+)\s+\d+\s+\d+\s+(?P<comp_perf>[\d\.]+)\s+'
+ '(?P<comp_ratio>[\d\.]+)\s+(?P<dcomp_perf>[\d\.]+)\s*$')
+ )
+ except Exception as strerror:
+ raise RuntimeError(
+ "AndroidTestParser - Invalid regular expression '%s' - %s" % (
+ self.pattern, strerror))
+ units = None
+ prefix_hash = {}
+ with open(output_filename, 'r') as stream:
+ for lineno, line in enumerate(stream, 1):
+ if units is None:
+ match = unit_pat.search(line)
+ if not match:
+ continue
+ else:
+ units = match.group('units')
+
+ match = measure_pat.search(line)
+ if match:
+ tmpdata = match.groupdict()
+ test_case_prefix = '%s_%s_%s' % (tmpdata['format'],
+ tmpdata['subsamp'],
+ tmpdata['qual'])
+ if not prefix_hash.get(test_case_prefix):
+ prefix_hash[test_case_prefix] = True
+ test_case_prefix = '%s_%s' % (test_case_prefix,
+ 'scale_half')
+ common_data = {'log_filename': result_filename,
+ 'log_lineno': lineno,
+ 'result': 'pass'
+ }
+ comp_perf = {'test_case_id': '%s_%s' % (test_case_prefix,
+ 'comp_perf'),
+ 'units': units,
+ 'measurement': tmpdata['comp_perf']
+ }
+ comp_perf.update(common_data)
+ comp_ratio = {'test_case_id': '%s_%s' % (test_case_prefix,
+ 'comp_ratio'),
+ 'units': '%',
+ 'measurement': tmpdata['comp_ratio']
+ }
+ comp_ratio.update(common_data)
+ dcomp_perf = {'test_case_id': '%s_%s' % (test_case_prefix,
+ 'dcomp_perf'),
+ 'units': units,
+ 'measurement': tmpdata['dcomp_perf']
+ }
+ dcomp_perf.update(common_data)
+ self.results['test_results'].extend([comp_perf, comp_ratio,
+ dcomp_perf])
+ if self.fixupdict:
+ self.fixresults(self.fixupdict)
+ if self.appendall:
+ self.appendtoall(self.appendall)
+ self.fixmeasurements()
+ self.fixids(test_name=test_name)
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_host_pre=INSTALL_STEPS_HOST_PRE,
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=RUN_STEPS_ADB_SHELL)
+parser = TjbenchTestParser()
+testobj = lava_android_test.testdef.AndroidTest(testname="tjbench",
+ installer=inst,
+ runner=run,
+ parser=parser)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/usbhardware.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/usbhardware.py
new file mode 100644
index 0000000..8a2a796
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/usbhardware.py
@@ -0,0 +1,56 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Ensures USB is enabled on the device by checking /sys entries
+
+**URL:** None
+
+**Default options:** None
+"""
+
+import os
+import lava_android_test.testdef
+from lava_android_test.config import get_config
+
+test_name = 'usbhardware'
+config = get_config()
+curdir = os.path.realpath(os.path.dirname(__file__))
+test_sh_name = 'usbhardware.sh'
+test_sh_path = os.path.join(curdir, test_name, test_sh_name)
+test_sh_android_path = os.path.join(config.installdir_android,
+ test_name, test_sh_name)
+
+INSTALL_STEPS_ADB_PRE = ['push %s %s ' % (test_sh_path,
+ test_sh_android_path),
+ 'shell chmod 777 %s' % test_sh_android_path]
+
+ADB_SHELL_STEPS = [test_sh_android_path]
+PATTERN = "^\s*(?P<test_case_id>\w+)=(?P<result>\w+)\s*$"
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN)
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/usbhardware/usbhardware.sh b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/usbhardware/usbhardware.sh
new file mode 100755
index 0000000..d7e8f7d
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/usbhardware/usbhardware.sh
@@ -0,0 +1,13 @@
+#!/system/bin/sh
+
+test_func(){
+ if [ ! -f /sys/class/android_usb/android0/state ]; then
+ echo "usbhardware=fail"
+ exit
+ fi
+
+ cat /sys/class/android_usb/android0/state
+ echo "usbhardware=pass"
+}
+
+test_func
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/v8.py b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/v8.py
new file mode 100644
index 0000000..e017f00
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/test_definitions/v8.py
@@ -0,0 +1,53 @@
+# Copyright (c) 2012 Linaro
+
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+#
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Performs the v8 benchmark on Android and returns the metrics
+
+**URL:** http://v8.googlecode.com/svn/data/benchmarks/v5/run.html
+
+**Default options:** None
+"""
+
+
+import lava_android_test.config
+import lava_android_test.testdef
+
+test_name = 'v8'
+
+INSTALL_STEPS_ADB_PRE = []
+adb_shell = ('"'
+ 'cd /data/benchmark/v8;'
+ 'if which v8shell 2>/dev/null 1>/dev/null;'
+ 'then v8shell run.js; '
+ 'else d8 run.js; fi'
+ '"')
+ADB_SHELL_STEPS = [adb_shell]
+PATTERN = "^(?P<test_case_id>.*?):\s+(?P<measurement>[\d.]+)\s*$"
+
+inst = lava_android_test.testdef.AndroidTestInstaller(
+ steps_adb_pre=INSTALL_STEPS_ADB_PRE)
+run = lava_android_test.testdef.AndroidTestRunner(
+ adbshell_steps=ADB_SHELL_STEPS)
+parser = lava_android_test.testdef.AndroidTestParser(PATTERN)
+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
+ installer=inst,
+ runner=run,
+ parser=parser)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/testdef.py b/build/lib.linux-x86_64-2.7/lava_android_test/testdef.py
new file mode 100644
index 0000000..0cb97aa
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/testdef.py
@@ -0,0 +1,771 @@
+# Copyright (C) 2010-2012 Linaro Limited
+#
+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
+#
+# This file is part of LAVA Android Test.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import base64
+import hashlib
+import logging
+import os
+import re
+import string
+import time
+import tempfile
+import decimal
+import zipfile
+
+from datetime import datetime
+from uuid import uuid4
+
+from lava_android_test.adb import ADB
+from lava_android_test.api import ITest
+from lava_android_test.config import get_config
+from lava_android_test.utils import write_file, geturl
+from lava_android_test import hwprofile, swprofile
+from linaro_dashboard_bundle.io import DocumentIO
+
+
+class Attachment(object):
+
+ def __init__(self, pathname=None, mime_type=None):
+ self.pathname = pathname
+ self.mime_type = mime_type
+
+ def copy_to_result_dir(self, adb=None, resultsdir=None):
+ """
+ Copy the file specified by the pathname to result
+ directory of this time test, beacuse some test will
+ generate the result to the same path file.
+ And Please Note that pathname must be the absolute
+ path in the device.
+ """
+ if (not self.pathname) or (not self.pathname.startswith('/')):
+ return
+ if not resultsdir:
+ return
+ if not adb:
+ adb = ADB()
+ if not adb.exists(resultsdir):
+ adb.makedirs(resultsdir)
+ ret_code = adb.copy(self.pathname, os.path.join(resultsdir,
+ os.path.basename(self.pathname)))
+ if ret_code != 0:
+ raise RuntimeError(
+ "Failed to copy file '%s' to '%s' on device(%s)" %
+ (self.pathname, resultsdir, adb.get_serial()))
+
+ def generate_bundle(self, adb=None, resultsdir=None):
+ data_bundle = {}
+ if not self.pathname:
+ return data_bundle
+ if not adb:
+ adb = ADB()
+ config = get_config()
+ basename = os.path.basename(self.pathname)
+ android_path = os.path.join(resultsdir, basename)
+ if adb.exists(android_path):
+ tmp_path = os.path.join(config.tempdir_host, basename)
+ adb.pull(android_path, tmp_path)
+ with open(tmp_path, 'rb') as stream:
+ data = stream.read()
+ if data:
+ data_bundle = {"pathname": basename,
+ "mime_type": self.mime_type,
+ "content": base64.standard_b64encode(data)}
+ os.unlink(tmp_path)
+ return data_bundle
+
+
+class AndroidTest(ITest):
+ """Base class for defining tests.
+
+ This can be used by test definition files to create an object that
+ contains the building blocks for installing tests, running them,
+ and parsing the results.
+
+ testname - name of the test or test suite
+ version - version of the test or test suite
+ installer - AbrekInstaller instance to use
+ runner - AbrekRunner instance to use
+ parser - AbrekParser instance to use
+ """
+ adb = ADB()
+ default_attachments = [
+ Attachment(pathname="stderr.log", mime_type="text/plain"),
+ Attachment(pathname="stdout.log", mime_type="text/plain"),
+ Attachment(pathname="screencap.png", mime_type="image/png"),
+ Attachment(pathname="tombstones.zip", mime_type="application/zip")
+ ]
+
+ def setadb(self, adb=None):
+ self.adb = adb
+
+ def getadb(self):
+ return self.adb
+
+ def __init__(self, testname, version="", installer=None, runner=None,
+ parser=None, default_options=None,
+ org_ouput_file='stdout.log',
+ attachments=[]):
+ self.testname = testname
+ self.version = version
+ self.installer = installer
+ self.runner = runner
+ self.parser = parser
+ self.default_options = default_options
+ self.org_ouput_file = org_ouput_file
+ self.origdir = os.path.abspath(os.curdir)
+ self.attachments = self.default_attachments
+ if self.org_ouput_file and (self.org_ouput_file != "stdout.log"):
+ self.attachments.append(
+ Attachment(pathname=self.org_ouput_file,
+ mime_type="text/plain"))
+ if attachments:
+ self.attachments.extend(attachments)
+
+ def set_runner(self, runner=None):
+ self.runner = runner
+
+ def set_parser(self, parser=None):
+ self.parser = parser
+
+ def install(self, install_options=None):
+ """Install the test suite.
+
+ This creates an install directory under the user's XDG_DATA_HOME
+ directory to mark that the test is installed. The installer's
+ install() method is then called from this directory to complete any
+ test specific install that may be needed.
+ """
+ if not self.installer:
+ raise RuntimeError("no installer defined for '%s'" %
+ self.testname)
+ self.installer.setadb(self.adb)
+ config = get_config()
+ if not os.path.exists(config.tempdir_host):
+ os.makedirs(config.tempdir_host)
+ os.chdir(config.tempdir_host)
+ installdir = os.path.join(config.installdir_android, self.testname)
+ if self.adb.exists(installdir):
+ raise RuntimeError("%s is already installed" % self.testname)
+ ret_code = self.adb.makedirs(installdir)
+ if ret_code != 0:
+ raise RuntimeError(
+ "Failed to create directory(%s) for test(%s)" %
+ (installdir, self.testname))
+
+ if install_options is not None:
+ self.adb.shell('echo "%s" > %s/install_options' %
+ (install_options, installdir))
+ try:
+ self.installer.install(install_options)
+ except Exception as e:
+ self.uninstall()
+ raise RuntimeError(
+ "Failed to install test(%s):%s" % (self.testname, e))
+ finally:
+ os.chdir(self.origdir)
+
+ def uninstall(self):
+ """Uninstall the test suite.
+
+ Uninstalling just recursively removes the test specific directory
+ under the user's XDG_DATA_HOME directory. This will both mark
+ the test as removed, and clean up any files that were downloaded
+ or installed under that directory. Dependencies are intentionally
+ not removed by this. And others installed files won't be removed too.
+ """
+ config = get_config()
+ path = os.path.join(config.installdir_android, self.testname)
+ if self.adb.exists(path):
+ self.adb.rmtree(path)
+
+ def _add_install_options(self, bundle, config):
+ optionfile = "%s/%s/install_options" % (config.installdir_android,
+ self.testname)
+ if self.adb.exists(optionfile):
+ output = self.adb.run_adb_cmd('shell cat %s' % optionfile)[1]
+ bundle['test_runs'][0]['attributes']['install_options'] = output[0]
+
+ def _savetestdata(self, analyzer_assigned_uuid, run_options=""):
+ config = get_config()
+ TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'
+ bundle = {
+ 'format': config.bundle_format,
+ 'test_runs': [
+ {
+ 'analyzer_assigned_uuid': analyzer_assigned_uuid,
+ 'analyzer_assigned_date':
+ self.runner.starttime.strftime(TIMEFORMAT),
+ 'time_check_performed': False,
+ 'attributes':{},
+ 'test_id': self.testname,
+ 'test_results':[],
+ 'attachments':[],
+ 'hardware_context': hwprofile.get_hardware_context(self.adb),
+ 'software_context': swprofile.get_software_context(self.adb)
+ }
+ ]
+ }
+ if run_options:
+ bundle['test_runs'][0]['attributes']['run_options'] = run_options
+ self._add_install_options(bundle, config)
+ filename_host = os.path.join(config.tempdir_host, 'testdata.json')
+ write_file(DocumentIO.dumps(bundle), filename_host)
+ filename_target = os.path.join(self.resultsdir, 'testdata.json')
+ self.adb.push(filename_host, filename_target)
+
+ def run(self, quiet=False, run_options=None):
+ if not self.runner:
+ raise RuntimeError("no test runner defined for '%s'" %
+ self.testname)
+ if not run_options:
+ run_options = self.default_options
+
+ self.runner.setadb(self.adb)
+ config = get_config()
+ if not os.path.exists(config.tempdir_host):
+ os.mkdir(config.tempdir_host)
+ os.chdir(config.tempdir_host)
+ resultname = (self.testname +
+ str(time.mktime(datetime.utcnow().timetuple())))
+ self.resultsdir = os.path.join(config.resultsdir_android, resultname)
+ self.adb.makedirs(self.resultsdir)
+ self.runner.run(self.resultsdir, run_options=run_options)
+ self._gather_tombstones(self.resultsdir)
+ self._copyattachments(self.resultsdir)
+ self._screencap(self.resultsdir)
+ self._savetestdata(str(uuid4()), run_options=run_options)
+ result_id = os.path.basename(self.resultsdir)
+ print("ANDROID TEST RUN COMPLETE: Result id is '%s'" % result_id)
+ os.chdir(self.origdir)
+ return result_id
+
+ def _screencap(self, resultsdir):
+ target_path = '/system/bin/screenshot'
+ self.adb.shell('%s %s' % (target_path, os.path.join(resultsdir,
+ 'screencap.png')))
+
+ def _gather_tombstones(self, resultsdir):
+ """
+ Extension of the generate bundle function.
+ Grabs the tombstones and appends them to the bundle.
+ """
+ config = get_config()
+ tombstone_path = '/data/tombstones'
+ tombstone_zip = os.path.join(config.tempdir_host, 'tombstones.zip')
+ if self.adb.exists(tombstone_path):
+ tmp_path = os.path.join(config.tempdir_host, 'tombstones')
+ self.adb.pull(tombstone_path, tmp_path)
+ self.adb.shell("rm -R " + tombstone_path)
+ zipf = zipfile.ZipFile(tombstone_zip, mode='w')
+ for rootdir, dirs, files in os.walk(tmp_path):
+ for f in files:
+ zipf.write(os.path.join(rootdir, f), arcname=f)
+ zipf.close()
+ self.adb.push(tombstone_zip, os.path.join(resultsdir,
+ 'tombstones.zip'))
+ os.unlink(tombstone_zip)
+
+ def _copyattachments(self, resultsdir):
+ for attachment in self.attachments:
+ attachment.copy_to_result_dir(adb=self.adb, resultsdir=resultsdir)
+
+ def parse(self, resultname):
+ if not self.parser:
+ raise RuntimeError("no test parser defined for '%s'" %
+ self.testname)
+ output_filename = os.path.basename(self.org_ouput_file)
+ config = get_config()
+ os.chdir(config.tempdir_host)
+ resultsdir_android = os.path.join(config.resultsdir_android,
+ resultname)
+ result_filename_android = os.path.join(resultsdir_android,
+ output_filename)
+ result_filename_host_temp = tempfile.mkstemp(prefix=output_filename,
+ dir=config.tempdir_host)[1]
+ self.adb.pull(result_filename_android, result_filename_host_temp)
+ self.parser.parse(output_filename,
+ output_filename=result_filename_host_temp,
+ test_name=self.testname)
+ os.remove(result_filename_host_temp)
+ os.chdir(self.origdir)
+
+
+class AndroidTestInstaller(object):
+
+ adb = ADB()
+
+ """Base class for defining an installer object.
+
+ This class can be used as-is for simple installers, or extended for more
+ advanced funcionality.
+
+ steps_host - list of steps to be executed on host
+ steps_android - list of steps to be executed on android
+ url - location from which the test suite should be downloaded
+ md5 - md5sum to check the integrety of the download
+ """
+ def __init__(self, steps_host_pre=[], steps_adb_pre=[], apks=[],
+ steps_adb_post=[], steps_host_post=[],
+ url=None, md5=None, **kwargs):
+ self.steps_host_pre = steps_host_pre
+ self.steps_adb_pre = steps_adb_pre
+ self.apks = apks
+ self.steps_adb_post = steps_adb_post
+ self.steps_host_post = steps_host_post
+ self.url = url
+ self.md5 = md5
+
+ def _download(self):
+ """Download the file specified by the url and check the md5.
+ Returns the path and filename if successful, otherwise return None
+ """
+ if not self.url:
+ return 0
+ config = get_config()
+ filename = geturl(self.url, config.tempdir_host)
+ #If the file does not exist, then the download was not successful
+ if not os.path.exists(filename):
+ return None
+ if self.md5:
+ checkmd5 = hashlib.md5()
+ with open(filename, 'rb') as fd:
+ data = fd.read(0x10000)
+ while data:
+ checkmd5.update(data)
+ data = fd.read(0x10000)
+ if checkmd5.hexdigest() != self.md5:
+ raise RuntimeError("Unexpected md5sum downloading %s" %
+ filename)
+ return None
+ return filename
+
+ def _installapk(self):
+ for apk in self.apks:
+ rc = self.adb.installapk(apk)
+ if rc:
+ raise RuntimeError(
+ "Failed to install apk '%s' failed. %d" % (apk, rc))
+
+ def install(self, install_options=None):
+ self._download()
+ _run_steps_host(self.steps_host_pre, self.adb.serial, install_options)
+ _run_steps_adb(self.steps_adb_pre, self.adb.serial, install_options)
+ self._installapk()
+ _run_steps_adb(self.steps_adb_post, self.adb.serial, install_options)
+ _run_steps_host(self.steps_host_post, self.adb.serial, install_options)
+
+ def setadb(self, adb=None):
+ self.adb = adb
+
+
+class AndroidTestRunner(object):
+
+ adb = ADB()
+ """Base class for defining an test runner object.
+
+ This class can be used as-is for simple execution with the expectation
+ that the run() method will be called from the directory where the test
+ was installed. Steps, if used, should handle changing directories from
+ there to the directory where the test was extracted if necessary.
+ This class can also be extended for more advanced funcionality.
+
+ steps - list of steps to be executed in a shell
+ """
+ def __init__(self, steps_host_pre=[], steps_adb_pre=[],
+ adbshell_steps=[], steps_adb_post=[], steps_host_post=[]):
+ self.steps_host_pre = steps_host_pre
+ self.steps_adb_pre = steps_adb_pre
+ self.adbshell_steps = adbshell_steps
+ self.steps_adb_post = steps_adb_post
+ self.steps_host_post = steps_host_post
+ self.testoutput = []
+
+ def _run_steps_adbshell(self, resultsdir, option=None):
+ stdoutlog = os.path.join(resultsdir, 'stdout.log')
+ stderrlog = os.path.join(resultsdir, 'stderr.log')
+ try:
+ for cmd in self.adbshell_steps:
+ if option is not None:
+ cmd = cmd.replace('$(OPTIONS)', option)
+ else:
+ cmd = cmd.replace('$(OPTIONS)', '')
+ if resultsdir is not None:
+ cmd = cmd.replace('$(RESULTDIR)', resultsdir)
+ else:
+ cmd = cmd.replace('$(RESULTDIR)', '')
+ cmd = cmd.strip()
+ ret_code = self.adb.run_adb_shell_for_test(cmd,
+ stdoutlog,
+ stderrlog)
+ if ret_code != 0:
+ raise Exception(
+ "Failed to execute command(%s):ret_code=%d" % (cmd,
+ ret_code))
+ except:
+ raise
+ finally:
+ self.adb.shell('getprop',
+ os.path.join(resultsdir, 'propoutput.log'))
+ self.adb.shell('cat /proc/cpuinfo',
+ os.path.join(resultsdir, 'cpuinfo.log'))
+ self.adb.shell('cat /proc/meminfo',
+ os.path.join(resultsdir, 'meminfo.log'))
+
+ def run(self, resultsdir, run_options=None):
+ self.starttime = datetime.utcnow()
+ _run_steps_host(self.steps_host_pre, self.adb.serial,
+ option=run_options, resultsdir=resultsdir)
+ _run_steps_adb(self.steps_adb_pre, self.adb.serial,
+ option=run_options, resultsdir=resultsdir)
+ self._run_steps_adbshell(resultsdir, option=run_options)
+ _run_steps_adb(self.steps_adb_post, self.adb.serial,
+ option=run_options, resultsdir=resultsdir)
+ _run_steps_host(self.steps_host_post, self.adb.serial,
+ option=run_options, resultsdir=resultsdir)
+ self.endtime = datetime.utcnow()
+
+ def setadb(self, adb=None):
+ self.adb = adb
+
+
+class AndroidTestParser(object):
+ adb = ADB()
+ PASS_PATS = ['PASS', 'OK', 'TRUE', 'DONE']
+ FAIL_PATS = ['FAIL', 'NG', 'FALSE']
+ SKIP_PATS = ['SKIP']
+
+ """Base class for defining a test parser
+
+ This class can be used as-is for simple results parsers, but will
+ likely need to be extended slightly for many. If used as it is,
+ the parse() method should be called while already in the results
+ directory and assumes that a file for test output will exist called
+ testoutput.log.
+
+ pattern - regexp pattern to identify important elements of test output
+ For example: If your testoutput had lines that look like:
+ "test01: PASS", then you could use a pattern like this:
+ "^(?P<testid>\w+):\W+(?P<result>\w+)"
+ This would result in identifying "test01" as testid and
+ "PASS" as result. Once parse() has been called,
+ self.results.test_results[] contains a list of dicts of all the
+ key,value pairs found for each test result
+ fixupdict - dict of strings to convert test results to standard strings
+ For example: if you want to standardize on having pass/fail results
+ in lower case, but your test outputs them in upper case, you could
+ use a fixupdict of something like: {'PASS':'pass','FAIL':'fail'}
+ appendall - Append a dict to the test_results entry for each result.
+ For example: if you would like to add units="MB/s" to each result:
+ appendall={'units':'MB/s'}
+ failure_patterns - regexp pattern to identify whether the test is failed
+ or success
+ If there is a string match one pattern in failure_patterns,
+ then this test will be deal as failed.
+ """
+ def __init__(self, pattern=None, fixupdict=None, appendall={},
+ failure_patterns=[]):
+ self.pattern = pattern
+ self.fixupdict = fixupdict
+ self.results = {'test_results': []}
+ self.appendall = appendall
+ self.failure_patterns = failure_patterns
+
+ def _find_testid(self, test_id):
+ for x in self.results['test_results']:
+ if x['testid'] == test_id:
+ return self.results['test_results'].index(x)
+
+ def parse(self, result_filename='stdout.log',
+ output_filename='stdout.log', test_name=''):
+ """Parse test output to gather results
+
+ Use the pattern specified when the class was instantiated to look
+ through the results line-by-line and find lines that match it.
+ Results are then stored in self.results. If a fixupdict was supplied
+ it is used to convert test result strings to a standard format.
+ """
+
+ self.real_parse(result_filename=result_filename,
+ output_filename=output_filename, test_name=test_name)
+
+ self.fixresults(self.fixupdict)
+ if self.appendall:
+ self.appendtoall(self.appendall)
+ self.fixmeasurements()
+ self.fixids(test_name=test_name)
+
+ def real_parse(self, result_filename='stdout.log',
+ output_filename='stdout.log', test_name=''):
+ """Using the pattern to do the real parse operation
+
+ generate the test_results elements from the result file by parsing
+ with the pattern specified.
+ """
+ if not self.pattern:
+ return
+
+ try:
+ pat = re.compile(self.pattern)
+ except Exception as strerror:
+ raise RuntimeError(
+ "AndroidTestParser - Invalid regular expression '%s' - %s" % (
+ self.pattern, strerror))
+
+ failure_pats = []
+ for failure_pattern in self.failure_patterns:
+ try:
+ failure_pat = re.compile(failure_pattern)
+ except Exception as strerror:
+ raise RuntimeError(
+ "AndroidTestParser - Invalid regular expression '%s' - %s" % (
+ failure_pattern, strerror))
+ failure_pats.append(failure_pat)
+ test_ok = True
+
+ with open(output_filename, 'r') as stream:
+ for lineno, line in enumerate(stream, 1):
+ if test_ok == True:
+ for failure_pat in failure_pats:
+ failure_match = failure_pat.search(line)
+ if failure_match:
+ test_ok = False
+
+ match = pat.search(line)
+ if not match:
+ continue
+ data = match.groupdict()
+ data["log_filename"] = result_filename
+ data["log_lineno"] = lineno
+ if data.get('result') is None:
+ data['result'] = test_ok and 'pass' or 'fail'
+ self.results['test_results'].append(data)
+
+ def append(self, testid, entry):
+ """Appends a dict to the test_results entry for a specified testid
+
+ This lets you add a dict to the entry for a specific testid
+ entry should be a dict, updates it in place
+ """
+ index = self._find_testid(testid)
+ self.results['test_results'][index].update(entry)
+
+ def appendtoall(self, entry):
+ """Append entry to each item in the test_results.
+
+ entry - dict of key,value pairs to add to each item in the
+ test_results
+ """
+ for t in self.results['test_results']:
+ t.update(entry)
+
+ def fixresults(self, fixupdict):
+ """Convert results to a known, standard format
+
+ pass it a dict of keys/values to replace
+ For instance:
+ {"TPASS":"pass", "TFAIL":"fail"}
+ This is really only used for qualitative tests
+ """
+ for t in self.results['test_results']:
+ if "result" in t:
+ if not fixupdict:
+ if self.is_result_match(t['result'], self.PASS_PATS):
+ t['result'] = 'pass'
+ elif self.is_result_match(t['result'], self.FAIL_PATS):
+ t['result'] = 'fail'
+ elif self.is_result_match(t['result'], self.SKIP_PATS):
+ t['result'] = 'skip'
+ else:
+ t['result'] = 'unknown'
+ elif t['result'] in fixupdict:
+ t['result'] = fixupdict[t['result']]
+ else:
+ t['result'] = 'unknown'
+
+ def is_result_match(self, result, patterns=[]):
+ cap_result = string.upper(result)
+ for pattern in patterns:
+ cap_pattern = string.upper(pattern)
+ pat_index = string.find(cap_result, cap_pattern)
+ if pat_index > -1:
+ return True
+
+ return False
+
+ def fixmeasurements(self):
+ """Measurements are often read as strings, but need to be
+ decimal.Decimal as per dashboard bundle format JSON schema.
+ """
+ for test_case in self.results['test_results']:
+ if 'measurement' in test_case:
+ try:
+ test_case['measurement'] = decimal.Decimal(
+ test_case['measurement'])
+ except decimal.InvalidOperation:
+ logging.warning("Invalid measurement %s" % (
+ test_case['measurement']))
+ del test_case['measurement']
+
+ def fixids(self, test_name=''):
+ """
+ Convert spaces to _ in test_case_id and remove illegal characters
+ """
+ badchars = "[^a-zA-Z0-9\._-]"
+ for test_case in self.results['test_results']:
+ if 'test_case_id' in test_case:
+ test_case['test_case_id'] = test_case[
+ 'test_case_id'].replace(" ", "_")
+ test_case['test_case_id'] = re.sub(badchars, "",
+ test_case['test_case_id'])
+ else:
+ test_case['test_case_id'] = test_name
+
+ def setadb(self, adb=None):
+ self.adb = adb
+
+ def set_result_patterns(self, pass_pat=[], fail_pat=[], skip_pat=[]):
+ if pass_pat:
+ self.PASS_PATS = pass_pat
+ if fail_pat:
+ self.FAIL_PATS = fail_pat
+ if skip_pat:
+ self.SKIP_PATS = skip_pat
+
+
+class AndroidInstrumentTestParser(AndroidTestParser):
+
+ def parse(self, result_filename='stdout.log', output_filename='stdout.log',
+ test_name=''):
+ """Parser for Instrument test that run with the -r option
+ """
+ pat_test = re.compile(
+ r'^\s*INSTRUMENTATION_STATUS:\s*test=(?P<test_case_id>.+)\s*$')
+ pat_status_code = re.compile(
+ r'^\s*INSTRUMENTATION_STATUS_CODE:\s*(?P<status_code>[\d-]+)\s*$')
+ data = {}
+ with open(output_filename, 'r') as stream:
+ for lineno, line in enumerate(stream, 1):
+ match = pat_test.search(line)
+ if match:
+ data['test_case_id'] = match.group('test_case_id')
+ continue
+
+ match = pat_status_code.search(line)
+ if match:
+ status_code = match.group('status_code')
+ if status_code == '1':
+ # test case started
+ data = {}
+ elif data['test_case_id']:
+ if status_code == '0':
+ data['result'] = 'pass'
+ else:
+ data['result'] = 'fail'
+ data["log_filename"] = result_filename
+ data["log_lineno"] = lineno
+ self.results['test_results'].append(data)
+ data = {}
+ continue
+
+ if self.fixupdict:
+ self.fixresults(self.fixupdict)
+ if self.appendall:
+ self.appendtoall(self.appendall)
+ self.fixmeasurements()
+ self.fixids()
+
+
+class AndroidSimpleTestParser(AndroidTestParser):
+
+ def real_parse(self, result_filename='stdout.log',
+ output_filename='stdout.log', test_name=''):
+ self.res_pattern = ("^\s*(?P<test_case_id>.+?)\s*="
+ "\s*(?P<result>(pass|fail|ok|ng|true|false|skip|done))\s*$")
+ self.measurement_pattern = ("^\s*(?P<test_case_id>.+?)\s*="
+ "\s*(?P<measurement>[\.\d]+)\s*$")
+ self.measurement_units_pattern = ("^\s*(?P<test_case_id>.+?)\s*="
+ "\s*(?P<measurement>[\.\d]+)\s+(?P<units>\S+)\s*$")
+
+ res_pat = re.compile(self.res_pattern)
+ measurement_pat = re.compile(self.measurement_pattern)
+ measurement_units_pat = re.compile(self.measurement_units_pattern)
+
+ with open(output_filename, 'r') as stream:
+ for lineno, line in enumerate(stream, 1):
+ match = res_pat.search(line)
+ if not match:
+ match = measurement_pat.search(line)
+ if not match:
+ match = measurement_units_pat.search(line)
+ if not match:
+ continue
+ data = match.groupdict()
+ data["log_filename"] = result_filename
+ data["log_lineno"] = lineno
+ if data.get('result') is None:
+ data['result'] = 'pass'
+
+ self.results['test_results'].append(data)
+
+
+def _run_steps_host(steps=[], serial=None, option=None, resultsdir=None):
+ adb = ADB(serial)
+ for cmd in steps:
+ if serial is not None:
+ cmd = cmd.replace('$(SERIAL)', serial)
+ else:
+ cmd = cmd.replace('$(SERIAL)', '')
+ if option is not None:
+ cmd = cmd.replace('$(OPTIONS)', option)
+ else:
+ cmd = cmd.replace('$(OPTIONS)', '')
+ if resultsdir is not None:
+ cmd = cmd.replace('$(RESULTDIR)', resultsdir)
+ else:
+ cmd = cmd.replace('$(RESULTDIR)', '')
+
+ cmd = cmd.strip()
+ rc, output = adb.run_cmd_host(cmd, quiet=False)
+ if rc:
+ raise RuntimeError(
+ "Run step '%s' failed. %d : %s" % (cmd, rc, output))
+ if resultsdir is not None:
+ stdoutlog = os.path.join(resultsdir, 'stdout.log')
+ adb.push_stream_to_device(output, stdoutlog)
+
+
+def _run_steps_adb(steps=[], serial=None, option=None, resultsdir=None):
+ adb = ADB(serial)
+ for cmd in steps:
+ if option is not None:
+ cmd = cmd.replace('$(OPTIONS)', option)
+ else:
+ cmd = cmd.replace('$(OPTIONS)', '')
+ if resultsdir is not None:
+ cmd = cmd.replace('$(RESULTDIR)', resultsdir)
+ else:
+ cmd = cmd.replace('$(RESULTDIR)', '')
+ cmd = cmd.strip()
+ rc, output = adb.run_adb_cmd(cmd, quiet=False)
+ if rc:
+ raise RuntimeError(
+ "Run step '%s' failed. %d : %s" % (cmd, rc, output))
+ if resultsdir is not None:
+ stdoutlog = os.path.join(resultsdir, 'stdout.log')
+ adb.push_stream_to_device(output, stdoutlog)
diff --git a/build/lib.linux-x86_64-2.7/lava_android_test/utils.py b/build/lib.linux-x86_64-2.7/lava_android_test/utils.py
new file mode 100644
index 0000000..75290d2
--- /dev/null
+++ b/build/lib.linux-x86_64-2.7/lava_android_test/utils.py
@@ -0,0 +1,202 @@
+# Copyright (c) 2010-2012 Linaro
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import re
+import os
+import pexpect
+import shutil
+import subprocess
+import sys
+import time
+import urllib2
+import urlparse
+
+_fake_files = None
+_fake_paths = None
+_fake_machine = None
+
+
+class Tee(file):
+ """ A file-like object that optionally mimics tee functionality.
+
+ By default, output will go to both stdout and the file specified.
+ Optionally, quiet=True can be used to mute the output to stdout.
+ """
+ def __init__(self, *args, **kwargs):
+ try:
+ self.quiet = kwargs.pop('quiet')
+ except KeyError:
+ self.quiet = False
+ super(Tee, self).__init__(*args, **kwargs)
+
+ def write(self, data):
+ super(Tee, self).write(data)
+ if self.quiet is False:
+ sys.stdout.write(data)
+
+
+def geturl(url, path=""):
+ urlpath = urlparse.urlsplit(url).path
+ filename = os.path.basename(urlpath)
+ if path:
+ filename = os.path.join(path, filename)
+ fd = open(filename, "w")
+ try:
+ response = urllib2.urlopen(urllib2.quote(url, safe=":/"))
+ fd = open(filename, 'wb')
+ shutil.copyfileobj(response, fd, 0x10000)
+ fd.close()
+ response.close()
+ except:
+ raise RuntimeError("Could not retrieve %s" % url)
+ return filename
+
+
+def write_file(data, path):
+ with open(path, "w") as fd:
+ fd.write(data)
+
+
+def read_file(path):
+ global _fake_files
+ global _fake_paths
+ if _fake_files is not None:
+ if path in _fake_files:
+ return _fake_files[path]
+ if _fake_paths is not None:
+ if path in _fake_paths:
+ path = _fake_paths[path]
+ with open(path) as fd:
+ data = fd.read()
+ return data
+
+
+def fake_file(path, data=None, newpath=None):
+ """
+ Set up a fake file to be read with read_file() in testing
+ If data is specified, the string passed as data will be returned instead
+ if newpath is specified, the file attempted to be read will be replaced
+ by newfile
+ """
+ global _fake_files
+ global _fake_paths
+ if data is not None:
+ if _fake_files is None:
+ _fake_files = {}
+ _fake_files[path] = data
+ if newpath is not None:
+ if _fake_paths is None:
+ _fake_paths = {}
+ _fake_paths[path] = newpath
+
+
+def fake_machine(type):
+ """
+ Set up a fake machine type for testing
+ """
+ global _fake_machine
+ _fake_machine = type
+
+
+def clear_fakes():
+ global _fake_files
+ global _fake_paths
+ _fake_files = {}
+ _fake_paths = {}
+
+
+def clear_fake_machine():
+ global _fake_machine
+ _fake_machine = None
+
+
+def run_and_log(cmd, fd, quiet=False):
+ """
+ Run a command and log the output to fd
+ """
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT, shell=True)
+ while proc.returncode == None:
+ proc.poll()
+ data = proc.stdout.readline()
+ fd.write(data)
+ if quiet is False:
+ sys.stdout.write(data)
+ return proc.returncode
+
+
+def get_machine_type():
+ """
+ Return the machine type
+ """
+ global _fake_machine
+ if _fake_machine is None:
+ return os.uname()[-1]
+ return _fake_machine
+
+
+def get_local_name(url):
+ url = url.strip()
+ url = re.sub('[\/]+$', '', url)
+ rest = urllib2.splittype(url)[1]
+ host, rest = urllib2.splithost(rest)
+ if rest is None or rest == '':
+ return host
+ return os.path.basename(rest)
+
+
+def check_command_exist(command):
+ rc = subprocess.call(["which", command], stdout=open('/dev/null', 'w'))
+ return rc == 0
+
+
+def find_files(target_dir, ext):
+ file_list = []
+ for rootdir, dirs, files in os.walk(target_dir):
+ for f in files:
+ if f.upper().endswith(ext.upper()):
+ file_list.append(os.path.join(rootdir, f))
+
+ file_list.sort()
+ return file_list
+
+
+def delete_files(flist=[]):
+ for f in flist:
+ if os.path.exists(f):
+ os.unlink(f)
+
+
+def stop_at_pattern(command=None, pattern=None, timeout=-1):
+ if not command:
+ return
+
+ if not pattern:
+ response = [pexpect.EOF]
+ else:
+ response = [pattern, pexpect.EOF]
+
+ result = True
+ proc = pexpect.spawn(command, logfile=sys.stdout)
+ try:
+ match_id = proc.expect(response, timeout=timeout)
+ if match_id == 0:
+ time.sleep(5)
+ except pexpect.TIMEOUT:
+ result = False
+ finally:
+ proc.sendcontrol('C')
+ proc.sendline('')
+
+ return result