fix broken tests

This commit is contained in:
virusdefender 2016-03-18 13:18:02 +08:00
parent 62619ae9da
commit 62f6e7a8ed

View File

@ -56,27 +56,27 @@ class JudgerTest(TestCase):
def _judger_cpu_time_args_check(self): def _judger_cpu_time_args_check(self):
with self.assertRaisesRegexp(ValueError, "max_cpu_time must > 1 ms"): with self.assertRaisesRegexp(ValueError, "max_cpu_time must > 1 ms"):
judger.run(path="/bin/ls", judger.run(path="/bin/ls",
in_file=os.path.join(os.path.dirname(os.path.abspath(__file__)), "/dev/null"), in_file="/dev/null",
out_file="/dev/null", max_cpu_time=-1, max_memory=200000000, out_file="/dev/null", max_cpu_time=-1, max_memory=200000000,
env=["aaa=123"], use_sandbox=False, use_nobody=False) env=["aaa=123"], use_sandbox=False, use_nobody=False)
def _judger_memory_args_check(self): def _judger_memory_args_check(self):
with self.assertRaisesRegexp(ValueError, "max_memory must > 16M"): with self.assertRaisesRegexp(ValueError, "max_memory must > 16M"):
judger.run(path="/bin/ls", judger.run(path="/bin/ls",
in_file=os.path.join(os.path.dirname(os.path.abspath(__file__)), "/dev/null"), in_file="/dev/null",
out_file="/dev/null", max_cpu_time=1000, max_memory=100, out_file="/dev/null", max_cpu_time=1000, max_memory=100,
env=["aaa=123"], use_sandbox=True, use_nobody=True) env=["aaa=123"], use_sandbox=True, use_nobody=True)
def _judger_exec_file_args_check(self): def _judger_exec_file_args_check(self):
with self.assertRaisesRegexp(ValueError, "in_file does not exist"): with self.assertRaisesRegexp(ValueError, "Exec file does not exist"):
judger.run(path="/bin/xxx", judger.run(path="/bin/xxx",
in_file=os.path.join(os.path.dirname(os.path.abspath(__file__)), "/dev/null"), in_file="/dev/null",
out_file="/dev/null", max_cpu_time=1000, max_memory=200000000, out_file="/dev/null", max_cpu_time=1000, max_memory=200000000,
env=["aaa=123"], use_sandbox=True, use_nobody=True) env=["aaa=123"], use_sandbox=True, use_nobody=True)
def _judger_in_file_args_check(self): def _judger_in_file_args_check(self):
with self.assertRaisesRegexp(ValueError, "in_file does not exist"): with self.assertRaisesRegexp(ValueError, "in_file does not exist"):
judger.run(path="/bin/xxx", judger.run(path="/bin/ls",
in_file="/dev/xxx", in_file="/dev/xxx",
out_file="/dev/null", max_cpu_time=1000, max_memory=200000000, out_file="/dev/null", max_cpu_time=1000, max_memory=200000000,
env=["aaa=123"], use_sandbox=True, use_nobody=True) env=["aaa=123"], use_sandbox=True, use_nobody=True)
@ -123,7 +123,7 @@ class JudgerTest(TestCase):
os.setuid(pwd.getpwnam("nobody").pw_uid) os.setuid(pwd.getpwnam("nobody").pw_uid)
with self.assertRaisesRegexp(ValueError, "Root user is required when use_nobody=True"): with self.assertRaisesRegexp(ValueError, "Root user is required when use_nobody=True"):
judger.run(path="/bin/ls", judger.run(path="/bin/ls",
in_file=os.path.join(os.path.dirname(os.path.abspath(__file__)), "/dev/null"), in_file="/dev/null",
out_file="/dev/null", max_cpu_time=2000, max_memory=200000000, out_file="/dev/null", max_cpu_time=2000, max_memory=200000000,
env=["aaa=123"], use_sandbox=True, use_nobody=True) env=["aaa=123"], use_sandbox=True, use_nobody=True)