diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-09-09 20:00:52 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-09-09 20:00:52 -0700 |
commit | 1896c00715d1cbfd47a295c9564691dcf88d6032 (patch) | |
tree | d2cc60a400f2b1878b63ae3773bd605701e36676 /tests/runner.py | |
parent | 953ebf768763fe93a0af76f5007d1f69f91d6440 (diff) |
check for segfaults in SAFE_HEAP
Diffstat (limited to 'tests/runner.py')
-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 b81cee9a..a089d7b8 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -2108,6 +2108,37 @@ c5,de,15,8a ''' self.do_run(src, '*11,74,32,1012*\n*11*\n*22*') + def test_segfault(self): + Settings.SAFE_HEAP = 1 + + for addr in ['0', '7', 'new D2()']: + print addr + src = r''' + #include <stdio.h> + + struct Classey { + virtual void doIt() = 0; + }; + + struct D1 : Classey { + virtual void doIt() { printf("fleefl\n"); } + }; + + struct D2 : Classey { + virtual void doIt() { printf("marfoosh\n"); } + }; + + int main(int argc, char **argv) + { + Classey *p = argc == 100 ? new D1() : (Classey*)%s; + + p->doIt(); + + return 0; + } + ''' % addr + self.do_run(src, 'segmentation fault' if addr.isdigit() else 'marfoosh') + def test_dynamic_cast(self): if self.emcc_args is None: return self.skip('need libcxxabi') |