diff options
Diffstat (limited to 'lava_android_test/test_definitions/hostshells')
6 files changed, 553 insertions, 0 deletions
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 "$@" + |