security-manager-tests: use full proper path for applications
[platform/core/test/security-tests.git] / tests / common / tests_common.cpp
index 8e60c2b..a8afc7b 100644 (file)
@@ -187,10 +187,20 @@ int files_compare(int fd1, int fd2)
 
 void mkdirSafe(const std::string &path, mode_t mode)
 {
-    RUNNER_ASSERT_ERRNO_MSG(0 == mkdir(path.c_str(), mode),
+    RUNNER_ASSERT_ERRNO_MSG(0 == mkdir(path.c_str(), mode) || errno == EEXIST,
                             "mkdir for <" << path << "> with mode <" << mode << "> failed");
 }
 
+void mktreeSafe(const std::string &path, mode_t mode)
+{
+    // Create subsequent parent directories
+    // Assume that path is absolute - i.e. starts with '/'
+    for (size_t pos = 0; (pos = path.find("/", pos + 1)) != std::string::npos; )
+        mkdirSafe(path.substr(0, pos).c_str(), mode);
+
+    mkdirSafe(path, mode);
+}
+
 void creatSafe(const std::string &path, mode_t mode)
 {
     RUNNER_ASSERT_ERRNO_MSG(-1 != creat(path.c_str(), mode),