diff options
author | Botao Sun <botao.sun@linaro.org> | 2015-05-15 22:57:19 +1000 |
---|---|---|
committer | Milosz Wasilewski <milosz.wasilewski@linaro.org> | 2015-05-21 07:50:30 +0000 |
commit | e6509f3dd86f6e21d303032c91f9d770d0cd63d9 (patch) | |
tree | 9da16767b70bdbdd009102ce2d0aaf8f923fa15b | |
parent | 10c705738a37c6a8c10d08b9fb87cb29a609ea80 (diff) |
Android: Add CTS Test for Linaro android images.
This change replaced old lava-android-test to handle CTS test.
Huge bundle size issue has also been solved.
Signed-off by: Botao Sun <botao.sun@linaro.org>
Change-Id: I42679e731c32995cb74a2a0b994fb85b1e8fcc97
-rw-r--r-- | android/cts-host.yaml | 39 | ||||
-rw-r--r-- | android/cts-target.yaml | 33 | ||||
-rwxr-xr-x | android/scripts/cts.py | 102 |
3 files changed, 174 insertions, 0 deletions
diff --git a/android/cts-host.yaml b/android/cts-host.yaml new file mode 100644 index 0000000..9bc00f9 --- /dev/null +++ b/android/cts-host.yaml @@ -0,0 +1,39 @@ +metadata: + name: cts-host + format: "Lava-Test-Shell Test Definition 1.0" + description: "Run CTS on Linaro android. Host side; + Get user defined CTS test command from JSON and run; + The value put in params section in this file is default, user can overwrite them by the values in JSON file." + maintainer: + - botao.sun@linaro.org + os: + - ubuntu + devices: + - kvm + scope: + - functional + +install: + deps: + - xz-utils + - python-lxml + - python-setuptools + +params: + JDK: "default-jdk" + JRE: "default-jre" + CTS_URL: "http://testdata.validation.linaro.org/cts/android-cts-5.0-armv8.zip" + TEST_NAME: "android-cts-5.0-armv8" + TEST_PARAMS: "run cts --package android.aadb --disable-reboot" + +run: + steps: + - apt-add-repository -y http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu + - apt-get update -y + - apt-get install -y android-tools-adb android-tools-fastboot zip $JDK $JRE + - lava-wait $TEST_NAME-send-ip + - IPADDR=`awk -F '=' '{print $2}' /tmp/lava_multi_node_cache.txt` + - adb connect $IPADDR + - adb wait-for-device + - "./android/scripts/cts.py $CTS_URL $TEST_PARAMS" + - lava-sync $TEST_NAME-finished diff --git a/android/cts-target.yaml b/android/cts-target.yaml new file mode 100644 index 0000000..e2200be --- /dev/null +++ b/android/cts-target.yaml @@ -0,0 +1,33 @@ +metadata: + name: cts-target + format: "Lava-Test-Shell Test Definition 1.0" + description: "Run CTS on Linaro android. Target side. + The value put in params section in this file is default, user can overwrite them by the values in JSON file." + maintainer: + - botao.sun@linaro.org + os: + - android + devices: + - panda + - panda-es + - vexpress-a9 + - vexpress-tc2 + - juno + scope: + - functional + +params: + TEST_NAME: "android-cts-5.0-armv8" + +run: + steps: + - lava-test-case step1-cat-build-info --shell cat /system/build.prop + - IPADDR=$(getprop dhcp.eth0.ipaddress) + - if [ -z $IPADDR ]; then netcfg eth0 up; netcfg eth0 dhcp; IPADDR=$(getprop dhcp.eth0.ipaddress); fi + - lava-test-case step2-get-adb --shell getprop service.adb.tcp.port + - lava-test-case step3-set-adb --shell setprop service.adb.tcp.port 5555 + - lava-test-case step3-set-adb --shell setprop service.adb.root 1 + - lava-test-case step4-stop-adbd --shell stop adbd + - lava-test-case step5-start-adbd --shell start adbd + - lava-test-case step6-send-ip --shell lava-send $TEST_NAME-send-ip ipaddr=$IPADDR + - lava-test-case step7-multinode-sync --shell lava-sync $TEST_NAME-finished diff --git a/android/scripts/cts.py b/android/scripts/cts.py new file mode 100755 index 0000000..af08881 --- /dev/null +++ b/android/scripts/cts.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python +# +# CTS test for Linaro Android. +# +# Copyright (C) 2010 - 2015, Linaro Limited. +# +# 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 2 +# 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Author: Botao Sun <botao.sun@linaro.org> + +import os +import sys +import shlex +import urllib +import zipfile +import subprocess +import xml.etree.ElementTree as ET + +# Switch to home path of current user to avoid any permission issue +home_path = os.environ['HOME'] +os.chdir(home_path) +print os.getcwd() + +debug_switcher = False +def collect_result(testcase_id, result): + if debug_switcher is False: + subprocess.call(['lava-test-case', testcase_id, '--result', result]) + else: + print ['lava-test-case', testcase_id, '--result', result] + +def result_parser(xml_file): + tree = ET.parse(xml_file) + # dump test result xml to stdout for debug + if debug_switcher is True: + ET.dump(tree) + root = tree.getroot() + print 'There are ' + str(len(root.findall('TestPackage'))) + ' Test Packages in this test result file: ' + xml_file + testcase_counter = 0 + for elem in root.findall('TestPackage'): + # Naming: Package Name + Test Case Name + Test Name + if 'abi' in elem.attrib.keys(): + package_name = '.'.join([elem.attrib['abi'], elem.attrib['appPackageName']]) + else: + package_name = elem.attrib['appPackageName'] + for testcase in elem.iter('TestCase'): + testcase_name = testcase.attrib['name'] + for test in testcase.iter('Test'): + testcase_counter = testcase_counter + 1 + test_name = test.attrib['name'] + testcase_id = '.'.join([package_name, testcase_name, test_name]) + result = test.attrib['result'] + collect_result(testcase_id, result) + print 'There are ' + str(testcase_counter) + ' test cases in this test result file: ' + xml_file + +# download and extract the CTS zip package +ctsurl = sys.argv[1] +ctsfile = urllib.urlretrieve(ctsurl, ctsurl.split('/')[-1]) +with zipfile.ZipFile(ctsurl.split('/')[-1]) as z: + z.extractall() +z.close() +os.chmod('android-cts/tools/cts-tradefed', 0755) + +# receive user input from JSON file and run +cts_stdout = open('cts_stdout.txt', 'w') +command = 'android-cts/tools/cts-tradefed ' + ' '.join([str(para) for para in sys.argv[2:]]) +print command +return_check = subprocess.call(shlex.split(command), stdout=cts_stdout) +print 'The return value of CTS command run is ' + str(return_check) +if return_check != 0: + # even though the whole command may not run successfully, continue to submit the existing result anyway + # add test case CTS-Command-Check to indicate this incident + print 'CTS command: ' + command + ' run failed!' + collect_result(testcase_id='CTS-Command-Check', result='fail') +cts_stdout.close() + +# compress then attach the CTS stdout file to LAVA bundle +compress = 'xz -9 cts_stdout.txt' +subprocess.call(shlex.split(compress)) +subprocess.call(['lava-test-run-attach', 'cts_stdout.txt.xz']) + +# locate and parse the test result +result_dir = 'android-cts/repository/results' +test_result = 'testResult.xml' +dir_list = [os.path.join(result_dir, item) for item in os.listdir(result_dir) if os.path.isdir(os.path.join(result_dir, item))==True] +print dir_list +for item in dir_list: + if test_result in os.listdir(item): + result_parser(xml_file=os.path.join(item, test_result)) + else: + print 'Could not find the test result file in ' + item + ', Skip!' |