mirror of
https://github.com/QingdaoU/Judger.git
synced 2024-12-29 16:31:42 +00:00
增加参数检查测试
This commit is contained in:
parent
656c04f35a
commit
03e425b0d6
@ -1,5 +1,6 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
import os
|
import os
|
||||||
|
import pwd
|
||||||
import json
|
import json
|
||||||
import judger
|
import judger
|
||||||
import shutil
|
import shutil
|
||||||
@ -41,7 +42,14 @@ class JudgerTest(TestCase):
|
|||||||
result = json.loads(open(os.path.join(test_dir, "result")).read())
|
result = json.loads(open(os.path.join(test_dir, "result")).read())
|
||||||
self.assertEqual(result["flag"], run_result["flag"])
|
self.assertEqual(result["flag"], run_result["flag"])
|
||||||
self.assertEqual(result["signal"], run_result["signal"])
|
self.assertEqual(result["signal"], run_result["signal"])
|
||||||
self.assertEqual(open(os.path.join(test_dir, "out")).read(), open(os.path.join(self.tmp_path, str(i) + ".out")).read())
|
self.assertEqual(open(os.path.join(test_dir, "out")).read(),
|
||||||
|
open(os.path.join(self.tmp_path, str(i) + ".out")).read())
|
||||||
|
|
||||||
|
def test_args_check(self):
|
||||||
|
os.setuid(pwd.getpwnam("nobody").pw_uid)
|
||||||
|
with self.assertRaisesRegexp(ValueError, "root user is required when using nobody"):
|
||||||
|
judger.run(path="/bin/ls", in_file="1/in", out_file="/dev/null", max_cpu_time=2000, max_memory=200000000,
|
||||||
|
env=["aaa=123"], use_sandbox=True, use_nobody=True)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user