#include "common.h"
#include "tap.h"
-#define NR_TESTS 23
+#define NR_TESTS 29
void run_seek_begin(char *path, uint64_t expected_begin)
{
bt_context_put(ctx);
}
+void run_seek_time_at_last(char *path, uint64_t expected_last)
+{
+ struct bt_context *ctx;
+ struct bt_ctf_iter *iter;
+ struct bt_ctf_event *event;
+ struct bt_iter_pos newpos;
+ int ret;
+ uint64_t timestamp_last;
+
+ /* Open the trace */
+ ctx = create_context_with_path(path);
+ if (!ctx) {
+ plan_skip_all("Cannot create valid context");
+ }
+
+ /* Create iterator with null last and end */
+ iter = bt_ctf_iter_create(ctx, NULL, NULL);
+ if (!iter) {
+ plan_skip_all("Cannot create valid iterator");
+ }
+
+ event = bt_ctf_iter_read_event(iter);
+
+ ok(event, "Event valid at beginning");
+
+ /* Seek to last */
+ newpos.type = BT_SEEK_TIME;
+ newpos.u.seek_time = expected_last;
+ ret = bt_iter_set_pos(bt_ctf_get_iter(iter), &newpos);
+
+ ok(ret == 0, "Seek time at last retval %d", ret);
+
+ event = bt_ctf_iter_read_event(iter);
+
+ ok(event, "Event valid at last position");
+
+ timestamp_last = bt_ctf_get_timestamp(event);
+
+ ok1(timestamp_last == expected_last);
+
+ /* Try to read next event */
+ ret = bt_iter_next(bt_ctf_get_iter(iter));
+
+ ok(ret == 0, "iter next should return an error");
+
+ event = bt_ctf_iter_read_event(iter);
+
+ ok(event == 0, "Event after last should be invalid");
+
+ bt_context_put(ctx);
+}
+
void run_seek_cycles(char *path,
uint64_t expected_begin,
uint64_t expected_last)
}
run_seek_begin(path, expected_begin);
+ run_seek_time_at_last(path, expected_last);
run_seek_last(path, expected_last);
run_seek_cycles(path, expected_begin, expected_last);