cpufeatures: fix ARM-specific bug

The __ARM_ARCH__ macro is not defined by default anymore by the toolchain
so use __arm__ instead to include <machine/cpu-features.h> for this
platform.

Note: The toolchain does define __ARM_ARCH_5TE__ or __ARM_ARCH_7A__
depending on compiler flags though...

Change-Id: I3da100ece98fe59b1401ea63c17807cb0d5c1f44
diff --git a/sources/android/cpufeatures/cpu-features.c b/sources/android/cpufeatures/cpu-features.c
index fb5accd..1601013 100644
--- a/sources/android/cpufeatures/cpu-features.c
+++ b/sources/android/cpufeatures/cpu-features.c
@@ -42,7 +42,7 @@
  * NDK r4: Initial release
  */
 #include <sys/system_properties.h>
-#ifdef __ARM_ARCH__
+#ifdef __arm__
 #include <machine/cpu-features.h>
 #endif
 #include <pthread.h>
diff --git a/tests/device/test-cpufeatures/jni/Android.mk b/tests/device/test-cpufeatures/jni/Android.mk
new file mode 100644
index 0000000..340f4dd
--- /dev/null
+++ b/tests/device/test-cpufeatures/jni/Android.mk
@@ -0,0 +1,9 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := test_cpufeatures
+LOCAL_SRC_FILES := test_cpufeatures.c
+LOCAL_STATIC_LIBRARIES := cpufeatures
+include $(BUILD_EXECUTABLE)
+
+$(call import-module,android/cpufeatures)
diff --git a/tests/device/test-cpufeatures/jni/test_cpufeatures.c b/tests/device/test-cpufeatures/jni/test_cpufeatures.c
new file mode 100644
index 0000000..202d53f
--- /dev/null
+++ b/tests/device/test-cpufeatures/jni/test_cpufeatures.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <cpu-features.h>
+#include <stdio.h>
+
+int main(void)
+{
+    AndroidCpuFamily family = android_getCpuFamily();
+    switch (family) {
+    case ANDROID_CPU_FAMILY_ARM:
+        printf("CPU family is ARM\n");
+        break;
+    case ANDROID_CPU_FAMILY_X86:
+        printf("CPU family is x86\n");
+        break;
+    default:
+        fprintf(stderr, "Unsupported CPU family: %d\n", family);
+        return 1;
+    }
+
+    if (family == ANDROID_CPU_FAMILY_ARM) {
+        uint64_t features = android_getCpuFeatures();
+        printf( "Supported ARM features:\n");
+        if ((features & ANDROID_CPU_ARM_FEATURE_ARMv7) != 0) {
+            printf( "  ARMv7\n" );
+        }
+        if ((features & ANDROID_CPU_ARM_FEATURE_VFPv3) != 0) {
+            printf( "  VFPv3\n" );
+        }
+        if ((features & ANDROID_CPU_ARM_FEATURE_NEON) != 0) {
+            printf( "  NEON\n" );
+        }
+    }
+    return 0;
+}
diff --git a/tests/run-tests.sh b/tests/run-tests.sh
index 6eb690f..c0cd585 100755
--- a/tests/run-tests.sh
+++ b/tests/run-tests.sh
@@ -148,9 +148,9 @@
     fi
     if [ $VERBOSE = "yes" ] ; then
         echo "$ADB_CMD shell $@"
-        $ADB_CMD shell "$@ && echo 'OK' || echo 'KO'" | tee $ADB_CMD_LOG
+        $ADB_CMD shell $@ "&&" echo OK "||" echo KO | tee $ADB_CMD_LOG
     else
-        $ADB_CMD shell "$@ && echo 'OK' || echo 'KO'" > $ADB_CMD_LOG
+        $ADB_CMD shell $@ "&&" echo OK "||" echo KO > $ADB_CMD_LOG
     fi
     # Get last line in log, should be OK or KO
     RET=`tail -n1 $ADB_CMD_LOG`
@@ -371,7 +371,7 @@
         fi
         # First, copy all files to /data/local, except for gdbserver
         # or gdb.setup.
-        adb_cmd mkdir $DSTDIR
+        adb_cmd mkdir -p $DSTDIR
         for SRCFILE in `ls $SRCDIR`; do
             DSTFILE=`basename $SRCFILE`
             if [ "$DSTFILE" = "gdbserver" -o "$DSTFILE" = "gdb.setup" ] ; then