diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-02-19 17:28:22 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-02-19 17:28:22 -0800 |
commit | 239e82b02c67a8a0e840dfa499fb3b4f1726cb61 (patch) | |
tree | 8a3b68c1d4cdbe660b1fada35e310dcbe28b71bf /tests | |
parent | f9728ef5b36fce1639af4ba6e9ac1e68321053fd (diff) |
support realloc in corruption checker
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/runner.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py index f0340cd0..3b2fcd58 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -7250,6 +7250,37 @@ def process(filename): ''' self.do_run(src, 'missing!\nall ok\n') + def test_corruption_3(self): + if Settings.ASM_JS: return self.skip('cannot use corruption checks in asm') + if Settings.USE_TYPED_ARRAYS != 2: return self.skip('needs ta2 for actual test') + + Settings.CORRUPTION_CHECK = 1 + + # realloc + src = r''' + #include <stdlib.h> + #include <stdio.h> + #include <assert.h> + + void bye() { + printf("all ok\n"); + } + + int main(int argc, char **argv) { + atexit(bye); + + char *buffer = (char*)malloc(100); + for (int i = 0; i < 100; i++) buffer[i] = (i*i)%256; + buffer = (char*)realloc(buffer, argc + 50); + for (int i = 0; i < argc + 50; i++) { + //printf("%d : %d : %d : %d\n", i, (int)(buffer + i), buffer[i], (char)((i*i)%256)); + assert(buffer[i] == (char)((i*i)%256)); + } + return 1; + } + ''' + self.do_run(src, 'all ok\n') + ### Integration tests def test_ccall(self): |