Misc fixes

1. Fix issue when APP_PLATFORM specified in env. var can't be adjusted
2. revert linux-x86 host compiler to the original glibc2.7
   (when __USE_OLD_LINUX_HOST_GCC=yes) to generate binaries run on server
   with very old libc.so
3. Fix issue about run-tests.sh --abi=armeabi-v7a-hard
4. Add 4.9 to some BROKEN_RUN
5. LOCAL_CPPFLAGS += -UNDEBUG for libc++ test becasue there are real work
   done inside assert (bad, bad, bad) for some tests.

Change-Id: If9f507303186ba85fc9ed0962732d027a2dd246e
diff --git a/build/core/add-application.mk b/build/core/add-application.mk
index 04630e3..c1e6c55 100644
--- a/build/core/add-application.mk
+++ b/build/core/add-application.mk
@@ -98,15 +98,15 @@
 #
 APP_PLATFORM_LEVEL := $(strip $(subst android-,,$(APP_PLATFORM)))
 ifneq (,$(filter 6 7,$(APP_PLATFORM_LEVEL)))
-    APP_PLATFORM := android-5
+    override APP_PLATFORM := android-5
 endif
 ifneq (,$(filter 10 11,$(APP_PLATFORM_LEVEL)))
-    APP_PLATFORM := android-9
+    override APP_PLATFORM := android-9
 endif
 ifneq (,$(call gt,$(APP_PLATFORM_LEVEL),20))
-    APP_PLATFORM := android-20
+    override APP_PLATFORM := android-20
 endif
-ifneq ($(APP_PLATFORM),$(APP_PLATFORM_LEVEL))
+ifneq ($(APP_PLATFORM),android-$(APP_PLATFORM_LEVEL))
     $(call ndk_log,  Adjusting APP_PLATFORM android-$(APP_PLATFORM_LEVEL) to $(APP_PLATFORM))
 endif
 
@@ -129,7 +129,7 @@
 _bad_platform := $(strip $(filter-out $(NDK_ALL_PLATFORMS),$(APP_PLATFORM)))
 ifdef _bad_platform
     $(call ndk_log,Application $(_app) targets unknown platform '$(_bad_platform)')
-    APP_PLATFORM := android-$(NDK_MAX_PLATFORM_LEVEL)
+    override APP_PLATFORM := android-$(NDK_MAX_PLATFORM_LEVEL)
     $(call ndk_log,Switching to $(APP_PLATFORM))
 endif
 
diff --git a/build/tools/prebuilt-common.sh b/build/tools/prebuilt-common.sh
index 38626aa..2dc555f 100644
--- a/build/tools/prebuilt-common.sh
+++ b/build/tools/prebuilt-common.sh
@@ -27,6 +27,11 @@
 . $NDK_BUILDTOOLS_PATH/ndk-common.sh
 . $NDK_BUILDTOOLS_PATH/dev-defaults.sh
 
+# Binaries built by new linux host toolchain "prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6"
+# may contain functions missing from server runs very old libc.so.  Define __USE_OLD_LINUX_HOST_GCC=yes
+# to use the original "prebuilts/tools/gcc-sdk" with glibc2.7 sysroot
+__USE_OLD_LINUX_HOST_GCC=yes
+
 #====================================================
 #
 #  UTILITY FUNCTIONS
@@ -770,19 +775,35 @@
     # generate wrappers for BUILD toolchain
     # this is required for mingw/darwin build to avoid tools canadian cross configuration issues
     # 32-bit BUILD toolchain
-    LEGACY_TOOLCHAIN_DIR="$ANDROID_NDK_ROOT/../prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6"
-    $NDK_BUILDTOOLS_PATH/gen-toolchain-wrapper.sh --src-prefix=i386-linux-gnu- \
-            --cflags="-m32" --cxxflags="-m32" --ldflags="-m elf_i386" --asflags="--32" \
-            --dst-prefix="$LEGACY_TOOLCHAIN_DIR/bin/x86_64-linux-" "$CROSS_WRAP_DIR"
-    $NDK_BUILDTOOLS_PATH/gen-toolchain-wrapper.sh --src-prefix=i386-pc-linux-gnu- \
-            --cflags="-m32" --cxxflags="-m32" --ldflags="-m elf_i386" --asflags="--32" \
-            --dst-prefix="$LEGACY_TOOLCHAIN_DIR/bin/x86_64-linux-" "$CROSS_WRAP_DIR"
-    # 64-bit BUILD toolchain.  libbfd is still built in 32-bit.
-    $NDK_BUILDTOOLS_PATH/gen-toolchain-wrapper.sh --src-prefix=x86_64-linux-gnu- \
-            --dst-prefix="$LEGACY_TOOLCHAIN_DIR/bin/x86_64-linux-" "$CROSS_WRAP_DIR"
-    $NDK_BUILDTOOLS_PATH/gen-toolchain-wrapper.sh --src-prefix=x86_64-pc-linux-gnu- \
-            --dst-prefix="$LEGACY_TOOLCHAIN_DIR/bin/x86_64-linux-" "$CROSS_WRAP_DIR"
-    fail_panic "Could not create $DEBIAN_NAME wrapper toolchain in $CROSS_WRAP_DIR"
+    if [ "$__USE_OLD_LINUX_HOST_GCC" = "yes" ]; then
+        LEGACY_TOOLCHAIN_DIR="$ANDROID_NDK_ROOT/../prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6"
+        $NDK_BUILDTOOLS_PATH/gen-toolchain-wrapper.sh --src-prefix=i386-linux-gnu- \
+                --dst-prefix="$LEGACY_TOOLCHAIN_DIR/bin/i686-linux-" "$CROSS_WRAP_DIR"
+        $NDK_BUILDTOOLS_PATH/gen-toolchain-wrapper.sh --src-prefix=i386-pc-linux-gnu- \
+                --dst-prefix="$LEGACY_TOOLCHAIN_DIR/bin/i686-linux-" "$CROSS_WRAP_DIR"
+        # 64-bit BUILD toolchain.  libbfd is still built in 32-bit.  Use gcc-sdk instead
+        # of x86_64-linux-glibc2.7-4.6 which is a 64-bit-only tool
+        LEGACY_TOOLCHAIN_DIR="$ANDROID_NDK_ROOT/../prebuilts/tools/gcc-sdk"
+        $NDK_BUILDTOOLS_PATH/gen-toolchain-wrapper.sh --src-prefix=x86_64-linux-gnu- \
+                --dst-prefix="$LEGACY_TOOLCHAIN_DIR/" "$CROSS_WRAP_DIR"
+        $NDK_BUILDTOOLS_PATH/gen-toolchain-wrapper.sh --src-prefix=x86_64-pc-linux-gnu- \
+                --dst-prefix="$LEGACY_TOOLCHAIN_DIR/" "$CROSS_WRAP_DIR"
+        fail_panic "Could not create $DEBIAN_NAME wrapper toolchain in $CROSS_WRAP_DIR"
+    else
+        LEGACY_TOOLCHAIN_DIR="$ANDROID_NDK_ROOT/../prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6"
+        $NDK_BUILDTOOLS_PATH/gen-toolchain-wrapper.sh --src-prefix=i386-linux-gnu- \
+                --cflags="-m32" --cxxflags="-m32" --ldflags="-m elf_i386" --asflags="--32" \
+                --dst-prefix="$LEGACY_TOOLCHAIN_DIR/bin/x86_64-linux-" "$CROSS_WRAP_DIR"
+        $NDK_BUILDTOOLS_PATH/gen-toolchain-wrapper.sh --src-prefix=i386-pc-linux-gnu- \
+                --cflags="-m32" --cxxflags="-m32" --ldflags="-m elf_i386" --asflags="--32" \
+                --dst-prefix="$LEGACY_TOOLCHAIN_DIR/bin/x86_64-linux-" "$CROSS_WRAP_DIR"
+        # 64-bit BUILD toolchain.  libbfd is still built in 32-bit.
+        $NDK_BUILDTOOLS_PATH/gen-toolchain-wrapper.sh --src-prefix=x86_64-linux-gnu- \
+                --dst-prefix="$LEGACY_TOOLCHAIN_DIR/bin/x86_64-linux-" "$CROSS_WRAP_DIR"
+        $NDK_BUILDTOOLS_PATH/gen-toolchain-wrapper.sh --src-prefix=x86_64-pc-linux-gnu- \
+                --dst-prefix="$LEGACY_TOOLCHAIN_DIR/bin/x86_64-linux-" "$CROSS_WRAP_DIR"
+        fail_panic "Could not create $DEBIAN_NAME wrapper toolchain in $CROSS_WRAP_DIR"
+    fi
 
     export PATH=$CROSS_WRAP_DIR:$PATH
     dump "Using $DEBIAN_NAME wrapper: $CROSS_WRAP_DIR/${BINPREFIX}gcc"
@@ -849,8 +870,13 @@
     if [ -z "$CC" ]; then
         LEGACY_TOOLCHAIN_DIR=
         if [ "$HOST_OS" = "linux" ]; then
-            LEGACY_TOOLCHAIN_DIR="$ANDROID_NDK_ROOT/../prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/bin"
-            LEGACY_TOOLCHAIN_PREFIX="$LEGACY_TOOLCHAIN_DIR/x86_64-linux-"
+            if [ "$__USE_OLD_LINUX_HOST_GCC" = "yes" ]; then
+                LEGACY_TOOLCHAIN_DIR="$ANDROID_NDK_ROOT/../prebuilts/tools/gcc-sdk"
+                LEGACY_TOOLCHAIN_PREFIX="$LEGACY_TOOLCHAIN_DIR/"
+	    else
+                LEGACY_TOOLCHAIN_DIR="$ANDROID_NDK_ROOT/../prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/bin"
+                LEGACY_TOOLCHAIN_PREFIX="$LEGACY_TOOLCHAIN_DIR/x86_64-linux-"
+	    fi
         elif [ "$HOST_OS" = "darwin" ]; then
             LEGACY_TOOLCHAIN_DIR="$ANDROID_NDK_ROOT/../prebuilts/gcc/darwin-x86/host/i686-apple-darwin-4.2.1/bin"
             LEGACY_TOOLCHAIN_PREFIX="$LEGACY_TOOLCHAIN_DIR/i686-apple-darwin10-"
diff --git a/sources/cxx-stl/llvm-libc++/libcxx/include/__config b/sources/cxx-stl/llvm-libc++/libcxx/include/__config
index 8739453..4c993f1 100644
--- a/sources/cxx-stl/llvm-libc++/libcxx/include/__config
+++ b/sources/cxx-stl/llvm-libc++/libcxx/include/__config
@@ -427,7 +427,7 @@
 #define __gxx__cxx_access_control_sfinae          !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) || !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE) // Also see usage in 7 tests
 #define __gxx__cxx_alias_templates                !defined(_LIBCPP_HAS_NO_TEMPLATE_ALIASES)
 #define __gxx__cxx_alignas                        0  // Not sure, doesn't matter.
-#define __gxx__cxx_atomic                         0  // In c11-atomic branch targeted for GCC 4.9.  Also see usages in 20+ places
+#define __gxx__cxx_atomic                         0  // (_GNUC_VER >= 409) seems to support _Atomic in -std=c11 not -std=c++11 !
 #define __gxx__cxx_attributes                     0  // Not sure. Also see usage in libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp
 #define __gxx__cxx_auto_type                      !deinfed(_LIBCPP_HAS_NO_AUTO_TYPE)
 #define __gxx__cxx_constexpr                      !defined(_LIBCPP_HAS_NO_CONSTEXPR)
diff --git a/sources/cxx-stl/llvm-libc++/libcxx/test/testit_android b/sources/cxx-stl/llvm-libc++/libcxx/test/testit_android
index e3c0603..1591300 100755
--- a/sources/cxx-stl/llvm-libc++/libcxx/test/testit_android
+++ b/sources/cxx-stl/llvm-libc++/libcxx/test/testit_android
@@ -306,7 +306,7 @@
     fi
     if ! $(echo $ERR | grep -iq "Text file busy"); then
       if [ "$i" != "1" ]; then
-        ## Dump error message to help diagnostics
+        # Dump error message to help diagnostics
         echo "ERR=$ERR"
       fi
       break;
diff --git a/tests/abcc/jni/Abcc.cpp b/tests/abcc/jni/Abcc.cpp
index f2d0a39..20e2fc6 100644
--- a/tests/abcc/jni/Abcc.cpp
+++ b/tests/abcc/jni/Abcc.cpp
@@ -34,7 +34,7 @@
 using namespace abcc;
 
 TargetAbi::TargetAbi(const std::string &abi) {
-  if (abi == "armeabi-v7a")
+  if (abi == "armeabi-v7a" || abi == "armeabi-v7a-hard") //ToDo: support armeabi-v7a-hard
     mAbi = ARMEABI_V7A;
   else if (abi == "armeabi")
     mAbi = ARMEABI;
diff --git a/tests/build/clang-multiple-arm-enable-ehabi/BROKEN_BUILD b/tests/build/clang-multiple-arm-enable-ehabi/BROKEN_BUILD
index 7e11d24..0ff872a 100644
--- a/tests/build/clang-multiple-arm-enable-ehabi/BROKEN_BUILD
+++ b/tests/build/clang-multiple-arm-enable-ehabi/BROKEN_BUILD
@@ -1 +1 @@
-4.4.3 4.6 4.7 4.8
\ No newline at end of file
+4.4.3 4.6 4.7 4.8 4.9
\ No newline at end of file
diff --git a/tests/build/issue65705-asm-pc/jni/Application.mk b/tests/build/issue65705-asm-pc/jni/Application.mk
index f05229c..cb12f4f 100644
--- a/tests/build/issue65705-asm-pc/jni/Application.mk
+++ b/tests/build/issue65705-asm-pc/jni/Application.mk
@@ -1 +1 @@
-APP_ABI := armeabi armeabi-v7a
+APP_ABI := armeabi armeabi-v7a armeabi-v7a-hard
diff --git a/tests/build/issue65705-asm-pc/jni/issue65705-asm-pc.c b/tests/build/issue65705-asm-pc/jni/issue65705-asm-pc.c
index 2b11984..44c76cb 100644
--- a/tests/build/issue65705-asm-pc/jni/issue65705-asm-pc.c
+++ b/tests/build/issue65705-asm-pc/jni/issue65705-asm-pc.c
@@ -20,7 +20,7 @@
 
 int func_1()
 {
-#if !defined(__le32__)
+#if !defined(__le32__) && !defined(__le64__)
    register unsigned long pc asm ("pc");
    func_2(pc);
 #endif
diff --git a/tests/build/warn-noabi/build.sh b/tests/build/warn-noabi/build.sh
index b6e6d58..70cdbe2 100755
--- a/tests/build/warn-noabi/build.sh
+++ b/tests/build/warn-noabi/build.sh
@@ -11,7 +11,7 @@
 
 if [ -n "$NDK_TOOLCHAIN_VERSION" ];  then
     case "$NDK_TOOLCHAIN_VERSION" in
-        4.4.3|4.6|4.7*|4.8*)
+        4.4.3|4.6|4.7*|4.8*|4.9*)
            VERSION=$NDK_TOOLCHAIN_VERSION
             ;;
         clang*)
diff --git a/tests/device/test-libc++-shared-full/BROKEN_RUN b/tests/device/test-libc++-shared-full/BROKEN_RUN
index 16ae732..cc5d747 100644
--- a/tests/device/test-libc++-shared-full/BROKEN_RUN
+++ b/tests/device/test-libc++-shared-full/BROKEN_RUN
@@ -414,6 +414,11 @@
     nalibcxxg++  stoi.pass.cpp -lc++_shared -latomic
       I/DEBUG   (   51): Abort message: '/tmp/ndk-andrewhsieh/tmp/build-10543/build-libc++/ndk/sources/cxx-stl/llvm-libc++/../../android/support/src/wchar_support.c:361: wcstol: assertion "0" failed'
 
+FAIL: strings___string.conversions___stol
+  cd ~/libcxx-test/strings/string.conversions
+    nalibcxxg++  stol.pass.cpp -lc++_shared -latomic
+      I/DEBUG   (   51): Abort message: '/tmp/ndk-andrewhsieh/tmp/build-10543/build-libc++/ndk/sources/cxx-stl/llvm-libc++/../../android/support/src/wchar_support.c:361: wcstol: assertion "0" failed'
+
 FAIL: strings___string.conversions___stold
   cd ~/libcxx-test/strings/string.conversions
     nalibcxxg++  stold.pass.cpp -lc++_shared -latomic
@@ -424,11 +429,6 @@
     nalibcxxg++  stoll.pass.cpp -lc++_shared -latomic
       I/DEBUG   (   51): Abort message: '/tmp/ndk-andrewhsieh/tmp/build-10543/build-libc++/ndk/sources/cxx-stl/llvm-libc++/../../android/support/src/wchar_support.c:373: wcstoll: assertion "0" failed'
 
-FAIL: strings___string.conversions___stol
-  cd ~/libcxx-test/strings/string.conversions
-    nalibcxxg++  stol.pass.cpp -lc++_shared -latomic
-      I/DEBUG   (   51): Abort message: '/tmp/ndk-andrewhsieh/tmp/build-10543/build-libc++/ndk/sources/cxx-stl/llvm-libc++/../../android/support/src/wchar_support.c:361: wcstol: assertion "0" failed'
-
 FAIL: strings___string.conversions___stoull
   cd ~/libcxx-test/strings/string.conversions
     nalibcxxg++  stoull.pass.cpp -lc++_shared -latomic
diff --git a/tests/device/test-libc++-shared-full/jni/Android.mk b/tests/device/test-libc++-shared-full/jni/Android.mk
index 39e8013..2ff5b40 100644
--- a/tests/device/test-libc++-shared-full/jni/Android.mk
+++ b/tests/device/test-libc++-shared-full/jni/Android.mk
@@ -8,7 +8,7 @@
 LOCAL_SRC_FILES := $(libcxx-test-path)/$$(__test).pass.cpp
 LOCAL_MODULE := $$(subst /,___,$$(__test))
 
-# armeabi and mips needs libatomic to provide __atomic_is_lock_free, for example
+# armeabi and mips needs libatomic to provide "__atomic_is_lock_free"
 LOCAL_LDLIBS += -latomic
 
 # Enable RTTI and exception handling for some tests
@@ -18,11 +18,10 @@
 LOCAL_C_INCLUDES += $(libcxx-test-path)/support
 LOCAL_CPPFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
 # Add -UNDEBUG because some libc++ tests use assert() which become nothing when -DNDEBUG
-# (defined in toolchains/*clang*/setup.mk for release build).  Unfortunately adding -UNDEBUG
-# crashes both clang3.4 and clang3.3 for test like libcxx/test/atomics/atomics.types.generic/address.pass.cpp.
-ifeq (,$(filter clang%,$(NDK_TOOLCHAIN_VERSION)))
+# is defined in toolchains/*clang*/setup.mk for release build.  Interestingly there
+# is real work done inside some assert, so removing assert() isn't an option.
+#
 LOCAL_CPPFLAGS += -UNDEBUG
-endif
 
 include $(BUILD_EXECUTABLE)
 endef
@@ -112,6 +111,8 @@
     utilities/utility/pairs/pairs.pair/rv_pair_U_V \
     utilities/utility/pairs/pairs.spec/make_pair
 
+black_list_gcc4_9 := # for now
+
 black_list_x86 := \
     language.support/support.types/max_align_t
 
@@ -128,6 +129,9 @@
 ifeq (4.8,$(NDK_TOOLCHAIN_VERSION))
 black_list += $(black_list_gcc4_8)
 endif
+ifeq (4.9,$(NDK_TOOLCHAIN_VERSION))
+black_list += $(black_list_gcc4_9)
+endif
 endif
 endif
 
diff --git a/tests/device/test-libc++-static-full/BROKEN_RUN b/tests/device/test-libc++-static-full/BROKEN_RUN
index 16ae732..cc5d747 100644
--- a/tests/device/test-libc++-static-full/BROKEN_RUN
+++ b/tests/device/test-libc++-static-full/BROKEN_RUN
@@ -414,6 +414,11 @@
     nalibcxxg++  stoi.pass.cpp -lc++_shared -latomic
       I/DEBUG   (   51): Abort message: '/tmp/ndk-andrewhsieh/tmp/build-10543/build-libc++/ndk/sources/cxx-stl/llvm-libc++/../../android/support/src/wchar_support.c:361: wcstol: assertion "0" failed'
 
+FAIL: strings___string.conversions___stol
+  cd ~/libcxx-test/strings/string.conversions
+    nalibcxxg++  stol.pass.cpp -lc++_shared -latomic
+      I/DEBUG   (   51): Abort message: '/tmp/ndk-andrewhsieh/tmp/build-10543/build-libc++/ndk/sources/cxx-stl/llvm-libc++/../../android/support/src/wchar_support.c:361: wcstol: assertion "0" failed'
+
 FAIL: strings___string.conversions___stold
   cd ~/libcxx-test/strings/string.conversions
     nalibcxxg++  stold.pass.cpp -lc++_shared -latomic
@@ -424,11 +429,6 @@
     nalibcxxg++  stoll.pass.cpp -lc++_shared -latomic
       I/DEBUG   (   51): Abort message: '/tmp/ndk-andrewhsieh/tmp/build-10543/build-libc++/ndk/sources/cxx-stl/llvm-libc++/../../android/support/src/wchar_support.c:373: wcstoll: assertion "0" failed'
 
-FAIL: strings___string.conversions___stol
-  cd ~/libcxx-test/strings/string.conversions
-    nalibcxxg++  stol.pass.cpp -lc++_shared -latomic
-      I/DEBUG   (   51): Abort message: '/tmp/ndk-andrewhsieh/tmp/build-10543/build-libc++/ndk/sources/cxx-stl/llvm-libc++/../../android/support/src/wchar_support.c:361: wcstol: assertion "0" failed'
-
 FAIL: strings___string.conversions___stoull
   cd ~/libcxx-test/strings/string.conversions
     nalibcxxg++  stoull.pass.cpp -lc++_shared -latomic
diff --git a/tests/device/test-libc++-static-full/jni/Android.mk b/tests/device/test-libc++-static-full/jni/Android.mk
index b2dfeb2..2ff5b40 100644
--- a/tests/device/test-libc++-static-full/jni/Android.mk
+++ b/tests/device/test-libc++-static-full/jni/Android.mk
@@ -18,11 +18,10 @@
 LOCAL_C_INCLUDES += $(libcxx-test-path)/support
 LOCAL_CPPFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
 # Add -UNDEBUG because some libc++ tests use assert() which become nothing when -DNDEBUG
-# (defined in toolchains/*clang*/setup.mk for release build).  Unfortunately adding -UNDEBUG
-# crashes both clang3.4 and clang3.3 for test like libcxx/test/atomics/atomics.types.generic/address.pass.cpp.
-ifeq (,$(filter clang%,$(NDK_TOOLCHAIN_VERSION)))
+# is defined in toolchains/*clang*/setup.mk for release build.  Interestingly there
+# is real work done inside some assert, so removing assert() isn't an option.
+#
 LOCAL_CPPFLAGS += -UNDEBUG
-endif
 
 include $(BUILD_EXECUTABLE)
 endef
@@ -112,6 +111,8 @@
     utilities/utility/pairs/pairs.pair/rv_pair_U_V \
     utilities/utility/pairs/pairs.spec/make_pair
 
+black_list_gcc4_9 := # for now
+
 black_list_x86 := \
     language.support/support.types/max_align_t
 
@@ -128,6 +129,9 @@
 ifeq (4.8,$(NDK_TOOLCHAIN_VERSION))
 black_list += $(black_list_gcc4_8)
 endif
+ifeq (4.9,$(NDK_TOOLCHAIN_VERSION))
+black_list += $(black_list_gcc4_9)
+endif
 endif
 endif
 
diff --git a/tests/run-libcxx.sh b/tests/run-libcxx.sh
index 7398c98..4d5d144 100755
--- a/tests/run-libcxx.sh
+++ b/tests/run-libcxx.sh
@@ -15,6 +15,9 @@
   TOOLCHAIN_DIR_ARM=/tmp/ndk-$USER/android-ndk-api14-arm-4.8-clang${LLVM_VERSION}-libc++
   TOOLCHAIN_DIR_X86=/tmp/ndk-$USER/android-ndk-api14-x86-4.8-clang${LLVM_VERSION}-libc++
   TOOLCHAIN_DIR_MIPS=/tmp/ndk-$USER/android-ndk-api14-mips-4.8-clang${LLVM_VERSION}-libc++
+  TOOLCHAIN49_DIR_ARM=/tmp/ndk-$USER/android-ndk-api14-arm-4.9-clang${LLVM_VERSION}-libc++
+  TOOLCHAIN49_DIR_X86=/tmp/ndk-$USER/android-ndk-api14-x86-4.9-clang${LLVM_VERSION}-libc++
+  TOOLCHAIN49_DIR_MIPS=/tmp/ndk-$USER/android-ndk-api14-mips-4.9-clang${LLVM_VERSION}-libc++
 
   ./build/tools/make-standalone-toolchain.sh --platform=android-14 --llvm-version=${LLVM_VERSION} \
         --install-dir=$TOOLCHAIN_DIR_ARM --toolchain=arm-linux-androideabi-4.8 --stl=libc++
@@ -22,6 +25,12 @@
         --install-dir=$TOOLCHAIN_DIR_MIPS --toolchain=mipsel-linux-android-4.8 --stl=libc++
   ./build/tools/make-standalone-toolchain.sh --platform=android-14 --llvm-version=${LLVM_VERSION} \
         --install-dir=$TOOLCHAIN_DIR_X86 --toolchain=x86-4.8 --stl=libc++
+  ./build/tools/make-standalone-toolchain.sh --platform=android-14 --llvm-version=${LLVM_VERSION} \
+        --install-dir=$TOOLCHAIN49_DIR_ARM --toolchain=arm-linux-androideabi-4.9 --stl=libc++
+  ./build/tools/make-standalone-toolchain.sh --platform=android-14 --llvm-version=${LLVM_VERSION} \
+        --install-dir=$TOOLCHAIN49_DIR_MIPS --toolchain=mipsel-linux-android-4.9 --stl=libc++
+  ./build/tools/make-standalone-toolchain.sh --platform=android-14 --llvm-version=${LLVM_VERSION} \
+        --install-dir=$TOOLCHAIN49_DIR_X86 --toolchain=x86-4.9 --stl=libc++
 
   cd $NDK/sources/cxx-stl/llvm-libc++/libcxx/test
 
@@ -51,6 +60,30 @@
     fi
 
     if [ -z "$DEVICE_arm" ]; then
+      echo "### gcc4.9 armeabi-v7a: no device"
+    else
+      echo "### gcc4.9 armeabi-v7a"
+      ADB="adb -s $DEVICE_arm" PATH=$TOOLCHAIN49_DIR_ARM/bin:$PATH \
+        ./testit_android --abi=armeabi-v7a $MODE
+    fi
+
+    if [ -z "$DEVICE_x86" ]; then
+      echo "### gcc4.9 x86: no device"
+    else
+      echo "### gcc4.9 x86"
+      ADB="adb -s $DEVICE_x86" PATH=$TOOLCHAIN49_DIR_X86/bin:$PATH \
+        ./testit_android --abi=x86 $MODE
+    fi
+
+    if [ -z "$DEVICE_mips" ]; then
+      echo "### gcc4.9 mips: no device"
+    else
+      echo "### gcc4.9 mips"
+      ADB="adb -s $DEVICE_mips" PATH=$TOOLCHAIN49_DIR_MIPS/bin:$PATH \
+        ./testit_android --abi=mips $MODE
+    fi
+
+    if [ -z "$DEVICE_arm" ]; then
       echo "### gcc4.8 armeabi-v7a: no device"
     else
       echo "### gcc4.8 armeabi-v7a"
diff --git a/tests/run-tests.sh b/tests/run-tests.sh
index 32c8551..afa8009 100755
--- a/tests/run-tests.sh
+++ b/tests/run-tests.sh
@@ -36,7 +36,7 @@
 # directoy and tested separately from armeabi-v7a.  Some tests are now compiled with both
 # APP_ABI=armeabi-v7a and APP_ABI=armeabi-v7a-hard. Without _NDK_TESTING_ALL_=yes, tests
 # may fail to install due to race condition on the same libs/armeabi-v7a
-_NDK_TESTING_ALL_=yes
+export _NDK_TESTING_ALL_=yes
 
 # The list of tests that are too long to be part of a normal run of
 # run-tests.sh. Most of these do not run properly at the moment.
@@ -432,7 +432,7 @@
 case $ABI in
     default)  # Let the APP_ABI in jni/Application.mk decide what to build
         ;;
-    armeabi|armeabi-v7a|x86|x86_64|mips|armeabi-v7a-hard|arm64-v8a|x86_64|mips64)
+    armeabi|armeabi-v7a|arm64-v8a|x86|x86_64|mips|mips64|armeabi-v7a-hard)
         NDK_BUILD_FLAGS="$NDK_BUILD_FLAGS APP_ABI=$ABI"
         ;;
     *)
@@ -952,10 +952,6 @@
         dump "SKIPPING RUNNING TESTS ON DEVICE!"
     else
         AT_LEAST_CPU_ABI_MATCH=
-        REAL_ABI=$ABI
-        if [ "$REAL_ABI" = "armeabi-v7a-hard" ]; then
-            REAL_ABI=armeabi-v7a
-        fi
         for DEVICE in $ADB_DEVICES; do
             # undo earlier ' '-to-'#' translation
             DEVICE=$(echo "$DEVICE" | tr '#' ' ')
@@ -976,7 +972,7 @@
             fi
             log "CPU_ABIS=$CPU_ABIS"
             for CPU_ABI in $CPU_ABIS; do
-                if [ "$REAL_ABI" = "default" -o "$REAL_ABI" = "$CPU_ABI" -o "$REAL_ABI" = "$(find_ndk_unknown_archs)" ] ; then
+                if [ "$ABI" = "default" -o "$ABI" = "$CPU_ABI" -o "$ABI" = "$(find_ndk_unknown_archs)" ] ; then
                     AT_LEAST_CPU_ABI_MATCH="yes"
                     for DIR in `ls -d $ROOTDIR/tests/device/*`; do
                         if is_buildable $DIR; then