diff options
Diffstat (limited to '')
| -rw-r--r-- | tests/test_nsjail.py | 28 | 
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_nsjail.py b/tests/test_nsjail.py index ec5c56f..c0ed96b 100644 --- a/tests/test_nsjail.py +++ b/tests/test_nsjail.py @@ -67,6 +67,34 @@ class NsJailTests(unittest.TestCase):          self.assertIn("Resource temporarily unavailable", result.stdout)          self.assertEqual(result.stderr, None) +    def test_multiprocess_resource_limits(self): +        code = dedent(""" +            import time +            from multiprocessing import Process + +            def f(): +                object = "A" * 40_000_000 +                time.sleep(0.5) + + +            proc_1 = Process(target=f) +            proc_2 = Process(target=f) + +            proc_1.start() +            proc_2.start() + +            proc_1.join() +            proc_2.join() + +            print(proc_1.exitcode, proc_2.exitcode) +        """) + +        result = self.nsjail.python3(code) + +        exit_codes = result.stdout.strip().split() +        self.assertIn("-9", exit_codes) +        self.assertEqual(result.stderr, None) +      def test_read_only_file_system(self):          for path in ("/", "/etc", "/lib", "/lib64", "/snekbox", "/usr"):              with self.subTest(path=path):  |