增加参数检查测试

This commit is contained in:
virusdefender 2016-03-18 10:14:14 +08:00
parent 656c04f35a
commit 03e425b0d6

View File

@ -1,5 +1,6 @@
# coding=utf-8
import os
import pwd
import json
import judger
import shutil
@ -41,7 +42,14 @@ class JudgerTest(TestCase):
result = json.loads(open(os.path.join(test_dir, "result")).read())
self.assertEqual(result["flag"], run_result["flag"])
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__":