From: Christian Babeux Date: Wed, 19 Dec 2012 19:22:27 +0000 (-0500) Subject: Tests: Fix rundir not created in ust-multi-test X-Git-Tag: v2.1.0~7 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=48137251d51074da54a37d0377a3d8b0b9773b85;p=lttng-ust.git Tests: Fix rundir not created in ust-multi-test Signed-off-by: Christian Babeux Signed-off-by: Mathieu Desnoyers --- diff --git a/tests/ust-multi-test/ust-multi-test.c b/tests/ust-multi-test/ust-multi-test.c index 3f00f7ed..015211c9 100644 --- a/tests/ust-multi-test/ust-multi-test.c +++ b/tests/ust-multi-test/ust-multi-test.c @@ -693,6 +693,8 @@ static void set_ulimit(void) int main(int argc, char **argv) { const char *home_dir; + char home_rundir[PATH_MAX]; + char *cmd = NULL; int ret, wait_shm_fd; struct sigaction act; mode_t old_umask = 0; @@ -743,6 +745,21 @@ int main(int argc, char **argv) strcpy(apps_sock_path, DEFAULT_GLOBAL_APPS_UNIX_SOCK); old_umask = umask(0); } else { + home_dir = (const char *) getenv("HOME"); + if (!home_dir) { + perror("getenv error"); + return -ENOENT; + } + + snprintf(home_rundir, PATH_MAX, + LTTNG_HOME_RUNDIR, home_dir); + + ret = mkdir(home_rundir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + if (ret && errno != EEXIST) { + perror("mkdir"); + return -1; + } + snprintf(local_apps_wait_shm_path, PATH_MAX, DEFAULT_HOME_APPS_WAIT_SHM_PATH, getuid()); wait_shm_fd = get_wait_shm(local_apps_wait_shm_path, @@ -751,11 +768,6 @@ int main(int argc, char **argv) perror("local wait shm error"); return -1; } - home_dir = (const char *) getenv("HOME"); - if (!home_dir) { - perror("getenv error"); - return -ENOENT; - } snprintf(apps_sock_path, PATH_MAX, DEFAULT_HOME_APPS_UNIX_SOCK, home_dir); } @@ -846,5 +858,20 @@ end: return -1; } + if (geteuid()) { + printf("Removing %s directory\n", home_rundir); + ret = asprintf(&cmd, "rm -rf %s", home_rundir); + if (ret < 0) { + printf("asprintf failed. Something is really wrong!\n"); + return -1; + } + + /* Remove lttng run directory */ + ret = system(cmd); + if (ret < 0) { + printf("Unable to clean %s\n", home_rundir); + } + } + return 0; }