Add init and finish functionality
[platform/core/test/security-tests.git] / src / framework / include / dpl / test / test_runner_multiprocess.h
index 279b5ef..ac6939e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
 #ifndef DPL_TEST_RUNNER_MULTIPROCESS_H
 #define DPL_TEST_RUNNER_MULTIPROCESS_H
 
+#include <ctime>
+#include <functional>
+#include <memory>
+#include <string>
+#include <tuple>
+
+#include <dpl/availability.h>
 #include <dpl/test/test_runner_child.h>
 
 namespace DPL {
@@ -39,22 +46,23 @@ class SimplePipeWrapper :
     Status receive(std::string &data, bool &empty, time_t deadline);
 };
 
-void RunMultiProc(TestRunner::TestCase procMulti);
+void RunMultiProc(const std::function<void(void)>& testFunc);
 } // namespace Test
 } // namespace DPL
 
-#define RUNNER_MULTIPROCESS_TEST(Proc)                                               \
-    void Proc();                                                                     \
-    void Proc##Multi();                                                              \
-    static int Static##Proc##Init()                                                  \
-    {                                                                                \
-        DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc);       \
-        return 0;                                                                    \
-    }                                                                                \
-    const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init();               \
-    void Proc(){                                                                     \
-        DPL::Test::RunMultiProc(&Proc##Multi);                                       \
-    }                                                                                \
-    void Proc##Multi()
+#define RUNNER_MULTIPROCESS_TEST(Proc, ...)                                             \
+    void Proc(std::tuple<__VA_ARGS__> &optionalArgsTuple);                              \
+    void Proc##Multi(std::tuple<__VA_ARGS__> &optionalArgsTuple);                       \
+    static int Static##Proc##Init()                                                     \
+    {                                                                                   \
+        DPL::Test::TestRunnerSingleton::Instance().RegisterTest(                        \
+            new DPL::Test::TestCaseExtended<__VA_ARGS__>(#Proc, &Proc));                \
+        return 0;                                                                       \
+    }                                                                                   \
+    const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init();                  \
+    void Proc(std::tuple<__VA_ARGS__> &optionalArgsTuple) {                             \
+        DPL::Test::RunMultiProc(std::bind(Proc##Multi, optionalArgsTuple));             \
+    }                                                                                   \
+    void Proc##Multi(std::tuple<__VA_ARGS__> &optionalArgsTuple DPL_UNUSED)
 
 #endif // DPL_TEST_RUNNER_MULTIPROCESS_H