2 * Copyright (c) 2013 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.
18 * @file tests_common.h
19 * @author Lukasz Kostyra (l.kostyra@partner.samsung.com)
21 * @brief Common functions and macros used in security-tests package.
24 #ifndef _TESTS_COMMON_H_
25 #define _TESTS_COMMON_H_
27 #include <sys/smack.h>
28 #include <dpl/test/test_runner.h>
29 #include <dpl/test/test_runner_child.h>
30 #include <dpl/test/test_runner_multiprocess.h>
32 int smack_runtime_check(void);
33 int smack_check(void);
35 #define RUNNER_TEST_SMACK(Proc) \
37 static int Static##Proc##Init() \
40 DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc); \
44 const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \
47 #define RUNNER_TEST_NOSMACK(Proc) \
49 static int Static##Proc##Init() \
51 if(!(smack_check())) \
52 DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc); \
56 const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \
59 #define RUNNER_CHILD_TEST_SMACK(Proc) \
62 static int Static##Proc##Init() \
65 DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc); \
68 const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \
70 DPL::Test::RunChildProc(&Proc##Child); \
74 #define RUNNER_CHILD_TEST_NOSMACK(Proc) \
77 static int Static##Proc##Init() \
79 if(!(smack_check())) \
80 DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc); \
83 const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \
85 DPL::Test::RunChildProc(&Proc##Child); \
89 #define RUNNER_MULTIPROCESS_TEST_SMACK(Proc) \
92 static int Static##Proc##Init() \
95 DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc); \
98 const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \
100 DPL::Test::RunMultiProc(&Proc##Multi); \
104 #define RUNNER_MULTIPROCESS_TEST_NOSMACK(Proc) \
106 void Proc##Multi(); \
107 static int Static##Proc##Init() \
109 if(!(smack_check())) \
110 DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc); \
113 const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \
115 DPL::Test::RunMultiProc(&Proc##Multi); \