summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Moore <paul@paul-moore.com>2017-02-27 15:03:38 -0500
committerPaul Moore <paul@paul-moore.com>2017-02-27 16:57:39 -0500
commit8f318099c1a520f1601053491ccbba865281eb60 (patch)
treeb6a58d9ce31ccdee93f59fa3652ac8149858a767 /tests
parentdbc83fc01ec07b68f87a7998e90a357c149cbbea (diff)
downloadlibseccomp-8f318099c1a520f1601053491ccbba865281eb60.tar.gz
python: add support for Python 3.x
This patch adds the necessary tweaks to support building against Python v2.x and v3.x. In the process we also fix some problems with the Python live tests; it is unclear when they broke, but they are working now. Tested on Python v2.7.13 and v3.6.0. Signed-off-by: Paul Moore <paul@paul-moore.com> (imported from commit ce5aea6a4ae7523b57ec13e2e6150aa5d83c1b4e)
Diffstat (limited to 'tests')
-rwxr-xr-xtests/15-basic-resolver.py4
-rwxr-xr-xtests/20-live-basic_die.py1
-rwxr-xr-xtests/21-live-basic_allow.py1
-rwxr-xr-xtests/24-live-arg_allow.py4
-rw-r--r--tests/util.py4
5 files changed, 8 insertions, 6 deletions
diff --git a/tests/15-basic-resolver.py b/tests/15-basic-resolver.py
index 12c4d7d..3ce3389 100755
--- a/tests/15-basic-resolver.py
+++ b/tests/15-basic-resolver.py
@@ -41,11 +41,11 @@ def test():
sys_num = resolve_syscall(Arch(), "open")
sys_name = resolve_syscall(Arch(), sys_num)
- if (sys_name != "open"):
+ if (sys_name != b"open"):
raise RuntimeError("Test failure")
sys_num = resolve_syscall(Arch(), "read")
sys_name = resolve_syscall(Arch(), sys_num)
- if (sys_name != "read"):
+ if (sys_name != b"read"):
raise RuntimeError("Test failure")
test()
diff --git a/tests/20-live-basic_die.py b/tests/20-live-basic_die.py
index 389a50f..26013f6 100755
--- a/tests/20-live-basic_die.py
+++ b/tests/20-live-basic_die.py
@@ -33,6 +33,7 @@ def test():
if action == TRAP:
util.install_trap()
f = SyscallFilter(action)
+ f.add_rule(ALLOW, "getpid")
f.add_rule(ALLOW, "rt_sigreturn")
f.add_rule(ALLOW, "sigreturn")
f.add_rule(ALLOW, "exit_group")
diff --git a/tests/21-live-basic_allow.py b/tests/21-live-basic_allow.py
index b6703de..8e16ead 100755
--- a/tests/21-live-basic_allow.py
+++ b/tests/21-live-basic_allow.py
@@ -50,6 +50,7 @@ def test():
f.add_rule(ALLOW, "brk")
f.add_rule(ALLOW, "exit_group")
f.load()
+
try:
util.write_file("/dev/null")
except OSError as ex:
diff --git a/tests/24-live-arg_allow.py b/tests/24-live-arg_allow.py
index 019c8a8..51e6110 100755
--- a/tests/24-live-arg_allow.py
+++ b/tests/24-live-arg_allow.py
@@ -35,7 +35,7 @@ def test():
quit(1)
util.install_trap()
- fd = os.open("/dev/null", os.O_WRONLY|os.O_CREAT, 0600)
+ fd = os.open("/dev/null", os.O_WRONLY|os.O_CREAT)
f = SyscallFilter(TRAP)
# NOTE: additional syscalls required for python
@@ -48,7 +48,7 @@ def test():
f.load()
try:
- if not os.write(fd, "testing") == len("testing"):
+ if not os.write(fd, b"testing") == len("testing"):
raise IOError("failed to write the full test string")
quit(160)
except OSError as ex:
diff --git a/tests/util.py b/tests/util.py
index f085c88..e601f2d 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -100,8 +100,8 @@ def write_file(path):
Description:
Open the specified file, write a string to the file, and close the file.
"""
- fd = os.open(path, os.O_WRONLY|os.O_CREAT, 0600)
- if not os.write(fd, "testing") == len("testing"):
+ fd = os.open(str(path), os.O_WRONLY|os.O_CREAT)
+ if not os.write(fd, b"testing") == len("testing"):
raise IOError("failed to write the full test string in write_file()")
os.close(fd)