diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-02-17 17:49:19 +0100 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-02-17 17:49:19 +0100 |
commit | b3e9426b9775daf99210f337659a37876013d623 (patch) | |
tree | 0a3245a0e3b3c55c2097e0c9de56f953f17b3a7d /tests/runner.py | |
parent | d9d2876b0b7370ff99c37483a5f6e97515499e81 (diff) |
memory corruption checker
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-x | tests/runner.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py index 0d44541e..aad97db9 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -7185,6 +7185,32 @@ def process(filename): ''' self.do_run(src, '''AD:-1,1''', build_ll_hook=self.do_autodebug) + def test_corruption(self): + Settings.CORRUPTION_CHECK = 1 + + src = r''' + #include <stdio.h> + #include <stdlib.h> + #include <string.h> + int main(int argc, char **argv) { + int size = 1024*argc; + char *buffer = (char*)malloc(size); + #if CORRUPT + memset(buffer, argc, size+15); + #else + memset(buffer, argc, size); + #endif + for (int x = 0; x < size; x += argc*3) buffer[x] = x/3; + int ret = 0; + for (int x = 0; x < size; x++) ret += buffer[x]; + free(buffer); + printf("All ok, %d\n", ret); + } + ''' + + for corrupt in [1]: + self.do_run(src.replace('CORRUPT', str(corrupt)), 'Heap corruption detected!' if corrupt else 'All ok, 4209') + ### Integration tests def test_ccall(self): |