mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 08:11:16 +00:00
systemclock: tests: added stress test for async order
Keep inserting alarms at the beginning of the list. Due to https://bugzilla.gnome.org/show_bug.cgi?id=760757 alarm thread will get confused and not serve them in order.
This commit is contained in:
parent
f0e94b4cdf
commit
077db508a8
1 changed files with 53 additions and 0 deletions
|
@ -338,6 +338,58 @@ GST_START_TEST (test_async_order)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
|
GST_START_TEST (test_async_order_stress_test)
|
||||||
|
{
|
||||||
|
#define ALARM_COUNT 20
|
||||||
|
GstClock *clock;
|
||||||
|
GstClockID id[ALARM_COUNT];
|
||||||
|
GList *cb_list = NULL, *cb_list_it;
|
||||||
|
GstClockTime base;
|
||||||
|
GstClockReturn result;
|
||||||
|
|
||||||
|
clock = gst_system_clock_obtain ();
|
||||||
|
fail_unless (clock != NULL, "Could not create instance of GstSystemClock");
|
||||||
|
|
||||||
|
gst_clock_debug (clock);
|
||||||
|
base = gst_clock_get_time (clock);
|
||||||
|
|
||||||
|
/* keep inserting at the beginning of the list.
|
||||||
|
* We expect the alarm thread to keep detecting the new entries and to
|
||||||
|
* switch to wait on the first entry on the list
|
||||||
|
*/
|
||||||
|
for (unsigned int i = ALARM_COUNT; i > 0; --i) {
|
||||||
|
id[i - 1] = gst_clock_new_single_shot_id (clock, base + i * TIME_UNIT);
|
||||||
|
result =
|
||||||
|
gst_clock_id_wait_async (id[i - 1], store_callback, &cb_list, NULL);
|
||||||
|
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
g_usleep (TIME_UNIT * (ALARM_COUNT + 1) / 1000);
|
||||||
|
/* at this point all the timers should have timed out */
|
||||||
|
g_mutex_lock (&store_lock);
|
||||||
|
fail_unless (cb_list != NULL, "expected notification");
|
||||||
|
cb_list_it = cb_list;
|
||||||
|
/* alarms must trigger in order.
|
||||||
|
* Will fail if alarm thread did not properly switch to wait on first entry
|
||||||
|
* from the list
|
||||||
|
*/
|
||||||
|
for (unsigned int i = 0; i < ALARM_COUNT; ++i) {
|
||||||
|
fail_unless (cb_list_it != NULL, "No notification received for id[%d]", i);
|
||||||
|
fail_unless (cb_list_it->data == id[i],
|
||||||
|
"Expected notification for id[%d]", i);
|
||||||
|
cb_list_it = g_list_next (cb_list_it);
|
||||||
|
}
|
||||||
|
g_mutex_unlock (&store_lock);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < ALARM_COUNT; ++i)
|
||||||
|
gst_clock_id_unref (id[i]);
|
||||||
|
g_list_free (cb_list);
|
||||||
|
|
||||||
|
gst_object_unref (clock);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
struct test_async_sync_interaction_data
|
struct test_async_sync_interaction_data
|
||||||
{
|
{
|
||||||
GMutex lock;
|
GMutex lock;
|
||||||
|
@ -713,6 +765,7 @@ gst_systemclock_suite (void)
|
||||||
tcase_add_test (tc_chain, test_periodic_shot);
|
tcase_add_test (tc_chain, test_periodic_shot);
|
||||||
tcase_add_test (tc_chain, test_periodic_multi);
|
tcase_add_test (tc_chain, test_periodic_multi);
|
||||||
tcase_add_test (tc_chain, test_async_order);
|
tcase_add_test (tc_chain, test_async_order);
|
||||||
|
tcase_add_test (tc_chain, test_async_order_stress_test);
|
||||||
tcase_add_test (tc_chain, test_async_sync_interaction);
|
tcase_add_test (tc_chain, test_async_sync_interaction);
|
||||||
tcase_add_test (tc_chain, test_diff);
|
tcase_add_test (tc_chain, test_diff);
|
||||||
tcase_add_test (tc_chain, test_mixed);
|
tcase_add_test (tc_chain, test_mixed);
|
||||||
|
|
Loading…
Reference in a new issue