+ if(a_test9 || a_test_all) {
+ double t0, t1;
+ /* Run seek_forward and seek_backward test */
+ guint count;
+ LttvTracesetContext *tsc = &ts->parent;
+ LttvTracesetContextPosition *saved_pos =
+ lttv_traceset_context_position_new(tsc);
+ g_message("Running test 9 : seek_forward and seek_backward");
+ lttv_process_traceset_seek_time(tsc, ltt_time_zero);
+
+ count = lttv_process_traceset_seek_n_forward(tsc, 500, NULL, NULL, NULL);
+ g_assert(count == 500);
+ lttv_traceset_context_position_save(tsc, saved_pos);
+ t0 = get_time();
+ count = lttv_process_traceset_seek_n_forward(tsc, 150000, NULL, NULL, NULL);
+ t1 = get_time();
+ g_message("Seek forward 150000 events in %g seconds", t1 - t0);
+ g_assert(count == 150000);
+ t0 = get_time();
+ count = lttv_process_traceset_seek_n_backward(tsc, 150000,
+ seek_back_default_offset, lttv_process_traceset_seek_time, NULL,
+ NULL, NULL);
+ t1 = get_time();
+ g_message("Seek backward 150000 events in %g seconds", t1 - t0);
+ g_assert(count == 150000);
+ if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos)) {
+ g_warning("Problem with seek_n ! Positions differ. (1)");
+ }
+
+ lttv_process_traceset_seek_n_forward(tsc, 500, NULL, NULL, NULL);
+ lttv_traceset_context_position_save(tsc, saved_pos);
+ lttv_process_traceset_seek_n_forward(tsc, 15000, NULL, NULL, NULL);
+ lttv_process_traceset_seek_n_backward(tsc, 15005,
+ seek_back_default_offset, lttv_process_traceset_seek_time, NULL,
+ NULL, NULL);
+ lttv_process_traceset_seek_n_forward(tsc, 5, NULL, NULL, NULL);
+ if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos)) {
+ g_warning("Problem with seek_n ! Positions differ. (2)");
+ }
+
+ lttv_process_traceset_seek_time(tsc, ltt_time_infinite);
+
+ count = lttv_process_traceset_seek_n_forward(tsc, 15000, NULL, NULL, NULL);
+ if(count > 0)
+ g_warning("Problem with seek_n ! Forward at end of traceset.");
+
+ lttv_process_traceset_seek_time(tsc, ltt_time_infinite);
+
+ lttv_traceset_context_position_save(tsc, saved_pos);
+ t0 = get_time();
+ lttv_process_traceset_seek_n_backward(tsc, 300,
+ seek_back_default_offset, lttv_process_traceset_seek_time, NULL,
+ NULL, NULL);
+ t1 = get_time();
+ g_message("Seek backward 300 events in %g seconds", t1 - t0);
+ count = lttv_process_traceset_seek_n_forward(tsc, 299, NULL, NULL, NULL);
+ count = lttv_process_traceset_seek_n_forward(tsc, 1, NULL, NULL, NULL);
+
+ if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos)) {
+ g_warning("Problem with seek_n ! Positions differ. (4)");
+ }
+
+ lttv_traceset_context_position_save(tsc, saved_pos);
+ t0 = get_time();
+ lttv_process_traceset_seek_n_backward(tsc, 10,
+ seek_back_default_offset, lttv_process_traceset_seek_time, NULL,
+ NULL, NULL);
+ t1 = get_time();
+ g_message("Seek backward 10 events in %g seconds", t1 - t0);
+ t0 = get_time();
+ count = lttv_process_traceset_seek_n_forward(tsc, 10, NULL, NULL, NULL);
+ t1 = get_time();
+ g_message("Seek forward 10 events in %g seconds", t1 - t0);
+
+
+ /* try a volountary error */
+ lttv_process_traceset_seek_time(tsc, ltt_time_infinite);
+
+ lttv_traceset_context_position_save(tsc, saved_pos);
+ lttv_process_traceset_seek_n_backward(tsc, 301,
+ seek_back_default_offset, lttv_process_traceset_seek_time, NULL,
+ NULL, NULL);
+ count = lttv_process_traceset_seek_n_forward(tsc, 299, NULL, NULL, NULL);
+ count = lttv_process_traceset_seek_n_forward(tsc, 1, NULL, NULL, NULL);
+
+ if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos) == 0) {
+ g_warning("Problem with seek_n ! Positions _should_ differ. (5)");
+ }
+
+ /* Try a seek by closest time : Hint : try this one with and without states
+ * computed. */
+ lttv_process_traceset_seek_time(tsc, ltt_time_zero);
+ count = lttv_process_traceset_seek_n_forward(tsc, 200000, NULL, NULL, NULL);
+ lttv_traceset_context_position_save(tsc, saved_pos);
+ t0 = get_time();
+ lttv_process_traceset_seek_n_backward(tsc, 100301,
+ seek_back_default_offset,
+ (seek_time_fct)lttv_state_traceset_seek_time_closest, NULL,
+ NULL, NULL);
+ t1 = get_time();
+ g_message("Seek backward 100301 events (with seek closest) in %g seconds",
+ t1 - t0);
+ count = lttv_process_traceset_seek_n_forward(tsc, 100301, NULL, NULL, NULL);
+
+ if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos)) {
+ g_warning("Problem with seek_n with state seek time! Positions differ. (6)");
+ }
+
+ lttv_traceset_context_position_destroy(saved_pos);
+ }
+
+ if(a_test10 || a_test_all) {
+ g_message("Running test 10 : check seek traceset context position");
+ LttvTracesetContext *tsc = &ts->parent;
+ LttvTracesetContextPosition *saved_pos =
+ lttv_traceset_context_position_new(tsc);
+
+ lttv_process_traceset_seek_time(tsc, ltt_time_zero);
+ lttv_process_traceset_seek_n_forward(tsc, 200000, NULL, NULL, NULL);
+ lttv_traceset_context_position_save(tsc, saved_pos);
+ if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos) != 0)
+ g_critical("Error in seek position. (1)");
+
+ lttv_process_traceset_seek_time(tsc, ltt_time_infinite);
+ lttv_process_traceset_seek_n_backward(tsc, 500,
+ seek_back_default_offset, lttv_process_traceset_seek_time, NULL,
+ NULL, NULL);
+ lttv_traceset_context_position_save(tsc, saved_pos);
+
+ if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos) != 0)
+ g_critical("Error in seek position. (2)");
+
+ lttv_traceset_context_position_destroy(saved_pos);
+ }
+