Skip SeccompTests that fail when running under an emulated ABI.
Bug: 22416639
Change-Id: I4d91d9cf85267a32606cac0170f24c65b845339e
diff --git a/tests/tests/os/jni/android_os_cts_SeccompTest.cpp b/tests/tests/os/jni/android_os_cts_SeccompTest.cpp
index 528696b..1ba8550 100644
--- a/tests/tests/os/jni/android_os_cts_SeccompTest.cpp
+++ b/tests/tests/os/jni/android_os_cts_SeccompTest.cpp
@@ -33,7 +33,7 @@
struct __test_metadata* get_seccomp_test_list();
}
-static const char TAG[] = "SecompBpfTest-Native";
+static const char TAG[] = "SeccompBpfTest-Native";
jboolean android_security_cts_SeccompBpfTest_runKernelUnitTest(
JNIEnv* env, jobject thiz __unused, jstring name) {
diff --git a/tests/tests/os/src/android/os/cts/SeccompTest.java b/tests/tests/os/src/android/os/cts/SeccompTest.java
index 0340580..7376079 100644
--- a/tests/tests/os/src/android/os/cts/SeccompTest.java
+++ b/tests/tests/os/src/android/os/cts/SeccompTest.java
@@ -50,6 +50,15 @@
System.loadLibrary("ctsos_jni");
}
+ // As this test validates a kernel system call interface, if the CTS tests
+ // were built for ARM but are running on an x86 CPU, the system call numbers
+ // will not be correct, so skip those tests.
+ private boolean isRunningUnderEmulatedAbi() {
+ final String primaryAbi = Build.SUPPORTED_ABIS[0];
+ return (CpuFeatures.isArmCpu() || CpuFeatures.isArm64Cpu()) &&
+ !(primaryAbi.equals("armeabi-v7a") || primaryAbi.equals("arm64-v8a"));
+ }
+
public void testSeccomp() {
if (OSFeatures.needsSeccompSupport()) {
assertTrue("Please enable seccomp support "
@@ -62,6 +71,11 @@
if (!OSFeatures.needsSeccompSupport())
return;
+ if (isRunningUnderEmulatedAbi()) {
+ Log.d(TAG, "Skipping test running under an emulated ABI");
+ return;
+ }
+
final String[] tests = {
"global.mode_strict_support",
"global.mode_strict_cannot_call_prctl",
@@ -137,6 +151,11 @@
if (!OSFeatures.needsSeccompSupport())
return;
+ if (isRunningUnderEmulatedAbi()) {
+ Log.d(TAG, "Skipping test running under an emulated ABI");
+ return;
+ }
+
final String[] tests = {
"global.seccomp_syscall",
"global.seccomp_syscall_mode_lock",
@@ -175,6 +194,11 @@
if (!OSFeatures.needsSeccompSupport())
return;
+ if (isRunningUnderEmulatedAbi()) {
+ Log.d(TAG, "Skipping test running under an emulated ABI");
+ return;
+ }
+
final IsolatedServiceConnection peer = new IsolatedServiceConnection();
final Intent intent = new Intent(getContext(), IsolatedService.class);
assertTrue(getContext().bindService(intent, peer, Context.BIND_AUTO_CREATE));
@@ -201,6 +225,11 @@
if (!OSFeatures.needsSeccompSupport())
return;
+ if (isRunningUnderEmulatedAbi()) {
+ Log.d(TAG, "Skipping test running under an emulated ABI");
+ return;
+ }
+
final IsolatedServiceConnection peer = new IsolatedServiceConnection();
final Intent intent = new Intent(getContext(), IsolatedService.class);
assertTrue(getContext().bindService(intent, peer, Context.BIND_AUTO_CREATE));