Revert "require seccomp"
This reverts commit fa79c10e91454f2af57691fde2648e9c8daada3b.
diff --git a/tests/jni/Android.mk b/tests/jni/Android.mk
index 0f7511e..39aafa1 100644
--- a/tests/jni/Android.mk
+++ b/tests/jni/Android.mk
@@ -23,7 +23,6 @@
LOCAL_SRC_FILES := \
CtsJniOnLoad.cpp \
- android_os_cts_OSFeatures.cpp \
android_os_cts_FileUtils.cpp \
android_net_cts_NetlinkSocket.cpp
diff --git a/tests/jni/CtsJniOnLoad.cpp b/tests/jni/CtsJniOnLoad.cpp
index 99ea37e..d029b2d 100644
--- a/tests/jni/CtsJniOnLoad.cpp
+++ b/tests/jni/CtsJniOnLoad.cpp
@@ -20,8 +20,6 @@
extern int register_android_os_cts_CpuFeatures(JNIEnv*);
-extern int register_android_os_cts_OSFeatures(JNIEnv*);
-
extern int register_android_os_cts_FileUtils(JNIEnv*);
jint JNI_OnLoad(JavaVM *vm, void *reserved) {
@@ -35,10 +33,6 @@
return JNI_ERR;
}
- if (register_android_os_cts_OSFeatures(env)) {
- return JNI_ERR;
- }
-
if (register_android_os_cts_FileUtils(env)) {
return JNI_ERR;
}
diff --git a/tests/jni/android_os_cts_OSFeatures.cpp b/tests/jni/android_os_cts_OSFeatures.cpp
deleted file mode 100644
index 50baaa2..0000000
--- a/tests/jni/android_os_cts_OSFeatures.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2013 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 <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <linux/filter.h>
-#include <linux/seccomp.h>
-
-#include <sys/prctl.h>
-#include <sys/utsname.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#define DENY BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_KILL)
-
-static void test_seccomp() {
- if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) < 0) {
- _exit(0);
- }
-
- struct sock_filter filter[] = { DENY };
- struct sock_fprog prog;
- memset(&prog, 0, sizeof(prog));
- prog.len = sizeof(filter) / sizeof(filter[0]);
- prog.filter = filter;
-
- if (prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog) < 0) {
- _exit(0);
- }
-
- _exit(0); // should crash with SIGSYS
-}
-
-jboolean android_os_cts_OSFeatures_hasSeccompSupport(JNIEnv* env, jobject thiz)
-{
- pid_t pid = fork();
- if (pid == -1) {
- return false;
- }
- if (pid == 0) {
- // child
- test_seccomp();
- _exit(0);
- }
-
- int status;
- waitpid(pid, &status, 0);
- return WIFSIGNALED(status) && (WTERMSIG(status) == SIGSYS);
-}
-
-jboolean android_os_cts_OSFeatures_needsSeccompSupport(JNIEnv* env, jobject thiz)
-{
-#if !defined(__arm__) && !defined(__i386__) && !defined(__x86_64__)
- // Seccomp support is only available for ARM and x86.
- return false;
-#endif
-
- int major;
- int minor;
- struct utsname uts;
- if (uname(&uts) == -1) {
- return false;
- }
-
- if (sscanf(uts.release, "%d.%d", &major, &minor) != 2) {
- return false;
- }
-
- // Kernels before 3.5 don't have seccomp
- if ((major < 3) || ((major == 3) && (minor < 5))) {
- return false;
- }
-
- return true;
-}
-
-static JNINativeMethod gMethods[] = {
- { "hasSeccompSupport", "()Z",
- (void *) android_os_cts_OSFeatures_hasSeccompSupport },
- { "needsSeccompSupport", "()Z",
- (void *) android_os_cts_OSFeatures_needsSeccompSupport },
-};
-
-int register_android_os_cts_OSFeatures(JNIEnv* env)
-{
- jclass clazz = env->FindClass("android/os/cts/OSFeatures");
-
- return env->RegisterNatives(clazz, gMethods,
- sizeof(gMethods) / sizeof(JNINativeMethod));
-}
diff --git a/tests/src/android/os/cts/OSFeatures.java b/tests/src/android/os/cts/OSFeatures.java
deleted file mode 100644
index 0bb733d..0000000
--- a/tests/src/android/os/cts/OSFeatures.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.
- */
-
-package android.os.cts;
-
-public class OSFeatures {
- static {
- System.loadLibrary("cts_jni");
- }
-
- public static native boolean hasSeccompSupport();
- public static native boolean needsSeccompSupport();
-}
diff --git a/tests/tests/os/src/android/os/cts/SeccompTest.java b/tests/tests/os/src/android/os/cts/SeccompTest.java
deleted file mode 100644
index 6f59550..0000000
--- a/tests/tests/os/src/android/os/cts/SeccompTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2013 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 junit.framework.TestCase;
-
-public class SeccompTest extends TestCase {
-
- public void testSeccomp() {
- if (OSFeatures.needsSeccompSupport()) {
- assertTrue("Please enable seccomp support "
- + "in your kernel (CONFIG_SECCOMP_FILTER=y)",
- OSFeatures.hasSeccompSupport());
- }
- }
-}