]> git.proxmox.com Git - mirror_libseccomp.git/commitdiff
tests: add test for SCMP_ACT_LOG of all syscalls
authorTyler Hicks <tyhicks@canonical.com>
Wed, 18 Oct 2017 06:16:57 +0000 (06:16 +0000)
committerPaul Moore <paul@paul-moore.com>
Wed, 1 Nov 2017 16:51:15 +0000 (12:51 -0400)
Test SCMP_ACT_LOG as the default action which all syscalls trigger.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
tests/.gitignore
tests/40-sim-log.c [new file with mode: 0644]
tests/40-sim-log.py [new file with mode: 0755]
tests/40-sim-log.tests [new file with mode: 0644]
tests/Makefile.am

index 47953e5a10ed23ec167809fa4633d0d8dd8a6884..eef049a7745f73d3dcf9df52b35096cef7441877 100644 (file)
@@ -45,3 +45,4 @@ util.pyc
 37-sim-ipc_syscalls_be
 38-basic-pfc_coverage
 39-basic-api_level
+40-sim-log
diff --git a/tests/40-sim-log.c b/tests/40-sim-log.c
new file mode 100644 (file)
index 0000000..cdd2a5e
--- /dev/null
@@ -0,0 +1,59 @@
+/**
+ * Seccomp Library test program
+ *
+ * Originally 01-sim-allow.c but updated to use SCMP_ACT_LOG.
+ *
+ * Copyright (c) 2012 Red Hat <pmoore@redhat.com>
+ * Author: Paul Moore <paul@paul-moore.com>
+ *
+ * Copyright (c) 2017 Canonical Ltd.
+ * Author: Tyler Hicks <tyhicks@canonical.com>
+ */
+
+/*
+ * 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 = NULL;
+
+       rc = util_getopt(argc, argv, &opts);
+       if (rc < 0)
+               goto out;
+
+       rc = seccomp_api_set(3);
+       if (rc != 0)
+               return EOPNOTSUPP;
+
+       ctx = seccomp_init(SCMP_ACT_LOG);
+       if (ctx == NULL)
+               return ENOMEM;
+
+       rc = util_filter_output(&opts, ctx);
+       if (rc)
+               goto out;
+
+out:
+       seccomp_release(ctx);
+       return (rc < 0 ? -rc : rc);
+}
diff --git a/tests/40-sim-log.py b/tests/40-sim-log.py
new file mode 100755 (executable)
index 0000000..63b217e
--- /dev/null
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+
+#
+# Seccomp Library test program
+#
+# Originally 01-sim-allow.py but updated to use LOG.
+#
+# Copyright (c) 2012 Red Hat <pmoore@redhat.com>
+# Author: Paul Moore <paul@paul-moore.com>
+#
+# Copyright (c) 2017 Canonical Ltd.
+# Author: Tyler Hicks <tyhicks@canonical.com>
+#
+
+#
+# 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):
+    set_api(3)
+
+    f = SyscallFilter(LOG)
+    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/40-sim-log.tests b/tests/40-sim-log.tests
new file mode 100644 (file)
index 0000000..8fd5510
--- /dev/null
@@ -0,0 +1,21 @@
+#
+# libseccomp regression test automation data
+#
+# Copyright Canonical Ltd. 2017
+# Author: Tyler Hicks <tyhicks@canonical.com>
+#
+
+test type: bpf-sim
+
+# Testname     Arch    Syscall Arg0    Arg1    Arg2    Arg3    Arg4    Arg5    Result
+40-sim-log     all     0-350   N       N       N       N       N       N       LOG
+
+test type: bpf-sim-fuzz
+
+# Testname     StressCount
+40-sim-log     50
+
+test type: bpf-valgrind
+
+# Testname
+40-sim-log
index df1a244581359c5fc79dfe8987ad5dab84815c47..f1d9969ab27a2472361b4379c21140c0273f1aee 100644 (file)
@@ -78,7 +78,8 @@ check_PROGRAMS = \
        36-sim-ipc_syscalls \
        37-sim-ipc_syscalls_be \
        38-basic-pfc_coverage \
-       39-basic-api_level
+       39-basic-api_level \
+       40-sim-log
 
 EXTRA_DIST_TESTPYTHON = \
        util.py \
@@ -118,7 +119,8 @@ EXTRA_DIST_TESTPYTHON = \
        34-sim-basic_blacklist.py \
        35-sim-negative_one.py \
        36-sim-ipc_syscalls.py \
-       37-sim-ipc_syscalls_be.py
+       37-sim-ipc_syscalls_be.py \
+       40-sim-log.py
 
 EXTRA_DIST_TESTCFGS = \
        01-sim-allow.tests \
@@ -159,7 +161,8 @@ EXTRA_DIST_TESTCFGS = \
        36-sim-ipc_syscalls.tests \
        37-sim-ipc_syscalls_be.tests \
        38-basic-pfc_coverage.tests \
-       39-basic-api_level.tests
+       39-basic-api_level.tests \
+       40-sim-log.tests
 
 EXTRA_DIST_TESTSCRIPTS = \
        38-basic-pfc_coverage.sh 38-basic-pfc_coverage.pfc