diff options
author | Wouter van Oortmerssen <aardappel@gmail.com> | 2020-09-17 10:55:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-17 10:55:02 -0700 |
commit | 6116553a91b5da4fd877480bb27fc88b264b737f (patch) | |
tree | 0f96e01ec6e618fd012fa97a7b9bbcf4b3fb33d1 /src | |
parent | 9f7a053bf0ca3185336eb4616f88d85df573adbf (diff) | |
download | binaryen-6116553a91b5da4fd877480bb27fc88b264b737f.tar.gz binaryen-6116553a91b5da4fd877480bb27fc88b264b737f.tar.bz2 binaryen-6116553a91b5da4fd877480bb27fc88b264b737f.zip |
Improve testing on Windows (#3142)
This PR contains:
- Changes that enable/disable tests on Windows to allow for better local testing.
- Also changes many abort() into Fatal() when it is really just exiting on error. This is because abort() generates a dialog window on Windows which is not great in automated scripts.
- Improvements to CMake to better work with the project in IDEs (VS).
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/ExtractFunction.cpp | 3 | ||||
-rw-r--r-- | src/passes/pass.cpp | 18 | ||||
-rw-r--r-- | src/tools/execution-results.h | 2 | ||||
-rw-r--r-- | src/tools/wasm-as.cpp | 5 | ||||
-rw-r--r-- | src/tools/wasm-opt.cpp | 3 | ||||
-rw-r--r-- | src/tools/wasm-shell.cpp | 10 | ||||
-rw-r--r-- | src/tools/wasm2js.cpp | 3 | ||||
-rw-r--r-- | src/wasm/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/wasm2js.h | 31 |
9 files changed, 29 insertions, 48 deletions
diff --git a/src/passes/ExtractFunction.cpp b/src/passes/ExtractFunction.cpp index fbc1aa7c4..34fb449d4 100644 --- a/src/passes/ExtractFunction.cpp +++ b/src/passes/ExtractFunction.cpp @@ -42,8 +42,7 @@ struct ExtractFunction : public Pass { } } if (!found) { - std::cerr << "could not find the function to extract\n"; - abort(); + Fatal() << "could not find the function to extract\n"; } // clear data module->memory.segments.clear(); diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index 62c4c6452..48d121098 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -591,16 +591,15 @@ void PassRunner::run() { if (!WasmValidator().validate(*wasm, validationFlags)) { WasmPrinter::printModule(wasm); if (passDebug >= 2) { - std::cerr << "Last pass (" << pass->name - << ") broke validation. Here is the module before: \n" - << moduleBefore.str() << "\n"; + Fatal() << "Last pass (" << pass->name + << ") broke validation. Here is the module before: \n" + << moduleBefore.str() << "\n"; } else { - std::cerr << "Last pass (" << pass->name - << ") broke validation. Run with BINARYEN_PASS_DEBUG=2 " - "in the env to see the earlier state, or 3 to dump " - "byn-* files for each pass\n"; + Fatal() << "Last pass (" << pass->name + << ") broke validation. Run with BINARYEN_PASS_DEBUG=2 " + "in the env to see the earlier state, or 3 to dump " + "byn-* files for each pass\n"; } - abort(); } } if (passDebug >= 3) { @@ -613,8 +612,7 @@ void PassRunner::run() { std::cerr << "[PassRunner] (final validation)\n"; if (!WasmValidator().validate(*wasm, validationFlags)) { WasmPrinter::printModule(wasm); - std::cerr << "final module does not validate\n"; - abort(); + Fatal() << "final module does not validate\n"; } } } else { diff --git a/src/tools/execution-results.h b/src/tools/execution-results.h index 0881163f1..b63a276ae 100644 --- a/src/tools/execution-results.h +++ b/src/tools/execution-results.h @@ -99,7 +99,7 @@ struct ExecutionResults { optimizedResults.get(wasm); if (optimizedResults != *this) { std::cout << "[fuzz-exec] optimization passes changed execution results"; - abort(); + exit(1); } } diff --git a/src/tools/wasm-as.cpp b/src/tools/wasm-as.cpp index 3a907c4c3..be18ed355 100644 --- a/src/tools/wasm-as.cpp +++ b/src/tools/wasm-as.cpp @@ -54,9 +54,8 @@ int main(int argc, const char* argv[]) { Options::Arguments::One, [](Options* o, const std::string& argument) { if (argument != "web" && argument != "none" && argument != "wasm") { - std::cerr << "Valid arguments for --validate flag are 'wasm', " - "'web', and 'none'.\n"; - exit(1); + Fatal() << "Valid arguments for --validate flag are 'wasm', " + "'web', and 'none'.\n"; } o->extra["validate"] = argument; }) diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp index 24ea9c31c..ecf4f1c7c 100644 --- a/src/tools/wasm-opt.cpp +++ b/src/tools/wasm-opt.cpp @@ -377,8 +377,7 @@ int main(int argc, const char* argv[]) { auto secondOutput = runCommand(extraFuzzCommand); std::cout << "[extra-fuzz-command second output:]\n" << firstOutput << '\n'; if (firstOutput != secondOutput) { - std::cerr << "extra fuzz command output differs\n"; - abort(); + Fatal() << "extra fuzz command output differs\n"; } } return 0; diff --git a/src/tools/wasm-shell.cpp b/src/tools/wasm-shell.cpp index 8ba6a4142..69670192b 100644 --- a/src/tools/wasm-shell.cpp +++ b/src/tools/wasm-shell.cpp @@ -192,8 +192,7 @@ static void run_asserts(Name moduleName, Colors::red(std::cerr); std::cerr << "[should have been invalid]\n"; Colors::normal(std::cerr); - std::cerr << &wasm << '\n'; - abort(); + Fatal() << &wasm << '\n'; } } else if (id == INVOKE) { assert(wasm); @@ -222,8 +221,7 @@ static void run_asserts(Name moduleName, } std::cerr << "seen " << result << ", expected " << expected << '\n'; if (expected != result) { - std::cout << "unexpected, should be identical\n"; - abort(); + Fatal() << "unexpected, should be identical\n"; } } if (id == ASSERT_TRAP) { @@ -314,8 +312,8 @@ int main(int argc, const char* argv[]) { bool valid = WasmValidator().validate(*modules[moduleName]); if (!valid) { WasmPrinter::printModule(modules[moduleName].get()); + Fatal() << "module failed to validate, see above"; } - assert(valid); run_asserts(moduleName, &i, &checked, @@ -329,7 +327,7 @@ int main(int argc, const char* argv[]) { } } catch (ParseException& p) { p.dump(std::cerr); - abort(); + exit(1); } if (checked) { diff --git a/src/tools/wasm2js.cpp b/src/tools/wasm2js.cpp index 524be4c5c..68334708f 100644 --- a/src/tools/wasm2js.cpp +++ b/src/tools/wasm2js.cpp @@ -630,8 +630,7 @@ Ref AssertionEmitter::emitAssertReturnFunc(Builder& wasmBuilder, } default: { - std::cerr << "Unhandled type in assert: " << resType << std::endl; - abort(); + Fatal() << "Unhandled type in assert: " << resType; } } } else { diff --git a/src/wasm/CMakeLists.txt b/src/wasm/CMakeLists.txt index 32cdf50c8..d24618c63 100644 --- a/src/wasm/CMakeLists.txt +++ b/src/wasm/CMakeLists.txt @@ -1,4 +1,4 @@ -FILE(GLOB wasm_HEADERS *.h) +file(GLOB wasm_HEADERS ../*.h) set(wasm_SOURCES literal.cpp wasm.cpp diff --git a/src/wasm2js.h b/src/wasm2js.h index 8418d5b15..727e87379 100644 --- a/src/wasm2js.h +++ b/src/wasm2js.h @@ -1268,9 +1268,8 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, ValueBuilder::makePtrShift(ptr, 2)); break; default: { - std::cerr << "Unhandled number of bytes in i32 load: " - << curr->bytes << std::endl; - abort(); + Fatal() << "Unhandled number of bytes in i32 load: " + << curr->bytes; } } break; @@ -1284,8 +1283,7 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, ValueBuilder::makePtrShift(ptr, 3)); break; default: { - std::cerr << "Unhandled type in load: " << curr->type << std::endl; - abort(); + Fatal() << "Unhandled type in load: " << curr->type; } } if (curr->isAtomic) { @@ -1378,9 +1376,7 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, ValueBuilder::makePtrShift(ptr, 3)); break; default: { - std::cerr << "Unhandled type in store: " << curr->valueType - << std::endl; - abort(); + Fatal() << "Unhandled type in store: " << curr->valueType; } } if (curr->isAtomic) { @@ -1431,7 +1427,7 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, PLUS, ValueBuilder::makeDouble(curr->value.getf64())); } default: - abort(); + Fatal() << "unknown const type"; } } @@ -1510,9 +1506,7 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, ValueBuilder::makeNum(16)); } default: { - std::cerr << "Unhandled unary i32 operator: " << curr - << std::endl; - abort(); + Fatal() << "Unhandled unary i32 operator: " << curr; } } } @@ -1607,8 +1601,7 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, return ret; } default: { - std::cerr << "Unhandled type in unary: " << curr << std::endl; - abort(); + Fatal() << "Unhandled type in unary: " << curr; } } } @@ -1771,17 +1764,14 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, case CopySignFloat32: case CopySignFloat64: default: - std::cerr << "Unhandled binary float operator: " << curr - << std::endl; - abort(); + Fatal() << "Unhandled binary float operator: "; } if (curr->type == Type::f32) { return makeAsmCoercion(ret, ASM_FLOAT); } return ret; default: - std::cerr << "Unhandled type in binary: " << curr << std::endl; - abort(); + Fatal() << "Unhandled type in binary: " << curr; } return makeAsmCoercion(ret, wasmToAsmType(curr->type)); } @@ -2266,8 +2256,7 @@ void Wasm2JSGlue::emitPreES6() { // yet. if (baseModuleMap.count(base) && baseModuleMap[base] != module) { Fatal() << "the name " << base << " cannot be imported from " - << "two different modules yet\n"; - abort(); + << "two different modules yet"; } baseModuleMap[base] = module; |