File: test_wasm2c.py

package info (click to toggle)
binaryen 108-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 35,424 kB
  • sloc: cpp: 151,487; javascript: 62,522; ansic: 13,124; python: 5,260; pascal: 441; sh: 75; asm: 27; makefile: 8
file content (21 lines) | stat: -rw-r--r-- 882 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)