Fix: liblttng-ust-fork Makefile flags mismatch
[lttng-ust.git] / tests / ust-basic-tracing / ust-basic-tracing.c
index cd2d6f058b90f4af8eeeb2e30cbf74585d94aced..18fb08789f637b58ac06b6b04acf84bf9cc2455e 100644 (file)
@@ -40,6 +40,7 @@
 #include <sys/socket.h>
 
 #include <ust-comm.h>
+#include <lttng/ust-error.h>
 #include "../../libringbuffer/backend.h"
 #include "../../libringbuffer/frontend.h"
 #include "../../liblttng-ust/compat.h" /* For ENODATA */
@@ -102,7 +103,7 @@ int open_streams(int sock, int channel_handle, struct lttng_ust_object_data *str
                        }
                        k++;
                }
-               if (ret == -ENOENT)
+               if (ret == -LTTNG_UST_ERR_NOENT)
                        break;
                if (ret)
                        return ret;
@@ -701,6 +702,8 @@ static void set_ulimit(void)
 int main(int argc, const 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;
@@ -764,6 +767,21 @@ int main(int argc, const 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,
@@ -772,11 +790,6 @@ int main(int argc, const 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);
        }
@@ -822,6 +835,7 @@ int main(int argc, const char **argv)
                        pid_t ppid;
                        uid_t uid;
                        gid_t gid;
+                       uint32_t bits_per_long;
                        char name[16];  /* Process name */
                } reg_msg;
                char bufname[17];
@@ -867,5 +881,22 @@ 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 -1;
+               }
+       }
+
+
        return 0;
 }
This page took 0.024924 seconds and 4 git commands to generate.