* @brief This file is the implementation file of test runner
*/
#include <stddef.h>
+#include <dpl/assert.h>
#include <dpl/test/test_failed.h>
#include <dpl/test/test_ignored.h>
#include <dpl/test/test_runner.h>
return SUCCESS;
}
-void RunChildProc(TestRunner::TestCase procChild)
+void RunChildProc(const std::function<void(void)> &testFunc)
{
PipeWrapper pipe;
if (!pipe.isReady()) {
// End Runner after current test
TestRunnerSingleton::Instance().Terminate();
- int code = CHILD_TEST_PASS;
- std::string msg;
-
bool allowLogs = TestRunnerSingleton::Instance().GetAllowChildLogs();
close(STDIN_FILENO);
pipe.setUsage(PipeWrapper::WRITEONLY);
- try {
- procChild();
- } catch (const DPL::Test::TestFailed &e) {
- msg = e.GetMessage();
- code = CHILD_TEST_FAIL;
- } catch (const DPL::Test::TestIgnored &e) {
- msg = e.GetMessage();
- code = CHILD_TEST_IGNORED;
- } catch (...) { // catch all exception generated by "user" code
- msg = "unhandled exeception";
- code = CHILD_TEST_FAIL;
+ int code;
+ std::string msg;
+ switch (TryCatch(testFunc, msg)) {
+ case TestResult::FailStatus::FAILED:
+ code = CHILD_TEST_FAIL;
+ break;
+ case TestResult::FailStatus::IGNORED:
+ code = CHILD_TEST_IGNORED;
+ break;
+ case TestResult::FailStatus::NONE:
+ code = CHILD_TEST_PASS;
+ break;
+ default:
+ Assert(false && "Unhandled fail status");
}
if (allowLogs) {