2 * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file test_runner_child.h
18 * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
19 * @author Marcin Niesluchowski (m.niesluchow@samsung.com)
21 * @brief This file is the header file of test runner
23 #ifndef DPL_TEST_RUNNER_CHILD_H
24 #define DPL_TEST_RUNNER_CHILD_H
30 #include <dpl/availability.h>
31 #include <dpl/test/test_case_extended.h>
32 #include <dpl/test/test_runner.h>
37 class PipeWrapper : DPL::Noncopyable
55 void setUsage(Usage usage);
57 virtual ~PipeWrapper();
59 Status send(int code, std::string &message);
60 Status sendPerformance(const ConstPerformanceResultPtr &performance);
62 Status receive(int &code,
64 PerformanceResultPtr &performance,
71 std::string toBinaryString(int data);
73 void closeHelp(int desc);
75 Status writeHelp(const void *buffer, int size);
77 Status readHelp(void *buf, int size, time_t deadline);
79 static const int PIPE_CLOSED = -1;
84 void RunChildProc(const std::function<void(void)> &testFunc);
88 #define RUNNER_CHILD_TEST(Proc, ...) \
89 void Proc(std::tuple<__VA_ARGS__> &optionalArgsTuple); \
90 void Proc##Child(std::tuple<__VA_ARGS__> &optionalArgsTuple); \
91 static int Static##Proc##Init() \
93 DPL::Test::TestRunnerSingleton::Instance().RegisterTest( \
94 new DPL::Test::TestCaseExtended<__VA_ARGS__>(#Proc, &Proc)); \
97 const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \
98 void Proc(std::tuple<__VA_ARGS__> &optionalArgsTuple) { \
99 DPL::Test::RunChildProc(std::bind(Proc##Child, optionalArgsTuple)); \
101 void Proc##Child(std::tuple<__VA_ARGS__> &optionalArgsTuple DPL_UNUSED)
103 #endif // DPL_TEST_RUNNER_CHILD_H