security-manager-tests: use full proper path for applications
[platform/core/test/security-tests.git] / tests / common / tests_common.h
index 98e6a5b..52c0500 100644 (file)
 #include <privilege-control.h>
 #include <sys/smack.h>
 #include <string>
-
-#include "gdbbacktrace.h"
+#include <errno.h>
+#include <string.h>
 
 const uid_t APP_UID = 5000;
 const gid_t APP_GID = 5000;
 const uid_t DB_ALARM_UID = 6001;
 const gid_t DB_ALARM_GID = 6001;
+const std::string TMP_DIR("/tmp");
 
 int smack_runtime_check(void);
 int smack_check(void);
-int drop_root_privileges(void);
+int drop_root_privileges(uid_t appUid = APP_UID, gid_t appGid = APP_GID);
 void setLabelForSelf(const int line, const char *label);
 void add_process_group(const char* group_name);
 void remove_process_group(const char* group_name);
 std::string formatCstr(const char *cstr);
+int files_compare(int fd1, int fd2);
+void mkdirSafe(const std::string &path, mode_t mode);
+void mktreeSafe(const std::string &path, mode_t mode);
+void creatSafe(const std::string &path, mode_t mode);
+void symlinkSafe(const std::string &targetPath, const std::string &linkPath);
+void removeDir(const std::string &path);
 
 #define RUNNER_TEST_SMACK(Proc)                                                     \
     void Proc();                                                                    \
@@ -131,10 +138,6 @@ std::string formatCstr(const char *cstr);
     }                                                                                \
     void Proc##Multi()
 
-#define RUNNER_ASSERT_MSG_BT(test, msg) RUNNER_ASSERT_MSG(test,\
-                                                          msg << gdbbacktrace())
-#define RUNNER_ASSERT_BT(test) RUNNER_ASSERT_MSG_BT(test, "")
-
 namespace DB {
 
     class Transaction
@@ -145,7 +148,7 @@ namespace DB {
 
         Transaction() {
             db_result = perm_begin();
-            RUNNER_ASSERT_MSG_BT(PC_OPERATION_SUCCESS == db_result,
+            RUNNER_ASSERT_MSG(PC_OPERATION_SUCCESS == db_result,
                               "perm_begin returned: " << db_result);
         }
 
@@ -165,7 +168,7 @@ namespace DB {
         DB::Transaction db_transaction;
 
 #define DB_END }                                                                   \
-        RUNNER_ASSERT_MSG_BT(PC_OPERATION_SUCCESS == DB::Transaction::db_result,      \
+        RUNNER_ASSERT_MSG(PC_OPERATION_SUCCESS == DB::Transaction::db_result,      \
         "perm_end returned: " << DB::Transaction::db_result);
 
 // Common macros and labels used in tests