diff options
Diffstat (limited to 'tests/test_other.py')
-rw-r--r-- | tests/test_other.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/tests/test_other.py b/tests/test_other.py index e381e1b3..2fecf09e 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -2521,16 +2521,24 @@ int main() } ''') + IMPLICIT_WARNING = '''warning: implicit declaration of function 'strnlen' is invalid in C99''' + IMPLICIT_ERROR = '''error: implicit declaration of function 'strnlen' is invalid in C99''' + for opts, expected, compile_expected in [ - ([], ['abort()', 'it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this'], []), - (['-s', 'ASSERTIONS=2'], ['abort()', 'This pointer might make sense in another type signature'], []), - (['-O1'], ['hello 2\nhello 5\n'], []), # invalid output - second arg is sent as varargs, but needs to be int. llvm optimizer avoided the crash silently, caused undefined behavior... at least people can debug this by running an -O0 build. + ([], None, [IMPLICIT_ERROR]), + (['-Wno-error=implicit-function-declaration'], ['abort()', 'it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this'], [IMPLICIT_WARNING]), # turn error into warning + (['-Wno-implicit-function-declaration'], ['abort()', 'it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this'], []), # turn error into nothing at all + (['-Wno-error=implicit-function-declaration', '-s', 'ASSERTIONS=2'], ['abort()', 'This pointer might make sense in another type signature'], []), + (['-Wno-error=implicit-function-declaration', '-O1'], ['hello 2\nhello 5\n'], []), # invalid output - second arg is sent as varargs, but needs to be int. llvm optimizer avoided the crash silently, caused undefined behavior... at least people can debug this by running an -O0 build. ]: print opts, expected stdout, stderr = Popen([PYTHON, EMCC, 'src.c'] + opts, stderr=PIPE).communicate() - output = run_js(os.path.join(self.get_dir(), 'a.out.js'), stderr=PIPE, full_output=True) - for e in expected: - self.assertContained(e, output) - for ce in compile_expected + ['''warning: implicit declaration of function 'strnlen' is invalid in C99''', '''warning: incompatible pointer types''']: + for ce in compile_expected + ['''warning: incompatible pointer types''']: self.assertContained(ce, stderr) + if expected is None: + assert not os.path.exists('a.out.js') + else: + output = run_js(os.path.join(self.get_dir(), 'a.out.js'), stderr=PIPE, full_output=True) + for e in expected: + self.assertContained(e, output) |