summaryrefslogtreecommitdiff
path: root/automated/android/apk-automation/apk-automation.sh
blob: 5ecdba80b8e7fd7579d6e81e7d4ab8eb9a4da812 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
# shellcheck disable=SC1091

. ./../../lib/sh-test-lib
. ./../../lib/android-test-lib

SKIP_INSTALL="false"
ANDROID_SERIAL=""
BOOT_TIMEOUT="300"
LOOPS="1"
TEST_NAME="linpack"
APK_DIR="./apks"
BASE_URL="http://testdata.validation.linaro.org/apks/"

usage() {
    echo "Usage: $0 [-S <true|false>] [-s <serialno>] [-t <timeout>] [-l <loops>] [-n <test_name>] [-d <apk_dir>] ['-u <base_url>']" 1>&2
    exit 1
}

while getopts ":S:s:t:l:n:d:u:" opt; do
    case "${opt}" in
        S) SKIP_INSTALL="${OPTARG}" ;;
        s) ANDROID_SERIAL="${OPTARG}" ;;
        t) BOOT_TIMEOUT="${OPTARG}" ;;
        l) LOOPS="${OPTARG}" ;;
        n) TEST_NAME="${OPTARG}" ;;
        d) APK_DIR="${OPTARG}" ;;
        u) BASE_URL="${OPTARG}" ;;
        *) usage ;;
    esac
done

OUTPUT="$(pwd)/output/${TEST_NAME}"
export OUTPUT
RESULT_FILE="${OUTPUT}/result.txt"
export RESULT_FILE

! check_root && error_msg "Please run this script as superuser!"
if [ "${SKIP_INSTALL}" = "true" ] || [ "${SKIP_INSTALL}" = "True" ]; then
    info_msg "Package installation skipped"
else
    install_deps "git python python-lxml python-pil python-setuptools curl tar xz-utils" "${SKIP_INSTALL}"
    git clone https://github.com/dtmilano/AndroidViewClient
    (
    cd AndroidViewClient/ || exit
    python setup.py install
    )
fi

initialize_adb
adb_root
wait_boot_completed "${BOOT_TIMEOUT}"
disable_suspend

info_msg "device-${ANDROID_SERIAL}: About to run ${TEST_NAME}..."
python main.py -l "${LOOPS}" -n "${TEST_NAME}" -d "${APK_DIR}" -u "${BASE_URL}"