Tests: spawn ht_cleanup thread in unit tests
[lttng-tools.git] / tests / unit / test_session.c
index 4f90c3347ec13c7894030ac8d37dd846093b6497..f2343c9916bd5636a455807616b549cfc1e56811 100644 (file)
@@ -16,7 +16,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#define _GNU_SOURCE
 #include <assert.h>
 #include <errno.h>
 #include <stdio.h>
@@ -30,6 +29,8 @@
 
 #include <bin/lttng-sessiond/session.h>
 #include <bin/lttng-sessiond/ust-app.h>
+#include <bin/lttng-sessiond/ht-cleanup.h>
+#include <bin/lttng-sessiond/health-sessiond.h>
 #include <common/sessiond-comm/sessiond-comm.h>
 #include <common/common.h>
 
@@ -41,7 +42,9 @@
 /* Number of TAP tests in this file */
 #define NUM_TESTS 11
 
+struct health_app *health_sessiond;
 static struct ltt_session_list *session_list;
+static pthread_t ht_cleanup_thread;
 
 /* For error.h */
 int lttng_opt_quiet = 1;
@@ -109,8 +112,7 @@ static void empty_session_list(void)
        struct ltt_session *iter, *tmp;
 
        cds_list_for_each_entry_safe(iter, tmp, &session_list->head, list) {
-               cds_list_del(&iter->list);
-               free(iter);
+               session_destroy(iter);
        }
 
        /* Session list must be 0 */
@@ -295,6 +297,9 @@ int main(int argc, char **argv)
 {
        plan_tests(NUM_TESTS);
 
+       health_sessiond = health_app_create(NR_HEALTH_SESSIOND_TYPES);
+       assert(!init_ht_cleanup_thread(&ht_cleanup_thread));
+
        diag("Sessions unit tests");
 
        test_session_list();
@@ -313,5 +318,7 @@ int main(int argc, char **argv)
 
        test_large_session_number();
 
+       assert(!fini_ht_cleanup_thread(&ht_cleanup_thread));
+
        return exit_status();
 }
This page took 0.025706 seconds and 5 git commands to generate.