[CRIU] [PATCH] test: seccomp -- Make sure __NR_seccomp is present to not fail building on old kernels
Cyrill Gorcunov
gorcunov at openvz.org
Thu Feb 25 06:02:34 PST 2016
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
Guys, take a look please.
test/zdtm/static/seccomp_filter.c | 39 ++++++++++++++++++++------
test/zdtm/static/seccomp_filter_inheritance.c | 40 +++++++++++++++++++++------
test/zdtm/static/seccomp_filter_tsync.c | 31 ++++++++++++++++++---
test/zdtm/static/seccomp_strict.c | 37 ++++++++++++++++++++-----
4 files changed, 120 insertions(+), 27 deletions(-)
diff --git a/test/zdtm/static/seccomp_filter.c b/test/zdtm/static/seccomp_filter.c
index 1a1f34302a1b..4272532d6821 100644
--- a/test/zdtm/static/seccomp_filter.c
+++ b/test/zdtm/static/seccomp_filter.c
@@ -4,19 +4,25 @@
#include <stddef.h>
#include <sys/prctl.h>
#include <sys/ptrace.h>
-#include <linux/seccomp.h>
-#include <linux/filter.h>
-#include <linux/limits.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/wait.h>
-#include <sys/syscall.h>
+
+#ifdef __NR_seccomp
+# include <linux/seccomp.h>
+# include <linux/filter.h>
+# include <linux/limits.h>
+# include <stdlib.h>
+# include <sys/types.h>
+# include <sys/socket.h>
+# include <sys/wait.h>
+# include <sys/syscall.h>
+#endif
+
#include "zdtmtst.h"
const char *test_doc = "Check that SECCOMP_MODE_FILTER is restored";
const char *test_author = "Tycho Andersen <tycho.andersen at canonical.com>";
+#ifdef __NR_seccomp
+
int get_seccomp_mode(pid_t pid)
{
FILE *f;
@@ -185,3 +191,20 @@ err:
kill(pid, SIGKILL);
return 1;
}
+
+#else /* __NR_seccomp */
+
+int main(int argc, char ** argv)
+{
+ test_init(argc, argv);
+
+ test_msg("Skipping test on incompatible kernel");
+
+ test_daemon();
+ test_waitsig();
+
+ pass();
+ return 0;
+}
+
+#endif /* __NR_seccomp */
diff --git a/test/zdtm/static/seccomp_filter_inheritance.c b/test/zdtm/static/seccomp_filter_inheritance.c
index ff0c46a7d7e6..c3c501e1dcfd 100644
--- a/test/zdtm/static/seccomp_filter_inheritance.c
+++ b/test/zdtm/static/seccomp_filter_inheritance.c
@@ -4,19 +4,25 @@
#include <stddef.h>
#include <sys/prctl.h>
#include <sys/ptrace.h>
-#include <linux/seccomp.h>
-#include <linux/filter.h>
-#include <linux/limits.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/wait.h>
-#include <sys/syscall.h>
+
+#ifdef __NR_seccomp
+# include <linux/seccomp.h>
+# include <linux/filter.h>
+# include <linux/limits.h>
+# include <stdlib.h>
+# include <sys/types.h>
+# include <sys/socket.h>
+# include <sys/wait.h>
+# include <sys/syscall.h>
+#endif
+
#include "zdtmtst.h"
const char *test_doc = "Check that SECCOMP_MODE_FILTER is restored";
const char *test_author = "Tycho Andersen <tycho.andersen at canonical.com>";
+#ifdef __NR_seccomp
+
int get_seccomp_mode(pid_t pid)
{
FILE *f;
@@ -174,3 +180,21 @@ err:
kill(pid, SIGKILL);
return 1;
}
+
+
+#else /* __NR_seccomp */
+
+int main(int argc, char ** argv)
+{
+ test_init(argc, argv);
+
+ test_msg("Skipping test on incompatible kernel");
+
+ test_daemon();
+ test_waitsig();
+
+ pass();
+ return 0;
+}
+
+#endif /* __NR_seccomp */
diff --git a/test/zdtm/static/seccomp_filter_tsync.c b/test/zdtm/static/seccomp_filter_tsync.c
index a5835498f80e..1473959cc0bb 100644
--- a/test/zdtm/static/seccomp_filter_tsync.c
+++ b/test/zdtm/static/seccomp_filter_tsync.c
@@ -4,15 +4,19 @@
#include <stddef.h>
#include <sys/prctl.h>
#include <sys/ptrace.h>
-#include <linux/seccomp.h>
-#include <linux/filter.h>
-#include <linux/limits.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/syscall.h>
-#include <pthread.h>
+
+#ifdef __NR_seccomp
+# include <linux/seccomp.h>
+# include <linux/filter.h>
+# include <linux/limits.h>
+# include <pthread.h>
+#endif
+
#include "zdtmtst.h"
#ifndef SECCOMP_SET_MODE_FILTER
@@ -26,6 +30,8 @@
const char *test_doc = "Check that SECCOMP_FILTER_FLAG_TSYNC works correctly after restore";
const char *test_author = "Tycho Andersen <tycho.andersen at canonical.com>";
+#ifdef __NR_seccomp
+
pthread_mutex_t getpid_wait;
int get_seccomp_mode(pid_t pid)
@@ -200,3 +206,20 @@ err:
kill(pid, SIGKILL);
return 1;
}
+
+#else /* __NR_seccomp */
+
+int main(int argc, char ** argv)
+{
+ test_init(argc, argv);
+
+ test_msg("Skipping test on incompatible kernel");
+
+ test_daemon();
+ test_waitsig();
+
+ pass();
+ return 0;
+}
+
+#endif /* __NR_seccomp */
diff --git a/test/zdtm/static/seccomp_strict.c b/test/zdtm/static/seccomp_strict.c
index 8b1a37ac5d3f..990e15d5838c 100644
--- a/test/zdtm/static/seccomp_strict.c
+++ b/test/zdtm/static/seccomp_strict.c
@@ -2,18 +2,24 @@
#include <stdbool.h>
#include <signal.h>
#include <sys/prctl.h>
-#include <linux/seccomp.h>
-#include <linux/limits.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/wait.h>
-#include <sys/syscall.h>
+
+#ifdef __NR_seccomp
+# include <linux/seccomp.h>
+# include <linux/limits.h>
+# include <stdlib.h>
+# include <sys/types.h>
+# include <sys/socket.h>
+# include <sys/wait.h>
+# include <sys/syscall.h>
+#endif
+
#include "zdtmtst.h"
const char *test_doc = "Check that SECCOMP_MODE_STRICT is restored";
const char *test_author = "Tycho Andersen <tycho.andersen at canonical.com>";
+#ifdef __NR_seccomp
+
int get_seccomp_mode(pid_t pid)
{
FILE *f;
@@ -120,3 +126,20 @@ err:
kill(pid, SIGKILL);
return 1;
}
+
+#else /* __NR_seccomp */
+
+int main(int argc, char ** argv)
+{
+ test_init(argc, argv);
+
+ test_msg("Skipping test on incompatible kernel");
+
+ test_daemon();
+ test_waitsig();
+
+ pass();
+ return 0;
+}
+
+#endif /* __NR_seccomp */
--
2.5.0
More information about the CRIU
mailing list