1#!/bin/bash
2
3function run() {
4    local FAILED_TESTS=()
5
6    # Tests directly relevant to HIDL infrustructure but aren't
7    # located in system/tools/hidl
8    local RELATED_RUNTIME_TESTS=(\
9        libhidl_test \
10    )
11
12    local RUN_TIME_TESTS=(\
13        libhidl-gen-utils_test \
14    )
15    RUN_TIME_TESTS+=(${RELATED_RUNTIME_TESTS[@]})
16
17    local SCRIPT_TESTS=(\
18        hidl_test\
19        hidl_test_java\
20        fmq_test\
21    )
22
23    $ANDROID_BUILD_TOP/build/soong/soong_ui.bash --make-mode -j \
24        ${RUN_TIME_TESTS[*]} ${SCRIPT_TESTS[*]} || return
25
26    adb sync || return
27
28    local BITNESS=("nativetest" "nativetest64")
29
30    for test in ${RUN_TIME_TESTS[@]}; do
31        for bits in ${BITNESS[@]}; do
32            echo $bits $test
33            adb shell /data/$bits/$test/$test ||
34                FAILED_TESTS+=("$bits:$test")
35        done
36    done
37
38    for test in ${SCRIPT_TESTS[@]}; do
39        echo $test
40        adb shell /data/nativetest64/$test ||
41            FAILED_TESTS+=("$test")
42    done
43
44    echo
45    echo ===== ALL DEVICE TESTS SUMMARY =====
46    echo
47    if [ ${#FAILED_TESTS[@]} -gt 0 ]; then
48        for failed in ${FAILED_TESTS[@]}; do
49            echo "FAILED TEST: $failed"
50        done
51    else
52        echo "SUCCESS"
53    fi
54}
55
56run