From: Zofia Abramowska Date: Thu, 19 Oct 2017 15:39:54 +0000 (+0200) Subject: Merge branch 'tizen' into security-manager X-Git-Tag: security-manager_5.5_testing~11^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5aafad94d2f96c3ca9d13435be07621982adf512;hp=b0b52bc6aadee215649803da3a7541596ae3fe51;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git Merge branch 'tizen' into security-manager Change-Id: I3fa314322c8005c432cbdcfca15043d3679622b9 --- diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 0bfeb9b..caccd72 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -7,6 +7,7 @@ PKG_CHECK_MODULES(COMMON_TARGET_DEP dbus-1 sqlite3 libgum + libtzplatform-config glib-2.0 cynara-creds-socket cynara-creds-dbus diff --git a/src/common/tests_common.cpp b/src/common/tests_common.cpp index d08893c..b5dff60 100644 --- a/src/common/tests_common.cpp +++ b/src/common/tests_common.cpp @@ -246,3 +246,26 @@ void change_label(const char* label) int ret = smack_set_label_for_self(label); RUNNER_ASSERT_MSG(0 == ret, "Error in smack_set_label_for_self("< &process) { + pid_t pid = fork(); + RUNNER_ASSERT_ERRNO_MSG(pid >= 0, "fork failed"); + + if (pid == 0) { + process(); + exit(EXIT_SUCCESS); + } + return pid; +} + +void runInChildParentWait(const std::function &process) { + pid_t pid = fork(); + RUNNER_ASSERT_ERRNO_MSG(pid >= 0, "fork failed"); + if (pid == 0) { + process(); + exit(EXIT_SUCCESS); + } else { + waitPid(pid); + } +} + diff --git a/src/common/tests_common.h b/src/common/tests_common.h index 251e111..3f109b9 100644 --- a/src/common/tests_common.h +++ b/src/common/tests_common.h @@ -29,7 +29,8 @@ #include #include #include -#include + +#include #include #include #include @@ -59,6 +60,9 @@ void removeDir(const std::string &path); void waitPid(pid_t pid); void change_label(const char* label); +pid_t runInChild(const std::function &process); +void runInChildParentWait(const std::function &process); + #define RUNNER_TEST_SMACK(Proc, ...) \ void Proc(std::tuple<__VA_ARGS__> &optionalArgsTuple); \ static int Static##Proc##Init() \ diff --git a/src/cynara-tests/test_cases_helpers.cpp b/src/cynara-tests/test_cases_helpers.cpp index 06aa14d..33481a6 100644 --- a/src/cynara-tests/test_cases_helpers.cpp +++ b/src/cynara-tests/test_cases_helpers.cpp @@ -66,18 +66,6 @@ private: std::string m_label = "cynara_helpers"; }; -pid_t runInChild(const std::function &process) { - pid_t pid = fork(); - RUNNER_ASSERT_ERRNO_MSG(pid >= 0, "fork failed"); - - if (pid == 0) { - process(); - exit(EXIT_SUCCESS); - } - - return pid; -} - cynara_client_creds getClientDefaultMethod() { cynara_client_creds def; int ret = cynara_creds_get_default_client_method(&def); diff --git a/src/framework/include/dpl/test/test_runner.h b/src/framework/include/dpl/test/test_runner.h index efa057d..93809ae 100644 --- a/src/framework/include/dpl/test/test_runner.h +++ b/src/framework/include/dpl/test/test_runner.h @@ -25,6 +25,7 @@ #ifndef DPL_TEST_RUNNER_H #define DPL_TEST_RUNNER_H +#include #include #include #include diff --git a/src/security-manager-tests/common/sm_commons.cpp b/src/security-manager-tests/common/sm_commons.cpp index d6b0ee8..acaf64d 100644 --- a/src/security-manager-tests/common/sm_commons.cpp +++ b/src/security-manager-tests/common/sm_commons.cpp @@ -330,28 +330,6 @@ CapsSetsUniquePtr setCaps(const char *cap_string) return caps; } -pid_t runInChild(const std::function &process) { - pid_t pid = fork(); - RUNNER_ASSERT_ERRNO_MSG(pid >= 0, "fork failed"); - - if (pid == 0) { - process(); - exit(EXIT_SUCCESS); - } - return pid; -} - -void runInChildParentWait(const std::function &process) { - pid_t pid = fork(); - RUNNER_ASSERT_ERRNO_MSG(pid >= 0, "fork failed"); - if (pid == 0) { - process(); - exit(EXIT_SUCCESS); - } else { - waitPid(pid); - } -} - static int getOppositeAccessType(int accessType) { return accessType ^ (R_OK | W_OK | X_OK); } diff --git a/src/security-manager-tests/common/sm_commons.h b/src/security-manager-tests/common/sm_commons.h index 02e9a13..902d70c 100644 --- a/src/security-manager-tests/common/sm_commons.h +++ b/src/security-manager-tests/common/sm_commons.h @@ -63,9 +63,6 @@ void check_exact_smack_accesses(const std::string &subject, CapsSetsUniquePtr setCaps(const char *cap_string); -pid_t runInChild(const std::function &process); - -void runInChildParentWait(const std::function &process); void runAccessTest(const std::string &label, uid_t uid, gid_t gid, const std::string &testPath, int accessType); void runAccessTest(const AppInstallHelper &app, const std::string &testPath, int accessType);