SET(CMAKE_C_FLAGS_RELEASE "-O2")
SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
-#SET(SMACK_ENABLE ON)
+SET(SMACK_ENABLE ON)
OPTION(DPL_LOG "DPL logs status" ON)
IF(DPL_LOG)
WORLD_EXECUTE
)
+ADD_SUBDIRECTORY(common)
ADD_SUBDIRECTORY(libprivilege-control-tests)
ADD_SUBDIRECTORY(libsmack-tests)
ADD_SUBDIRECTORY(security-server-tests)
--- /dev/null
+INCLUDE(FindPkgConfig)
+SET(COMMON_TARGET_TEST "tests-common")
+
+#dependencies
+PKG_CHECK_MODULES(COMMON_TARGET_DEP
+ libsmack
+ dpl-test-efl
+ REQUIRED
+ )
+
+#files to compile
+SET(COMMON_TARGET_TEST_SOURCES
+ ${PROJECT_SOURCE_DIR}/tests/common/tests_common.cpp
+ )
+
+#header directories
+INCLUDE_DIRECTORIES(
+ ${COMMON_TARGET_DEP_INCLUDE_DIRS}
+ )
+
+#output OBJECT format
+ADD_LIBRARY(${COMMON_TARGET_TEST} ${COMMON_TARGET_TEST_SOURCES})
--- /dev/null
+/*
+ * Copyright (c) 2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file tests_common.cpp
+ * @author Lukasz Kostyra (l.kostyra@partner.samsung.com)
+ * @version 1.0
+ * @brief Common functions and macros used in security-tests package.
+ */
+
+#include "tests_common.h"
+
+int smack_runtime_check(void)
+{
+ static int smack_present = -1;
+ if (-1 == smack_present) {
+ if (smack_smackfs_path()) {
+ smack_present = 1;
+ } else {
+ smack_present = 0;
+ }
+ }
+ return smack_present;
+}
+
+int smack_check(void)
+{
+#ifndef WRT_SMACK_ENABLED
+ return 0;
+#else
+ return smack_runtime_check();
+#endif
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file tests_common.h
+ * @author Lukasz Kostyra (l.kostyra@partner.samsung.com)
+ * @version 1.0
+ * @brief Common functions and macros used in security-tests package.
+ */
+
+#ifndef _TESTS_COMMON_H_
+#define _TESTS_COMMON_H_
+
+#include <sys/smack.h>
+#include <dpl/test/test_runner.h>
+#include <dpl/test/test_runner_child.h>
+
+int smack_runtime_check(void);
+int smack_check(void);
+
+#define RUNNER_TEST_SMACK(Proc) \
+ void Proc(); \
+ static int Static##Proc##Init() \
+ { \
+ if(smack_check()) \
+ DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc); \
+ \
+ return 0; \
+ } \
+ const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \
+ void Proc()
+
+#define RUNNER_TEST_NOSMACK(Proc) \
+ void Proc(); \
+ static int Static##Proc##Init() \
+ { \
+ if(!(smack_check())) \
+ DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc); \
+ \
+ return 0; \
+ } \
+ const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \
+ void Proc()
+
+#define RUNNER_CHILD_TEST_SMACK(Proc) \
+ void Proc(); \
+ void Proc##Child(); \
+ static int Static##Proc##Init() \
+ { \
+ if(smack_check()) \
+ DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc); \
+ return 0; \
+ } \
+ const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \
+ void Proc(){ \
+ DPL::Test::RunChildProc(&Proc##Child); \
+ } \
+ void Proc##Child()
+
+#define RUNNER_CHILD_TEST_NOSMACK(Proc) \
+ void Proc(); \
+ void Proc##Child(); \
+ static int Static##Proc##Init() \
+ { \
+ if(!(smack_check())) \
+ DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc); \
+ return 0; \
+ } \
+ const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \
+ void Proc(){ \
+ DPL::Test::RunChildProc(&Proc##Child); \
+ } \
+ void Proc##Child()
+
+#endif
#header directories
INCLUDE_DIRECTORIES(
${LPC_TARGET_DEP_INCLUDE_DIRS}
+ ${PROJECT_SOURCE_DIR}/tests/common/
)
#preprocessor definitions
#linker directories
TARGET_LINK_LIBRARIES(${LPC_TARGET_TEST}
${LPC_TARGET_DEP_LIBRARIES}
+ tests-common
)
#place for output file
INSTALL(FILES
${PROJECT_SOURCE_DIR}/tests/libprivilege-control-tests/EFL_test_privilege_control_rules_efl.smack
DESTINATION /usr/share/privilege-control/
- )
\ No newline at end of file
+ )
#include <fstream>
#include <sstream>
#include <sys/stat.h>
+#include <tests_common.h>
#define SMACK_RULES_DIR "/opt/etc/smack-app/accesses.d/"
#define SMACK_STARTUP_RULES_FILE "/opt/etc/smack-app-early/accesses.d/rules"
RUNNER_ASSERT_MSG(pass_1 == 1, "Rule " << EARLY_RULE_SUBJECT << " " << APP_ID << " " << EARLY_RULE_RIGHTS << " found");
RUNNER_ASSERT_MSG(pass_2 == 1, "Rule " << EARLY_RULE_SUBJECT << " " << APP_TEST_APP_1 << " " << EARLY_RULE_RIGHTS << " found");
}
+
+RUNNER_TEST_SMACK(privilege_control24a_test_whether_macro_works_smack)
+{
+ RUNNER_IGNORED_MSG("STUB: I should be called on SMACK environment only.");
+}
+
+RUNNER_TEST_NOSMACK(privilege_control24b_test_whether_macro_works_nosmack)
+{
+ RUNNER_IGNORED_MSG("STUB: I should be called on NOSMACK environment only.");
+}
+
+RUNNER_CHILD_TEST_SMACK(privilege_control24c_test_whether_macro_works_child_smack)
+{
+ //Until a fix for RUNNER_IGNORED_MSG comes up to wrt-commons, this must be commented out.
+ //RUNNER_IGNORED_MSG("STUB: I should be called on SMACK environment only.");
+}
+
+RUNNER_CHILD_TEST_NOSMACK(privilege_control24d_test_whether_macro_works_child_nosmack)
+{
+ //Until a fix for RUNNER_IGNORED_MSG comes up to wrt-commons, this must be commented out.
+ //RUNNER_IGNORED_MSG("STUB: I should be called on NOSMACK environment only.");
+}