Skip to content

Commit

Permalink
Implement Testing Summary output to a file along with -testsummary op…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
kasaurov committed Sep 11, 2015
1 parent de3d5b4 commit eb83709
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
35 changes: 31 additions & 4 deletions src/hexl/hexl_base/HexlTestRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "HexlResource.hpp"
#include <sstream>
#include "Utils.hpp"
#include <time.h>

namespace hexl {

Expand Down Expand Up @@ -154,43 +155,69 @@ 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;
}

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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/hexl/hexl_base/HexlTestRunner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/hexl/hexl_exe/HexlRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/hsail_conformance/amdhsa.exclude
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
prm/core/special/misc/debugtrap
prm/image/limits/size
3 changes: 2 additions & 1 deletion src/hsail_conformance/exe/HsailConformanceRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down

0 comments on commit eb83709

Please sign in to comment.