1 #!/bin/sh 2 3 PROGDIR=`dirname $0` 4 NDK=`cd $PROGDIR/.. && pwd` 5 NDK_BUILDTOOLS_PATH=$NDK/build/tools 6 . $NDK_BUILDTOOLS_PATH/ndk-common.sh 7 . $NDK_BUILDTOOLS_PATH/prebuilt-common.sh 8 9 # Find all devices 10 DEVICE_arm= 11 DEVICE_mips= 12 DEVICE_x86= 13 14 ADB_CMD=`which adb` 15 if [ -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 38 fi 39 40 echo "DEVICE_arm=$DEVICE_arm" 41 echo "DEVICE_x86=$DEVICE_x86" 42 echo "DEVICE_mips=$DEVICE_mips" 43 44 # 45 # check if we need to also test 32-bit host toolchain 46 # 47 TEST_HOST_32BIT=no 48 TAGS=$HOST_TAG 49 case "$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 73 esac 74 75 # 76 # Run run-tests.sh 77 # 78 SYSTEM=$(get_prebuilt_host_tag) 79 NDK_TOOLCHAIN_VERSIONS= 80 for V in $DEFAULT_GCC_VERSION_LIST; do 81 NDK_TOOLCHAIN_VERSIONS=$NDK_TOOLCHAIN_VERSIONS" gcc"$V 82 done 83 for V in $DEFAULT_LLVM_VERSION_LIST; do 84 NDK_TOOLCHAIN_VERSIONS=$NDK_TOOLCHAIN_VERSIONS" clang"$V 85 done 86 87 # keep this simple, only intend to test the case when NDK_TOOLCHAIN_VERSION isn't specified 88 dump "### Run simple tests" 89 ANDROID_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 91 dump "### Run simple tests with clang" 92 NDK_TOOLCHAIN_VERSION=clang ANDROID_SERIAL=none ./run-tests.sh --continue-on-build-fail --abi=armeabi-v7a 93 94 # enumerate all cases using $SYSTEM toolchain 95 for 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 98 done 99 100 if [ "$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 105 fi 106 107 if [ "$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 113 fi 114 115 if [ "$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 121 fi 122 123 # add more if you want ... 124 125 # 126 # Run standalone tests 127 # 128 STANDALONE_TMPDIR=$NDK_TMPDIR 129 130 # $1: Host tag 131 # $2: API level 132 # $3: Arch 133 # $4: GCC version 134 # $5: STL 135 standalone_path () 136 { 137 local TAG=$1 138 local API=$2 139 local ARCH=$3 140 local GCC_VERSION=$4 141 local STL=$5 142 143 echo ${STANDALONE_TMPDIR}/android-ndk-api${API}-${ARCH}-${TAG}-${GCC_VERSION}-${STL} 144 } 145 146 # $1: Host tag 147 # $2: API level 148 # $3: Arch 149 # $4: GCC version 150 # $5: LLVM version 151 # $6: STL 152 make_standalone () 153 { 154 local TAG=$1 155 local API=$2 156 local ARCH=$3 157 local GCC_VERSION=$4 158 local LLVM_VERSION=$5 159 local STL=$6 160 161 (cd $NDK && \ 162 ./build/tools/make-standalone-toolchain.sh \ 163 --platform=android-$API \ 164 --install-dir=$(standalone_path $TAG $API $ARCH $GCC_VERSION $STL) \ 165 --llvm-version=$LLVM_VERSION \ 166 --toolchain=$(get_toolchain_name_for_arch $ARCH $GCC_VERSION) \ 167 --system=$TAG \ 168 --stl=$STL) 169 } 170 171 API=14 172 for ARCH in $(commas_to_spaces $DEFAULT_ARCHS); do 173 for GCC_VERSION in $(commas_to_spaces $DEFAULT_GCC_VERSION_LIST); do 174 for TAG in $TAGS; do 175 dump "### [$TAG] Testing $ARCH gcc-$GCC_VERSION toolchain with --sysroot" 176 (cd $NDK && \ 177 ./tests/standalone/run.sh --prefix=$(get_toolchain_binprefix_for_arch $ARCH $GCC_VERSION $TAG)-gcc) 178 for STL in gnustl stlport; do 179 GCC_TESTED=no 180 for LLVM_VERSION in $(commas_to_spaces $DEFAULT_LLVM_VERSION_LIST); do 181 dump "### [$TAG] Making $ARCH gcc-$GCC_VERSION/clang$LLVM_VERSION standalone toolchain STL=$STL" 182 make_standalone $TAG $API $ARCH $GCC_VERSION $LLVM_VERSION $STL 183 if [ "$GCC_TESTED" != "yes" ]; then 184 dump "### [$TAG] Testing $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 $STL)/bin/$(get_default_toolchain_prefix_for_arch $ARCH)-gcc) 188 GCC_TESTED=yes 189 fi 190 dump "### [$TAG] Testing clang$LLVM_VERSION in $ARCH gcc-$GCC_VERSION standalone toolchain STL=$STL" 191 (cd $NDK && \ 192 ./tests/standalone/run.sh --no-sysroot \ 193 --prefix=$(standalone_path $TAG $API $ARCH $GCC_VERSION $STL)/bin/clang) 194 rm -rf $(standalone_path $TAG $API $ARCH $GCC_VERSION $STL) 195 done 196 done 197 done 198 done 199 done 200 201 # clean up 202 rm -rf $STANDALONE_TMPDIR 203