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>
31 int smack_runtime_check(void);
32 int smack_check(void);
34 #define RUNNER_TEST_SMACK(Proc) \
36 static int Static##Proc##Init() \
39 DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc); \
43 const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \
46 #define RUNNER_TEST_NOSMACK(Proc) \
48 static int Static##Proc##Init() \
50 if(!(smack_check())) \
51 DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc); \
55 const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \
58 #define RUNNER_CHILD_TEST_SMACK(Proc) \
61 static int Static##Proc##Init() \
64 DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc); \
67 const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \
69 DPL::Test::RunChildProc(&Proc##Child); \
73 #define RUNNER_CHILD_TEST_NOSMACK(Proc) \
76 static int Static##Proc##Init() \
78 if(!(smack_check())) \
79 DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc); \
82 const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \
84 DPL::Test::RunChildProc(&Proc##Child); \