增加内存测试3

This commit is contained in:
LiYang 2016-08-25 10:13:23 +08:00
parent efaf2675df
commit 9ef795258f
4 changed files with 23 additions and 2 deletions

View File

@ -8,5 +8,6 @@ int main()
int *a = NULL;
a = (int *)malloc(size);
memset(a, 1, size);
free(a);
return 0;
}

View File

@ -12,6 +12,7 @@ int main()
}
else {
memset(a, 1, size);
free(a);
return 0;
}
}

View File

@ -0,0 +1,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int arr[102400000];
int main()
{
memset(arr, 1, sizeof(arr));
return 0;
}

View File

@ -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"]))