diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_integration.py | 21 | ||||
-rw-r--r-- | tests/test_nsjail.py | 6 |
2 files changed, 18 insertions, 9 deletions
diff --git a/tests/test_integration.py b/tests/test_integration.py index 086abab..ba0d9b5 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -62,11 +62,15 @@ class IntegrationTests(unittest.TestCase): "path": "main.py", "content": b64encode_code( """ + from pathlib import Path from mod import lib print(lib.var) - with open('output.txt', 'w') as f: - f.write('file write test') + with open('output/test.txt', 'w') as f: + f.write('test 1') + + Path('output/dir').mkdir() + Path('output/dir/test2.txt').write_text('test 2') """ ), }, @@ -80,10 +84,15 @@ class IntegrationTests(unittest.TestCase): "returncode": 0, "files": [ { - "path": "output.txt", - "size": len("file write test"), - "content": b64encode_code("file write test"), - } + "path": "dir/test2.txt", + "size": len("test 2"), + "content": b64encode_code("test 2"), + }, + { + "path": "test.txt", + "size": len("test 1"), + "content": b64encode_code("test 1"), + }, ], } diff --git a/tests/test_nsjail.py b/tests/test_nsjail.py index da2afea..d63180d 100644 --- a/tests/test_nsjail.py +++ b/tests/test_nsjail.py @@ -190,16 +190,16 @@ class NsJailTests(unittest.TestCase): data = "a" * 1024 size = 32 * 1024 * 1024 - with open("src", "w") as f: + with open("output/file", "w") as f: for _ in range((size // 1024) - 5): f.write(data) for i in range(100): - os.symlink("src", f"output{i}") + os.symlink("file", f"output/file{i}") """ ).strip() - nsjail = NsJail(memfs_instance_size=48 * 1024 * 1024, files_timeout=1) + nsjail = NsJail(memfs_instance_size=32 * 1024 * 1024, files_timeout=1) result = nsjail.python3(["-c", code]) self.assertEqual(result.returncode, None) self.assertEqual( |