Merge "Enhance the CTS tests."
diff --git a/build/test_executable.mk b/build/test_executable.mk
index 74b3a95..fb41b73 100644
--- a/build/test_executable.mk
+++ b/build/test_executable.mk
@@ -27,14 +27,15 @@
cts_executable_xml := $(CTS_TESTCASES_OUT)/$(LOCAL_MODULE).xml
-$(cts_executable_xml): PRIVATE_PATH := $(cts_src_test_path)
$(cts_executable_xml): PRIVATE_TEST_PACKAGE := $(LOCAL_CTS_TEST_PACKAGE)
$(cts_executable_xml): PRIVATE_EXECUTABLE := $(LOCAL_MODULE)
-$(cts_executable_xml): $(addprefix $(LOCAL_PATH)/,$(LOCAL_SRC_FILES)) $(CTS_EXPECTATIONS) $(CTS_NATIVE_TEST_SCANNER) $(CTS_XML_GENERATOR)
+$(cts_executable_xml): PRIVATE_LIST_EXECUTABLE := $(HOST_OUT_EXECUTABLES)/$(LOCAL_MODULE)_list
+$(cts_executable_xml): $(HOST_OUT_EXECUTABLES)/$(LOCAL_MODULE)_list
+$(cts_executable_xml): $(addprefix $(LOCAL_PATH)/,$(LOCAL_SRC_FILES)) $(CTS_EXPECTATIONS) $(CTS_NATIVE_TEST_SCANNER) $(CTS_XML_GENERATOR) $(cts_list_executable)
$(hide) echo Generating test description for native package $(PRIVATE_TEST_PACKAGE)
$(hide) mkdir -p $(CTS_TESTCASES_OUT)
- $(hide) $(CTS_NATIVE_TEST_SCANNER) -s $(PRIVATE_PATH) \
- -t $(PRIVATE_TEST_PACKAGE) | \
+ $(hide) $(PRIVATE_LIST_EXECUTABLE) --gtest_list_tests | \
+ $(CTS_NATIVE_TEST_SCANNER) -t $(PRIVATE_TEST_PACKAGE) | \
$(CTS_XML_GENERATOR) -t native \
-n $(PRIVATE_EXECUTABLE) \
-p $(PRIVATE_TEST_PACKAGE) \
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index 5eaff9b..9b089df 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -29,15 +29,5 @@
name: "android.hardware.cts.SensorIntegrationTests#testSensorsWithSeveralClients",
name: "android.hardware.cts.SensorIntegrationTests#testSensorsMovingRates",
bug: 11352697
-},
-{
- name: "android.bionic.DEATHTEST",
- name: "android.bionic.TEST_NAME",
- name: "android.bionic.dlfcn",
- name: "android.bionic.math#isfinite",
- name: "android.bionic.math#signbit",
- name: "android.bionic.stack_protector",
- name: "android.bionic.stack_unwinding_DeathTest",
- bug: 11119006
}
]
diff --git a/tests/jni/Android.mk b/tests/jni/Android.mk
index 0f7511e..28aa15a 100644
--- a/tests/jni/Android.mk
+++ b/tests/jni/Android.mk
@@ -23,11 +23,12 @@
LOCAL_SRC_FILES := \
CtsJniOnLoad.cpp \
+ android_os_cts_TaggedPointer.cpp \
android_os_cts_OSFeatures.cpp \
android_os_cts_FileUtils.cpp \
android_net_cts_NetlinkSocket.cpp
-LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
+LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
LOCAL_SHARED_LIBRARIES := libnativehelper liblog
diff --git a/tests/jni/CtsJniOnLoad.cpp b/tests/jni/CtsJniOnLoad.cpp
index 99ea37e..e0bb813 100644
--- a/tests/jni/CtsJniOnLoad.cpp
+++ b/tests/jni/CtsJniOnLoad.cpp
@@ -20,6 +20,8 @@
extern int register_android_os_cts_CpuFeatures(JNIEnv*);
+extern int register_android_os_cts_TaggedPointer(JNIEnv*);
+
extern int register_android_os_cts_OSFeatures(JNIEnv*);
extern int register_android_os_cts_FileUtils(JNIEnv*);
@@ -35,6 +37,10 @@
return JNI_ERR;
}
+ if (register_android_os_cts_TaggedPointer(env)) {
+ return JNI_ERR;
+ }
+
if (register_android_os_cts_OSFeatures(env)) {
return JNI_ERR;
}
diff --git a/tests/jni/android_os_cts_CpuFeatures.cpp b/tests/jni/android_os_cts_CpuFeatures.cpp
index 053b44e..5276257 100644
--- a/tests/jni/android_os_cts_CpuFeatures.cpp
+++ b/tests/jni/android_os_cts_CpuFeatures.cpp
@@ -42,6 +42,24 @@
return cpuFamily == ANDROID_CPU_FAMILY_X86;
}
+jboolean android_os_cts_CpuFeatures_isArm64Cpu(JNIEnv* env, jobject thiz)
+{
+ AndroidCpuFamily cpuFamily = android_getCpuFamily();
+ return cpuFamily == ANDROID_CPU_FAMILY_ARM64;
+}
+
+jboolean android_os_cts_CpuFeatures_isMips64Cpu(JNIEnv* env, jobject thiz)
+{
+ AndroidCpuFamily cpuFamily = android_getCpuFamily();
+ return cpuFamily == ANDROID_CPU_FAMILY_MIPS64;
+}
+
+jboolean android_os_cts_CpuFeatures_isX86_64Cpu(JNIEnv* env, jobject thiz)
+{
+ AndroidCpuFamily cpuFamily = android_getCpuFamily();
+ return cpuFamily == ANDROID_CPU_FAMILY_X86_64;
+}
+
static JNINativeMethod gMethods[] = {
{ "isArmCpu", "()Z",
(void *) android_os_cts_CpuFeatures_isArmCpu },
@@ -51,6 +69,12 @@
(void *) android_os_cts_CpuFeatures_isMipsCpu },
{ "isX86Cpu", "()Z",
(void *) android_os_cts_CpuFeatures_isX86Cpu },
+ { "isArm64Cpu", "()Z",
+ (void *) android_os_cts_CpuFeatures_isArm64Cpu },
+ { "isMips64Cpu", "()Z",
+ (void *) android_os_cts_CpuFeatures_isMips64Cpu },
+ { "isX86_64Cpu", "()Z",
+ (void *) android_os_cts_CpuFeatures_isX86_64Cpu },
};
int register_android_os_cts_CpuFeatures(JNIEnv* env)
diff --git a/tests/jni/android_os_cts_TaggedPointer.cpp b/tests/jni/android_os_cts_TaggedPointer.cpp
new file mode 100644
index 0000000..e8f83a3
--- /dev/null
+++ b/tests/jni/android_os_cts_TaggedPointer.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2014 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 <jni.h>
+#include <inttypes.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdlib.h>
+
+//mask the top 8 bits
+#define TAG_MASK ((0xFFULL) << 56)
+
+#define PATTERN 0x600DC0DE
+
+static sigjmp_buf jmpenv;
+
+static void sigsegv_handler(int signum) {
+ siglongjmp(jmpenv, 1);
+}
+
+jboolean android_os_cts_TaggedPointer_hasTaggedPointer(JNIEnv* env, jobject thiz)
+{
+ uint32_t data;
+ uint32_t *tagged;
+ uintptr_t tmp;
+ int err;
+ jboolean ret = true;
+ struct sigaction sigsegv_act;
+ struct sigaction oldact;
+
+ tmp = TAG_MASK | (uintptr_t)(&data);
+ tagged = (uint32_t *)tmp;
+ data = PATTERN;
+
+ memset(&sigsegv_act, 0, sizeof(sigsegv_act));
+ sigsegv_act.sa_handler = sigsegv_handler;
+
+ err = sigaction(SIGSEGV, &sigsegv_act, &oldact);
+ if (err) {
+ ret = false;
+ goto err_sigaction;
+ }
+
+ if (sigsetjmp(jmpenv, 1)) {
+ ret = false;
+ goto err_segfault;
+ }
+
+ if (*tagged != PATTERN) {
+ ret = false;
+ }
+
+err_segfault:
+ sigaction(SIGSEGV, &oldact, NULL);
+err_sigaction:
+ return ret;
+}
+
+static JNINativeMethod gMethods[] = {
+ { "hasTaggedPointer", "()Z",
+ (void *) android_os_cts_TaggedPointer_hasTaggedPointer },
+};
+
+int register_android_os_cts_TaggedPointer(JNIEnv* env)
+{
+ jclass clazz = env->FindClass("android/os/cts/TaggedPointer");
+
+ return env->RegisterNatives(clazz, gMethods,
+ sizeof(gMethods) / sizeof(JNINativeMethod));
+}
diff --git a/tests/src/android/os/cts/CpuFeatures.java b/tests/src/android/os/cts/CpuFeatures.java
index 5009474..b767da2 100644
--- a/tests/src/android/os/cts/CpuFeatures.java
+++ b/tests/src/android/os/cts/CpuFeatures.java
@@ -37,4 +37,10 @@
public static native boolean isMipsCpu();
public static native boolean isX86Cpu();
+
+ public static native boolean isArm64Cpu();
+
+ public static native boolean isMips64Cpu();
+
+ public static native boolean isX86_64Cpu();
}
diff --git a/tests/src/android/os/cts/TaggedPointer.java b/tests/src/android/os/cts/TaggedPointer.java
new file mode 100644
index 0000000..16e76c9
--- /dev/null
+++ b/tests/src/android/os/cts/TaggedPointer.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package android.os.cts;
+
+public class TaggedPointer {
+
+ static {
+ System.loadLibrary("cts_jni");
+ }
+
+ public static native boolean hasTaggedPointer();
+}
diff --git a/tests/tests/bionic/Android.mk b/tests/tests/bionic/Android.mk
index 06b64ea..89081fc 100644
--- a/tests/tests/bionic/Android.mk
+++ b/tests/tests/bionic/Android.mk
@@ -1,26 +1,47 @@
LOCAL_PATH := $(call my-dir)
+test_executable := bionic-unit-tests-cts
+list_executable := $(test_executable)_list
+
include $(CLEAR_VARS)
-cts_src_test_path := bionic/tests
+LOCAL_MODULE := $(test_executable)
LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := bionic-unit-tests-cts
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
LOCAL_ADDITION_DEPENDENCIES := \
- $(LOCAL_PATH)/Android.mk \
+ $(LOCAL_PATH)/Android.mk \
LOCAL_SHARED_LIBRARIES += \
- libstlport \
- libdl \
+ libstlport \
+ libdl \
LOCAL_WHOLE_STATIC_LIBRARIES += \
- libBionicTests \
+ libBionicTests \
LOCAL_STATIC_LIBRARIES += \
- libgtest \
- libgtest_main \
+ libgtest \
+ libgtest_main \
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
LOCAL_CTS_TEST_PACKAGE := android.bionic
-
include $(BUILD_CTS_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := $(list_executable)
+
+LOCAL_ADDITION_DEPENDENCIES := \
+ $(LOCAL_PATH)/Android.mk \
+
+# A main without the extra output from the gtest main.
+LOCAL_SRC_FILES := \
+ main.cpp \
+
+LOCAL_LDLIBS += \
+ -lrt \
+
+LOCAL_WHOLE_STATIC_LIBRARIES += \
+ libBionicTests \
+
+include $(BUILD_HOST_NATIVE_TEST)
diff --git a/tests/tests/bionic/main.cpp b/tests/tests/bionic/main.cpp
new file mode 100644
index 0000000..b661af4
--- /dev/null
+++ b/tests/tests/bionic/main.cpp
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2014 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 <gtest/gtest.h>
+
+int main(int argc, char **argv) {
+ // Do not use gtest_main to avoid the Running main() ... output.
+ testing::InitGoogleTest(&argc, argv);
+
+ return RUN_ALL_TESTS();
+}
diff --git a/tests/tests/nativemedia/sl/Android.mk b/tests/tests/nativemedia/sl/Android.mk
index 90d8863..5b34b3d 100644
--- a/tests/tests/nativemedia/sl/Android.mk
+++ b/tests/tests/nativemedia/sl/Android.mk
@@ -1,13 +1,17 @@
# Build the unit tests.
LOCAL_PATH:= $(call my-dir)
+
+test_executable := NativeMediaTest_SL
+list_executable := $(test_executable)_list
+
include $(CLEAR_VARS)
-cts_src_test_path := $(LOCAL_PATH)
-
+LOCAL_MODULE := $(test_executable)
LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
-LOCAL_C_INCLUDES:= \
+LOCAL_C_INCLUDES := \
bionic \
bionic/libstdc++/include \
external/gtest/include \
@@ -15,22 +19,34 @@
external/stlport/stlport \
$(call include-path-for, wilhelm-ut)
-LOCAL_SRC_FILES:= \
+LOCAL_SRC_FILES := \
src/SLObjectCreationTest.cpp
LOCAL_SHARED_LIBRARIES := \
- libutils \
- liblog \
- libOpenSLES \
- libstlport
+ libutils \
+ liblog \
+ libOpenSLES \
+ libstlport
LOCAL_STATIC_LIBRARIES := \
libOpenSLESUT \
libgtest
-LOCAL_MODULE:= NativeMediaTest_SL
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
-
LOCAL_CTS_TEST_PACKAGE := android.nativemedia.sl
include $(BUILD_CTS_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := $(list_executable)
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ src/SLObjectCreationTest.cpp
+
+LOCAL_CFLAGS := \
+ -DBUILD_ONLY \
+
+LOCAL_SHARED_LIBRARIES := \
+ liblog \
+
+include $(BUILD_HOST_NATIVE_TEST)
diff --git a/tests/tests/nativemedia/sl/src/SLObjectCreationTest.cpp b/tests/tests/nativemedia/sl/src/SLObjectCreationTest.cpp
index 804263e..d0b3be0 100644
--- a/tests/tests/nativemedia/sl/src/SLObjectCreationTest.cpp
+++ b/tests/tests/nativemedia/sl/src/SLObjectCreationTest.cpp
@@ -35,12 +35,16 @@
#define LOG_NDEBUG 0
#define LOG_TAG "SLObjectCreationTest"
+#include <gtest/gtest.h>
#include <utils/Log.h>
+
+#if !defined(BUILD_ONLY)
#include "SLES/OpenSLES.h"
#include "SLES/OpenSLES_Android.h"
#include "OpenSLESUT.h"
-#include <gtest/gtest.h>
+#endif
+#if !defined(BUILD_ONLY)
//-----------------------------------------------------------------
/* Checks for error and displays the error code if any */
bool IsOk(SLresult res) {
@@ -305,6 +309,20 @@
(*audioRecorderObj)->Destroy(audioRecorderObj);
}
};
+#else
+class SLObjectCreationTest : public ::testing::Test {
+protected:
+ void OutputMixCreation() { }
+ void AudioPlayerFromUriCreation() { }
+ void AudioPlayerFromFdCreation() { }
+ void AudioPlayerFromPcmBqCreation() { }
+ void AudioPlayerFromTsAbqCreation() { }
+ void AudioPlayerFromUriToPcmBqCreation() { }
+ void AudioPlayerFromFdToPcmBqCreation() { }
+ void AudioPlayerFromAdtsAbqToPcmBqCreation() { }
+ void AudioRecorderCreation(bool) { }
+};
+#endif
//-------------------------------------------------------------------------------------------------
TEST_F(SLObjectCreationTest, testEngineCreation) {
diff --git a/tests/tests/nativemedia/xa/Android.mk b/tests/tests/nativemedia/xa/Android.mk
index 9ff2110..6995bc0 100644
--- a/tests/tests/nativemedia/xa/Android.mk
+++ b/tests/tests/nativemedia/xa/Android.mk
@@ -1,13 +1,17 @@
# Build the unit tests.
LOCAL_PATH:= $(call my-dir)
+
+test_executable := NativeMediaTest_XA
+list_executable := $(test_executable)_list
+
include $(CLEAR_VARS)
-cts_src_test_path := $(LOCAL_PATH)
-
+LOCAL_MODULE:= $(test_executable)
LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
-LOCAL_C_INCLUDES:= \
+LOCAL_C_INCLUDES := \
bionic \
bionic/libstdc++/include \
external/gtest/include \
@@ -15,7 +19,7 @@
external/stlport/stlport \
$(call include-path-for, wilhelm-ut)
-LOCAL_SRC_FILES:= \
+LOCAL_SRC_FILES := \
src/XAObjectCreationTest.cpp
LOCAL_SHARED_LIBRARIES := \
@@ -27,9 +31,21 @@
LOCAL_STATIC_LIBRARIES := \
libgtest
-LOCAL_MODULE:= NativeMediaTest_XA
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
-
LOCAL_CTS_TEST_PACKAGE := android.nativemedia.xa
include $(BUILD_CTS_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := $(list_executable)
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ src/XAObjectCreationTest.cpp
+
+LOCAL_CFLAGS := \
+ -DBUILD_ONLY \
+
+LOCAL_SHARED_LIBRARIES := \
+ liblog \
+
+include $(BUILD_HOST_NATIVE_TEST)
diff --git a/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp b/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp
index 3ff84c2..d905451 100644
--- a/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp
+++ b/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp
@@ -24,12 +24,15 @@
#define LOG_NDEBUG 0
#define LOG_TAG "XAObjectCreationTest"
+#include <gtest/gtest.h>
#include <utils/Log.h>
+
+#if !defined(BUILD_ONLY)
#include "OMXAL/OpenMAXAL.h"
#include "OMXAL/OpenMAXAL_Android.h"
-//#include <android/native_window_jni.h>
-#include <gtest/gtest.h>
+#endif
+#if !defined(BUILD_ONLY)
//-----------------------------------------------------------------
/* Checks for error and displays the error code if any */
bool IsOk(XAresult res) {
@@ -115,6 +118,12 @@
}
};
+#else
+class XAObjectCreationTest : public ::testing::Test {
+protected:
+ void OutputMixCreation() { }
+};
+#endif
//-------------------------------------------------------------------------------------------------
TEST_F(XAObjectCreationTest, testEngineCreation) {
diff --git a/tests/tests/os/src/android/os/cts/BundleTest.java b/tests/tests/os/src/android/os/cts/BundleTest.java
index 7674b6b..0db5fd0 100644
--- a/tests/tests/os/src/android/os/cts/BundleTest.java
+++ b/tests/tests/os/src/android/os/cts/BundleTest.java
@@ -31,9 +31,11 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Set;
public class BundleTest extends AndroidTestCase {
+
private static final boolean BOOLEANKEYVALUE = false;
private static final int INTKEYVALUE = 20;
@@ -513,12 +515,37 @@
assertBundleEquals(bundle2, (Bundle) ret.get(1));
}
- public void testGetSerializable() {
+ public void testGetSerializableWithString() {
assertNull(mBundle.getSerializable(KEY));
- mBundle.putSerializable(KEY, "android");
- assertEquals("android", mBundle.getSerializable(KEY));
+ String s = "android";
+ mBundle.putSerializable(KEY, s);
+ assertEquals(s, mBundle.getSerializable(KEY));
roundtrip();
- assertEquals("android", mBundle.getSerializable(KEY));
+ assertEquals(s, mBundle.getSerializable(KEY));
+ }
+
+ public void testGetSerializableWithStringArray() {
+ assertNull(mBundle.getSerializable(KEY));
+ String[] strings = new String[]{"first", "last"};
+ mBundle.putSerializable(KEY, strings);
+ assertEquals(Arrays.asList(strings),
+ Arrays.asList((String[]) mBundle.getSerializable(KEY)));
+ roundtrip();
+ assertEquals(Arrays.asList(strings),
+ Arrays.asList((String[]) mBundle.getSerializable(KEY)));
+ }
+
+ public void testGetSerializableWithMultiDimensionalObjectArray() {
+ assertNull(mBundle.getSerializable(KEY));
+ Object[][] objects = new Object[][] {
+ {"string", 1L}
+ };
+ mBundle.putSerializable(KEY, objects);
+ assertEquals(Arrays.asList(objects[0]),
+ Arrays.asList(((Object[][]) mBundle.getSerializable(KEY))[0]));
+ roundtrip();
+ assertEquals(Arrays.asList(objects[0]),
+ Arrays.asList(((Object[][]) mBundle.getSerializable(KEY))[0]));
}
public void testGetShort1() {
@@ -812,9 +839,5 @@
MockClassLoader() {
super();
}
-
- MockClassLoader(ClassLoader parent) {
- super(parent);
- }
}
}
diff --git a/tests/tests/os/src/android/os/cts/TaggedPointerTest.java b/tests/tests/os/src/android/os/cts/TaggedPointerTest.java
new file mode 100644
index 0000000..4c619de
--- /dev/null
+++ b/tests/tests/os/src/android/os/cts/TaggedPointerTest.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package android.os.cts;
+
+
+import android.test.AndroidTestCase;
+
+import android.os.cts.CpuFeatures;
+import android.os.cts.TaggedPointer;
+
+public class TaggedPointerTest extends AndroidTestCase {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testHasTaggedPointer() {
+ if (!CpuFeatures.isArm64Cpu()) {
+ return;
+ }
+ assertTrue("Machine does not support tagged pointers", TaggedPointer.hasTaggedPointer());
+ }
+}
diff --git a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
index ab6ff46..cc51404 100644
--- a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
@@ -727,6 +727,7 @@
private static final Set<File> CHAR_DEV_EXCEPTIONS = new HashSet<File>(
Arrays.asList(
// All exceptions should be alphabetical and associated with a bug number.
+ new File("/dev/adsprpc-smd"), // b/11710243
new File("/dev/alarm"), // b/9035217
new File("/dev/ashmem"),
new File("/dev/binder"),
diff --git a/tests/tests/security/src/android/security/cts/SELinuxTest.java b/tests/tests/security/src/android/security/cts/SELinuxTest.java
index 838eb8a..000664a 100644
--- a/tests/tests/security/src/android/security/cts/SELinuxTest.java
+++ b/tests/tests/security/src/android/security/cts/SELinuxTest.java
@@ -17,6 +17,7 @@
package android.security.cts;
import junit.framework.TestCase;
+import java.io.File;
/**
* Verify that the SELinux configuration is sane.
@@ -51,5 +52,11 @@
assertTrue(checkSELinuxAccess("u:r:init:s0", "u:object_r:runas_exec:s0", "file", "getattr", "/system/bin/run-as"));
}
+ public void testNoBooleans() throws Exception {
+ // Intentionally not using JNI bindings to keep things simple
+ File[] files = new File("/sys/fs/selinux/booleans/").listFiles();
+ assertEquals(0, files.length);
+ }
+
private static native boolean checkSELinuxAccess(String scon, String tcon, String tclass, String perm, String extra);
}
diff --git a/tools/cts-native-scanner/src/com/android/cts/nativescanner/CtsNativeScanner.java b/tools/cts-native-scanner/src/com/android/cts/nativescanner/CtsNativeScanner.java
index a7599b0..2414138 100644
--- a/tools/cts-native-scanner/src/com/android/cts/nativescanner/CtsNativeScanner.java
+++ b/tools/cts-native-scanner/src/com/android/cts/nativescanner/CtsNativeScanner.java
@@ -15,7 +15,8 @@
*/
package com.android.cts.nativescanner;
-import java.io.File;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
@@ -27,18 +28,18 @@
private static void usage(String[] args) {
System.err.println("Arguments: " + Arrays.asList(args));
- System.err.println("Usage: cts-native-scanner -s SOURCE_DIR -t TEST_SUITE");
+ System.err.println("Usage: cts-native-scanner -t TEST_SUITE");
+ System.err.println(" This code reads from stdin the list of tests.");
+ System.err.println(" The format expected:");
+ System.err.println(" TEST_CASE_NAME.");
+ System.err.println(" TEST_NAME");
System.exit(1);
}
public static void main(String[] args) throws Exception {
- File sourceDir = null;
String testSuite = null;
-
for (int i = 0; i < args.length; i++) {
- if ("-s".equals(args[i])) {
- sourceDir = new File(getArg(args, ++i, "Missing value for source directory"));
- } else if ("-t".equals(args[i])) {
+ if ("-t".equals(args[i])) {
testSuite = getArg(args, ++i, "Missing value for test suite");
} else {
System.err.println("Unsupported flag: " + args[i]);
@@ -46,19 +47,14 @@
}
}
- if (sourceDir == null) {
- System.out.println("Source directory is required");
- usage(args);
- }
-
if (testSuite == null) {
System.out.println("Test suite is required");
usage(args);
}
- TestScanner scanner = new TestScanner(sourceDir, testSuite);
- List<String> testNames = scanner.getTestNames();
- for (String name : testNames) {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
+ TestScanner scanner = new TestScanner(reader, testSuite);
+ for (String name : scanner.getTestNames()) {
System.out.println(name);
}
}
diff --git a/tools/cts-native-scanner/src/com/android/cts/nativescanner/TestScanner.java b/tools/cts-native-scanner/src/com/android/cts/nativescanner/TestScanner.java
index 370b509..6fcb353 100644
--- a/tools/cts-native-scanner/src/com/android/cts/nativescanner/TestScanner.java
+++ b/tools/cts-native-scanner/src/com/android/cts/nativescanner/TestScanner.java
@@ -16,100 +16,60 @@
package com.android.cts.nativescanner;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FilenameFilter;
+import java.io.BufferedReader;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
-import java.util.Scanner;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
/**
- * Scanner of C++ gTest source files.
+ * Read from the BufferedReader a list of test case names and test cases.
*
- * It looks for test declarations and outputs a file following this format:
- * suite:TestSuite
- * case:TestCase1
- * test:Test1
- * test:Test2
- * suite:TestSuite
- * case:TestCase2
- * test:Test1
- * test:Test2
+ * The expected format of the incoming test list:
+ * TEST_CASE_NAME.
+ * TEST_NAME1
+ * TEST_NAME2
*
+ * The output:
+ * suite:TestSuite
+ * case:TEST_CASE_NAME
+ * test:TEST_NAME1
+ * test:TEST_NAME2
*/
class TestScanner {
- /** Directory to recursively scan for gTest test declarations. */
- private final File mSourceDir;
-
private final String mTestSuite;
- TestScanner(File sourceDir, String testSuite) {
- mSourceDir = sourceDir;
+ private final BufferedReader mReader;
+
+ TestScanner(BufferedReader reader, String testSuite) {
mTestSuite = testSuite;
+ mReader = reader;
}
public List<String> getTestNames() throws IOException {
List<String> testNames = new ArrayList<String>();
- scanDir(mSourceDir, testNames);
- return testNames;
- }
- private void scanDir(File dir, List<String> testNames) throws FileNotFoundException {
- // Find both C++ files to find tests and directories to look for more tests!
- File[] files = dir.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String filename) {
- return filename.endsWith(".cpp") || filename.endsWith(".cc")
- || new File(dir, filename).isDirectory();
- }
- });
-
- for (int i = 0; i < files.length; i++) {
- File file = files[i];
- if (file.isDirectory()) {
- scanDir(file, testNames);
+ String testCaseName = null;
+ String line;
+ while ((line = mReader.readLine()) != null) {
+ if (line.length() > 0) {
+ if (line.charAt(0) == ' ') {
+ if (testCaseName != null) {
+ testNames.add("test:" + line.trim());
+ } else {
+ throw new IOException("TEST_CASE_NAME not defined before first test.");
+ }
} else {
- scanFile(new Scanner(file), testNames);
+ testCaseName = line.trim();
+ if (testCaseName.endsWith(".")) {
+ testCaseName = testCaseName.substring(0, testCaseName.length()-1);
+ }
+ testNames.add("suite:" + mTestSuite);
+ testNames.add("case:" + testCaseName);
}
+ }
}
- }
-
- // We want to find lines like TEST_F(SLObjectCreationTest, testAudioPlayerFromFdCreation)
- // or TEST(stdio, printf) { ...
- // and extract the "SLObjectCreationTest" as group #1,
- // "testAudioPlayerFromFdCreation" as group #2
- // TODO: It would be better to concatenate the two parts.
- private static final Pattern METHOD_REGEX =
- Pattern.compile("\\s*TEST(?:_F)?\\((\\w+),\\s*(\\w+)\\).*");
-
- public void scanFile(Scanner scanner, List<String> testNames) {
- try {
- String lastCase = "";
- while (scanner.hasNextLine()) {
- String line = scanner.nextLine();
-
- Matcher matcher = METHOD_REGEX.matcher(line);
-
- if (!matcher.matches()) {
- continue;
- }
-
- if (!lastCase.equals(matcher.group(1))) {
- testNames.add("suite:" + mTestSuite);
- testNames.add("case:" + matcher.group(1));
- lastCase = matcher.group(1);
- }
-
- testNames.add("test:" + matcher.group(2));
- }
- } finally {
- if (scanner != null) {
- scanner.close();
- }
- }
+ return testNames;
}
}
diff --git a/tools/cts-native-scanner/tests/src/com/android/cts/nativescanner/TestScannerTest.java b/tools/cts-native-scanner/tests/src/com/android/cts/nativescanner/TestScannerTest.java
index 18732fd..b00c7dc 100644
--- a/tools/cts-native-scanner/tests/src/com/android/cts/nativescanner/TestScannerTest.java
+++ b/tools/cts-native-scanner/tests/src/com/android/cts/nativescanner/TestScannerTest.java
@@ -19,12 +19,10 @@
import junit.framework.TestCase;
-import java.io.File;
+import java.io.BufferedReader;
+import java.io.IOException;
import java.io.StringReader;
-import java.lang.StringBuilder;
-import java.util.Scanner;
import java.util.List;
-import java.util.ArrayList;
import java.util.Iterator;
/**
@@ -32,31 +30,49 @@
*/
public class TestScannerTest extends TestCase {
- public void testScanFile() {
- TestScanner testScanner = new TestScanner(new File("unused"), "TestSuite");
+ public void testSingleTestNamesCase() throws Exception {
+ StringReader singleTestString = new StringReader("FakeTestCase.\n FakeTestName\n");
+ BufferedReader reader = new BufferedReader(singleTestString);
- String newLine = System.getProperty("line.separator");
- StringBuilder sb = new StringBuilder();
- sb.append("foobar" + newLine); // ignored
- sb.append("TEST_F(TestCase1, TestName1)" + newLine); // valid
- sb.append("TEST_F(TestCase1, TestName2)" + newLine); // valid
- sb.append("TEST_F(TestCase2, TestName1) foo" + newLine); // valid
- sb.append("TEST_F(TestCase2, TestName1 foo)" + newLine); // ignored
- sb.append("foo TEST_F(TestCase2, TestName1)" + newLine); // ignored
+ TestScanner testScanner = new TestScanner(reader, "TestSuite");
- List<String> names = new ArrayList<String>();
- Scanner scanner = new Scanner(new StringReader(sb.toString()));
- testScanner.scanFile(scanner, names);
+ List<String> names = testScanner.getTestNames();
Iterator it = names.iterator();
-
assertEquals("suite:TestSuite", it.next());
- assertEquals("case:TestCase1", it.next());
- assertEquals("test:TestName1", it.next());
- assertEquals("test:TestName2", it.next());
- assertEquals("suite:TestSuite", it.next());
- assertEquals("case:TestCase2", it.next());
- assertEquals("test:TestName1", it.next());
+ assertEquals("case:FakeTestCase", it.next());
+ assertEquals("test:FakeTestName", it.next());
assertFalse(it.hasNext());
- scanner.close();
+ }
+
+ public void testMultipleTestNamesCase() throws Exception {
+ StringReader singleTestString = new StringReader(
+ "Case1.\n Test1\n Test2\nCase2.\n Test3\n Test4\n");
+ BufferedReader reader = new BufferedReader(singleTestString);
+
+ TestScanner testScanner = new TestScanner(reader, "TestSuite");
+
+ List<String> names = testScanner.getTestNames();
+ Iterator it = names.iterator();
+ assertEquals("suite:TestSuite", it.next());
+ assertEquals("case:Case1", it.next());
+ assertEquals("test:Test1", it.next());
+ assertEquals("test:Test2", it.next());
+ assertEquals("case:Case2", it.next());
+ assertEquals("test:Test3", it.next());
+ assertEquals("test:Test4", it.next());
+ assertFalse(it.hasNext());
+ }
+
+ public void testMissingTestCaseNameCase() {
+ StringReader singleTestString = new StringReader(" Test1\n");
+ BufferedReader reader = new BufferedReader(singleTestString);
+
+ TestScanner testScanner = new TestScanner(reader, "TestSuite");
+
+ try {
+ List<String> names = testScanner.getTestNames();
+ fail();
+ } catch (IOException expected) {
+ }
}
}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/GeeTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/GeeTest.java
index 5cfafc6..035b4a2 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/GeeTest.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/GeeTest.java
@@ -40,6 +40,8 @@
public class GeeTest implements IBuildReceiver, IDeviceTest, IRemoteTest {
private static final String NATIVE_TESTS_DIRECTORY = "/data/local/tmp/cts-native-tests";
+ private static final String NATIVE_TESTS_DIRECTORY_TMP = "/data/local/tmp";
+ private static final String ANDROID_PATH_SEPARATOR = "/";
private int mMaxTestTimeMs = 1 * 60 * 1000;
@@ -75,8 +77,8 @@
return false;
}
- File devicePath = new File(NATIVE_TESTS_DIRECTORY, mExeName);
- if (!mDevice.pushFile(nativeExe, devicePath.toString())) {
+ String devicePath = NATIVE_TESTS_DIRECTORY + ANDROID_PATH_SEPARATOR + mExeName;
+ if (!mDevice.pushFile(nativeExe, devicePath)) {
CLog.e("Failed to push native test to device");
return false;
}
@@ -87,13 +89,11 @@
if (mDevice.doesFileExist(remoteFilePath)) {
return true;
}
- File remoteFile = new File(remoteFilePath);
- String parentPath = remoteFile.getParent();
- if (parentPath != null) {
- if (!createRemoteDir(parentPath)) {
- return false;
- }
+ if (!(mDevice.doesFileExist(NATIVE_TESTS_DIRECTORY_TMP))) {
+ CLog.e("Could not find the /data/local/tmp directory");
+ return false;
}
+
mDevice.executeShellCommand(String.format("mkdir %s", remoteFilePath));
return mDevice.doesFileExist(remoteFilePath);
}
@@ -102,7 +102,7 @@
GeeTestResultParser resultParser = new GeeTestResultParser(mPackageName, listener);
resultParser.setFakePackagePrefix(mPackageName + ".");
- String fullPath = NATIVE_TESTS_DIRECTORY + File.separator + mExeName;
+ String fullPath = NATIVE_TESTS_DIRECTORY + ANDROID_PATH_SEPARATOR + mExeName;
String flags = "";
CLog.v("Running gtest %s %s on %s", fullPath, flags, mDevice.getSerialNumber());
// force file to be executable