diff options
author | Alon Zakai <azakai@google.com> | 2022-10-17 13:47:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-17 20:47:40 +0000 |
commit | a60a7167e202003ec1fbea5405ee53e80fd85e21 (patch) | |
tree | e36b38c40af5a00e4260ddf07e1d2728c9f3219a /test | |
parent | 3e44a9fc542572592ee1ee1bdec19bf1904faaa3 (diff) | |
download | binaryen-a60a7167e202003ec1fbea5405ee53e80fd85e21.tar.gz binaryen-a60a7167e202003ec1fbea5405ee53e80fd85e21.tar.bz2 binaryen-a60a7167e202003ec1fbea5405ee53e80fd85e21.zip |
Binary format: Don't emit empty Memory sections (#5145)
If the only memories are imported, we don't need the section. We were already
doing that for tables, functions, etc.
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/input/only-imported-memory.wasm | bin | 0 -> 50 bytes | |||
-rw-r--r-- | test/unit/test_only_imported_memory.py | 8 | ||||
-rw-r--r-- | test/unit/utils.py | 6 |
3 files changed, 12 insertions, 2 deletions
diff --git a/test/unit/input/only-imported-memory.wasm b/test/unit/input/only-imported-memory.wasm Binary files differnew file mode 100644 index 000000000..175113e10 --- /dev/null +++ b/test/unit/input/only-imported-memory.wasm diff --git a/test/unit/test_only_imported_memory.py b/test/unit/test_only_imported_memory.py new file mode 100644 index 000000000..427f464d0 --- /dev/null +++ b/test/unit/test_only_imported_memory.py @@ -0,0 +1,8 @@ +from . import utils + + +class OnlyImportedMemoryTest(utils.BinaryenTestCase): + def test_only_imported_memory(self): + # We should not create a memories section for a file with only an + # imported memory: such a module has no declared memories. + self.roundtrip('only-imported-memory.wasm', debug=False) diff --git a/test/unit/utils.py b/test/unit/utils.py index b75ed311c..b0391afad 100644 --- a/test/unit/utils.py +++ b/test/unit/utils.py @@ -9,9 +9,11 @@ class BinaryenTestCase(unittest.TestCase): return os.path.join(shared.options.binaryen_test, 'unit', 'input', filename) - def roundtrip(self, filename, opts=[]): + def roundtrip(self, filename, opts=[], debug=True): + if debug: + opts = opts + ['-g'] path = self.input_path(filename) - p = shared.run_process(shared.WASM_OPT + ['-g', '-o', 'a.wasm', path] + + p = shared.run_process(shared.WASM_OPT + ['-o', 'a.wasm', path] + opts) self.assertEqual(p.returncode, 0) with open(path, 'rb') as f: |