File: test_web_limitations.py

package info (click to toggle)
binaryen 120-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,284 kB
  • sloc: cpp: 189,449; javascript: 62,189; ansic: 14,087; python: 5,379; pascal: 441; sh: 77; makefile: 30; asm: 27
file content (38 lines) | stat: -rw-r--r-- 1,224 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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)