diff --git a/tests/testcase/integration/memory1.c b/tests/testcase/integration/memory1.c index e2423bb..2ac49ee 100644 --- a/tests/testcase/integration/memory1.c +++ b/tests/testcase/integration/memory1.c @@ -8,5 +8,6 @@ int main() int *a = NULL; a = (int *)malloc(size); memset(a, 1, size); + free(a); return 0; } \ No newline at end of file diff --git a/tests/testcase/integration/memory2.c b/tests/testcase/integration/memory2.c index 826cc37..0d5d9b4 100644 --- a/tests/testcase/integration/memory2.c +++ b/tests/testcase/integration/memory2.c @@ -12,6 +12,7 @@ int main() } else { memset(a, 1, size); + free(a); return 0; } } \ No newline at end of file diff --git a/tests/testcase/integration/memory3.c b/tests/testcase/integration/memory3.c new file mode 100644 index 0000000..83f838c --- /dev/null +++ b/tests/testcase/integration/memory3.c @@ -0,0 +1,12 @@ +#include +#include +#include + +int arr[102400000]; + + +int main() +{ + memset(arr, 1, sizeof(arr)); + return 0; +} \ No newline at end of file diff --git a/tests/testcase/integration/test.py b/tests/testcase/integration/test.py index ab8508b..244385c 100644 --- a/tests/testcase/integration/test.py +++ b/tests/testcase/integration/test.py @@ -169,7 +169,7 @@ class IntegrationTest(base.BaseTestCase): self.assertEqual(result["signal"], signal.SIGKILL) self.assertTrue(result["cpu_time"] >= config["max_cpu_time"]) - def test_memory(self): + def test_memory1(self): config = self.config config["max_memory"] = 64 * 1024 * 1024 config["exe_path"] = self._compile("memory1.c") @@ -189,6 +189,14 @@ class IntegrationTest(base.BaseTestCase): self.assertTrue(result["memory"] < 12 * 1024 * 1024) self.assertEqual(result["result"], _judger.RUNTIME_ERROR) + def test_memory3(self): + config = self.config + config["max_memory"] = 512 * 1024 * 1024 + config["exe_path"] = self._compile("memory3.c") + result = _judger.run(**config) + self.assertEqual(result["result"], _judger.SUCCESS) + self.assertTrue(result["memory"] >= 102400000 * 4) + def test_re1(self): config = self.config config["exe_path"] = self._compile("re1.c") @@ -236,7 +244,6 @@ class IntegrationTest(base.BaseTestCase): config["uid"] = 65534 config["gid"] = 65534 result = _judger.run(**config) - print result self.assertEqual(result["result"], _judger.SUCCESS) output = "uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)\nuid 65534\ngid 65534\n" self.assertEqual(output, self.output_content(config["output_path"]))