summaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2019-03-25 18:11:45 -0700
committerGitHub <noreply@github.com>2019-03-25 18:11:45 -0700
commit56c5ff78310ad956e70bf1a00a64c72ee81d18bd (patch)
tree28d0a5ed42a44f18f314d57cd66dc1e545669b02 /test/unit
parent5e19a7b05144736ec17ee6b0bb366afa744137c6 (diff)
downloadbinaryen-56c5ff78310ad956e70bf1a00a64c72ee81d18bd.tar.gz
binaryen-56c5ff78310ad956e70bf1a00a64c72ee81d18bd.tar.bz2
binaryen-56c5ff78310ad956e70bf1a00a64c72ee81d18bd.zip
More validation tests and fixes for SIMD (#1964)
Moves the feature validation unit test file to a new directory, 'unit', and adds new tests for SIMD and sign-ext. Adds validation for v128 globals and v128.const.
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/__init__.py0
-rw-r--r--test/unit/test_features.py88
2 files changed, 88 insertions, 0 deletions
diff --git a/test/unit/__init__.py b/test/unit/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/test/unit/__init__.py
diff --git a/test/unit/test_features.py b/test/unit/test_features.py
new file mode 100644
index 000000000..9f9f618b0
--- /dev/null
+++ b/test/unit/test_features.py
@@ -0,0 +1,88 @@
+import unittest
+from scripts.test.shared import WASM_OPT, run_process
+
+
+class FeatureValidationTest(unittest.TestCase):
+ def check_feature(self, module, error, flag):
+ p = run_process(WASM_OPT + ['--mvp-features', '--print'],
+ input=module, check=False, capture_output=True)
+ self.assertIn(error, p.stderr)
+ self.assertIn("Fatal: error in validating input", p.stderr)
+ self.assertNotEqual(p.returncode, 0)
+ p = run_process(WASM_OPT + ['--mvp-features', flag, '--print'],
+ input=module, check=False, capture_output=True)
+ self.assertEqual(p.returncode, 0)
+
+ def check_simd(self, module, error):
+ self.check_feature(module, error, '--enable-simd')
+
+ def check_sign_ext(self, module, error):
+ self.check_feature(module, error, '--enable-sign-ext')
+
+ def test_v128_signature(self):
+ module = """
+ (module
+ (func $foo (param $0 v128) (result v128)
+ (local.get $0)
+ )
+ )
+ """
+ self.check_simd(module, "all used types should be allowed")
+
+ def test_v128_global(self):
+ module = """
+ (module
+ (global $foo (mut v128) (v128.const i32x4 0 0 0 0))
+ )
+ """
+ self.check_simd(module, "all used types should be allowed")
+
+ def test_v128_local(self):
+ module = """
+ (module
+ (func $foo
+ (local v128)
+ )
+ )
+ """
+ self.check_simd(module, "all used types should be allowed")
+
+ def test_simd_const(self):
+ module = """
+ (module
+ (func $foo
+ (drop (v128.const i32x4 0 0 0 0))
+ )
+ )
+ """
+ self.check_simd(module, "all used features should be allowed")
+
+ def test_simd_load(self):
+ module = """
+ (module
+ (func $foo
+ (drop (v128.load (i32.const 0)))
+ )
+ )
+ """
+ self.check_simd(module, "SIMD operation (SIMD is disabled)")
+
+ def test_simd_splat(self):
+ module = """
+ (module
+ (func $foo
+ (drop (i32x4.splat (i32.const 0)))
+ )
+ )
+ """
+ self.check_simd(module, "all used features should be allowed")
+
+ def test_sign_ext(self):
+ module = """
+ (module
+ (func $foo
+ (drop (i32.extend8_s (i32.const 7)))
+ )
+ )
+ """
+ self.check_sign_ext(module, "all used features should be allowed")