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