int ret = smack_set_label_for_self(label);
RUNNER_ASSERT_MSG(0 == ret, "Error in smack_set_label_for_self("<<label<<"). Error: " << ret);
}
+
+pid_t runInChild(const std::function<void(void)> &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<void(void)> &process) {
+ pid_t pid = fork();
+ RUNNER_ASSERT_ERRNO_MSG(pid >= 0, "fork failed");
+ if (pid == 0) {
+ process();
+ exit(EXIT_SUCCESS);
+ } else {
+ waitPid(pid);
+ }
+}
+
#include <dpl/test/test_runner.h>
#include <dpl/test/test_runner_child.h>
#include <dpl/test/test_runner_multiprocess.h>
-#include <sys/smack.h>
+
+#include <algorithm>
#include <sys/types.h>
#include <string>
#include <tuple>
void waitPid(pid_t pid);
void change_label(const char* label);
+pid_t runInChild(const std::function<void(void)> &process);
+void runInChildParentWait(const std::function<void(void)> &process);
+
#define RUNNER_TEST_SMACK(Proc, ...) \
void Proc(std::tuple<__VA_ARGS__> &optionalArgsTuple); \
static int Static##Proc##Init() \
std::string m_label = "cynara_helpers";
};
-pid_t runInChild(const std::function<void(void)> &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);
return caps;
}
-pid_t runInChild(const std::function<void(void)> &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<void(void)> &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);
}
CapsSetsUniquePtr setCaps(const char *cap_string);
-pid_t runInChild(const std::function<void(void)> &process);
-
-void runInChildParentWait(const std::function<void(void)> &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);