Move hash table to common/ directory
[lttng-tools.git] / tests / test_sessions.c
index 8ea365fed684f5d2ee09d08d79ab3400390ee8a2..5b17e63911eeb8c45fdd05723978d79eae209313 100644 (file)
 #include <string.h>
 #include <unistd.h>
 #include <time.h>
+#include <sys/types.h>
 
 #include <lttng-sessiond-comm.h>
-#include "ltt-sessiond/session.h"
+
+#include <lttng-sessiond/session.h>
 #include "utils.h"
 
 #define SESSION1 "test1"
@@ -117,7 +119,7 @@ static int create_one_session(char *name, char *path)
 {
        int ret;
 
-       ret = session_create(name, path);
+       ret = session_create(name, path, geteuid(), getegid());
        if (ret == LTTCOMM_OK) {
                /* Validate */
                ret = find_session_name(name);
@@ -142,15 +144,18 @@ static int create_one_session(char *name, char *path)
 /*
  * Test deletion of 1 session
  */
-static int destroy_one_session(char *name)
+static int destroy_one_session(struct ltt_session *session)
 {
        int ret;
 
-       ret = session_destroy(name);
+       ret = session_destroy(session);
 
        if (ret == LTTCOMM_OK) {
                /* Validate */
-               ret = find_session_name(name);
+               if (session == NULL) {
+                       return 0;
+               }
+               ret = find_session_name(session->name);
                if (ret < 0) {
                        /* Success, -1 means that the sesion is NOT found */
                        return 0;
@@ -201,12 +206,6 @@ static int fuzzing_destroy_args(void)
                return -1;
        }
 
-       ret = destroy_one_session(OVERFLOW_SESSION_NAME);
-       if (ret > 0) {
-               printf("Session destroyed with %s\n", OVERFLOW_SESSION_NAME);
-               return -1;
-       }
-
        /* Session list must be 0 */
        assert(!session_list->count);
 
@@ -253,6 +252,7 @@ int main(int argc, char **argv)
        }
 
        printf("Create 1 session %s: ", SESSION1);
+       fflush(stdout);
        ret = create_one_session(SESSION1, PATH1);
        if (ret < 0) {
                return -1;
@@ -260,13 +260,13 @@ int main(int argc, char **argv)
        PRINT_OK();
 
        printf("Validating created session %s: ", SESSION1);
+       fflush(stdout);
        tmp = session_find_by_name(SESSION1);
        if (tmp == NULL) {
                return -1;
        }
        /* Basic init session values */
        assert(tmp->kernel_session == NULL);
-       assert(tmp->ust_session_list.count == 0);
        assert(strlen(tmp->path));
        assert(strlen(tmp->name));
        session_lock(tmp);
@@ -275,13 +275,15 @@ int main(int argc, char **argv)
        PRINT_OK();
 
        printf("Destroy 1 session %s: ", SESSION1);
-       ret = destroy_one_session(SESSION1);
+       fflush(stdout);
+       ret = destroy_one_session(tmp);
        if (ret < 0) {
                return -1;
        }
        PRINT_OK();
 
        printf("Two session with same name: ");
+       fflush(stdout);
        ret = two_session_same_name();
        if (ret < 0) {
                return -1;
@@ -291,6 +293,7 @@ int main(int argc, char **argv)
        empty_session_list();
 
        printf("Fuzzing create_session arguments: ");
+       fflush(stdout);
        ret = fuzzing_create_args();
        if (ret < 0) {
                return -1;
@@ -298,6 +301,7 @@ int main(int argc, char **argv)
        PRINT_OK();
 
        printf("Fuzzing destroy_session argument: ");
+       fflush(stdout);
        ret = fuzzing_destroy_args();
        if (ret < 0) {
                return -1;
@@ -305,6 +309,7 @@ int main(int argc, char **argv)
        PRINT_OK();
 
        printf("Creating %d sessions: ", MAX_SESSIONS);
+       fflush(stdout);
        for (i = 0; i < MAX_SESSIONS; i++) {
                tmp_name = get_random_string();
                ret = create_one_session(tmp_name, PATH1);
@@ -317,9 +322,10 @@ int main(int argc, char **argv)
        PRINT_OK();
 
        printf("Destroying %d sessions: ", MAX_SESSIONS);
+       fflush(stdout);
        for (i = 0; i < MAX_SESSIONS; i++) {
                cds_list_for_each_entry_safe(iter, tmp, &session_list->head, list) {
-                       ret = destroy_one_session(iter->name);
+                       ret = destroy_one_session(iter);
                        if (ret < 0) {
                                printf("session %d (name: %s) creation failed\n", i, iter->name);
                                return -1;
This page took 0.024962 seconds and 4 git commands to generate.