[test runner] Improve error messaging for memory metrics tests

This commit is contained in:
Mikhail Pozdnyakov
2019-10-21 15:32:50 +03:00
parent 61d1018087
commit bb0e5ffb2c
2 changed files with 10 additions and 15 deletions

View File

@@ -125,9 +125,7 @@ int runRenderTests(int argc, char** argv) {
color = "red";
stats.erroredTests++;
printf(ANSI_COLOR_RED "* errored %s" ANSI_COLOR_RESET "\n", id.c_str());
if (!metadata.errorMessage.empty()) {
printf(ANSI_COLOR_RED "* error: %s" ANSI_COLOR_RESET "\n", metadata.errorMessage.c_str());
}
printf(ANSI_COLOR_RED "* error: %s" ANSI_COLOR_RESET "\n", metadata.errorMessage.c_str());
} else {
status = "failed";
color = "red";

View File

@@ -270,25 +270,22 @@ bool TestRunner::checkRenderTestResults(mbgl::PremultipliedImage&& actualImage,
}
bool passed{false};
float delta{0.0f};
std::stringstream errorStream;
std::tie(passed, delta) = MemoryProbe::checkPeak(expected.second, actual->second);
if (!passed) {
std::stringstream ss;
ss << "Allocated memory peak size at probe \"" << expected.first << "\" is " << actual->second.peak
<< " bytes, expected is " << expected.second.peak << "±" << delta << " bytes.";
metadata.errorMessage = ss.str();
return false;
errorStream << "Allocated memory peak size at probe \"" << expected.first << "\" is " << actual->second.peak
<< " bytes, expected is " << expected.second.peak << "±" << delta << " bytes.";
}
std::tie(passed, delta) = MemoryProbe::checkAllocations(expected.second, actual->second);
if (!passed) {
std::stringstream ss;
ss << "Number of allocations at probe \"" << expected.first << "\" is " << actual->second.allocations
<< ", expected is " << expected.second.allocations << "±" << std::round(delta) << " allocations.";
metadata.errorMessage = ss.str();
return false;
errorStream << "Number of allocations at probe \"" << expected.first << "\" is "
<< actual->second.allocations << ", expected is " << expected.second.allocations << "±"
<< std::round(delta) << " allocations.";
}
metadata.errorMessage = errorStream.str();
if (!metadata.errorMessage.empty()) return false;
}
// Check network metrics.