Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fizzy-bench: show more useful error messages #316

Merged
merged 1 commit into from
May 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions test/bench/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <iterator>
#include <memory>
#include <sstream>
#include <string>

namespace fs = std::filesystem;

Expand Down Expand Up @@ -113,13 +114,24 @@ void validate_benchmark_case(benchmark::State& state, fizzy::test::WasmEngine& e
if (benchmark_case.expected_result)
{
if (!result.value)
return state.SkipWithError("Missing result value");
{
const auto error_msg = "Missing result value, expected: " +
std::to_string(*benchmark_case.expected_result);
return state.SkipWithError(error_msg.c_str());
}
else if (*result.value != *benchmark_case.expected_result)
return state.SkipWithError("Incorrect result");
{
const auto error_msg = "Incorrect result value, expected: " +
std::to_string(*benchmark_case.expected_result) +
", got: " + std::to_string(*result.value);
return state.SkipWithError(error_msg.c_str());
}
}
else if (result.value)
return state.SkipWithError("Unexpected result");

{
return state.SkipWithError(
("Unexpected result value: " + std::to_string(*result.value)).c_str());
}
const auto memory = engine.get_memory();
if (memory.size() < benchmark_case.expected_memory.size())
return state.SkipWithError("Result memory is shorter than expected");
Expand Down