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
This commit is contained in:
Colin Walters 2013-07-22 19:31:35 +01:00
parent 2e471acfca
commit baf7f1e23e

View File

@ -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);