X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=tests%2Flib%2Ftest_seek.c;h=444f1ab7664420520592a6b6d1c7949e22b3e7fb;hp=b33f80dc2e08455987ecc01b244916371712e417;hb=61cf588beae752e5ddfc60b6b5310f769ac9e852;hpb=6b31ae9ce6bdca8682a6c936c6c20caae378e021 diff --git a/tests/lib/test_seek.c b/tests/lib/test_seek.c index b33f80dc..444f1ab7 100644 --- a/tests/lib/test_seek.c +++ b/tests/lib/test_seek.c @@ -18,21 +18,22 @@ * 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 #include #include #include +#include /* For symbol side-effects */ #include #include #include -#include +#include #include #include "common.h" -#define NR_TESTS 29 +#define NR_TESTS 36 void run_seek_begin(char *path, uint64_t expected_begin) { @@ -41,19 +42,21 @@ void run_seek_begin(char *path, uint64_t expected_begin) struct bt_ctf_event *event; struct bt_iter_pos newpos; int ret; - uint64_t timestamp_begin; - uint64_t timestamp_seek_begin; + int64_t timestamp_begin; + int64_t timestamp_seek_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); @@ -61,7 +64,7 @@ void run_seek_begin(char *path, uint64_t expected_begin) ok(event, "Event valid"); /* Validate that the first timestamp is right */ - timestamp_begin = bt_ctf_get_timestamp(event); + ok1(bt_ctf_get_timestamp(event, ×tamp_begin) == 0); ok1(timestamp_begin == expected_begin); @@ -75,7 +78,7 @@ void run_seek_begin(char *path, uint64_t expected_begin) ok(event, "Event valid"); - timestamp_seek_begin = bt_ctf_get_timestamp(event); + ok1(bt_ctf_get_timestamp(event, ×tamp_seek_begin) == 0); ok1(timestamp_begin == timestamp_seek_begin); @@ -90,18 +93,20 @@ void run_seek_last(char *path, uint64_t expected_last) struct bt_ctf_event *event; struct bt_iter_pos newpos; int ret; - uint64_t timestamp_last; + int64_t timestamp_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); @@ -118,7 +123,7 @@ void run_seek_last(char *path, uint64_t expected_last) ok(event, "Event valid at last position"); - timestamp_last = bt_ctf_get_timestamp(event); + ok1(bt_ctf_get_timestamp(event, ×tamp_last) == 0); ok1(timestamp_last == expected_last); @@ -141,18 +146,20 @@ void run_seek_time_at_last(char *path, uint64_t expected_last) struct bt_ctf_event *event; struct bt_iter_pos newpos; int ret; - uint64_t timestamp_last; + int64_t timestamp_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); @@ -170,7 +177,7 @@ void run_seek_time_at_last(char *path, uint64_t expected_last) ok(event, "Event valid at last position"); - timestamp_last = bt_ctf_get_timestamp(event); + ok1(bt_ctf_get_timestamp(event, ×tamp_last) == 0); ok1(timestamp_last == expected_last); @@ -195,18 +202,20 @@ void run_seek_cycles(char *path, struct bt_ctf_event *event; struct bt_iter_pos newpos; int ret; - uint64_t timestamp; + int64_t timestamp; /* 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); @@ -223,7 +232,7 @@ void run_seek_cycles(char *path, ok(event, "Event valid at last position"); - timestamp = bt_ctf_get_timestamp(event); + ok1(bt_ctf_get_timestamp(event, ×tamp) == 0); ok1(timestamp == expected_last); @@ -246,7 +255,7 @@ void run_seek_cycles(char *path, ok(event, "Event valid at first position"); - timestamp = bt_ctf_get_timestamp(event); + ok1(bt_ctf_get_timestamp(event, ×tamp) == 0); ok1(timestamp == expected_begin); @@ -260,7 +269,7 @@ void run_seek_cycles(char *path, ok(event, "Event valid at last position"); - timestamp = bt_ctf_get_timestamp(event); + ok1(bt_ctf_get_timestamp(event, ×tamp) == 0); ok1(timestamp == expected_last); @@ -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);