COMPMID-345 Fix the failure counter wrongly logging issue
Change-Id: Ic917b0361e602fadb8dbff69c6bec5582d6b261d
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/85956
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
diff --git a/tests/framework/Asserts.h b/tests/framework/Asserts.h
index b545a9e..936dfcf 100644
--- a/tests/framework/Asserts.h
+++ b/tests/framework/Asserts.h
@@ -54,6 +54,14 @@
return value;
}
+inline void ARM_COMPUTE_PRINT_INFO()
+{
+ std::stringstream msg;
+ arm_compute::test::framework::Framework::get().print_test_info(msg);
+ arm_compute::test::framework::Framework::get().log_info(msg.str());
+ arm_compute::test::framework::Framework::get().clear_test_info();
+}
+
#define ARM_COMPUTE_TEST_INFO(INFO) \
{ \
std::stringstream info; \
@@ -126,6 +134,7 @@
} \
arm_compute::test::framework::Framework::get().clear_test_info(); \
} while(false)
+
} // namespace framework
} // namespace test
} // namespace arm_compute
diff --git a/tests/framework/Framework.cpp b/tests/framework/Framework.cpp
index 315f8eb..8d015c6 100644
--- a/tests/framework/Framework.cpp
+++ b/tests/framework/Framework.cpp
@@ -179,6 +179,14 @@
}
}
+void Framework::log_info(const std::string &info)
+{
+ if(_log_level >= LogLevel::DEBUG && _printer != nullptr)
+ {
+ _printer->print_info(info);
+ }
+}
+
int Framework::num_iterations() const
{
return _num_iterations;
@@ -489,6 +497,11 @@
return ids;
}
+
+LogLevel Framework::log_level() const
+{
+ return _log_level;
+}
} // namespace framework
} // namespace test
} // namespace arm_compute
diff --git a/tests/framework/Framework.h b/tests/framework/Framework.h
index 055392c..6a26c29 100644
--- a/tests/framework/Framework.h
+++ b/tests/framework/Framework.h
@@ -191,6 +191,12 @@
*/
void log_failed_expectation(const TestError &error);
+ /** Print the debug information that has already been logged
+ *
+ * @param[in] info Description of the log info.
+ */
+ void log_info(const std::string &info);
+
/** Number of iterations per test case.
*
* @return Number of iterations per test case.
@@ -270,6 +276,12 @@
*/
std::vector<TestInfo> test_infos() const;
+ /** Get the current logging level
+ *
+ * @return The current logging level.
+ */
+ LogLevel log_level() const;
+
private:
Framework();
~Framework() = default;
diff --git a/tests/framework/printers/JSONPrinter.cpp b/tests/framework/printers/JSONPrinter.cpp
index 5b30389..bf8fce7 100644
--- a/tests/framework/printers/JSONPrinter.cpp
+++ b/tests/framework/printers/JSONPrinter.cpp
@@ -113,6 +113,16 @@
}
}
+void JSONPrinter::print_info(const std::string &info)
+{
+ std::istringstream iss(info);
+ for(std::string line; !std::getline(iss, line).fail();)
+ {
+ print_separator(_first_error);
+ *_stream << R"(")" << line << R"(")";
+ }
+}
+
void JSONPrinter::print_measurements(const Profiler::MeasurementsMap &measurements)
{
print_separator(_first_test_entry);
diff --git a/tests/framework/printers/JSONPrinter.h b/tests/framework/printers/JSONPrinter.h
index 14c8b35..18bd438 100644
--- a/tests/framework/printers/JSONPrinter.h
+++ b/tests/framework/printers/JSONPrinter.h
@@ -48,6 +48,7 @@
void print_errors_header() override;
void print_errors_footer() override;
void print_error(const std::exception &error) override;
+ void print_info(const std::string &info) override;
void print_measurements(const Profiler::MeasurementsMap &measurements) override;
private:
diff --git a/tests/framework/printers/PrettyPrinter.cpp b/tests/framework/printers/PrettyPrinter.cpp
index ec32e52..b0892a4 100644
--- a/tests/framework/printers/PrettyPrinter.cpp
+++ b/tests/framework/printers/PrettyPrinter.cpp
@@ -96,6 +96,11 @@
{
}
+void PrettyPrinter::print_info(const std::string &info)
+{
+ *_stream << begin_color("1") << "INFO: " << info << end_color() << "\n";
+}
+
void PrettyPrinter::print_error(const std::exception &error)
{
*_stream << begin_color("1") << "ERROR: " << error.what() << end_color() << "\n";
diff --git a/tests/framework/printers/PrettyPrinter.h b/tests/framework/printers/PrettyPrinter.h
index fa7b7b2..3e2bebd 100644
--- a/tests/framework/printers/PrettyPrinter.h
+++ b/tests/framework/printers/PrettyPrinter.h
@@ -54,6 +54,7 @@
void print_errors_header() override;
void print_errors_footer() override;
void print_error(const std::exception &error) override;
+ void print_info(const std::string &info) override;
void print_measurements(const Profiler::MeasurementsMap &measurements) override;
private:
diff --git a/tests/framework/printers/Printer.h b/tests/framework/printers/Printer.h
index 198d84d..16a4170 100644
--- a/tests/framework/printers/Printer.h
+++ b/tests/framework/printers/Printer.h
@@ -108,6 +108,12 @@
*/
virtual void print_error(const std::exception &error) = 0;
+ /** Print test log info.
+ *
+ * @param[in] info Description of the log.
+ */
+ virtual void print_info(const std::string &info) = 0;
+
/** Print measurements for a test.
*
* @param[in] measurements Measurements as collected by a @ref Profiler.
diff --git a/tests/validation/Validation.h b/tests/validation/Validation.h
index db95e06..49c7d83 100644
--- a/tests/validation/Validation.h
+++ b/tests/validation/Validation.h
@@ -316,7 +316,7 @@
ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target_value));
ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << framework::make_printable(reference_value));
ARM_COMPUTE_TEST_INFO("tolerance = " << std::setprecision(5) << framework::make_printable(static_cast<typename U::value_type>(tolerance_value)));
- ARM_COMPUTE_EXPECT_EQUAL(target_value, reference_value, framework::LogLevel::DEBUG);
+ framework::ARM_COMPUTE_PRINT_INFO();
++num_mismatches;
}