summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYongqin Liu <yongqin.liu@linaro.org>2018-03-05 22:39:11 +0800
committerYongqin Liu <yongqin.liu@linaro.org>2018-03-15 01:15:14 +0800
commit91d5a3b7a1702a20fa89425d373c417fc3e7444d (patch)
tree39be6fa750f93ba334f30c391004a69c41eb8b2e
parent3139ec3018bd07018e1958c9bc0f4c21f0027ab2 (diff)
automated/android: add wifi join test action
which help to connect to WIFI in the lab with the AP_SSID and AP_KEY defined in the job definition Also move the wifi connection call for tradefed test tradefed.sh after make sure the boot is complete Change-Id: I0e87bab99e09e75ae9edf34574402062b6095abc Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
-rwxr-xr-xautomated/android/adb-join-wifi/adb-join-wifi.sh50
-rw-r--r--automated/android/adb-join-wifi/adb-join-wifi.yaml32
-rwxr-xr-xautomated/android/tradefed/setup.sh12
-rwxr-xr-xautomated/android/tradefed/tradefed.sh13
-rw-r--r--automated/android/tradefed/tradefed.yaml2
-rwxr-xr-xautomated/lib/android-test-lib25
6 files changed, 119 insertions, 15 deletions
diff --git a/automated/android/adb-join-wifi/adb-join-wifi.sh b/automated/android/adb-join-wifi/adb-join-wifi.sh
new file mode 100755
index 0000000..427428a
--- /dev/null
+++ b/automated/android/adb-join-wifi/adb-join-wifi.sh
@@ -0,0 +1,50 @@
+#!/bin/sh -e
+# shellcheck disable=SC1091
+
+OUTPUT="$(pwd)/output"
+LOGFILE="${OUTPUT}/ping.log"
+RESULT_FILE="${OUTPUT}/result.txt"
+export RESULT_FILE
+ANDROID_SERIAL=""
+BOOT_TIMEOUT="300"
+SERVER="www.google.com"
+AP_SSID=""
+AP_KEY=""
+
+usage() {
+ echo "Usage: $0 [-s <android_serial>] [-t <boot_timeout>] [-S <server>] [-a <ap_ssid>] [-k <ap_key>]" 1>&2
+ exit 1
+}
+
+while getopts ":s:t:S:a:k:" o; do
+ case "$o" in
+ s) ANDROID_SERIAL="${PTARG}" ;;
+ t) BOOT_TIMEOUT="${OPTARG}" ;;
+ S) SERVER="${OPTARG}" ;;
+ a) AP_SSID="${OPTARG}" ;;
+ k) AP_KEY="${OPTARG}" ;;
+ *) usage ;;
+ esac
+done
+
+. ../../lib/sh-test-lib
+. ../../lib/android-test-lib
+
+initialize_adb
+wait_boot_completed "${BOOT_TIMEOUT}"
+create_out_dir "${OUTPUT}"
+adb_root
+
+# try to connect wifi if AP information specified
+adb_join_wifi "${AP_SSID}" "${AP_KEY}"
+
+# wait for a while till the wifi connecting operation finished
+sleep 60
+
+info_msg "device-${ANDROID_SERIAL}: About to check with ping ${SERVER}..."
+adb shell 'ping -c 10 '"${SERVER}"'; echo exitcode: $?' | tee "${LOGFILE}"
+if grep -q "exitcode: 0" "${LOGFILE}"; then
+ report_pass "adb_join_wifi"
+else
+ report_fail "adb_join_wifi"
+fi
diff --git a/automated/android/adb-join-wifi/adb-join-wifi.yaml b/automated/android/adb-join-wifi/adb-join-wifi.yaml
new file mode 100644
index 0000000..85df455
--- /dev/null
+++ b/automated/android/adb-join-wifi/adb-join-wifi.yaml
@@ -0,0 +1,32 @@
+metadata:
+ name: adb-join-wifi
+ format: "Lava-Test-Shell Test Definition 1.0"
+ description: "Run tradefed based tests in LAVA."
+ maintainer:
+ - milosz.wasilewski@linaro.org
+ - chase.qi@linaro.org
+ os:
+ - debian
+ - ubuntu
+ devices:
+ - lxc
+ scope:
+ - functional
+
+params:
+ # Specify device serial no. when more than one device connected.
+ ANDROID_SERIAL: ""
+ # Specify timeout in seconds for wait_boot_completed.
+ BOOT_TIMEOUT: "300"
+ # Specify the server to ping.
+ SERVER: "www.google.com"
+ ## WIFI AP SSID
+ AP_SSID: ""
+ ## KEY for WIFI AP
+ AP_KEY: ""
+
+run:
+ steps:
+ - cd ./automated/android/adb-join-wifi
+ - ./adb-join-wifi.sh -s "${ANDROID_SERIAL}" -t "${BOOT_TIMEOUT}" -S "${SERVER}" -a "${AP_SSID}" -k "${AP_KEY}"
+ - ../../utils/send-to-lava.sh ./output/result.txt
diff --git a/automated/android/tradefed/setup.sh b/automated/android/tradefed/setup.sh
index de4c359..e0f38d3 100755
--- a/automated/android/tradefed/setup.sh
+++ b/automated/android/tradefed/setup.sh
@@ -26,15 +26,3 @@ esac
install_latest_adb
initialize_adb
adb_root
-
-lava_test_dir="$(find /lava-* -maxdepth 0 -type d -regex '/lava-[0-9]+' 2>/dev/null | sort | tail -1)"
-if test -f "${lava_test_dir}/secrets"; then
- # shellcheck disable=SC1090
- . "${lava_test_dir}/secrets"
-fi
-
-if [ ! -z "${AP_SSID}" ] && [ ! -z "${AP_KEY}" ]; then
- wget http://testdata.validation.linaro.org/apks/wifi/wifi.apk
- adb install wifi.apk
- adb shell am start -n com.steinwurf.adbjoinwifi/.MainActivity -e ssid "${AP_SSID}" -e password_type WPA -e password "${AP_KEY}"
-fi
diff --git a/automated/android/tradefed/tradefed.sh b/automated/android/tradefed/tradefed.sh
index ff696bf..112473c 100755
--- a/automated/android/tradefed/tradefed.sh
+++ b/automated/android/tradefed/tradefed.sh
@@ -15,13 +15,17 @@ RESULT_FILE="$(pwd)/output/result.txt"
export RESULT_FILE
# the default number of failed test cases to be printed
FAILURES_PRINTED="0"
+# WIFI AP SSID
+AP_SSID=""
+# WIFI AP KEY
+AP_KEY=""
usage() {
- echo "Usage: $0 [-o timeout] [-n serialno] [-c cts_url] [-t test_params] [-p test_path] [-r <aggregated|atomic>] [-f failures_printed]" 1>&2
+ echo "Usage: $0 [-o timeout] [-n serialno] [-c cts_url] [-t test_params] [-p test_path] [-r <aggregated|atomic>] [-f failures_printed] [-a <ap_ssid>] [-k <ap_key>]" 1>&2
exit 1
}
-while getopts ':o:n:c:t:p:r:f:' opt; do
+while getopts ':o:n:c:t:p:r:f:a:k:' opt; do
case "${opt}" in
o) TIMEOUT="${OPTARG}" ;;
n) export ANDROID_SERIAL="${OPTARG}" ;;
@@ -30,6 +34,8 @@ while getopts ':o:n:c:t:p:r:f:' opt; do
p) TEST_PATH="${OPTARG}" ;;
r) RESULT_FORMAT="${OPTARG}" ;;
f) FAILURES_PRINTED="${OPTARG}" ;;
+ a) AP_SSID="${OPTARG}" ;;
+ k) AP_KEY="${OPTARG}" ;;
*) usage ;;
esac
done
@@ -74,6 +80,9 @@ if [ -e "${TEST_PATH}/testcases/vts/testcases/kernel/linux_kselftest/kselftest_c
sed -i "/suspend/d" "${TEST_PATH}"/testcases/vts/testcases/kernel/linux_kselftest/kselftest_config.py
fi
+# try to connect wifi if AP information specified
+adb_join_wifi "${AP_SSID}" "${AP_KEY}"
+
# Run tradefed test.
info_msg "About to run tradefed shell on device ${ANDROID_SERIAL}"
./tradefed-runner.py -t "${TEST_PARAMS}" -p "${TEST_PATH}" -r "${RESULT_FORMAT}" -f "${FAILURES_PRINTED}"
diff --git a/automated/android/tradefed/tradefed.yaml b/automated/android/tradefed/tradefed.yaml
index e30f074..07cbcb0 100644
--- a/automated/android/tradefed/tradefed.yaml
+++ b/automated/android/tradefed/tradefed.yaml
@@ -45,7 +45,7 @@ run:
# create test use to run the cts/vts tests
- useradd -m testuser && echo "testuser created successfully"
- chown testuser:testuser .
- - sudo -u testuser ./tradefed.sh -o "${TIMEOUT}" -c "${TEST_URL}" -t "${TEST_PARAMS}" -p "${TEST_PATH}" -r "${RESULTS_FORMAT}" -n "${ANDROID_SERIAL}" -f "${FAILURES_PRINTED}"
+ - sudo -u testuser ./tradefed.sh -o "${TIMEOUT}" -c "${TEST_URL}" -t "${TEST_PARAMS}" -p "${TEST_PATH}" -r "${RESULTS_FORMAT}" -n "${ANDROID_SERIAL}" -f "${FAILURES_PRINTED}" -a "${AP_SSID}" -k "${AP_KEY}"
# Upload test log and result files to artifactorial.
- cp -r ./${TEST_PATH}/results ./output/ || true
- cp -r ./${TEST_PATH}/logs ./output/ || true
diff --git a/automated/lib/android-test-lib b/automated/lib/android-test-lib
index a904411..1b7e4af 100755
--- a/automated/lib/android-test-lib
+++ b/automated/lib/android-test-lib
@@ -227,3 +227,28 @@ parse_common_args() {
esac
done
}
+
+# Try to find the WIFI AP info and connect to it
+# depends on WIFI AP information specified by lava job like following:
+# secrets:
+# AP_SSID: "${AP_SSID}"
+# AP_KEY: "${AP_KEY}"
+adb_join_wifi() {
+ AP_SSID=$1
+ AP_KEY=$2
+ if [ -z "${AP_SSID}" ] || [ -z "${AP_KEY}" ]; then
+ # Try to find the WIFI AP information specified by the job definition if not specified via command line
+ lava_test_dir="$(find /lava-* -maxdepth 0 -type d -regex '/lava-[0-9]+' 2>/dev/null | sort | tail -1)"
+ if test -f "${lava_test_dir}/secrets"; then
+ # shellcheck disable=SC1090
+ . "${lava_test_dir}/secrets"
+ fi
+ fi
+
+ # Try to connect to wifi if found the WIFI AP information
+ if [ ! -z "${AP_SSID}" ] && [ ! -z "${AP_KEY}" ]; then
+ wget http://testdata.validation.linaro.org/apks/wifi/wifi.apk
+ adb install wifi.apk
+ adb shell am start -n com.steinwurf.adbjoinwifi/.MainActivity -e ssid "${AP_SSID}" -e password_type WPA -e password "${AP_KEY}"
+ fi
+}