1#!/bin/sh 2 3PROGDIR=`dirname $0` 4NDK=`cd $PROGDIR/.. && pwd` 5NDK_BUILDTOOLS_PATH=$NDK/build/tools 6. $NDK/build/core/ndk-common.sh 7. $NDK/build/tools/prebuilt-common.sh 8 9# Find all devices 10DEVICE_arm= 11DEVICE_mips= 12DEVICE_x86= 13 14ADB_CMD=`which adb` 15if [ -n $ADB_CMD ] ; then 16 # Get list of online devices, turn ' ' in device into '.' 17 DEVICES=`$ADB_CMD devices | grep -v offline | awk 'NR>1 {gsub(/[ \t]+device$/,""); print;}' | sed '/^$/d' | tr ' ' '.'` 18 for DEVICE in $DEVICES; do 19 # undo previous ' '-to-'.' translation 20 DEVICE=$(echo $DEVICE | tr '.' ' ') 21 # get arch 22 ARCH=`$ADB_CMD -s "$DEVICE" shell getprop ro.product.cpu.abi | tr -dc '[:print:]'` 23 case "$ARCH" in 24 armeabi*) 25 DEVICE_arm=$DEVICE 26 ;; 27 x86) 28 DEVICE_x86=$DEVICE 29 ;; 30 mips*) 31 DEVICE_mips=$DEVICE 32 ;; 33 *) 34 echo "ERROR: Unsupported architecture: $ARCH" 35 exit 1 36 esac 37 done 38fi 39 40echo "DEVICE_arm=$DEVICE_arm" 41echo "DEVICE_x86=$DEVICE_x86" 42echo "DEVICE_mips=$DEVICE_mips" 43 44# 45# check if we need to also test 32-bit host toolchain 46# 47TEST_HOST_32BIT=no 48TAGS=$HOST_TAG 49case "$HOST_TAG" in 50 linux-x86_64|darwin-x86_64) 51 if [ -d "$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/$HOST_TAG" ] ; then 52 if [ -d "$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/$HOST_TAG32" ] ; then 53 # ideally we should check each individual compiler the presence of 64-bit 54 # but for test script this is fine 55 TEST_HOST_32BIT=yes 56 TAGS=$TAGS" $HOST_TAG32" 57 fi 58 else 59 TAGS=$HOST_TAG32 60 fi 61 ;; 62 windows*) 63 if [ "$ProgramW6432" != "" ] ; then 64 if [ -d "$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64" ] ; then 65 if [ -d "$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/windows" ] ; then 66 TEST_HOST_32BIT=yes 67 TAGS=$TAGS" windows-x86_64" 68 fi 69 else 70 TAGS=windows 71 fi 72 fi 73esac 74 75# 76# Run run-tests.sh 77# 78SYSTEM=$(get_prebuilt_host_tag) 79NDK_TOOLCHAIN_VERSIONS= 80for V in $DEFAULT_GCC_VERSION_LIST; do 81 NDK_TOOLCHAIN_VERSIONS=$NDK_TOOLCHAIN_VERSIONS" gcc"$V 82done 83for V in $DEFAULT_LLVM_VERSION_LIST; do 84 NDK_TOOLCHAIN_VERSIONS=$NDK_TOOLCHAIN_VERSIONS" clang"$V 85done 86 87# keep this simple, only intend to test the case when NDK_TOOLCHAIN_VERSION isn't specified 88dump "### Run simple tests" 89ANDROID_SERIAL=none ./run-tests.sh --continue-on-build-fail --abi=armeabi 90# Another simple test to test NDK_TOOLCHAIN_VERSION=clang which picks up the most recent version 91dump "### Run simple tests with clang" 92NDK_TOOLCHAIN_VERSION=clang ANDROID_SERIAL=none ./run-tests.sh --continue-on-build-fail --abi=armeabi-v7a 93 94# enumerate all cases using $SYSTEM toolchain 95for V in $NDK_TOOLCHAIN_VERSIONS; do 96 dump "### Running $HOST_TAG $V full tests" 97 NDK_TOOLCHAIN_VERSION="${V#gcc*}" ./run-tests.sh --continue-on-build-fail --full 98done 99 100if [ "$TEST_HOST_32BIT" = "yes" ] ; then 101 for V in $NDK_TOOLCHAIN_VERSIONS; do 102 dump "### Running $HOST_TAG32 $V tests (32-bit host)" 103 NDK_HOST_32BIT=1 NDK_TOOLCHAIN_VERSION="${V#gcc*}" ./run-tests.sh --continue-on-build-fail 104 done 105fi 106 107if [ "$SYSTEM" = "linux-x86" -a -d "$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64" ] ; then 108 # using 64-bit windows toolchain 109 for V in $NDK_TOOLCHAIN_VERSIONS; do 110 dump "### Running windows-x86_64 $V tests" 111 NDK_TOOLCHAIN_VERSION="${V#gcc*}" ./run-tests.sh --continue-on-build-fail --wine # --full 112 done 113fi 114 115if [ "$SYSTEM" = "linux-x86" -a -d "$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/windows" ] ; then 116 # using 32-bit windows toolchain 117 for V in $NDK_TOOLCHAIN_VERSIONS; do 118 dump "### Running windows $V tests" 119 NDK_HOST_32BIT=1 NDK_TOOLCHAIN_VERSION="${V#gcc*}" ./run-tests.sh --continue-on-build-fail --wine # --full 120 done 121fi 122 123# add more if you want ... 124 125# 126# Run standalone tests 127# 128STANDALONE_TMPDIR=$NDK_TMPDIR 129 130# $1: Host tag 131# $2: API level 132# $3: Arch 133# $4: GCC version 134standalone_path () 135{ 136 local TAG=$1 137 local API=$2 138 local ARCH=$3 139 local GCC_VERSION=$4 140 141 echo ${STANDALONE_TMPDIR}/android-ndk-api${API}-${ARCH}-${TAG}-${GCC_VERSION} 142} 143 144# $1: Host tag 145# $2: API level 146# $3: Arch 147# $4: GCC version 148# $5: LLVM version 149make_standalone () 150{ 151 local TAG=$1 152 local API=$2 153 local ARCH=$3 154 local GCC_VERSION=$4 155 local LLVM_VERSION=$5 156 157 (cd $NDK && \ 158 ./build/tools/make-standalone-toolchain.sh \ 159 --platform=android-$API \ 160 --install-dir=$(standalone_path $TAG $API $ARCH $GCC_VERSION) \ 161 --llvm-version=$LLVM_VERSION \ 162 --toolchain=$(get_toolchain_name_for_arch $ARCH $GCC_VERSION) \ 163 --system=$TAG) 164} 165 166API=14 167for ARCH in $(commas_to_spaces $DEFAULT_ARCHS); do 168 for GCC_VERSION in $(commas_to_spaces $DEFAULT_GCC_VERSION_LIST); do 169 for TAG in $TAGS; do 170 dump "### [$TAG] Testing $ARCH gcc-$GCC_VERSION toolchain with --sysroot" 171 (cd $NDK && \ 172 ./tests/standalone/run.sh --prefix=$(get_toolchain_binprefix_for_arch $ARCH $GCC_VERSION $TAG)-gcc) 173 GCC_TESTED=no 174 for LLVM_VERSION in $(commas_to_spaces $DEFAULT_LLVM_VERSION_LIST); do 175 dump "### [$TAG] Making $ARCH gcc-$GCC_VERSION/clang$LLVM_VERSION standalone toolchain" 176 make_standalone $TAG $API $ARCH $GCC_VERSION $LLVM_VERSION 177 if [ "$GCC_TESTED" != "yes" ]; then 178 dump "### [$TAG] Testing $ARCH gcc-$GCC_VERSION standalone toolchain" 179 (cd $NDK && \ 180 ./tests/standalone/run.sh --no-sysroot \ 181 --prefix=$(standalone_path $TAG $API $ARCH $GCC_VERSION)/bin/$(get_default_toolchain_prefix_for_arch $ARCH)-gcc) 182 GCC_TESTED=yes 183 fi 184 dump "### [$TAG] Testing clang$LLVM_VERSION in $ARCH gcc-$GCC_VERSION standalone toolchain" 185 (cd $NDK && \ 186 ./tests/standalone/run.sh --no-sysroot \ 187 --prefix=$(standalone_path $TAG $API $ARCH $GCC_VERSION)/bin/clang) 188 rm -rf $(standalone_path $TAG $API $ARCH $GCC_VERSION) 189 done 190 done 191 done 192done 193 194# clean up 195rm -rf $STANDALONE_TMPDIR 196