1#!/bin/sh 2 3known_tests=( 4 bluetoothtbd_test 5 net_test_audio_a2dp_hw 6 net_test_bluetooth 7 net_test_btcore 8 net_test_bta 9 net_test_btif 10 net_test_device 11 net_test_hci 12 net_test_stack 13 net_test_stack_multi_adv 14 net_test_stack_ad_parser 15 net_test_stack_smp 16 net_test_osi 17) 18 19known_remote_tests=( 20 net_test_rfcomm 21) 22 23 24usage() { 25 binary="$(basename "$0")" 26 echo "Usage: ${binary} --help" 27 echo " ${binary} [-i <iterations>] [-s <specific device>] [--all] [<test name>[.<filter>] ...] [--<arg> ...]" 28 echo 29 echo "Unknown long arguments are passed to the test." 30 echo 31 echo "Known test names:" 32 33 for name in "${known_tests[@]}" 34 do 35 echo " ${name}" 36 done 37 38 echo 39 echo "Known tests that need a remote device:" 40 for name in "${known_remote_tests[@]}" 41 do 42 echo " ${name}" 43 done 44} 45 46iterations=1 47device= 48tests=() 49test_args=() 50while [ $# -gt 0 ] 51do 52 case "$1" in 53 -h|--help) 54 usage 55 exit 0 56 ;; 57 -i) 58 shift 59 if [ $# -eq 0 ]; then 60 echo "error: number of iterations expected" 1>&2 61 usage 62 exit 2 63 fi 64 iterations=$(( $1 )) 65 shift 66 ;; 67 -s) 68 shift 69 if [ $# -eq 0 ]; then 70 echo "error: no device specified" 1>&2 71 usage 72 exit 2 73 fi 74 device="$1" 75 shift 76 ;; 77 --all) 78 tests+=( "${known_tests[@]}" ) 79 shift 80 ;; 81 --*) 82 test_args+=( "$1" ) 83 shift 84 ;; 85 *) 86 tests+=( "$1" ) 87 shift 88 ;; 89 esac 90done 91 92if [ "${#tests[@]}" -eq 0 ]; then 93 tests+=( "${known_tests[@]}" ) 94fi 95 96adb=( "adb" ) 97if [ -n "${device}" ]; then 98 adb+=( "-s" "${device}" ) 99fi 100 101failed_tests=() 102for spec in "${tests[@]}" 103do 104 name="${spec%%.*}" 105 binary="/data/nativetest/${name}/${name}" 106 107 push_command=( "${adb[@]}" push {"${ANDROID_PRODUCT_OUT}",}"${binary}" ) 108 test_command=( "${adb[@]}" shell "${binary}" ) 109 if [ "${name}" != "${spec}" ]; then 110 filter="${spec#*.}" 111 test_command+=( "--gtest_filter=${filter}" ) 112 fi 113 test_command+=( "${test_args[@]}" ) 114 115 echo "--- ${name} ---" 116 echo "pushing..." 117 "${push_command[@]}" 118 echo "running..." 119 failed_count=0 120 for i in $(seq 1 ${iterations}) 121 do 122 "${test_command[@]}" || failed_count=$(( $failed_count + 1 )) 123 done 124 125 if [ $failed_count != 0 ]; then 126 failed_tests+=( "${name} ${failed_count}/${iterations}" ) 127 fi 128done 129 130if [ "${#failed_tests[@]}" -ne 0 ]; then 131 for failed_test in "${failed_tests[@]}" 132 do 133 echo "!!! FAILED TEST: ${failed_test} !!!" 134 done 135 exit 1 136fi 137 138exit 0 139