forked from seccomp/libseccomp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: introduce a simple seccomp_load() test as part of the non-live…
… tests This is a bit controversial as historically we've refrained from doing any tests that rely on the host kernel in the non-live tests, but I think enough time has past that we can do a simple seccomp_load() and not break the world's build/test platforms. The obvious big advantage is we are now testing the basic prctl()/seccomp() filter load infrastructure as part of the main regression test run. Signed-off-by: Paul Moore <[email protected]>
- Loading branch information
Showing
5 changed files
with
104 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,3 +57,4 @@ util.pyc | |
49-sim-64b_comparisons | ||
50-sim-hash_collision | ||
51-live-user_notification | ||
52-basic-load |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Seccomp Library test program | ||
* | ||
* Copyright (c) 2019 Cisco Systems, Inc. <[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 = NULL; | ||
|
||
rc = util_getopt(argc, argv, &opts); | ||
if (rc < 0) | ||
goto out; | ||
|
||
ctx = seccomp_init(SCMP_ACT_ALLOW); | ||
if (ctx == NULL) | ||
return ENOMEM; | ||
|
||
rc = seccomp_load(ctx); | ||
|
||
out: | ||
seccomp_release(ctx); | ||
return (rc < 0 ? -rc : rc); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env python | ||
|
||
# | ||
# Seccomp Library test program | ||
# | ||
# Copyright (c) 2019 Cisco Systems, Inc. <[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(): | ||
f = SyscallFilter(ALLOW) | ||
f.load() | ||
|
||
test() | ||
|
||
# kate: syntax python; | ||
# kate: indent-mode python; space-indent on; indent-width 4; mixedindent off; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# | ||
# libseccomp regression test automation data | ||
# | ||
# Copyright (c) 2013 Red Hat <[email protected]> | ||
# Author: Paul Moore <[email protected]> | ||
# | ||
|
||
test type: basic | ||
|
||
# Test command | ||
52-basic-load |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters