Chase Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 1 | #!/bin/sh -ex |
| 2 | # shellcheck disable=SC1090 |
| 3 | |
| 4 | TEST_DIR=$(dirname "$(realpath "$0")") |
| 5 | OUTPUT="${TEST_DIR}/output" |
Chase Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 6 | SKIP_INSTALL="false" |
| 7 | ANDROID_SERIAL="" |
| 8 | BOOT_TIMEOUT="300" |
Lisa Nguyen | b8c25bd | 2018-01-31 13:21:07 -0800 | [diff] [blame] | 9 | PROBE="" |
Chase Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 10 | WA_TAG="master" |
Milosz Wasilewski | 52179ae | 2018-03-23 04:46:09 +0000 | [diff] [blame] | 11 | WA_GIT_REPO="https://github.com/ARM-software/workload-automation" |
Chase Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 12 | WA_TEMPLATES_REPO="https://git.linaro.org/qa/wa2-lava.git" |
| 13 | TEMPLATES_BRANCH="wa-templates" |
| 14 | CONFIG="config/generic-android.py" |
| 15 | AGENDA="agenda/generic-linpack.yaml" |
| 16 | BUILD_TOOLS_URL="http://testdata.validation.linaro.org/apks/workload-automation/build-tools.tar.gz" |
| 17 | WA_HOME_URL="http://testdata.validation.linaro.org/apks/workload-automation/workload_automation_home.tar.gz" |
Milosz Wasilewski | d3a509a | 2018-04-09 12:44:44 +0100 | [diff] [blame] | 18 | DEVLIB_REPO="https://github.com/ARM-software/devlib.git" |
| 19 | DEVLIB_TAG="master" |
Chase Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 20 | |
| 21 | usage() { |
Milosz Wasilewski | d3a509a | 2018-04-09 12:44:44 +0100 | [diff] [blame] | 22 | 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 Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 23 | exit 1 |
| 24 | } |
| 25 | |
Milosz Wasilewski | d3a509a | 2018-04-09 12:44:44 +0100 | [diff] [blame] | 26 | while getopts ":s:S:t:T:r:g:c:a:b:w:p:o:R:D:d:" opt; do |
Chase Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 27 | 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 Wasilewski | 52179ae | 2018-03-23 04:46:09 +0000 | [diff] [blame] | 38 | R) WA_GIT_REPO="${OPTARG}" ;; |
Lisa Nguyen | b8c25bd | 2018-01-31 13:21:07 -0800 | [diff] [blame] | 39 | p) PROBE="${OPTARG}" ;; |
Milosz Wasilewski | 6bb7a68 | 2018-02-22 08:44:41 +0000 | [diff] [blame] | 40 | o) NEW_OUTPUT="${OPTARG}" ;; |
Milosz Wasilewski | d3a509a | 2018-04-09 12:44:44 +0100 | [diff] [blame] | 41 | D) DEVLIB_TAG="${OPTARG}" ;; |
| 42 | d) DEVLIB_REPO="${OPTARG}" ;; |
Chase Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 43 | *) usage ;; |
| 44 | esac |
| 45 | done |
| 46 | |
| 47 | . "${TEST_DIR}/../../lib/sh-test-lib" |
| 48 | . "${TEST_DIR}/../../lib/android-test-lib" |
| 49 | |
| 50 | cd "${TEST_DIR}" |
Milosz Wasilewski | 6bb7a68 | 2018-02-22 08:44:41 +0000 | [diff] [blame] | 51 | if [ ! -z "${NEW_OUTPUT}" ]; then |
| 52 | OUTPUT="${NEW_OUTPUT}" |
| 53 | fi |
Chase Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 54 | create_out_dir "${OUTPUT}" |
Milosz Wasilewski | 6bb7a68 | 2018-02-22 08:44:41 +0000 | [diff] [blame] | 55 | RESULT_FILE="${OUTPUT}/result.txt" |
| 56 | export RESULT_FILE |
Chase Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 57 | |
| 58 | if [ "${SKIP_INSTALL}" = "true" ] || [ "${SKIP_INSTALL}" = "True" ]; then |
| 59 | info_msg "WA installation skipped" |
| 60 | else |
Milosz Wasilewski | 584800b | 2018-03-20 07:35:08 +0000 | [diff] [blame] | 61 | 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 Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 62 | ! check_root && error_msg "Please run this test as root." |
| 63 | dpkg --add-architecture i386 |
Karsten Tausche | 3546a7c | 2018-03-20 10:47:31 +0100 | [diff] [blame] | 64 | apt-get update -q |
Chase Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 65 | install_deps "${PKGS}" |
Milosz Wasilewski | 584800b | 2018-03-20 07:35:08 +0000 | [diff] [blame] | 66 | # only install adb if it's not already available |
| 67 | which adb || install_deps adb |
Milosz Wasilewski | 9d840e8 | 2018-02-28 16:28:36 +0000 | [diff] [blame] | 68 | pip install --upgrade --quiet pip && hash -r |
| 69 | pip install --upgrade --quiet setuptools |
| 70 | pip install --quiet pexpect pyserial pyyaml docutils python-dateutil |
Milosz Wasilewski | d3a509a | 2018-04-09 12:44:44 +0100 | [diff] [blame] | 71 | 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 Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 79 | info_msg "Installing workload-automation..." |
| 80 | rm -rf workload-automation |
Milosz Wasilewski | 52179ae | 2018-03-23 04:46:09 +0000 | [diff] [blame] | 81 | git clone "${WA_GIT_REPO}" workload-automation |
Chase Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 82 | ( |
| 83 | cd workload-automation |
Milosz Wasilewski | 0fab925 | 2018-02-28 14:54:53 +0000 | [diff] [blame] | 84 | git checkout "${WA_TAG}" |
Chase Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 85 | ) |
Milosz Wasilewski | 9d840e8 | 2018-02-28 16:28:36 +0000 | [diff] [blame] | 86 | pip2 install --quiet ./workload-automation |
Chase Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 87 | 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 Wasilewski | a46477e | 2018-04-09 17:38:21 +0100 | [diff] [blame] | 102 | test -f workload_automation_home.tar.gz || wget -S --progress=dot:giga "${WA_HOME_URL}" -O workload_automation_home.tar.gz |
Chase Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 103 | tar -xf workload_automation_home.tar.gz |
| 104 | ) |
Milosz Wasilewski | 3d9438b | 2017-11-02 19:35:37 +0000 | [diff] [blame] | 105 | wa --version |
| 106 | wa list instruments |
Chase Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 107 | fi |
| 108 | |
| 109 | initialize_adb |
| 110 | adb_root |
| 111 | wait_boot_completed "${BOOT_TIMEOUT}" |
| 112 | disable_suspend |
| 113 | |
| 114 | rm -rf wa-templates |
| 115 | git 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 | |
| 123 | sed -i "s/adb_name=.*/adb_name=\'${ANDROID_SERIAL}\',/" ./config.py |
| 124 | # Ensure that csv is enabled in result processors. |
| 125 | if ! awk '/result_processors = [[]/,/[]]/' ./config.py | grep -q 'csv'; then |
| 126 | sed -i "s/result_processors = [[]/result_processors = [\n 'csv',/" ./config.py |
| 127 | fi |
| 128 | |
Lisa Nguyen | b8c25bd | 2018-01-31 13:21:07 -0800 | [diff] [blame] | 129 | if [ -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) |
| 132 | fi |
| 133 | |
| 134 | # If AEP exists, find the correct AEP config file and update the AEP config path in the agenda. |
| 135 | if [ -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 Wasilewski | acbcd28 | 2018-05-08 11:21:12 +0100 | [diff] [blame^] | 142 | 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 Wasilewski | bf4b25b | 2018-04-03 14:57:00 +0100 | [diff] [blame] | 144 | # update AEP config path on config.yaml |
| 145 | if [ -f /root/.workload_automation/config.yaml ]; then |
Milosz Wasilewski | acbcd28 | 2018-05-08 11:21:12 +0100 | [diff] [blame^] | 146 | 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 Wasilewski | bf4b25b | 2018-04-03 14:57:00 +0100 | [diff] [blame] | 148 | fi |
Lisa Nguyen | b8c25bd | 2018-01-31 13:21:07 -0800 | [diff] [blame] | 149 | ) |
| 150 | fi |
| 151 | |
Chase Qi | fd6dd1e | 2017-05-04 13:20:15 +0800 | [diff] [blame] | 152 | info_msg "device-${ANDROID_SERIAL}: About to run WA with ${AGENDA}..." |
| 153 | wa 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. |
| 157 | awk -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}" |