aboutsummaryrefslogtreecommitdiff
path: root/lava_android_test/test_definitions
diff options
context:
space:
mode:
Diffstat (limited to 'lava_android_test/test_definitions')
-rw-r--r--lava_android_test/test_definitions/0xbench.py89
-rw-r--r--lava_android_test/test_definitions/__init__.py0
-rw-r--r--lava_android_test/test_definitions/android-0xbenchmark/ZeroxBench_Preference.xml5
-rwxr-xr-xlava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_kill.py69
-rw-r--r--lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_modify_path.py121
-rwxr-xr-xlava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_wait.py54
-rw-r--r--lava_android_test/test_definitions/bctest.py52
-rw-r--r--lava_android_test/test_definitions/big_LITTLE.py51
-rw-r--r--lava_android_test/test_definitions/blackbox.py494
-rw-r--r--lava_android_test/test_definitions/bluetooth.py47
-rw-r--r--lava_android_test/test_definitions/busybox.py57
-rwxr-xr-xlava_android_test/test_definitions/busybox/busybox_test.sh35
-rw-r--r--lava_android_test/test_definitions/cache_coherency.py47
-rw-r--r--lava_android_test/test_definitions/commands/__init__.py30
-rw-r--r--lava_android_test/test_definitions/commands/bionic_libc_tests.py29
-rw-r--r--lava_android_test/test_definitions/commands/example.py31
-rw-r--r--lava_android_test/test_definitions/commands/linaro_android_kernel_test.py30
-rw-r--r--lava_android_test/test_definitions/commands/tjunittest.py30
-rw-r--r--lava_android_test/test_definitions/cts.py70
-rwxr-xr-xlava_android_test/test_definitions/cts/cts_list_result_wrapper.sh26
-rwxr-xr-xlava_android_test/test_definitions/cts/cts_prepare.sh131
-rwxr-xr-xlava_android_test/test_definitions/cts/cts_redirect.sh24
-rwxr-xr-xlava_android_test/test_definitions/cts/cts_run_wrapper.sh25
-rwxr-xr-xlava_android_test/test_definitions/cts/cts_wrapper.py353
-rw-r--r--lava_android_test/test_definitions/cts/ctshelper.jarbin0 -> 1738 bytes
-rw-r--r--lava_android_test/test_definitions/gatortest.py52
-rw-r--r--lava_android_test/test_definitions/gatortest/daemoncheck.py20
-rw-r--r--lava_android_test/test_definitions/gatortest/modulecheck.py20
-rw-r--r--lava_android_test/test_definitions/glmark2.py52
-rwxr-xr-xlava_android_test/test_definitions/glmark2/glmark2.sh35
-rwxr-xr-xlava_android_test/test_definitions/glmark2/glmark2_wait.py51
-rw-r--r--lava_android_test/test_definitions/helloworld.py46
-rw-r--r--lava_android_test/test_definitions/hostshells/__init__.py31
-rwxr-xr-xlava_android_test/test_definitions/hostshells/connect-lab-wifi.sh170
-rwxr-xr-xlava_android_test/test_definitions/hostshells/example.sh62
-rwxr-xr-xlava_android_test/test_definitions/hostshells/install-overlay.sh79
-rwxr-xr-xlava_android_test/test_definitions/hostshells/sdcard-mounted.sh65
-rwxr-xr-xlava_android_test/test_definitions/hostshells/workload.sh146
-rw-r--r--lava_android_test/test_definitions/ime.py57
-rwxr-xr-xlava_android_test/test_definitions/ime/ime_test.sh13
-rw-r--r--lava_android_test/test_definitions/install_prep_4bench.py46
-rw-r--r--lava_android_test/test_definitions/instruments/__init__.py28
-rw-r--r--lava_android_test/test_definitions/instruments/example.py32
-rw-r--r--lava_android_test/test_definitions/iozone.py118
-rwxr-xr-xlava_android_test/test_definitions/iozone/iozone.sh14
-rw-r--r--lava_android_test/test_definitions/memtester.py45
-rw-r--r--lava_android_test/test_definitions/methanol.py65
-rwxr-xr-xlava_android_test/test_definitions/methanol/methanol.sh327
-rwxr-xr-xlava_android_test/test_definitions/methanol/methanol_merge_results.py86
-rwxr-xr-xlava_android_test/test_definitions/methanol/start_server.py62
-rw-r--r--lava_android_test/test_definitions/mmtest.py63
-rw-r--r--lava_android_test/test_definitions/monkey.py57
-rwxr-xr-xlava_android_test/test_definitions/monkey/monkey.sh6
-rw-r--r--lava_android_test/test_definitions/monkey_long_run.py78
-rw-r--r--lava_android_test/test_definitions/monkey_long_run/juice_package_black_list7
-rwxr-xr-xlava_android_test/test_definitions/monkey_long_run/monkey_long_run.sh13
-rw-r--r--lava_android_test/test_definitions/monkey_long_run/package_black_list2
-rw-r--r--lava_android_test/test_definitions/pm_qa.py58
-rwxr-xr-xlava_android_test/test_definitions/pm_qa/pm-qa.sh63
-rw-r--r--lava_android_test/test_definitions/sched_tests.py49
-rw-r--r--lava_android_test/test_definitions/shells/__init__.py33
-rwxr-xr-xlava_android_test/test_definitions/shells/binder.sh13
-rwxr-xr-xlava_android_test/test_definitions/shells/custom.sh14
-rwxr-xr-xlava_android_test/test_definitions/shells/dalvik-vm-unit-tests.sh12
-rwxr-xr-xlava_android_test/test_definitions/shells/example.sh4
-rw-r--r--lava_android_test/test_definitions/skia.py89
-rw-r--r--lava_android_test/test_definitions/sleep.py48
-rw-r--r--lava_android_test/test_definitions/task_placement.py49
-rw-r--r--lava_android_test/test_definitions/tjbench.py140
-rw-r--r--lava_android_test/test_definitions/usbhardware.py56
-rwxr-xr-xlava_android_test/test_definitions/usbhardware/usbhardware.sh13
-rw-r--r--lava_android_test/test_definitions/v8.py53
72 files changed, 4542 insertions, 0 deletions
diff --git a/lava_android_test/test_definitions/0xbench.py b/lava_android_test/test_definitions/0xbench.py
new file mode 100644
index 0000000..8327629
--- /dev/null
+++ b/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/lava_android_test/test_definitions/__init__.py b/lava_android_test/test_definitions/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/lava_android_test/test_definitions/__init__.py
diff --git a/lava_android_test/test_definitions/android-0xbenchmark/ZeroxBench_Preference.xml b/lava_android_test/test_definitions/android-0xbenchmark/ZeroxBench_Preference.xml
new file mode 100644
index 0000000..6f07a12
--- /dev/null
+++ b/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/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_kill.py b/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_kill.py
new file mode 100755
index 0000000..17a4fd7
--- /dev/null
+++ b/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/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_modify_path.py b/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_modify_path.py
new file mode 100644
index 0000000..0b0d309
--- /dev/null
+++ b/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/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_wait.py b/lava_android_test/test_definitions/android-0xbenchmark/android_0xbenchmark_wait.py
new file mode 100755
index 0000000..dcfdbfc
--- /dev/null
+++ b/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/lava_android_test/test_definitions/bctest.py b/lava_android_test/test_definitions/bctest.py
new file mode 100644
index 0000000..5609277
--- /dev/null
+++ b/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/lava_android_test/test_definitions/big_LITTLE.py b/lava_android_test/test_definitions/big_LITTLE.py
new file mode 100644
index 0000000..7aa6b1f
--- /dev/null
+++ b/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/lava_android_test/test_definitions/blackbox.py b/lava_android_test/test_definitions/blackbox.py
new file mode 100644
index 0000000..790569b
--- /dev/null
+++ b/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/lava_android_test/test_definitions/bluetooth.py b/lava_android_test/test_definitions/bluetooth.py
new file mode 100644
index 0000000..2ca1d8c
--- /dev/null
+++ b/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/lava_android_test/test_definitions/busybox.py b/lava_android_test/test_definitions/busybox.py
new file mode 100644
index 0000000..cc32fcc
--- /dev/null
+++ b/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/lava_android_test/test_definitions/busybox/busybox_test.sh b/lava_android_test/test_definitions/busybox/busybox_test.sh
new file mode 100755
index 0000000..4b3bd4e
--- /dev/null
+++ b/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/busybox 1>/dev/null 2>/dev/null
+
+test_func mkdir /data/busybox
+test_func touch /data/busybox/test.txt
+test_func ls /data/busybox/test.txt
+test_func ps
+test_func whoami
+test_func which busybox
+test_func basename /data/busybox/test.txt
+test_func cp /data/busybox/test.txt /data/busybox/test2.txt
+test_func rm /data/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/lava_android_test/test_definitions/cache_coherency.py b/lava_android_test/test_definitions/cache_coherency.py
new file mode 100644
index 0000000..72f1709
--- /dev/null
+++ b/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/lava_android_test/test_definitions/commands/__init__.py b/lava_android_test/test_definitions/commands/__init__.py
new file mode 100644
index 0000000..075f164
--- /dev/null
+++ b/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/lava_android_test/test_definitions/commands/bionic_libc_tests.py b/lava_android_test/test_definitions/commands/bionic_libc_tests.py
new file mode 100644
index 0000000..4beaac3
--- /dev/null
+++ b/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/lava_android_test/test_definitions/commands/example.py b/lava_android_test/test_definitions/commands/example.py
new file mode 100644
index 0000000..2a175da
--- /dev/null
+++ b/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/lava_android_test/test_definitions/commands/linaro_android_kernel_test.py b/lava_android_test/test_definitions/commands/linaro_android_kernel_test.py
new file mode 100644
index 0000000..39fd33c
--- /dev/null
+++ b/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/lava_android_test/test_definitions/commands/tjunittest.py b/lava_android_test/test_definitions/commands/tjunittest.py
new file mode 100644
index 0000000..e377fc4
--- /dev/null
+++ b/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/lava_android_test/test_definitions/cts.py b/lava_android_test/test_definitions/cts.py
new file mode 100644
index 0000000..6e0eec7
--- /dev/null
+++ b/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/lava_android_test/test_definitions/cts/cts_list_result_wrapper.sh b/lava_android_test/test_definitions/cts/cts_list_result_wrapper.sh
new file mode 100755
index 0000000..b6ef869
--- /dev/null
+++ b/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/lava_android_test/test_definitions/cts/cts_prepare.sh b/lava_android_test/test_definitions/cts/cts_prepare.sh
new file mode 100755
index 0000000..6b677a6
--- /dev/null
+++ b/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/lava_android_test/test_definitions/cts/cts_redirect.sh b/lava_android_test/test_definitions/cts/cts_redirect.sh
new file mode 100755
index 0000000..b23b3a5
--- /dev/null
+++ b/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/lava_android_test/test_definitions/cts/cts_run_wrapper.sh b/lava_android_test/test_definitions/cts/cts_run_wrapper.sh
new file mode 100755
index 0000000..6e4e5ba
--- /dev/null
+++ b/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/lava_android_test/test_definitions/cts/cts_wrapper.py b/lava_android_test/test_definitions/cts/cts_wrapper.py
new file mode 100755
index 0000000..b6d46bf
--- /dev/null
+++ b/lava_android_test/test_definitions/cts/cts_wrapper.py
@@ -0,0 +1,353 @@
+#!/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
+ force_abi = None
+ #--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')
+
+ force_abi = get_value_from_paras(paras=paras, option='--force-abi')
+
+ 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())
+
+ if force_abi:
+ run_wrapper_cmd = '%s --force-abi %s' % (run_wrapper_cmd,
+ force_abi)
+
+ 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/lava_android_test/test_definitions/cts/ctshelper.jar b/lava_android_test/test_definitions/cts/ctshelper.jar
new file mode 100644
index 0000000..0c253ae
--- /dev/null
+++ b/lava_android_test/test_definitions/cts/ctshelper.jar
Binary files differ
diff --git a/lava_android_test/test_definitions/gatortest.py b/lava_android_test/test_definitions/gatortest.py
new file mode 100644
index 0000000..a04ad6c
--- /dev/null
+++ b/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/lava_android_test/test_definitions/gatortest/daemoncheck.py b/lava_android_test/test_definitions/gatortest/daemoncheck.py
new file mode 100644
index 0000000..a1fa1b9
--- /dev/null
+++ b/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/lava_android_test/test_definitions/gatortest/modulecheck.py b/lava_android_test/test_definitions/gatortest/modulecheck.py
new file mode 100644
index 0000000..23f0ba6
--- /dev/null
+++ b/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/lava_android_test/test_definitions/glmark2.py b/lava_android_test/test_definitions/glmark2.py
new file mode 100644
index 0000000..f111c90
--- /dev/null
+++ b/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/lava_android_test/test_definitions/glmark2/glmark2.sh b/lava_android_test/test_definitions/glmark2/glmark2.sh
new file mode 100755
index 0000000..2a9b410
--- /dev/null
+++ b/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/lava_android_test/test_definitions/glmark2/glmark2_wait.py b/lava_android_test/test_definitions/glmark2/glmark2_wait.py
new file mode 100755
index 0000000..5c680ce
--- /dev/null
+++ b/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/lava_android_test/test_definitions/helloworld.py b/lava_android_test/test_definitions/helloworld.py
new file mode 100644
index 0000000..40ad04e
--- /dev/null
+++ b/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/lava_android_test/test_definitions/hostshells/__init__.py b/lava_android_test/test_definitions/hostshells/__init__.py
new file mode 100644
index 0000000..dcb0716
--- /dev/null
+++ b/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/lava_android_test/test_definitions/hostshells/connect-lab-wifi.sh b/lava_android_test/test_definitions/hostshells/connect-lab-wifi.sh
new file mode 100755
index 0000000..d04233d
--- /dev/null
+++ b/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/lava_android_test/test_definitions/hostshells/example.sh b/lava_android_test/test_definitions/hostshells/example.sh
new file mode 100755
index 0000000..50c81b7
--- /dev/null
+++ b/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/lava_android_test/test_definitions/hostshells/install-overlay.sh b/lava_android_test/test_definitions/hostshells/install-overlay.sh
new file mode 100755
index 0000000..996bcbb
--- /dev/null
+++ b/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/lava_android_test/test_definitions/hostshells/sdcard-mounted.sh b/lava_android_test/test_definitions/hostshells/sdcard-mounted.sh
new file mode 100755
index 0000000..4257850
--- /dev/null
+++ b/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/lava_android_test/test_definitions/hostshells/workload.sh b/lava_android_test/test_definitions/hostshells/workload.sh
new file mode 100755
index 0000000..a01a4a1
--- /dev/null
+++ b/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/lava_android_test/test_definitions/ime.py b/lava_android_test/test_definitions/ime.py
new file mode 100644
index 0000000..aacaef6
--- /dev/null
+++ b/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/lava_android_test/test_definitions/ime/ime_test.sh b/lava_android_test/test_definitions/ime/ime_test.sh
new file mode 100755
index 0000000..6a6d7a1
--- /dev/null
+++ b/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/lava_android_test/test_definitions/install_prep_4bench.py b/lava_android_test/test_definitions/install_prep_4bench.py
new file mode 100644
index 0000000..2687adc
--- /dev/null
+++ b/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/lava_android_test/test_definitions/instruments/__init__.py b/lava_android_test/test_definitions/instruments/__init__.py
new file mode 100644
index 0000000..43e06ba
--- /dev/null
+++ b/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/lava_android_test/test_definitions/instruments/example.py b/lava_android_test/test_definitions/instruments/example.py
new file mode 100644
index 0000000..b5c73d0
--- /dev/null
+++ b/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/lava_android_test/test_definitions/iozone.py b/lava_android_test/test_definitions/iozone.py
new file mode 100644
index 0000000..ab9a0b2
--- /dev/null
+++ b/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/lava_android_test/test_definitions/iozone/iozone.sh b/lava_android_test/test_definitions/iozone/iozone.sh
new file mode 100755
index 0000000..1820f86
--- /dev/null
+++ b/lava_android_test/test_definitions/iozone/iozone.sh
@@ -0,0 +1,14 @@
+#!/system/bin/sh
+#$1 is the testing location. The -b must be specified for parser.
+#the file itself does not matter as it is not used.
+#The -b cause results reports to be printed to stdout.
+
+#uncomment the following and add cross compiled iozone to this directory.
+#mount -o remount,rw /
+#iozone_cmd=$1"/iozone -a -i 0 -i 2 -s 16m -V teststring -b iozone_results"
+
+#The original command with a -b so excel results are printed to stdout and can be parsed
+iozone_cmd="iozone -a -i 0 -i 2 -s 16m -V teststring -b iozone_results"
+echo execute command=${iozone_cmd}
+${iozone_cmd}
+echo IOZONE_RET_CODE=$?
diff --git a/lava_android_test/test_definitions/memtester.py b/lava_android_test/test_definitions/memtester.py
new file mode 100644
index 0000000..2ddad92
--- /dev/null
+++ b/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/lava_android_test/test_definitions/methanol.py b/lava_android_test/test_definitions/methanol.py
new file mode 100644
index 0000000..5785317
--- /dev/null
+++ b/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/lava_android_test/test_definitions/methanol/methanol.sh b/lava_android_test/test_definitions/methanol/methanol.sh
new file mode 100755
index 0000000..81e2598
--- /dev/null
+++ b/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/lava_android_test/test_definitions/methanol/methanol_merge_results.py b/lava_android_test/test_definitions/methanol/methanol_merge_results.py
new file mode 100755
index 0000000..a57c602
--- /dev/null
+++ b/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/lava_android_test/test_definitions/methanol/start_server.py b/lava_android_test/test_definitions/methanol/start_server.py
new file mode 100755
index 0000000..6ca96b5
--- /dev/null
+++ b/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/lava_android_test/test_definitions/mmtest.py b/lava_android_test/test_definitions/mmtest.py
new file mode 100644
index 0000000..985a650
--- /dev/null
+++ b/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/lava_android_test/test_definitions/monkey.py b/lava_android_test/test_definitions/monkey.py
new file mode 100644
index 0000000..944d8ae
--- /dev/null
+++ b/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/lava_android_test/test_definitions/monkey/monkey.sh b/lava_android_test/test_definitions/monkey/monkey.sh
new file mode 100755
index 0000000..c774680
--- /dev/null
+++ b/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/lava_android_test/test_definitions/monkey_long_run.py b/lava_android_test/test_definitions/monkey_long_run.py
new file mode 100644
index 0000000..d3d448d
--- /dev/null
+++ b/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/lava_android_test/test_definitions/monkey_long_run/juice_package_black_list b/lava_android_test/test_definitions/monkey_long_run/juice_package_black_list
new file mode 100644
index 0000000..8899c05
--- /dev/null
+++ b/lava_android_test/test_definitions/monkey_long_run/juice_package_black_list
@@ -0,0 +1,7 @@
+com.android.browser
+com.android.development
+com.android.quicksearchbox
+com.android.speechrecorder
+com.android.connectivitymanagertest
+org.linaro.glmark2
+com.android.gallery3d
diff --git a/lava_android_test/test_definitions/monkey_long_run/monkey_long_run.sh b/lava_android_test/test_definitions/monkey_long_run/monkey_long_run.sh
new file mode 100755
index 0000000..afdc249
--- /dev/null
+++ b/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/lava_android_test/test_definitions/monkey_long_run/package_black_list b/lava_android_test/test_definitions/monkey_long_run/package_black_list
new file mode 100644
index 0000000..0fc6125
--- /dev/null
+++ b/lava_android_test/test_definitions/monkey_long_run/package_black_list
@@ -0,0 +1,2 @@
+com.android.camera
+com.android.connectivitymanagertest
diff --git a/lava_android_test/test_definitions/pm_qa.py b/lava_android_test/test_definitions/pm_qa.py
new file mode 100644
index 0000000..bf2cff8
--- /dev/null
+++ b/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/lava_android_test/test_definitions/pm_qa/pm-qa.sh b/lava_android_test/test_definitions/pm_qa/pm-qa.sh
new file mode 100755
index 0000000..a570d8e
--- /dev/null
+++ b/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/lava_android_test/test_definitions/sched_tests.py b/lava_android_test/test_definitions/sched_tests.py
new file mode 100644
index 0000000..df91439
--- /dev/null
+++ b/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/lava_android_test/test_definitions/shells/__init__.py b/lava_android_test/test_definitions/shells/__init__.py
new file mode 100644
index 0000000..7c13426
--- /dev/null
+++ b/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/lava_android_test/test_definitions/shells/binder.sh b/lava_android_test/test_definitions/shells/binder.sh
new file mode 100755
index 0000000..d3fb43d
--- /dev/null
+++ b/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/lava_android_test/test_definitions/shells/custom.sh b/lava_android_test/test_definitions/shells/custom.sh
new file mode 100755
index 0000000..4b78632
--- /dev/null
+++ b/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/lava_android_test/test_definitions/shells/dalvik-vm-unit-tests.sh b/lava_android_test/test_definitions/shells/dalvik-vm-unit-tests.sh
new file mode 100755
index 0000000..65ca818
--- /dev/null
+++ b/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/lava_android_test/test_definitions/shells/example.sh b/lava_android_test/test_definitions/shells/example.sh
new file mode 100755
index 0000000..7e7e858
--- /dev/null
+++ b/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/lava_android_test/test_definitions/skia.py b/lava_android_test/test_definitions/skia.py
new file mode 100644
index 0000000..8edbaee
--- /dev/null
+++ b/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/lava_android_test/test_definitions/sleep.py b/lava_android_test/test_definitions/sleep.py
new file mode 100644
index 0000000..faf39ad
--- /dev/null
+++ b/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/lava_android_test/test_definitions/task_placement.py b/lava_android_test/test_definitions/task_placement.py
new file mode 100644
index 0000000..04fe252
--- /dev/null
+++ b/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/lava_android_test/test_definitions/tjbench.py b/lava_android_test/test_definitions/tjbench.py
new file mode 100644
index 0000000..f86f3d6
--- /dev/null
+++ b/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/lava_android_test/test_definitions/usbhardware.py b/lava_android_test/test_definitions/usbhardware.py
new file mode 100644
index 0000000..8a2a796
--- /dev/null
+++ b/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/lava_android_test/test_definitions/usbhardware/usbhardware.sh b/lava_android_test/test_definitions/usbhardware/usbhardware.sh
new file mode 100755
index 0000000..d7e8f7d
--- /dev/null
+++ b/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/lava_android_test/test_definitions/v8.py b/lava_android_test/test_definitions/v8.py
new file mode 100644
index 0000000..e017f00
--- /dev/null
+++ b/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)