binaryen/test/unit/test_web_limitations.py
Jérôme Vouillon fcd8dfe7dd
Binary parser: Lift the limit on the number of locals (#6973)
This raises the number of locals accepted by the binary parser to the
absolute limit in the spec. A warning is now printed when writing a
binary file if the Web limit of 50,000 locals is exceeded.

Fixes #6968.
2024-09-30 12:37:09 -07:00

39 lines
1.2 KiB
Python

import os
from scripts.test import shared
from . import utils
class WebLimitations(utils.BinaryenTestCase):
def test_many_params(self):
"""Test that we warn on large numbers of parameters, which Web VMs
disallow."""
params = '(param i32) ' * 1001
module = '''
(module
(func $foo %s
)
)
''' % params
p = shared.run_process(shared.WASM_OPT + ['-o', os.devnull],
input=module, capture_output=True)
self.assertIn('Some VMs may not accept this binary because it has a large number of parameters in function foo.',
p.stderr)
def test_many_locals(self):
"""Test that we warn on large numbers of locals, which Web VMs
disallow."""
params = '(local i32) ' * 50_001
module = '''
(module
(func $foo %s
)
)
''' % params
p = shared.run_process(shared.WASM_OPT + ['-o', os.devnull],
input=module, capture_output=True)
self.assertIn('Some VMs may not accept this binary because it has a large number of locals in function foo.',
p.stderr)