blob: eac7ad0c9bc81a88bdf89128e8804b7157fdd78a [file] [log] [blame]
Chase Qifd6dd1e2017-05-04 13:20:15 +08001#!/bin/sh -ex
2# shellcheck disable=SC1090
3
4TEST_DIR=$(dirname "$(realpath "$0")")
5OUTPUT="${TEST_DIR}/output"
Chase Qifd6dd1e2017-05-04 13:20:15 +08006SKIP_INSTALL="false"
7ANDROID_SERIAL=""
8BOOT_TIMEOUT="300"
Lisa Nguyenb8c25bd2018-01-31 13:21:07 -08009PROBE=""
Chase Qifd6dd1e2017-05-04 13:20:15 +080010WA_TAG="master"
Milosz Wasilewski52179ae2018-03-23 04:46:09 +000011WA_GIT_REPO="https://github.com/ARM-software/workload-automation"
Chase Qifd6dd1e2017-05-04 13:20:15 +080012WA_TEMPLATES_REPO="https://git.linaro.org/qa/wa2-lava.git"
13TEMPLATES_BRANCH="wa-templates"
14CONFIG="config/generic-android.py"
15AGENDA="agenda/generic-linpack.yaml"
16BUILD_TOOLS_URL="http://testdata.validation.linaro.org/apks/workload-automation/build-tools.tar.gz"
17WA_HOME_URL="http://testdata.validation.linaro.org/apks/workload-automation/workload_automation_home.tar.gz"
Milosz Wasilewskid3a509a2018-04-09 12:44:44 +010018DEVLIB_REPO="https://github.com/ARM-software/devlib.git"
19DEVLIB_TAG="master"
Chase Qifd6dd1e2017-05-04 13:20:15 +080020
21usage() {
Milosz Wasilewskid3a509a2018-04-09 12:44:44 +010022 echo "Usage: $0 [-s <true|false>] [-S <android_serial>] [-t <boot_timeout>] [-T <wa_tag>] [-r <wa_templates_repo>] [-g <templates_branch>] [-c <config>] [-a <agenda>] [-b <build_tools_url>] [-w <wa_home_url>] [-p <aep_path>] [-o <output_dir>] [-R <wa_git_repository>] [-d <devlib_repo>] [-D <devlib_tag>]" 1>&2
Chase Qifd6dd1e2017-05-04 13:20:15 +080023 exit 1
24}
25
Milosz Wasilewskid3a509a2018-04-09 12:44:44 +010026while getopts ":s:S:t:T:r:g:c:a:b:w:p:o:R:D:d:" opt; do
Chase Qifd6dd1e2017-05-04 13:20:15 +080027 case "${opt}" in
28 s) SKIP_INSTALL="${OPTARG}" ;;
29 S) ANDROID_SERIAL="${OPTARG}" ;;
30 t) BOOT_TIMEOUT="${OPTARG}" ;;
31 T) WA_TAG="${OPTARG}" ;;
32 r) WA_TEMPLATES_REPO="${OPTARG}" ;;
33 g) TEMPLATES_BRANCH="${OPTARG}" ;;
34 c) CONFIG="${OPTARG}" ;;
35 a) AGENDA="${OPTARG}" ;;
36 b) BUILD_TOOLS_URL="${OPTARG}" ;;
37 w) WA_HOME_URL="${OPTARG}" ;;
Milosz Wasilewski52179ae2018-03-23 04:46:09 +000038 R) WA_GIT_REPO="${OPTARG}" ;;
Lisa Nguyenb8c25bd2018-01-31 13:21:07 -080039 p) PROBE="${OPTARG}" ;;
Milosz Wasilewski6bb7a682018-02-22 08:44:41 +000040 o) NEW_OUTPUT="${OPTARG}" ;;
Milosz Wasilewskid3a509a2018-04-09 12:44:44 +010041 D) DEVLIB_TAG="${OPTARG}" ;;
42 d) DEVLIB_REPO="${OPTARG}" ;;
Chase Qifd6dd1e2017-05-04 13:20:15 +080043 *) usage ;;
44 esac
45done
46
47. "${TEST_DIR}/../../lib/sh-test-lib"
48. "${TEST_DIR}/../../lib/android-test-lib"
49
50cd "${TEST_DIR}"
Milosz Wasilewski6bb7a682018-02-22 08:44:41 +000051if [ ! -z "${NEW_OUTPUT}" ]; then
52 OUTPUT="${NEW_OUTPUT}"
53fi
Chase Qifd6dd1e2017-05-04 13:20:15 +080054create_out_dir "${OUTPUT}"
Milosz Wasilewski6bb7a682018-02-22 08:44:41 +000055RESULT_FILE="${OUTPUT}/result.txt"
56export RESULT_FILE
Chase Qifd6dd1e2017-05-04 13:20:15 +080057
58if [ "${SKIP_INSTALL}" = "true" ] || [ "${SKIP_INSTALL}" = "True" ]; then
59 info_msg "WA installation skipped"
60else
Milosz Wasilewski584800b2018-03-20 07:35:08 +000061 PKGS="git wget zip tar xz-utils python python-yaml python-lxml python-setuptools python-numpy python-colorama python-pip sqlite3 lib32stdc++6 lib32z1 lib32gcc1 lib32ncurses5 aapt time sysstat python-jinja2 curl"
Chase Qifd6dd1e2017-05-04 13:20:15 +080062 ! check_root && error_msg "Please run this test as root."
63 dpkg --add-architecture i386
Karsten Tausche3546a7c2018-03-20 10:47:31 +010064 apt-get update -q
Chase Qifd6dd1e2017-05-04 13:20:15 +080065 install_deps "${PKGS}"
Milosz Wasilewski584800b2018-03-20 07:35:08 +000066 # only install adb if it's not already available
67 which adb || install_deps adb
Milosz Wasilewski9d840e82018-02-28 16:28:36 +000068 pip install --upgrade --quiet pip && hash -r
69 pip install --upgrade --quiet setuptools
70 pip install --quiet pexpect pyserial pyyaml docutils python-dateutil
Milosz Wasilewskid3a509a2018-04-09 12:44:44 +010071 info_msg "Installing devlib..."
72 rm -rf devlib
73 git clone "${DEVLIB_REPO}" devlib
74 (
75 cd devlib
76 git checkout "${DEVLIB_TAG}"
77 )
78 pip2 install --quiet ./devlib
Chase Qifd6dd1e2017-05-04 13:20:15 +080079 info_msg "Installing workload-automation..."
80 rm -rf workload-automation
Milosz Wasilewski52179ae2018-03-23 04:46:09 +000081 git clone "${WA_GIT_REPO}" workload-automation
Chase Qifd6dd1e2017-05-04 13:20:15 +080082 (
83 cd workload-automation
Milosz Wasilewski0fab9252018-02-28 14:54:53 +000084 git checkout "${WA_TAG}"
Chase Qifd6dd1e2017-05-04 13:20:15 +080085 )
Milosz Wasilewski9d840e82018-02-28 16:28:36 +000086 pip2 install --quiet ./workload-automation
Chase Qifd6dd1e2017-05-04 13:20:15 +080087 export PATH=$PATH:/usr/local/bin
88 which wa
89
90 info_msg "Installing SDK build-tools..."
91 (
92 cd /usr/
93 # Copy build-tools.tar.gz to /usr for local run.
94 test -f build-tools.tar.gz || wget -S --progress=dot:giga "${BUILD_TOOLS_URL}"
95 tar -xf build-tools.tar.gz
96 )
97
98 info_msg "Installing workloads bbench and APKs..."
99 (
100 cd /root/
101 # Copy workload_automation_home.tar.gz to /root for local run.
Milosz Wasilewskia46477e2018-04-09 17:38:21 +0100102 test -f workload_automation_home.tar.gz || wget -S --progress=dot:giga "${WA_HOME_URL}" -O workload_automation_home.tar.gz
Chase Qifd6dd1e2017-05-04 13:20:15 +0800103 tar -xf workload_automation_home.tar.gz
104 )
Milosz Wasilewski3d9438b2017-11-02 19:35:37 +0000105 wa --version
106 wa list instruments
Chase Qifd6dd1e2017-05-04 13:20:15 +0800107fi
108
109initialize_adb
110adb_root
111wait_boot_completed "${BOOT_TIMEOUT}"
112disable_suspend
113
114rm -rf wa-templates
115git clone "${WA_TEMPLATES_REPO}" wa-templates
116(
117 cd wa-templates
118 git checkout "${TEMPLATES_BRANCH}"
119 cp "${CONFIG}" ../config.py
120 cp "${AGENDA}" ../agenda.yaml
121)
122
123sed -i "s/adb_name=.*/adb_name=\'${ANDROID_SERIAL}\',/" ./config.py
124# Ensure that csv is enabled in result processors.
125if ! awk '/result_processors = [[]/,/[]]/' ./config.py | grep -q 'csv'; then
126 sed -i "s/result_processors = [[]/result_processors = [\n 'csv',/" ./config.py
127fi
128
Lisa Nguyenb8c25bd2018-01-31 13:21:07 -0800129if [ -z "${PROBE}" ]; then
130 # LAVA supports one probe per device for now.
131 PROBE=$(find /dev/serial/by-id/ -name "usb-NXP_SEMICOND_ARM_Energy_Probe*" | head -n 1)
132fi
133
134# If AEP exists, find the correct AEP config file and update the AEP config path in the agenda.
135if [ -n "${PROBE}" ]; then
136(
137 cd "${WA_EXTENSION_PATHS}"
138 # find config file with matching probe ID
139 CONFIG_FILE=$(basename "$(grep -rl "${PROBE}" .)")
140 cd -
141 # update AEP config path on agenda
Milosz Wasilewskiacbcd282018-05-08 11:21:12 +0100142 sed -i "s|\$WA_EXTENSION_PATHS/*.*|${WA_EXTENSION_PATHS}/${CONFIG_FILE}\"|" agenda.yaml
143 sed -i "s|\$WA_PLUGIN_PATHS/*.*|${WA_EXTENSION_PATHS}/${CONFIG_FILE}\"|" agenda.yaml
Milosz Wasilewskibf4b25b2018-04-03 14:57:00 +0100144 # update AEP config path on config.yaml
145 if [ -f /root/.workload_automation/config.yaml ]; then
Milosz Wasilewskiacbcd282018-05-08 11:21:12 +0100146 sed -i "s|\$WA_EXTENSION_PATHS/*.*|${WA_EXTENSION_PATHS}/${CONFIG_FILE}\"|" /root/.workload_automation/config.yaml
147 sed -i "s|\$WA_PLUGIN_PATHS/*.*|${WA_EXTENSION_PATHS}/${CONFIG_FILE}\"|" /root/.workload_automation/config.yaml
Milosz Wasilewskibf4b25b2018-04-03 14:57:00 +0100148 fi
Lisa Nguyenb8c25bd2018-01-31 13:21:07 -0800149)
150fi
151
Chase Qifd6dd1e2017-05-04 13:20:15 +0800152info_msg "device-${ANDROID_SERIAL}: About to run WA with ${AGENDA}..."
153wa run ./agenda.yaml -v -f -d "${OUTPUT}/wa" -c ./config.py || report_fail "wa-test-run"
154
155# Generate result.txt for sending results to LAVA.
156# Use id-iteration_metric as test case name.
157awk -F',' 'NR>1 {gsub(/[ _]/,"-",$4); printf("%s-itr%s_%s pass %s %s\n",$1,$3,$4,$5,$6)}' "${OUTPUT}/wa/results.csv" \
158 | sed 's/\r//g' \
159 | tee -a "${RESULT_FILE}"