Skip to content

Commit

Permalink
test(misc): add more tests for edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
cptpcrd committed Nov 9, 2020
1 parent 03726d9 commit 989976c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
@@ -28,3 +28,25 @@ def test_api_get_set() -> None:
assert pyseccomp.get_api() == 2
finally:
pyseccomp.set_api(orig_api)


def test_bad_action() -> None:
with pytest.raises(OSError, match="Invalid argument"):
pyseccomp.SyscallFilter(0xDEADBEEF)


def test_bad_rule_args() -> None:
filt = pyseccomp.SyscallFilter(pyseccomp.ALLOW)

with pytest.raises(ValueError, match=r"^Too many arguments$"):
filt.add_rule(
pyseccomp.KILL_PROCESS,
"prctl",
pyseccomp.Arg(1, pyseccomp.EQ, 0),
pyseccomp.Arg(2, pyseccomp.EQ, 0),
pyseccomp.Arg(3, pyseccomp.EQ, 0),
pyseccomp.Arg(4, pyseccomp.EQ, 0),
pyseccomp.Arg(5, pyseccomp.EQ, 0),
pyseccomp.Arg(6, pyseccomp.EQ, 0),
pyseccomp.Arg(7, pyseccomp.EQ, 0),
)

0 comments on commit 989976c

Please sign in to comment.