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