Commit ac664103 authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

tests: skip seccomp_filter_tsync if __NR_seccomp isn't defined

This change does two things to be more defensive: 1. add a checkskip script
which fails if __NR_seccomp isn't defined, and 2. allows
seccomp_filter_tsync to compile even if it isn't defined (and then fails
"gracefully" with a skip message if it does).

The checkskip bits are necessary because zdtm.sh gets confused if the test
exits 0 without actually invoking criu.
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent b352659c
......@@ -15,7 +15,22 @@
#include <pthread.h>
#include "zdtmtst.h"
#define seccomp(_op, _flags, _uargs) syscall(__NR_seccomp, _op, _flags, _uargs)
#undef __NR_seccomp
#ifdef __NR_seccomp
#define HAVE_SECCOMP 1
#else
#define HAVE_SECCOMP 0
#define __NR_seccomp -1
#endif
#ifndef SECCOMP_SET_MODE_FILTER
#define SECCOMP_SET_MODE_FILTER 1
#endif
#ifndef SECCOMP_FILTER_FLAG_TSYNC
#define SECCOMP_FILTER_FLAG_TSYNC 1
#endif
const char *test_doc = "Check that SECCOMP_FILTER_FLAG_TSYNC works correctly after restore";
const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>";
......@@ -91,6 +106,11 @@ int main(int argc, char ** argv)
test_init(argc, argv);
if (!HAVE_SECCOMP) {
skip("no seccomp present in this kernel\n");
return 0;
}
if (socketpair(PF_LOCAL, SOCK_SEQPACKET, 0, sk_pair)) {
pr_perror("socketpair");
return -1;
......
#!/bin/bash
set -e
cat > /tmp/has_nr_seccomp.c <<EOF
#include <syscall.h>
int main() {
return __NR_seccomp;
}
EOF
make /tmp/has_nr_seccomp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment