Tests: Fix test plans and do not skip on fail
[babeltrace.git] / tests / lib / test_seek.c
index b33f80dc2e08455987ecc01b244916371712e417..63e5a6ad2183991734cb697192e90ab3aad82e6f 100644 (file)
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
-#define _GNU_SOURCE
+
 #include <babeltrace/context.h>
 #include <babeltrace/iterator.h>
 #include <babeltrace/ctf/iterator.h>
 #include <babeltrace/ctf/events.h>
+#include <babeltrace/babeltrace-internal.h>    /* For symbol side-effects */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
-#include <limits.h>
+#include <babeltrace/compat/limits.h>
 
 #include <tap/tap.h>
 #include "common.h"
@@ -47,13 +48,15 @@ void run_seek_begin(char *path, uint64_t expected_begin)
        /* Open the trace */
        ctx = create_context_with_path(path);
        if (!ctx) {
-               plan_skip_all("Cannot create valid context");
+               diag("Cannot create valid context");
+               return;
        }
 
        /* Create iterator with null begin and end */
        iter = bt_ctf_iter_create(ctx, NULL, NULL);
        if (!iter) {
-               plan_skip_all("Cannot create valid iterator");
+               diag("Cannot create valid iterator");
+               return;
        }
 
        event = bt_ctf_iter_read_event(iter);
@@ -95,13 +98,15 @@ void run_seek_last(char *path, uint64_t expected_last)
        /* Open the trace */
        ctx = create_context_with_path(path);
        if (!ctx) {
-               plan_skip_all("Cannot create valid context");
+               diag("Cannot create valid context");
+               return;
        }
 
        /* Create iterator with null last and end */
        iter = bt_ctf_iter_create(ctx, NULL, NULL);
        if (!iter) {
-               plan_skip_all("Cannot create valid iterator");
+               diag("Cannot create valid iterator");
+               return;
        }
 
        event = bt_ctf_iter_read_event(iter);
@@ -146,13 +151,15 @@ void run_seek_time_at_last(char *path, uint64_t expected_last)
        /* Open the trace */
        ctx = create_context_with_path(path);
        if (!ctx) {
-               plan_skip_all("Cannot create valid context");
+               diag("Cannot create valid context");
+               return;
        }
 
        /* Create iterator with null last and end */
        iter = bt_ctf_iter_create(ctx, NULL, NULL);
        if (!iter) {
-               plan_skip_all("Cannot create valid iterator");
+               diag("Cannot create valid iterator");
+               return;
        }
 
        event = bt_ctf_iter_read_event(iter);
@@ -200,13 +207,15 @@ void run_seek_cycles(char *path,
        /* Open the trace */
        ctx = create_context_with_path(path);
        if (!ctx) {
-               plan_skip_all("Cannot create valid context");
+               diag("Cannot create valid context");
+               return;
        }
 
        /* Create iterator with null last and end */
        iter = bt_ctf_iter_create(ctx, NULL, NULL);
        if (!iter) {
-               plan_skip_all("Cannot create valid iterator");
+               diag("Cannot create valid iterator");
+               return;
        }
 
        event = bt_ctf_iter_read_event(iter);
@@ -273,11 +282,18 @@ int main(int argc, char **argv)
        uint64_t expected_begin;
        uint64_t expected_last;
 
+       /*
+        * Side-effects ensuring libs are not optimized away by static
+        * linking.
+        */
+       babeltrace_debug = 0;   /* libbabeltrace.la */
+       opt_clock_offset = 0;   /* libbabeltrace-ctf.la */
+
        plan_tests(NR_TESTS);
 
        if (argc < 4) {
-               plan_skip_all("Invalid arguments: need a trace path and the start and last timestamp");
-
+               diag("Invalid arguments: need a trace path and the start and last timestamp");
+               exit(1);
        }
 
        /* Parse arguments (Trace, begin timestamp) */
@@ -285,12 +301,14 @@ int main(int argc, char **argv)
 
        expected_begin = strtoull(argv[2], NULL, 0);
        if (ULLONG_MAX == expected_begin && errno == ERANGE) {
-               plan_skip_all("Invalid value for begin timestamp");
+               diag("Invalid value for begin timestamp");
+               exit(1);
        }
 
        expected_last = strtoull(argv[3], NULL, 0);
        if (ULLONG_MAX == expected_last && errno == ERANGE) {
-               plan_skip_all("Invalid value for last timestamp");
+               diag("Invalid value for last timestamp");
+               exit(1);
        }
 
        run_seek_begin(path, expected_begin);
This page took 0.025359 seconds and 4 git commands to generate.