From 2299a0cd07195aa5a98badb349a6491965ef0e4a Mon Sep 17 00:00:00 2001 From: virusdefender Date: Sat, 23 Jan 2016 19:09:17 +0800 Subject: [PATCH] add args test --- README.md | 7 +++---- tests/8/Main.c | 9 +++++++++ tests/8/in | 0 tests/8/out | 3 +++ tests/8/result | 1 + tests/test.py | 4 ++-- 6 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 tests/8/Main.c create mode 100644 tests/8/in create mode 100644 tests/8/out create mode 100644 tests/8/result diff --git a/README.md b/README.md index 97f72b4..b72016b 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ -#Judger - -[![Build Status](https://travis-ci.org/QingdaoU/Judger.svg?branch=master)](https://travis-ci.org/QingdaoU/Judger) +#Judger [![Build Status](https://travis-ci.org/QingdaoU/Judger.svg?branch=master)](https://travis-ci.org/QingdaoU/Judger) OnlineJudge 判题沙箱 -demo: +demo and usage: + ``` sudo python setup.py install cd demo && sudo python demo.py diff --git a/tests/8/Main.c b/tests/8/Main.c new file mode 100644 index 0000000..099679f --- /dev/null +++ b/tests/8/Main.c @@ -0,0 +1,9 @@ +#include + + +int main(int argc, char *argv[]) { + int j; + for (j = 0; j < argc; j++) + printf("argv[%d]: %s\n", j, argv[j]); + return 0; +} diff --git a/tests/8/in b/tests/8/in new file mode 100644 index 0000000..e69de29 diff --git a/tests/8/out b/tests/8/out new file mode 100644 index 0000000..25e217d --- /dev/null +++ b/tests/8/out @@ -0,0 +1,3 @@ +argv[0]: /tmp/judger_test/8 +argv[1]: hello +argv[2]: 123 diff --git a/tests/8/result b/tests/8/result new file mode 100644 index 0000000..ebd96f5 --- /dev/null +++ b/tests/8/result @@ -0,0 +1 @@ +{"flag": 0, "signal": 0} \ No newline at end of file diff --git a/tests/test.py b/tests/test.py index dc90112..f69fca9 100644 --- a/tests/test.py +++ b/tests/test.py @@ -23,14 +23,14 @@ class JudgerTest(TestCase): def test_run(self): shutil.rmtree(self.tmp_path, ignore_errors=True) 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)) 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) run_result = judger.run(path=exe_path, in_file=os.path.join(test_dir, "in"), 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()) self.assertEqual(result["flag"], run_result["flag"]) self.assertEqual(result["signal"], run_result["signal"])