From 213450db7cd88ecb718e1c31c7fedb96673dc727 Mon Sep 17 00:00:00 2001 From: Botond Baranyi <botond.baranyi@ericsson.com> Date: Fri, 28 Apr 2017 10:51:50 +0200 Subject: [PATCH] Fixed error logging in JUnitLogger (bug 515104) Change-Id: Ia83af2a298b9c9ef161935fba447b42a2a9c12f8 Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com> --- loggerplugins/JUnitLogger/JUnitLogger.cc | 12 +++++++----- loggerplugins/JUnitLogger/JUnitLogger.hh | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/loggerplugins/JUnitLogger/JUnitLogger.cc b/loggerplugins/JUnitLogger/JUnitLogger.cc index 812d340e4..dc41804b7 100644 --- a/loggerplugins/JUnitLogger/JUnitLogger.cc +++ b/loggerplugins/JUnitLogger/JUnitLogger.cc @@ -46,6 +46,7 @@ JUnitLogger::JUnitLogger() minor_version_ = 0; name_ = mcopystr("JUnitLogger"); help_ = mcopystr("JUnitLogger writes JUnit-compatible XML"); + error_message = ""; //printf("%5lu:constructed\n", (unsigned long)getpid()); } @@ -251,11 +252,13 @@ void JUnitLogger::log(const TitanLoggerApi::TitanLogEvent& event, case TitanLoggerApi::Verdict::v4error: fprintf(file_stream_, " <error type='DTE'>%s</error>\n", - (const char*)escape_xml_element(tct.reason())); + (const char*)error_message); break; } // error or skip based on verdict fputs(" </testcase>\n", file_stream_); + // erase the stored error message + error_message = ""; break; } case TitanLoggerApi::TestcaseEvent_choice::UNBOUND_VALUE: @@ -266,10 +269,9 @@ void JUnitLogger::log(const TitanLoggerApi::TitanLogEvent& event, break; } // testcaseOp case TitanLoggerApi::LogEventType_choice::ALT_errorLog: { - // A DTE is about to be thrown - const TitanLoggerApi::Categorized& cat = choice.errorLog(); - fprintf(file_stream_, " <error type='DTE'>%s</error>\n", - (const char*)escape_xml_element(cat.text())); + // A DTE is about to be thrown, + // store the error message until the testcase finished event + error_message += escape_xml_element(choice.errorLog().text()); break; } default: diff --git a/loggerplugins/JUnitLogger/JUnitLogger.hh b/loggerplugins/JUnitLogger/JUnitLogger.hh index 9894512d2..47cd5788f 100644 --- a/loggerplugins/JUnitLogger/JUnitLogger.hh +++ b/loggerplugins/JUnitLogger/JUnitLogger.hh @@ -50,6 +50,7 @@ private: // working values char *filename_; FILE *file_stream_; + CHARSTRING error_message; }; #endif // JUnitLogger_HH -- GitLab