summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Moore <pmoore@redhat.com>2013-01-22 17:10:30 -0500
committerPaul Moore <pmoore@redhat.com>2013-01-22 18:08:43 -0500
commitaffce10eef52b1bcd7d15ce8e572272f8c0b6d56 (patch)
tree2ccb012d8371f197d2cb3bea2452bc3339aa0c01
parentd76450119d16a92eb313be09612856cc7b34713f (diff)
downloadlibseccomp-affce10eef52b1bcd7d15ce8e572272f8c0b6d56.tar.gz
tests: remove arch specific code from the tests when possible
Signed-off-by: Paul Moore <pmoore@redhat.com>
-rw-r--r--tests/11-basic-errors.c23
-rwxr-xr-xtests/11-basic-errors.py14
2 files changed, 20 insertions, 17 deletions
diff --git a/tests/11-basic-errors.c b/tests/11-basic-errors.c
index 07710e6..c328577 100644
--- a/tests/11-basic-errors.c
+++ b/tests/11-basic-errors.c
@@ -106,11 +106,9 @@ int main(int argc, char *argv[])
SCMP_A0(_SCMP_CMP_MAX, 0));
if (rc != -EINVAL)
return -1;
-#if __i386__
- rc = seccomp_rule_add(ctx, SCMP_ACT_KILL, -1001, 0);
- if (rc != -EINVAL)
+ rc = seccomp_rule_add_exact(ctx, SCMP_ACT_KILL, -10001, 0);
+ if (rc != -EDOM)
return -1;
-#endif
}
seccomp_release(ctx);
ctx = NULL;
@@ -119,15 +117,18 @@ int main(int argc, char *argv[])
ctx = seccomp_init(SCMP_ACT_ALLOW);
if (ctx == NULL)
return -1;
- else {
-#if __i386__
- rc = seccomp_rule_add_exact(ctx,
- SCMP_ACT_KILL, SCMP_SYS(socket), 1,
- SCMP_A0(SCMP_CMP_EQ, 2));
- if (rc != -EINVAL)
+ if (seccomp_arch_native() != SCMP_ARCH_X86) {
+ rc = seccomp_arch_add(ctx, SCMP_ARCH_X86);
+ if (rc != 0)
+ return -1;
+ rc = seccomp_arch_remove(ctx, SCMP_ARCH_NATIVE);
+ if (rc != 0)
return -1;
-#endif
}
+ rc = seccomp_rule_add_exact(ctx, SCMP_ACT_KILL, SCMP_SYS(socket), 1,
+ SCMP_A0(SCMP_CMP_EQ, 2));
+ if (rc != -EINVAL)
+ return -1;
seccomp_release(ctx);
ctx = NULL;
diff --git a/tests/11-basic-errors.py b/tests/11-basic-errors.py
index 900548d..4923e9b 100755
--- a/tests/11-basic-errors.py
+++ b/tests/11-basic-errors.py
@@ -43,7 +43,7 @@ def test():
f = SyscallFilter(ALLOW)
try:
- f.syscall_priority(-1000, 1)
+ f.syscall_priority(-10000, 1)
except RuntimeError:
pass
@@ -74,11 +74,13 @@ def test():
pass
f = SyscallFilter(ALLOW)
- if f.exist_arch(Arch.X86):
- try:
- f.add_rule_exactly(KILL, "socket", Arg(0, EQ, 2))
- except RuntimeError:
- pass
+ if not f.exist_arch(Arch.X86):
+ f.add_arch(Arch.X86)
+ f.remove_arch(Arch.NATIVE)
+ try:
+ f.add_rule_exactly(KILL, "socket", Arg(0, EQ, 2))
+ except RuntimeError:
+ pass
test()