diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-02-18 16:09:37 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-02-18 16:09:37 -0800 |
commit | 565d3bb3d5f8d6ade54a18c30b4f2a27facc8e99 (patch) | |
tree | dc2d1ec71507b213c6db3029c4f0ed5ae992f354 /tests | |
parent | 8934707eb63b250bfaca4c0b2761fd32a1755ef3 (diff) |
useful info in ASSERTIONS=1 and 2 in fastcomp for bad function pointer calls, and update other.test_dangerous_func_cast to test that
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_other.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/tests/test_other.py b/tests/test_other.py index e5dbb38a..703680ba 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -521,7 +521,6 @@ f.close() assert 'function _malloc' in src def test_dangerous_func_cast(self): - if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp') src = r''' #include <stdio.h> typedef void (*voidfunc)(); @@ -543,13 +542,23 @@ f.close() self.assertContained(expected, run_js(self.in_dir('a.out.js'), stderr=PIPE, full_output=True)) return open(self.in_dir('a.out.js')).read() - test([], 'my func') # no asm, so casting func works - test(['-O2'], 'abort', ['Casting potentially incompatible function pointer i32 ()* to void (...)*, for my_func', - 'Incompatible function pointer casts are very dangerous with ASM_JS=1, you should investigate and correct these']) # asm, so failure - test(['-O2', '-s', 'ASSERTIONS=1'], - 'Invalid function pointer called. Perhaps a miscast function pointer (check compilation warnings) or bad vtable lookup (maybe due to derefing a bad pointer, like NULL)?', - ['Casting potentially incompatible function pointer i32 ()* to void (...)*, for my_func', - 'Incompatible function pointer casts are very dangerous with ASM_JS=1, you should investigate and correct these']) # asm, so failure + if os.environ.get('EMCC_FAST_COMPILER') != '1': + test([], 'my func') # no asm, so casting func works + test(['-O2'], 'abort', ['Casting potentially incompatible function pointer i32 ()* to void (...)*, for my_func', + 'Incompatible function pointer casts are very dangerous with ASM_JS=1, you should investigate and correct these']) # asm, so failure + test(['-O2', '-s', 'ASSERTIONS=1'], + 'Invalid function pointer called. Perhaps a miscast function pointer (check compilation warnings) or bad vtable lookup (maybe due to derefing a bad pointer, like NULL)?', + ['Casting potentially incompatible function pointer i32 ()* to void (...)*, for my_func', + 'Incompatible function pointer casts are very dangerous with ASM_JS=1, you should investigate and correct these']) # asm, so failure + else: + # fastcomp. all asm, so it can't just work with wrong sigs. but, ASSERTIONS=2 gives much better info to debug + test(['-O1'], 'abort') # no useful info + test(['-O1', '-s', 'ASSERTIONS=1'], '''Invalid function pointer called with signature 'v'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an different type, which will fail? +Build with ASSERTIONS=2 for more info. +''') # some useful text + test(['-O1', '-s', 'ASSERTIONS=2'], '''Invalid function pointer '1' called with signature 'v'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an different type, which will fail? +This pointer might make sense in another type signature: i: _my_func +''') # actually useful identity of the bad pointer, with comparisons to what it would be in other types/tables def test_l_link(self): # Linking with -lLIBNAME and -L/DIRNAME should work |