From 1f231c39e52eab712eda9bcbf540752b813b567d Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 24 Jul 2020 07:12:14 -0700 Subject: Wasm2c fuzz support: only emit a call to the hang limit function if present (#2977) It may not be present while reducing a testcase, if the reducer removed it. --- test/unit/test_wasm2c.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/unit/test_wasm2c.py (limited to 'test/unit/test_wasm2c.py') diff --git a/test/unit/test_wasm2c.py b/test/unit/test_wasm2c.py new file mode 100644 index 000000000..bcdab355b --- /dev/null +++ b/test/unit/test_wasm2c.py @@ -0,0 +1,21 @@ +from scripts.test import shared +from . import utils + + +class Wasm2CTest(utils.BinaryenTestCase): + def test_wrapper(self): + # the wrapper C code should only call the hang limit initializer if + # that is present. + empty_wasm = self.input_path('empty.wasm') + args = [empty_wasm, '--emit-wasm2c-wrapper=output.c'] + shared.run_process(shared.WASM_OPT + args) + with open('output.c') as f: + normal_output = f.read() + # running with ttf generates a new wasm for fuzzing, which always + # includes the hang limit initializer function + shared.run_process(shared.WASM_OPT + args + ['-ttf']) + with open('output.c') as f: + ttf_output = f.read() + hang_limit_name = 'hangLimitInitializer' + self.assertIn(hang_limit_name, ttf_output) + self.assertNotIn(hang_limit_name, normal_output) -- cgit v1.2.3