tests/clock: avoid a race cranking
authorMatthew Waters <matthew@centricular.com>
Wed, 3 Nov 2021 06:05:07 +0000 (17:05 +1100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 21 Feb 2022 03:23:23 +0000 (03:23 +0000)
commit6a7f2ca8194a530be1d27f5bf9cac7be77126bfc
tree5029dbe332f41a3742caeb9f042a52cd660df439
parent8ff5f10a40351a49e29ade27af14d98fa6232e31
tests/clock: avoid a race cranking

Scenario:
- Source 1 requesting and waiting a clock id
- Source 2 requesting and waiting on a clock id
- Test attempting to crank both sources in the same GstHarness

gst_test_clock_crank() originally dropped locks between the retrieving
of the next clock id and advancing to the next clock id.  This would
mean that both sources would race each other attempting to complete
their clock waits.  Sometimes the operations would be performed in the
correct order, other times they would not and a FALSE return value would
be produced.

This would lead to an assertion in gst_harness_push_from_src() expecting
that all clock cranks to succeed.

Fix by ensuring that the clock wait produced is dealt with before
processing the next by not dropping the relevant locks after retrieving
the next clock id.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1299>
subprojects/gstreamer/libs/gst/check/gsttestclock.c