Tests: Add filtering tests for uncovered cases
[lttng-tools.git] / tests / tools / test_sessions.c
index ce716e8c1a70c85dddda2f3a749be7b65f4b0d82..efe19ecdc08cd516aff7426277e21bef11eb7c88 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <bin/lttng-sessiond/session.h>
 #include <common/sessiond-comm/sessiond-comm.h>
+#include <common/common.h>
 
 #include "utils.h"
 
@@ -97,6 +98,17 @@ static int find_session_name(char *name)
        return -1;
 }
 
+static int session_list_count(void)
+{
+       int count = 0;
+       struct ltt_session *iter;
+
+       cds_list_for_each_entry(iter, &session_list->head, list) {
+               count++;
+       }
+       return count;
+}
+
 /*
  * Empty session list manually.
  */
@@ -106,12 +118,11 @@ static void empty_session_list(void)
 
        cds_list_for_each_entry_safe(iter, tmp, &session_list->head, list) {
                cds_list_del(&iter->list);
-               session_list->count--;
                free(iter);
        }
 
        /* Session list must be 0 */
-       assert(!session_list->count);
+       assert(!session_list_count());
 }
 
 /*
@@ -122,7 +133,7 @@ static int create_one_session(char *name, char *path)
        int ret;
 
        ret = session_create(name, path, geteuid(), getegid());
-       if (ret == LTTCOMM_OK) {
+       if (ret == LTTNG_OK) {
                /* Validate */
                ret = find_session_name(name);
                if (ret < 0) {
@@ -134,7 +145,7 @@ static int create_one_session(char *name, char *path)
                        return 0;
                }
        } else {
-               if (ret == LTTCOMM_EXIST_SESS) {
+               if (ret == LTTNG_ERR_EXIST_SESS) {
                        printf("(session already exists) ");
                }
                return -1;
@@ -152,7 +163,7 @@ static int destroy_one_session(struct ltt_session *session)
 
        ret = session_destroy(session);
 
-       if (ret == LTTCOMM_OK) {
+       if (ret == LTTNG_OK) {
                /* Validate */
                if (session == NULL) {
                        return 0;
@@ -186,14 +197,8 @@ static int fuzzing_create_args(void)
                return -1;
        }
 
-       ret = create_one_session(SESSION1, NULL);
-       if (ret > 0) {
-               printf("Session created with %s, (null)\n", SESSION1);
-               return -1;
-       }
-
        /* Session list must be 0 */
-       assert(!session_list->count);
+       assert(!session_list_count());
 
        return 0;
 }
@@ -209,7 +214,7 @@ static int fuzzing_destroy_args(void)
        }
 
        /* Session list must be 0 */
-       assert(!session_list->count);
+       assert(!session_list_count());
 
        return 0;
 }
@@ -342,7 +347,7 @@ int main(int argc, char **argv)
        PRINT_OK();
 
        /* Session list must be 0 */
-       assert(!session_list->count);
+       assert(!session_list_count());
 
        /* Success */
        return 0;
This page took 0.024295 seconds and 4 git commands to generate.