mirror of
https://github.com/QingdaoU/Judger.git
synced 2024-12-29 16:31:42 +00:00
add args test
This commit is contained in:
parent
6eba6a912d
commit
2299a0cd07
@ -1,12 +1,11 @@
|
|||||||
|
|
||||||
#Judger
|
#Judger [![Build Status](https://travis-ci.org/QingdaoU/Judger.svg?branch=master)](https://travis-ci.org/QingdaoU/Judger)
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/QingdaoU/Judger.svg?branch=master)](https://travis-ci.org/QingdaoU/Judger)
|
|
||||||
|
|
||||||
|
|
||||||
OnlineJudge 判题沙箱
|
OnlineJudge 判题沙箱
|
||||||
|
|
||||||
demo:
|
demo and usage:
|
||||||
|
|
||||||
```
|
```
|
||||||
sudo python setup.py install
|
sudo python setup.py install
|
||||||
cd demo && sudo python demo.py
|
cd demo && sudo python demo.py
|
||||||
|
9
tests/8/Main.c
Normal file
9
tests/8/Main.c
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
int j;
|
||||||
|
for (j = 0; j < argc; j++)
|
||||||
|
printf("argv[%d]: %s\n", j, argv[j]);
|
||||||
|
return 0;
|
||||||
|
}
|
0
tests/8/in
Normal file
0
tests/8/in
Normal file
3
tests/8/out
Normal file
3
tests/8/out
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
argv[0]: /tmp/judger_test/8
|
||||||
|
argv[1]: hello
|
||||||
|
argv[2]: 123
|
1
tests/8/result
Normal file
1
tests/8/result
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"flag": 0, "signal": 0}
|
@ -23,14 +23,14 @@ class JudgerTest(TestCase):
|
|||||||
def test_run(self):
|
def test_run(self):
|
||||||
shutil.rmtree(self.tmp_path, ignore_errors=True)
|
shutil.rmtree(self.tmp_path, ignore_errors=True)
|
||||||
os.mkdir(self.tmp_path)
|
os.mkdir(self.tmp_path)
|
||||||
for i in range(1, 8):
|
for i in range(1, 9):
|
||||||
test_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), str(i))
|
test_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), str(i))
|
||||||
exe_path = os.path.join("/tmp/judger_test", str(i))
|
exe_path = os.path.join("/tmp/judger_test", str(i))
|
||||||
self.assertEqual(self.compile_src(os.path.join(test_dir, "Main.c"), "c", exe_path), 0)
|
self.assertEqual(self.compile_src(os.path.join(test_dir, "Main.c"), "c", exe_path), 0)
|
||||||
run_result = judger.run(path=exe_path,
|
run_result = judger.run(path=exe_path,
|
||||||
in_file=os.path.join(test_dir, "in"),
|
in_file=os.path.join(test_dir, "in"),
|
||||||
out_file=os.path.join(self.tmp_path, str(i) + ".out"),
|
out_file=os.path.join(self.tmp_path, str(i) + ".out"),
|
||||||
max_cpu_time=2000, max_memory=200000000)
|
max_cpu_time=2000, max_memory=200000000, args=["hello", "123"])
|
||||||
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"])
|
||||||
|
Loading…
Reference in New Issue
Block a user