tests-clock: Fix race in test_late_crank
authorThibault Saunier <tsaunier@igalia.com>
Fri, 20 Dec 2019 13:53:21 +0000 (10:53 -0300)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 20 Dec 2019 15:51:45 +0000 (15:51 +0000)
There was a case where we started waiting on the clock before setting
the clock time, leading to the wait succeeding instead of being late:

    gsttestclock.c:1073:F:testclock:test_late_crank:0: '1 * GST_SECOND' (1000000000) is not equal to 'context.jitter' (-4000000000)

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/426

Co-authored by: Mathieu Duponchelle <mathieu@centricular.com>

tests/check/libs/gsttestclock.c

index 2b4333a7f3836977d1715ae22e8716ffabb123dc..8fa100f187b23e69953a83b989ad04148dec64f2 100644 (file)
@@ -1058,12 +1058,12 @@ GST_START_TEST (test_late_crank)
   clock_id = gst_clock_new_single_shot_id (clock, 5 * GST_SECOND);
   context.clock_id = gst_clock_id_ref (clock_id);
   context.jitter = 0;
-  worker_thread =
-      g_thread_new ("worker_thread_a",
-      test_wait_pending_single_shot_id_sync_worker, &context);
 
   /* crank the clock while the pending clock id is in the past */
   gst_test_clock_set_time (test_clock, 6 * GST_SECOND);
+  worker_thread =
+      g_thread_new ("worker_thread_a",
+      test_wait_pending_single_shot_id_sync_worker, &context);
   gst_test_clock_crank (test_clock);
 
   /* the clock should have advanced and the wait released */