diff options
author | Tyler Hicks <tyhicks@canonical.com> | 2017-10-18 06:16:57 +0000 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2017-11-01 12:51:15 -0400 |
commit | 0cc7203760c4776c67602a531bd633aba63a7851 (patch) | |
tree | 8677b7d8971956e97da5d3c6f8acc6679f7402af /tests | |
parent | 649d4fa3e0f86289d788010f4aadc27d3e9b1339 (diff) | |
download | libseccomp-0cc7203760c4776c67602a531bd633aba63a7851.tar.gz |
tests: add test for SCMP_ACT_LOG of all syscalls
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>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/.gitignore | 1 | ||||
-rw-r--r-- | tests/40-sim-log.c | 59 | ||||
-rwxr-xr-x | tests/40-sim-log.py | 47 | ||||
-rw-r--r-- | tests/40-sim-log.tests | 21 | ||||
-rw-r--r-- | tests/Makefile.am | 9 |
5 files changed, 134 insertions, 3 deletions
diff --git a/tests/.gitignore b/tests/.gitignore index 47953e5..eef049a 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -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 index 0000000..cdd2a5e --- /dev/null +++ b/tests/40-sim-log.c @@ -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 index 0000000..63b217e --- /dev/null +++ b/tests/40-sim-log.py @@ -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 index 0000000..8fd5510 --- /dev/null +++ b/tests/40-sim-log.tests @@ -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 diff --git a/tests/Makefile.am b/tests/Makefile.am index df1a244..f1d9969 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 |