tests: Speed up threaded toggle notify test unless -m slow is passed

On a fast laptop, this test currently takes about 7s to run, which is a
significant portion of the overall test suite time.

On a slower CI machine, especially running the test under valgrind, the
test can time out.

There’s no need to always run so many iterations: we run the tests under
CI so often that it’s likely a failure will eventually be hit (if there
is a bug) even with fewer iterations. We also now run the tests once a
week with `-m slow`, so the original iteration count will also still be
used then.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
Philip Withnall 2024-02-13 08:50:24 +00:00
parent 342fa9c161
commit 3c39a23a7e

View File

@ -480,6 +480,7 @@ test_threaded_toggle_notify (void)
ToggleNotifyThreadData data = { object, FALSE, 0 };
GThread *threads[3];
gsize i;
const int n_iterations = g_test_thorough () ? 1000000 : 100000;
g_test_bug ("https://gitlab.gnome.org/GNOME/glib/issues/2394");
g_test_summary ("Test that toggle reference notifications can be changed "
@ -498,7 +499,7 @@ test_threaded_toggle_notify (void)
* race to happen, so we wait for an high number of toggle changes to be met
* so that we can be consistent on each platform.
*/
while (g_atomic_int_get (&data.toggles) < 1000000)
while (g_atomic_int_get (&data.toggles) < n_iterations)
;
g_atomic_int_set (&data.done, TRUE);