public:
TestRunner() :
m_terminate(false)
+ , m_allowChildLogs(false)
{}
typedef void (*TestCase)();
// Some test requires to call fork function.
// Child process must not produce any logs and should die quietly.
bool m_terminate;
+ bool m_allowChildLogs;
+
void Banner();
void InvalidArgs(const std::string& message = "Invalid arguments!");
void Usage();
int ExecTestRunner(const ArgsList& args);
bool getRunIgnored() const;
// The runner will terminate as soon as possible (after current test).
- void terminate();
+ void Terminate();
+ bool GetAllowChildLogs();
};
typedef DPL::Singleton<TestRunner> TestRunnerSingleton;
fprintf(
stderr,
" --listingroup=<group name>\t Show a list of Test IDS in one group\n");
+ fprintf(stderr, " --allowchildlogs\t Allow to print logs from child process on screen.\n");
+ fprintf(stderr, " When active child process will be able to print logs on stdout and stderr.\n");
+ fprintf(stderr, " Both descriptors will be closed after test.\n");
fprintf(stderr, " --help\t This help\n\n");
std::for_each(m_collectors.begin(),
m_collectors.end(),
const std::string startCmd = "--start=";
const std::string listGroupsCmd = "--listgroups";
const std::string listInGroup = "--listingroup=";
+ const std::string allowChildLogs = "--allowchildlogs";
if (currentCollector) {
if (currentCollector->ParseCollectorSpecificArg(arg)) {
printf("ID:%s\n", test->name.c_str());
}
return 0;
+ } else if (arg.find(allowChildLogs) == 0) {
+ arg.erase(0, allowChildLogs.length());
+ m_allowChildLogs = true;
} else if (arg == "--help") {
showHelp = true;
} else if (arg.find(output) == 0) {
return m_runIgnored;
}
-void TestRunner::terminate()
+void TestRunner::Terminate()
{
m_terminate = true;
}
+
+bool TestRunner::GetAllowChildLogs()
+{
+ return m_allowChildLogs;
+}
+
}
} // namespace DPL
if (pipeReturn != PipeWrapper::SUCCESS) { // Timeout or reading error
pipe.closeAll();
- kill(pid, SIGINT);
+ kill(pid, SIGKILL);
}
int status;
// child code
// End Runner after current test
- TestRunnerSingleton::Instance().terminate();
+ TestRunnerSingleton::Instance().Terminate();
+
int code = 1;
std::string msg;
- // close(0); // stdin
- close(1); // stdout
- close(2); // stderr
+ bool allowLogs = TestRunnerSingleton::Instance().GetAllowChildLogs();
+
+ close(0); // stdin
+ if (!allowLogs) {
+ close(1); // stdout
+ close(2); // stderr
+ }
pipe.setUsage(PipeWrapper::WRITEONLY);
msg = "unhandled exeception";
code = 0;
}
+
+ if (allowLogs) {
+ close(1); // stdout
+ close(2); // stderr
+ }
+
pipe.send(code, msg);
}
}