Signed-off-by: Paul Moore <[email protected]>
---
 tests/.gitignore                |    2 +
 tests/19-missing-syscalls.c     |   66 +++++++++++++++++++++++++++++++++++++++
 tests/19-missing-syscalls.py    |   48 ++++++++++++++++++++++++++++
 tests/19-missing-syscalls.tests |   16 +++++++++
 tests/Makefile                  |    3 +-
 5 files changed, 134 insertions(+), 1 deletion(-)
 create mode 100644 tests/19-missing-syscalls.c
 create mode 100755 tests/19-missing-syscalls.py
 create mode 100644 tests/19-missing-syscalls.tests

diff --git a/tests/.gitignore b/tests/.gitignore
index 879bff5..69a083c 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,4 +1,5 @@
 *.bpf
+*.pfc
 util.pyc
 01-allow
 02-basic
@@ -18,3 +19,4 @@ util.pyc
 16-arch-basic
 17-arch-merge
 18-basic-whitelist
+19-missing-syscalls
diff --git a/tests/19-missing-syscalls.c b/tests/19-missing-syscalls.c
new file mode 100644
index 0000000..0ccb0f5
--- /dev/null
+++ b/tests/19-missing-syscalls.c
@@ -0,0 +1,66 @@
+/**
+ * Seccomp Library test program
+ *
+ * Copyright (c) 2013 Red Hat <[email protected]>
+ * Author: Paul Moore <[email protected]>
+ */
+
+/*
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, see <http://www.gnu.org/licenses>.
+ */
+
+#include <errno.h>
+#include <unistd.h>
+
+#include <seccomp.h>
+
+#include "util.h"
+
+int main(int argc, char *argv[])
+{
+       int rc;
+       struct util_options opts;
+       scmp_filter_ctx ctx;
+
+       rc = util_getopt(argc, argv, &opts);
+       if (rc < 0)
+               goto out;
+
+       ctx = seccomp_init(SCMP_ACT_KILL);
+       if (ctx == NULL)
+               goto out;
+
+       if (seccomp_arch_native() != SCMP_ARCH_X86) {
+               rc = seccomp_arch_add(ctx, SCMP_ARCH_X86);
+               if (rc != 0)
+                       goto out;
+               rc = seccomp_arch_remove(ctx, SCMP_ARCH_NATIVE);
+               if (rc != 0)
+                       goto out;
+       }
+
+       rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(tuxcall), 0);
+       if (rc != 0)
+               goto out;
+       rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(tuxcall), 0);
+       if (rc != -EDOM)
+               goto out;
+
+       rc = util_filter_output(&opts, ctx);
+       if (rc)
+               goto out;
+
+out:
+       seccomp_release(ctx);
+       return (rc < 0 ? -rc : rc);
+}
diff --git a/tests/19-missing-syscalls.py b/tests/19-missing-syscalls.py
new file mode 100755
index 0000000..38408b1
--- /dev/null
+++ b/tests/19-missing-syscalls.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+
+#
+# Seccomp Library test program
+#
+# Copyright (c) 2013 Red Hat <[email protected]>
+# Author: Paul Moore <[email protected]>
+#
+
+#
+# This library is free software; you can redistribute it and/or modify it
+# under the terms of version 2.1 of the GNU Lesser General Public License as
+# published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+# for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, see <http://www.gnu.org/licenses>.
+#
+
+import argparse
+import sys
+
+import util
+
+from seccomp import *
+
+def test(args):
+    f = SyscallFilter(KILL)
+    if not system_arch() == Arch.X86:
+        f.add_arch(Arch.X86)
+        f.remove_arch(Arch.NATIVE)
+    f.add_rule(ALLOW, "tuxcall")
+    try:
+        f.add_rule_exactly(ALLOW, "tuxcall")
+    except RuntimeError:
+        pass
+    return f
+
+args = util.get_opt()
+ctx = test(args)
+util.filter_output(args, ctx)
+
+# kate: syntax python;
+# kate: indent-mode python; space-indent on; indent-width 4; mixedindent off;
diff --git a/tests/19-missing-syscalls.tests b/tests/19-missing-syscalls.tests
new file mode 100644
index 0000000..7b34f0d
--- /dev/null
+++ b/tests/19-missing-syscalls.tests
@@ -0,0 +1,16 @@
+#
+# libseccomp regression test automation data
+#
+# Copyright (c) 2013 Red Hat <[email protected]>
+# Author: Paul Moore <[email protected]>
+#
+
+test type: bpf-sim
+
+# Testname             Arch    Syscall         Arg0    Arg1    Arg2    Arg3    
Arg4    Arg5    Result
+19-missing-syscalls    +x86    0-350           N       N       N       N       
N       N       KILL
+
+test type: bpf-sim-fuzz
+
+# Testname             StressCount
+19-missing-syscalls    50
diff --git a/tests/Makefile b/tests/Makefile
index 8b1ba1b..98b5fe4 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -53,7 +53,8 @@ TESTS = 01-allow \
        15-resolver \
        16-arch-basic \
        17-arch-merge \
-       18-basic-whitelist
+       18-basic-whitelist \
+       19-missing-syscalls
 
 DEPS_OBJS = $(OBJS:%.o=%.d)
 DEPS_TESTS = $(TESTS:%=%.d)


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
libseccomp-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libseccomp-discuss

Reply via email to