[CRIU] [PATCH] test: seccomp -- Make sure __NR_seccomp is present to not fail building on old kernels
Cyrill Gorcunov
gorcunov at gmail.com
Thu Feb 25 06:17:24 PST 2016
On Thu, Feb 25, 2016 at 05:02:34PM +0300, Cyrill Gorcunov wrote:
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>
> Guys, take a look please.
Update attached.
-------------- next part --------------
>From 7a343f89e6c5da8ffb6ae40b3628624fc0541abc Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Thu, 25 Feb 2016 17:02:00 +0300
Subject: [PATCH] test: seccomp -- Make sure __NR_seccomp is present to not
fail building on old kernels
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
test/zdtm/static/seccomp_filter.c | 16 ++++++++++++++--
test/zdtm/static/seccomp_filter_inheritance.c | 19 ++++++++++++++++---
test/zdtm/static/seccomp_filter_tsync.c | 20 ++++++++++++++++----
test/zdtm/static/seccomp_strict.c | 16 ++++++++++++++--
test/zdtm/static/skip-me.c | 12 ++++++++++++
5 files changed, 72 insertions(+), 11 deletions(-)
create mode 100644 test/zdtm/static/skip-me.c
diff --git a/test/zdtm/static/seccomp_filter.c b/test/zdtm/static/seccomp_filter.c
index 1a1f34302a1b..d14d65612be1 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>
+#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,9 @@ err:
kill(pid, SIGKILL);
return 1;
}
+
+#else /* __NR_seccomp */
+
+#include "skip-me.c"
+
+#endif /* __NR_seccomp */
diff --git a/test/zdtm/static/seccomp_filter_inheritance.c b/test/zdtm/static/seccomp_filter_inheritance.c
index ff0c46a7d7e6..0f669168d5bd 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>
+#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,10 @@ err:
kill(pid, SIGKILL);
return 1;
}
+
+
+#else /* __NR_seccomp */
+
+#include "skip-me.c"
+
+#endif /* __NR_seccomp */
diff --git a/test/zdtm/static/seccomp_filter_tsync.c b/test/zdtm/static/seccomp_filter_tsync.c
index a5835498f80e..c7e4cc4e9ad4 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,9 @@ err:
kill(pid, SIGKILL);
return 1;
}
+
+#else /* __NR_seccomp */
+
+#include "skip-me.c"
+
+#endif /* __NR_seccomp */
diff --git a/test/zdtm/static/seccomp_strict.c b/test/zdtm/static/seccomp_strict.c
index 8b1a37ac5d3f..054d0d98f256 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>
+#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,9 @@ err:
kill(pid, SIGKILL);
return 1;
}
+
+#else /* __NR_seccomp */
+
+#include "skip-me.c"
+
+#endif /* __NR_seccomp */
diff --git a/test/zdtm/static/skip-me.c b/test/zdtm/static/skip-me.c
new file mode 100644
index 000000000000..0cb53aabac77
--- /dev/null
+++ b/test/zdtm/static/skip-me.c
@@ -0,0 +1,12 @@
+int main(int argc, char ** argv)
+{
+ test_init(argc, argv);
+
+ test_msg("Skipping test on incompatible kernel");
+
+ test_daemon();
+ test_waitsig();
+
+ pass();
+ return 0;
+}
--
2.5.0
More information about the CRIU
mailing list