added stream writability checks in pollable unit test

This checks if the stream is writable before writing
to it. If the write succeeded with no error, then the
stream has to be also writable after the write
This commit is contained in:
Silvio Lazzeretti 2018-12-13 09:09:34 +01:00
parent 27369def50
commit ac0706aad0

View File

@ -65,9 +65,13 @@ write_callback (gpointer user_data)
gssize nwrote;
GError *error = NULL;
g_assert_true (g_pollable_output_stream_is_writable (G_POLLABLE_OUTPUT_STREAM (out)));
nwrote = g_output_stream_write (out, buf, 2, NULL, &error);
g_assert_no_error (error);
g_assert_cmpint (nwrote, ==, 2);
g_assert_true (g_pollable_output_stream_is_writable (G_POLLABLE_OUTPUT_STREAM (out)));
/* Give the pipe a few ticks to propagate the write for sockets. On my
* iMac i7, 40 works, 30 doesn't. */
g_usleep (80L);