Force usage of assert() condition when NDEBUG is defined
[lttng-tools.git] / tests / unit / test_payload.c
index be97d49904481f6ae01819dec5ffe98993b8d760..1c79b8931012b8135ee4d890bd0a9b66faf0a33d 100644 (file)
@@ -5,10 +5,12 @@
  *
  */
 
+#include <unistd.h>
+
+#include <common/compat/fcntl.h>
 #include <common/payload.h>
 #include <common/payload-view.h>
 #include <tap/tap.h>
-#include <sys/eventfd.h>
 
 static const int TEST_COUNT = 5;
 
@@ -27,14 +29,14 @@ static void test_fd_push_pop_order(void)
 
        diag("Validating fd push/pop order");
        for (i = 0; i < 3; i++) {
-               int fd = eventfd(0, 0);
+               int fd = fcntl(STDOUT_FILENO, F_DUPFD, 0);
                struct fd_handle *handle;
 
-               assert(fd >= 0);
+               LTTNG_ASSERT(fd >= 0);
                fds[i] = fd;
 
                handle = fd_handle_create(fd);
-               assert(handle);
+               LTTNG_ASSERT(handle);
 
                ret = lttng_payload_push_fd_handle(&payload, handle);
                fd_handle_put(handle);
@@ -76,12 +78,12 @@ static void test_fd_push_pop_imbalance(void)
        diag("Validating fd pop imbalance");
        for (i = 0; i < 10; i++) {
                struct fd_handle *handle;
-               int fd = eventfd(0, 0);
+               int fd = fcntl(STDOUT_FILENO, F_DUPFD, 0);
 
-               assert(fd >= 0);
+               LTTNG_ASSERT(fd >= 0);
 
                handle = fd_handle_create(fd);
-               assert(handle);
+               LTTNG_ASSERT(handle);
 
                ret = lttng_payload_push_fd_handle(&payload, handle);
                fd_handle_put(handle);
@@ -119,13 +121,16 @@ fail:
 static void test_fd_pop_fd_root_views(void)
 {
        int ret, i;
-       const int fd = eventfd(0, 0);
-       struct fd_handle *handle = fd_handle_create(fd);
+       int fd = fcntl(STDOUT_FILENO, F_DUPFD, 0);
+       struct fd_handle *handle;
        struct lttng_payload payload;
        const char * const test_description = "Same file descriptor returned when popping from different top-level views";
 
+       LTTNG_ASSERT(fd >= 0);
+       handle = fd_handle_create(fd);
+       LTTNG_ASSERT(handle);
+
        lttng_payload_init(&payload);
-       assert(handle);
 
        diag("Validating root view fd pop behaviour");
        ret = lttng_payload_push_fd_handle(&payload, handle);
@@ -173,8 +178,8 @@ static void test_fd_pop_fd_descendant_views(void)
        const char * const test_description = "Different file descriptors returned when popping from descendant views";
 
        lttng_payload_init(&payload);
-       assert(handle1);
-       assert(handle2);
+       LTTNG_ASSERT(handle1);
+       LTTNG_ASSERT(handle2);
 
        diag("Validating descendant view fd pop behaviour");
        ret = lttng_payload_push_fd_handle(&payload, handle1);
This page took 0.024932 seconds and 4 git commands to generate.