Add init and finish functionality
[platform/core/test/security-tests.git] / src / framework / src / test_runner_multiprocess.cpp
index 55e889b..81729c5 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <sys/file.h>
+#include <dpl/assert.h>
 #include <dpl/exception.h>
 #include <dpl/test/test_failed.h>
 #include <dpl/test/test_ignored.h>
@@ -131,11 +132,9 @@ PipeWrapper::Status SimplePipeWrapper::receive(std::string &data, bool &empty, t
     return ERROR;
 }
 
-void RunMultiProc(TestRunner::TestCase procMulti)
+void RunMultiProc(const std::function<void(void)> &testFunc)
 {
     SimplePipeWrapper pipe;
-    int code = MULTI_TEST_PASS;
-    std::string msg = "";
     int pipeReturn;
 
     int waitStatus;
@@ -147,21 +146,20 @@ void RunMultiProc(TestRunner::TestCase procMulti)
     }
     // pipe
 
-    try {
-        procMulti();
-    } catch (const TestFailed &e) {
-        code = MULTI_TEST_FAILED;
-        msg = e.GetMessage();
-    } catch (const TestIgnored &e) {
-        code = MULTI_TEST_IGNORED;
-        msg = e.GetMessage();
-    } catch (const std::exception &) {
-        code = MULTI_TEST_FAILED;
-        msg = "std exception";
-    } catch (...) {
-        // Unknown exception failure
-        code = MULTI_TEST_FAILED;
-        msg = "unknown exception";
+    int code;
+    std::string msg;
+    switch (TryCatch(testFunc, msg)) {
+        case TestResult::FailStatus::FAILED:
+            code = MULTI_TEST_FAILED;
+            break;
+        case TestResult::FailStatus::IGNORED:
+            code = MULTI_TEST_IGNORED;
+            break;
+        case TestResult::FailStatus::NONE:
+            code = MULTI_TEST_PASS;
+            break;
+        default:
+            Assert(false && "Unhandled fail status");
     }
 
     while (true) {