Merging tizen into ckm. Stage 1.
[platform/core/test/security-tests.git] / tests / common / tests_common.h
index 57880c6..dab6d75 100644 (file)
 #include <dpl/test/test_runner_multiprocess.h>
 #include <privilege-control.h>
 #include <sys/smack.h>
-
-#include "gdbbacktrace.h"
-
-const uid_t APP_UID = 5000;
-const gid_t APP_GID = 5000;
+#include <string>
+#include <errno.h>
+#include <string.h>
+
+// separate DB-space for async tests
+// gives independence: other test sets can modify the password per will
+// without risk of making async tests fail
+const uid_t APP_UID = 5003;
+const gid_t APP_GID = 5003;
 const uid_t DB_ALARM_UID = 6001;
 const gid_t DB_ALARM_GID = 6001;
-
-typedef std::unique_ptr<smack_accesses, std::function<void(smack_accesses*)> > AccessesUniquePtr;
-typedef std::unique_ptr<int, std::function<void(int*)> > FDUniquePtr;
+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);
 
 #define RUNNER_TEST_SMACK(Proc)                                                     \
     void Proc();                                                                    \
@@ -129,13 +136,6 @@ int drop_root_privileges(void);
     }                                                                                \
     void Proc##Multi()
 
-#define RUNNER_ASSERT_MSG_BT(test, msg) RUNNER_ASSERT_MSG(test,\
-                                                          msg + std::string("\n") + gdbbacktrace())
-#define RUNNER_ASSERT_BT(test) RUNNER_ASSERT_MSG_BT(test, "")
-
-void closeFdPtr(int *fd);
-void setLabelForSelf(const int line, const char *label);
-
 namespace DB {
 
     class Transaction