From b349c227aad37db102c644e6fe8030e9f939ef89 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 2 Aug 2016 20:35:15 -0700 Subject: better printing when assert_invalids fail --- src/tools/wasm-shell.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/tools/wasm-shell.cpp') diff --git a/src/tools/wasm-shell.cpp b/src/tools/wasm-shell.cpp index 72e8e13ba..32bc746b2 100644 --- a/src/tools/wasm-shell.cpp +++ b/src/tools/wasm-shell.cpp @@ -125,7 +125,13 @@ static void run_asserts(size_t* i, bool* checked, Module* wasm, // maybe parsed ok, but otherwise incorrect invalid = !WasmValidator().validate(wasm); } - assert(invalid); + if (!invalid) { + Colors::red(std::cerr); + std::cerr << "[should have been invalid]\n"; + Colors::normal(std::cerr); + std::cerr << &wasm << '\n'; + abort(); + } } else if (id == INVOKE) { assert(wasm); Invocation invocation(curr, instance.get(), *builder->get()); -- cgit v1.2.3 From ef82c858b9ca6e1a9e34e79398195e7b549507aa Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 9 Aug 2016 10:05:01 -0700 Subject: wasm-shell improvements: print out which module is built, add option to skip lines --- src/tools/wasm-shell.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/tools/wasm-shell.cpp') diff --git a/src/tools/wasm-shell.cpp b/src/tools/wasm-shell.cpp index 32bc746b2..a95ced87f 100644 --- a/src/tools/wasm-shell.cpp +++ b/src/tools/wasm-shell.cpp @@ -136,9 +136,8 @@ static void run_asserts(size_t* i, bool* checked, Module* wasm, assert(wasm); Invocation invocation(curr, instance.get(), *builder->get()); invocation.invoke(); - } else { + } else if (wasm) { // if no wasm, we skipped the module // an invoke test - assert(wasm); bool trapped = false; WASM_UNUSED(trapped); Literal result; @@ -175,6 +174,7 @@ static void run_asserts(size_t* i, bool* checked, Module* wasm, int main(int argc, const char* argv[]) { Name entry; + std::set skipped; Options options("wasm-shell", "Execute .wast files"); options @@ -182,6 +182,21 @@ int main(int argc, const char* argv[]) { "--entry", "-e", "call the entry point after parsing the module", Options::Arguments::One, [&entry](Options*, const std::string& argument) { entry = argument; }) + .add( + "--skip", "-s", "skip input on certain lines (comma-separated-list)", + Options::Arguments::One, + [&skipped](Options*, const std::string& argument) { + size_t i = 0; + while (i < argument.size()) { + auto ending = argument.find(',', i); + if (ending == std::string::npos) { + ending = argument.size(); + } + auto sub = argument.substr(i, ending - i); + skipped.insert(atoi(sub.c_str())); + i = ending + 1; + } + }) .add_positional("INFILE", Options::Arguments::One, [](Options* o, const std::string& argument) { o->extra["infile"] = argument; @@ -201,9 +216,19 @@ int main(int argc, const char* argv[]) { size_t i = 0; while (i < root.size()) { Element& curr = *root[i]; + if (skipped.count(curr.line) > 0) { + Colors::green(std::cerr); + std::cerr << "SKIPPING [line: " << curr.line << "]\n"; + Colors::normal(std::cerr); + i++; + continue; + } IString id = curr[0]->str(); if (id == MODULE) { if (options.debug) std::cerr << "parsing s-expressions to wasm...\n"; + Colors::green(std::cerr); + std::cerr << "BUILDING MODULE [line: " << curr.line << "]\n"; + Colors::normal(std::cerr); Module wasm; std::unique_ptr builder; builder = wasm::make_unique(wasm, *root[i]); -- cgit v1.2.3