From eb837090b59ca6ff1bb56a399288072e9f53ad50 Mon Sep 17 00:00:00 2001 From: Andrey Kasaurov Date: Fri, 11 Sep 2015 03:04:59 +0300 Subject: [PATCH] Implement Testing Summary output to a file along with -testsummary option --- src/hexl/hexl_base/HexlTestRunner.cpp | 35 ++++++++++++++++--- src/hexl/hexl_base/HexlTestRunner.hpp | 2 ++ src/hexl/hexl_exe/HexlRunner.cpp | 1 + src/hsail_conformance/amdhsa.exclude | 1 - .../exe/HsailConformanceRunner.cpp | 3 +- 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/hexl/hexl_base/HexlTestRunner.cpp b/src/hexl/hexl_base/HexlTestRunner.cpp index cdac89c..29afa98 100644 --- a/src/hexl/hexl_base/HexlTestRunner.cpp +++ b/src/hexl/hexl_base/HexlTestRunner.cpp @@ -20,6 +20,7 @@ #include "HexlResource.hpp" #include #include "Utils.hpp" +#include namespace hexl { @@ -154,24 +155,39 @@ void HTestRunner::BeforeTest(const std::string& path, Test* test) if (cpath != pathPrev) { if (!pathPrev.empty()) { RunnerLog() << " "; + RunnerLog(testSummary) << " "; pathStats.TestSet().PrintShort(RunnerLog()); + pathStats.TestSet().PrintShort(RunnerLog(testSummary)); RunnerLog() << std::endl; + RunnerLog(testSummary) << std::endl; } pathStats.Clear(); RunnerLog() << cpath << " " << std::endl; + RunnerLog(testSummary) << cpath << " " << std::endl; pathPrev = cpath; } } bool HTestRunner::BeforeTestSet(TestSet& testSet) { + time_t time_begin = time(0); + tm* time_begin_UTC = gmtime(&time_begin); std::string testLogName = context->Opts()->GetString("testlog", "test.log"); testLog.open(testLogName.c_str(), std::ofstream::out); if (!testLog.is_open()) { context->Error() << "Failed to open test log " << testLogName << std::endl; return false; } + std::string testSummaryName = context->Opts()->GetString("testsummary", "test_summary.log"); + testSummary.open(testSummaryName.c_str(), std::ofstream::out); + if (!testSummary.is_open()) { + context->Error() << "Failed to open test summary " << testSummaryName << std::endl; + return false; + } + RunnerLog() << "UTC Start Date & Time: " << asctime(time_begin_UTC) << std::endl; + RunnerLog(testSummary) << "UTC Start Date & Time: " << asctime(time_begin_UTC) << std::endl; if (context->Opts()->GetBoolean("dsign")) { + RunnerLog(testSummary) << "Digital Signature: " << "NNNNNNNNNNNNN" << std::endl << std::endl; testLog << "Digital Signature: " << "NNNNNNNNNNNNN" << std::endl << std::endl; } return true; @@ -179,18 +195,29 @@ bool HTestRunner::BeforeTestSet(TestSet& testSet) bool HTestRunner::AfterTestSet(TestSet& testSet) { - if (context->Opts()->GetBoolean("dsign")) { - testLog << "Digital Signature: " << "NNNNNNNNNNNNN" << std::endl; - } - testLog.close(); + time_t time_end = time(0); + tm* time_end_UTC = gmtime(&time_end); // Process first path. RunnerLog() << " "; + RunnerLog(testSummary) << " "; pathStats.TestSet().PrintShort(RunnerLog()); + pathStats.TestSet().PrintShort(RunnerLog(testSummary)); RunnerLog() << std::endl; + RunnerLog(testSummary) << std::endl; // Totals RunnerLog() << std::endl << "Testrun" << std::endl << " "; + RunnerLog(testSummary) << std::endl << "Testrun" << std::endl << " "; Stats().TestSet().PrintShort(RunnerLog()); RunnerLog() << std::endl; + Stats().TestSet().PrintShort(RunnerLog(testSummary)); RunnerLog(testSummary) << std::endl; + RunnerLog() << std::endl << "UTC Finish Date & Time: " << asctime(time_end_UTC) << std::endl; + RunnerLog(testSummary) << std::endl << "UTC Finish Date & Time: " << asctime(time_end_UTC) << std::endl; + if (context->Opts()->GetBoolean("dsign")) { + RunnerLog(testSummary) << "Digital Signature: " << "NNNNNNNNNNNNN" << std::endl; + testLog << "Digital Signature: " << "NNNNNNNNNNNNN" << std::endl; + } + testLog.close(); + testSummary.close(); return true; } diff --git a/src/hexl/hexl_base/HexlTestRunner.hpp b/src/hexl/hexl_base/HexlTestRunner.hpp index 8e97c15..c71a7c9 100644 --- a/src/hexl/hexl_base/HexlTestRunner.hpp +++ b/src/hexl/hexl_base/HexlTestRunner.hpp @@ -75,11 +75,13 @@ class HTestRunner : public TestRunnerBase { std::string pathPrev; std::ostringstream testOut; std::ofstream testLog; + std::ofstream testSummary; AllStats pathStats; unsigned testLogLevel; protected: std::ostream& RunnerLog() { return std::cout; } + std::ofstream& RunnerLog(std::ofstream& of) { return of; } std::ostream* TestOut() { return &testOut; } virtual bool BeforeTestSet(TestSet& testSet); virtual bool AfterTestSet(TestSet& testSet); diff --git a/src/hexl/hexl_exe/HexlRunner.cpp b/src/hexl/hexl_exe/HexlRunner.cpp index 2d9cc15..9ad2759 100644 --- a/src/hexl/hexl_exe/HexlRunner.cpp +++ b/src/hexl/hexl_exe/HexlRunner.cpp @@ -90,6 +90,7 @@ int HexlRunner::ParseOptions() optReg.RegisterBooleanOption("dsign"); optReg.RegisterOption("match"); optReg.RegisterOption("testlog"); + optReg.RegisterOption("testsummary"); optReg.RegisterOption("rtlib"); optReg.RegisterOption("timeout"); int n; diff --git a/src/hsail_conformance/amdhsa.exclude b/src/hsail_conformance/amdhsa.exclude index 7f4bbdf..929699a 100644 --- a/src/hsail_conformance/amdhsa.exclude +++ b/src/hsail_conformance/amdhsa.exclude @@ -1,2 +1 @@ -prm/core/special/misc/debugtrap prm/image/limits/size diff --git a/src/hsail_conformance/exe/HsailConformanceRunner.cpp b/src/hsail_conformance/exe/HsailConformanceRunner.cpp index 8cda6b2..2a9a115 100644 --- a/src/hsail_conformance/exe/HsailConformanceRunner.cpp +++ b/src/hsail_conformance/exe/HsailConformanceRunner.cpp @@ -180,7 +180,7 @@ void HCRunner::Run() " (" << "HSAIL " << BRIG_VERSION_HSAIL_MAJOR << "." << BRIG_VERSION_HSAIL_MINOR << ", BRIG " << BRIG_VERSION_BRIG_MAJOR << "." << BRIG_VERSION_BRIG_MINOR << - ")" << std::endl << std::endl; + ")" << std::endl; OptionRegistry optReg; optReg.RegisterOption("rt"); optReg.RegisterOption("runner"); @@ -190,6 +190,7 @@ void HCRunner::Run() optReg.RegisterOption("tests"); optReg.RegisterOption("testloglevel"); optReg.RegisterOption("testlog"); + optReg.RegisterOption("testsummary"); optReg.RegisterOption("rtlib"); optReg.RegisterOption("exclude"); optReg.RegisterBooleanOption("dummy");