From: Colin Walters Date: Mon, 22 Jul 2013 18:31:35 +0000 (+0100) Subject: tests/unix: Don't error immediately on timeout X-Git-Tag: 2.37.5~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=baf7f1e23e4c924049e75fe11ea029846c03706d;p=platform%2Fupstream%2Fglib.git tests/unix: Don't error immediately on timeout On a heavily loaded system, it's possible that both our normal condition *and* the timeout occurred. In that case we can just ignore the timeout. While I did add a "sig_timeout" boolean, we don't need to add any assertions around whether or not it was reached - the assertions covering the non-timeout case are sufficient. The sig_timeout boolean is mainly for later debugging. https://bugzilla.gnome.org/show_bug.cgi?id=700460 --- diff --git a/glib/tests/unix.c b/glib/tests/unix.c index f6a56ca..4731019 100644 --- a/glib/tests/unix.c +++ b/glib/tests/unix.c @@ -65,6 +65,7 @@ test_error (void) } static gboolean sig_received = FALSE; +static gboolean sig_timeout = FALSE; static int sig_counter = 0; static gboolean @@ -78,11 +79,11 @@ on_sig_received (gpointer user_data) } static gboolean -sig_not_received (gpointer data) +on_sig_timeout (gpointer data) { GMainLoop *loop = data; - (void) loop; - g_error ("Timed out waiting for signal"); + g_main_loop_quit (loop); + sig_timeout = TRUE; return G_SOURCE_REMOVE; } @@ -118,7 +119,7 @@ test_signal (int signum) g_unix_signal_add (signum, on_sig_received, mainloop); kill (getpid (), signum); g_assert (!sig_received); - id = g_timeout_add (5000, sig_not_received, mainloop); + id = g_timeout_add (5000, on_sig_timeout, mainloop); g_main_loop_run (mainloop); g_assert (sig_received); sig_received = FALSE; @@ -133,7 +134,7 @@ test_signal (int signum) sig_counter = 0; g_unix_signal_add (signum, on_sig_received_2, mainloop); g_unix_signal_add (signum, on_sig_received_2, mainloop); - id = g_timeout_add (500, sig_not_received, mainloop); + id = g_timeout_add (5000, on_sig_timeout, mainloop); kill (getpid (), signum); g_main_loop_run (mainloop);