Bug 1515917 - Multiple test-also flags + fix disablement tests. r=bbouvier
authorLars T Hansen <lhansen@mozilla.com>
Tue, 26 Feb 2019 09:08:44 +0100
changeset 519519 8eb14440dc5b45373528a2feb57e03a45254fcc8
parent 519518 b299e2b9886134da1abdc0d58459bd59d3ab0a88
child 519520 76f51b56356621314c701b39e134f9e3d3ebb06a
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1515917
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1515917 - Multiple test-also flags + fix disablement tests. r=bbouvier Allowing test-also to take multiple flags improves test coverage since we can test eg --wasm-gc --wasm-compiler=ion. Doing so uncovered some weaknesses in the tests that test what happens when features are disabled either by configuration or by flag, so this patch also fixes those problems and comments them more carefully." Differential Revision: https://phabricator.services.mozilla.com/D21180
js/src/jit-test/lib/wasm.js
js/src/jit-test/tests/wasm/gc/directives.txt
js/src/jit-test/tests/wasm/gc/disabled-ref.js
js/src/jit-test/tests/wasm/gc/disabled.js
js/src/tests/lib/jittests.py
--- a/js/src/jit-test/lib/wasm.js
+++ b/js/src/jit-test/lib/wasm.js
@@ -25,16 +25,40 @@ function wasmValidateText(str) {
 }
 
 function wasmFailValidateText(str, pattern) {
     let binary = wasmTextToBinary(str);
     assertEq(WebAssembly.validate(binary), false);
     assertErrorMessage(() => new WebAssembly.Module(binary), WebAssembly.CompileError, pattern);
 }
 
+// Expected compilation failure can happen in a couple of ways:
+//
+// - The compiler can be available but not capable of recognizing some opcodes:
+//   Compilation will start, but will fail with a CompileError.  This is what
+//   happens without --wasm-gc if opcodes enabled by --wasm-gc are used.
+//
+// - The compiler can be unavailable: Compilation will not start at all but will
+//   throw an Error.  This is what happens with "--wasm-gc --wasm-compiler=X" if
+//   X does not support the features enabled by --wasm-gc.
+
+function wasmCompilationShouldFail(bin, compile_error_regex) {
+    try {
+        new WebAssembly.Module(bin);
+    } catch (e) {
+        if (e instanceof WebAssembly.CompileError) {
+            assertEq(compile_error_regex.test(e), true);
+        } else if (e instanceof Error) {
+            assertEq(/can't use wasm debug\/gc without baseline/.test(e), true);
+        } else {
+            throw new Error("Unexpected exception value:\n" + e);
+        }
+    }
+}
+
 function mismatchError(actual, expect) {
     var str = `type mismatch: expression has type ${actual} but expected ${expect}`;
     return RegExp(str);
 }
 
 const emptyStackError = /from empty stack/;
 const unusedValuesError = /unused values not explicitly dropped by end of block/;
 
--- a/js/src/jit-test/tests/wasm/gc/directives.txt
+++ b/js/src/jit-test/tests/wasm/gc/directives.txt
@@ -1,1 +1,1 @@
-|jit-test| test-also=--wasm-gc; include:wasm.js
+|jit-test| test-also=--wasm-gc; test-also=--wasm-gc --wasm-compiler=ion; test-also=--wasm-gc --wasm-compiler=baseline; include:wasm.js
--- a/js/src/jit-test/tests/wasm/gc/disabled-ref.js
+++ b/js/src/jit-test/tests/wasm/gc/disabled-ref.js
@@ -1,4 +1,5 @@
 // |jit-test| skip-if: wasmGcEnabled()
 
-assertErrorMessage(() => wasmEvalText(`(module (func (param (ref 0)) (unreachable)))`),
-                   WebAssembly.CompileError, /reference types not enabled/);
+wasmCompilationShouldFail(
+    wasmTextToBinary(`(module (func (param (ref 0)) (unreachable)))`),
+    /reference types not enabled/);
--- a/js/src/jit-test/tests/wasm/gc/disabled.js
+++ b/js/src/jit-test/tests/wasm/gc/disabled.js
@@ -1,18 +1,14 @@
 // |jit-test| skip-if: wasmReftypesEnabled()
 
 const { CompileError, validate } = WebAssembly;
 
 const UNRECOGNIZED_OPCODE_OR_BAD_TYPE = /unrecognized opcode|(Structure|reference) types not enabled|invalid inline block type/;
 
-function assertValidateError(text) {
-    assertEq(validate(wasmTextToBinary(text)), false);
-}
-
 let simpleTests = [
     "(module (gc_feature_opt_in 3) (func (drop (ref.null))))",
     "(module (gc_feature_opt_in 3) (func $test (local anyref)))",
     "(module (gc_feature_opt_in 3) (func $test (param anyref)))",
     "(module (gc_feature_opt_in 3) (func $test (result anyref) (ref.null)))",
     "(module (gc_feature_opt_in 3) (func $test (block anyref (unreachable)) unreachable))",
     "(module (gc_feature_opt_in 3) (func $test (local anyref) (result i32) (ref.is_null (get_local 0))))",
     `(module (gc_feature_opt_in 3) (import "a" "b" (param anyref)))`,
@@ -20,28 +16,31 @@ let simpleTests = [
     `(module (gc_feature_opt_in 3) (type $s (struct)))`,
 ];
 
 // Two distinct failure modes:
 //
 // - if we have no compiled-in support for wasm-gc we'll get a syntax error when
 //   parsing the test programs that use ref types and structures.
 //
-// - if we have compiled-in support for wasm-gc, but wasm-gc is not currently
-//   enabled, we will succeed parsing but fail compilation and validation.
+// - if we have compiled-in support for wasm-gc, then there are several cases
+//   encapsulated in wasmCompilationShouldFail().
 //
-// But it should always be all of one or all of the other.
+// But it should always be all of one type of failure or or all of the other.
 
 var fail_syntax = 0;
 var fail_compile = 0;
 for (let src of simpleTests) {
+    let bin = null;
     try {
-        wasmTextToBinary(src);
+        bin = wasmTextToBinary(src);
     } catch (e) {
         assertEq(e instanceof SyntaxError, true);
         fail_syntax++;
         continue;
     }
-    assertErrorMessage(() => wasmEvalText(src), CompileError, UNRECOGNIZED_OPCODE_OR_BAD_TYPE);
-    assertValidateError(src);
+
+    assertEq(validate(bin), false);
+    wasmCompilationShouldFail(bin, UNRECOGNIZED_OPCODE_OR_BAD_TYPE);
+
     fail_compile++;
 }
 assertEq((fail_syntax == 0) != (fail_compile == 0), true);
--- a/js/src/tests/lib/jittests.py
+++ b/js/src/tests/lib/jittests.py
@@ -289,19 +289,19 @@ class JitTest:
                         test.allow_unhandlable_oom = True
                     elif name == 'allow-overrecursed':
                         test.allow_overrecursed = True
                     elif name == 'valgrind':
                         test.valgrind = options.valgrind
                     elif name == 'tz-pacific':
                         test.tz_pacific = True
                     elif name.startswith('test-also='):
-                        test.test_also.append([name[len('test-also='):]])
+                        test.test_also.append(re.split(r'\s+', name[len('test-also='):]))
                     elif name.startswith('test-join='):
-                        test.test_join.append([name[len('test-join='):]])
+                        test.test_join.append(re.split(r'\s+', name[len('test-join='):]))
                     elif name == 'module':
                         test.is_module = True
                     elif name == 'crash':
                         test.expect_crash = True
                     elif name.startswith('--'):
                         # // |jit-test| --ion-gvn=off; --no-sse4
                         test.jitflags.append(name)
                     else: