summaryrefslogtreecommitdiff
path: root/automated/android/cts/cts.sh
blob: 653a2d5840b2ea72a7045ae5f9b756d2c56f1dcf (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/sh -x

# shellcheck disable=SC1091
. ../../lib/sh-test-lib
# shellcheck disable=SC1091
. ../../lib/android-test-lib

SKIP_INSTALL="false"
TIMEOUT="300"
JDK="openjdk-8-jdk-headless"
PKG_DEPS="curl wget zip xz-utils python-lxml python-setuptools python-pexpect aapt android-tools-adb lib32z1-dev libc6-dev-i386 lib32gcc1 libc6:i386 libstdc++6:i386 libgcc1:i386 zlib1g:i386 libncurses5:i386"
CTS_URL="http://testdata.validation.linaro.org/cts/android-cts-7.1_r1.zip"
TEST_PARAMS="run cts -m CtsBionicTestCases --abi arm64-v8a --disable-reboot --skip-preconditions --skip-device-info"
RESULT_FILE="$(pwd)/output/result.txt"
export RESULT_FILE

usage() {
    echo "Usage: $0 [-s <true|false>] [-o timeout] [-n serialno] [-d jdk-version] [-c cts_url] [-t test_params]" 1>&2
    exit 1
}

while getopts ':s:o:n:d:c:t:' opt; do
    case "${opt}" in
        s) SKIP_INSTALL="${OPTARG}" ;;
        o) TIMEOUT="${OPTARG}" ;;
        n) SN="${OPTARG}" ;;
        d) JDK="${OPTARG}" ;;
        c) CTS_URL="${OPTARG}" ;;
        t) TEST_PARAMS="${OPTARG}" ;;
        *) usage ;;
    esac
done

if [ "${SKIP_INSTALL}" = "true" ] || [ "${SKIP_INSTALL}" = "True" ]; then
    info_msg "Package installation skipped"
else
    dist_name
    dist_info
    # shellcheck disable=SC2154
    case "${dist}" in
        debian)
            dpkg --add-architecture i386
            dist_info
            echo "deb [arch=amd64,i386] http://ftp.us.debian.org/debian ${Codename} main non-free contrib" > /etc/apt/sources.list.d/cts.list
            if [ "${Codename}" != "sid" ]; then
                echo "deb http://ftp.debian.org/debian ${Codename}-backports main" >> /etc/apt/sources.list.d/cts.list
            fi
            cat /etc/apt/sources.list.d/cts.list
            apt-get update || true
            install_deps "${JDK}" || install_deps "-t ${Codename}-backports ${JDK}"
            install_deps "${PKG_DEPS}"
            ;;
        *)
            install_deps "${PKG_DEPS} ${JDK}"
            ;;
    esac
fi

initialize_adb
wait_boot_completed "${TIMEOUT}"
wait_homescreen "${TIMEOUT}"

# Increase the heap size. KVM devices in LAVA default to ~250M of heap
export _JAVA_OPTIONS="-Xmx350M"
java -version

# Download CTS test package or copy it from local disk.
if echo "${CTS_URL}" | grep "^http" ; then
    wget -S --progress=dot:giga "${CTS_URL}"
else
    cp "${CTS_URL}" ./
fi
file_name=$(basename "${CTS_URL}")
unzip -q "${file_name}"
rm -f "${file_name}"

if [ -d android-cts/results ]; then
    mv android-cts/results "android-cts/results_$(date +%Y%m%d%H%M%S)"
fi

# Run CTS test.
./cts-runner.py -t "${TEST_PARAMS}" -n "${SN}"
check_return "cts-test-run"

# Cleanup.
rm -f /etc/apt/sources.list.d/cts.list