aboutsummaryrefslogtreecommitdiff
path: root/framework/Framework.cpp
diff options
context:
space:
mode:
authorMoritz Pflanzer <moritz.pflanzer@arm.com>2017-08-04 11:34:44 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-09-17 14:16:42 +0100
commit24a82463b683322a6bb11a103746ea9d9b3f53fb (patch)
treea444ba8dcc8c3cddd2540e722de49de7c0676e73 /framework/Framework.cpp
parent4dfc235367e602a366952a8495679e339d7a7263 (diff)
downloadComputeLibrary-24a82463b683322a6bb11a103746ea9d9b3f53fb.tar.gz
COMPMID-415: Use printer for errors
Change-Id: Idc2fc1dfd5706580d15c2bbfffe2830d41075a4b Reviewed-on: http://mpd-gerrit.cambridge.arm.com/82908 Reviewed-by: Anthony Barbier <anthony.barbier@arm.com> Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'framework/Framework.cpp')
-rw-r--r--framework/Framework.cpp42
1 files changed, 27 insertions, 15 deletions
diff --git a/framework/Framework.cpp b/framework/Framework.cpp
index 5a2b02fb21..315f8ebea7 100644
--- a/framework/Framework.cpp
+++ b/framework/Framework.cpp
@@ -166,11 +166,11 @@ void Framework::log_test_end(const TestInfo &info)
}
}
-void Framework::log_failed_expectation(const std::string &msg, LogLevel level)
+void Framework::log_failed_expectation(const TestError &error)
{
- if(_log_level >= level)
+ if(_log_level >= error.level() && _printer != nullptr)
{
- std::cerr << "ERROR: " << msg << "\n";
+ _printer->print_error(error);
}
if(_current_test_result != nullptr)
@@ -225,6 +225,11 @@ void Framework::run_test(const TestInfo &info, TestCaseFactory &test_factory)
_current_test_result = &result;
+ if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
+ {
+ _printer->print_errors_header();
+ }
+
try
{
std::unique_ptr<TestCase> test_case = test_factory.make();
@@ -256,9 +261,9 @@ void Framework::run_test(const TestInfo &info, TestCaseFactory &test_factory)
}
catch(const TestError &error)
{
- if(_log_level >= error.level())
+ if(_log_level >= error.level() && _printer != nullptr)
{
- std::cerr << "FATAL ERROR: " << error.what() << "\n";
+ _printer->print_error(error);
}
result.status = TestResult::Status::FAILED;
@@ -271,9 +276,11 @@ void Framework::run_test(const TestInfo &info, TestCaseFactory &test_factory)
#ifdef ARM_COMPUTE_CL
catch(const ::cl::Error &error)
{
- if(_log_level >= LogLevel::ERRORS)
+ if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
{
- std::cerr << "FATAL CL ERROR: " << error.what() << " with code " << error.err() << "\n";
+ std::stringstream stream;
+ stream << "Error code: " << error.err();
+ _printer->print_error(TestError(error.what(), LogLevel::ERRORS, stream.str()));
}
result.status = TestResult::Status::FAILED;
@@ -286,9 +293,9 @@ void Framework::run_test(const TestInfo &info, TestCaseFactory &test_factory)
#endif /* ARM_COMPUTE_CL */
catch(const std::exception &error)
{
- if(_log_level >= LogLevel::ERRORS)
+ if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
{
- std::cerr << "FATAL ERROR: Received unhandled error: '" << error.what() << "'\n";
+ _printer->print_error(error);
}
result.status = TestResult::Status::CRASHED;
@@ -300,9 +307,9 @@ void Framework::run_test(const TestInfo &info, TestCaseFactory &test_factory)
}
catch(...)
{
- if(_log_level >= LogLevel::ERRORS)
+ if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
{
- std::cerr << "FATAL ERROR: Received unhandled exception\n";
+ _printer->print_error(TestError("Received unknown exception"));
}
result.status = TestResult::Status::CRASHED;
@@ -315,9 +322,9 @@ void Framework::run_test(const TestInfo &info, TestCaseFactory &test_factory)
}
catch(const std::exception &error)
{
- if(_log_level >= LogLevel::ERRORS)
+ if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
{
- std::cerr << "FATAL ERROR: Received unhandled error during fixture creation: '" << error.what() << "'\n";
+ _printer->print_error(error);
}
result.status = TestResult::Status::CRASHED;
@@ -329,9 +336,9 @@ void Framework::run_test(const TestInfo &info, TestCaseFactory &test_factory)
}
catch(...)
{
- if(_log_level >= LogLevel::ERRORS)
+ if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
{
- std::cerr << "FATAL ERROR: Received unhandled exception during fixture creation\n";
+ _printer->print_error(TestError("Received unknown exception"));
}
result.status = TestResult::Status::CRASHED;
@@ -342,6 +349,11 @@ void Framework::run_test(const TestInfo &info, TestCaseFactory &test_factory)
}
}
+ if(_log_level >= LogLevel::ERRORS && _printer != nullptr)
+ {
+ _printer->print_errors_footer();
+ }
+
_current_test_result = nullptr;
if(result.status == TestResult::Status::FAILED)