mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
Merge branch 'wip/pwithnall/ci-fixes' into 'main'
Various unit test fixes See merge request GNOME/glib!2538
This commit is contained in:
commit
618d6873fd
@ -1038,7 +1038,10 @@ test_converter_pollable (void)
|
|||||||
|
|
||||||
/* After closing the write end, we can't get WOULD_BLOCK any more */
|
/* After closing the write end, we can't get WOULD_BLOCK any more */
|
||||||
if (!socket_out)
|
if (!socket_out)
|
||||||
g_assert_cmpint (res, !=, -1);
|
{
|
||||||
|
g_assert_no_error (error);
|
||||||
|
g_assert_cmpint (res, !=, -1);
|
||||||
|
}
|
||||||
|
|
||||||
if (res == -1)
|
if (res == -1)
|
||||||
{
|
{
|
||||||
|
@ -48,8 +48,9 @@ timeout_cb (gpointer user_data)
|
|||||||
* unrefs complete first. This is typically used on the shared connection, to
|
* unrefs complete first. This is typically used on the shared connection, to
|
||||||
* ensure it’s in a correct state before beginning the next test. */
|
* ensure it’s in a correct state before beginning the next test. */
|
||||||
static void
|
static void
|
||||||
assert_connection_has_one_ref (GDBusConnection *connection,
|
(assert_connection_has_one_ref) (GDBusConnection *connection,
|
||||||
GMainContext *context)
|
GMainContext *context,
|
||||||
|
const gchar *calling_function)
|
||||||
{
|
{
|
||||||
GSource *timeout_source = NULL;
|
GSource *timeout_source = NULL;
|
||||||
TimeoutData data = { context, FALSE };
|
TimeoutData data = { context, FALSE };
|
||||||
@ -63,7 +64,8 @@ assert_connection_has_one_ref (GDBusConnection *connection,
|
|||||||
|
|
||||||
while (g_atomic_int_get (&G_OBJECT (connection)->ref_count) != 1 && !data.timed_out)
|
while (g_atomic_int_get (&G_OBJECT (connection)->ref_count) != 1 && !data.timed_out)
|
||||||
{
|
{
|
||||||
g_debug ("refcount of %p is not right, sleeping", connection);
|
g_debug ("refcount of %p is not right (%u rather than 1) in %s(), sleeping",
|
||||||
|
connection, g_atomic_int_get (&G_OBJECT (connection)->ref_count), calling_function);
|
||||||
g_main_context_iteration (NULL, TRUE);
|
g_main_context_iteration (NULL, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,9 +73,14 @@ assert_connection_has_one_ref (GDBusConnection *connection,
|
|||||||
g_source_unref (timeout_source);
|
g_source_unref (timeout_source);
|
||||||
|
|
||||||
if (g_atomic_int_get (&G_OBJECT (connection)->ref_count) != 1)
|
if (g_atomic_int_get (&G_OBJECT (connection)->ref_count) != 1)
|
||||||
g_error ("connection %p had too many refs", connection);
|
g_error ("connection %p had too many refs (%u rather than 1) in %s()",
|
||||||
|
connection, g_atomic_int_get (&G_OBJECT (connection)->ref_count), calling_function);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Macro wrapper to add in the calling function name */
|
||||||
|
#define assert_connection_has_one_ref(connection, context) \
|
||||||
|
(assert_connection_has_one_ref) (connection, context, G_STRFUNC)
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
/* Ensure that signal and method replies are delivered in the right thread */
|
/* Ensure that signal and method replies are delivered in the right thread */
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
@ -87,11 +87,7 @@ gio_tests = {
|
|||||||
'memory-monitor' : {},
|
'memory-monitor' : {},
|
||||||
'memory-output-stream' : {},
|
'memory-output-stream' : {},
|
||||||
'mount-operation' : {},
|
'mount-operation' : {},
|
||||||
'network-address' : {
|
'network-address' : {'extra_sources': ['mock-resolver.c']},
|
||||||
'extra_sources': ['mock-resolver.c'],
|
|
||||||
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392
|
|
||||||
'should_fail' : host_system == 'darwin',
|
|
||||||
},
|
|
||||||
'network-monitor' : {},
|
'network-monitor' : {},
|
||||||
'network-monitor-race' : {},
|
'network-monitor-race' : {},
|
||||||
'permission' : {},
|
'permission' : {},
|
||||||
|
@ -16,10 +16,6 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
/* On smcv's laptop, 1e4 iterations didn't always exhibit the bug, but 1e5
|
|
||||||
* iterations exhibited it 10/10 times in practice. YMMV. */
|
|
||||||
#define ITERATIONS 100000
|
|
||||||
|
|
||||||
static GStaticPrivate sp;
|
static GStaticPrivate sp;
|
||||||
static GMutex *mutex;
|
static GMutex *mutex;
|
||||||
static GCond *cond;
|
static GCond *cond;
|
||||||
@ -51,6 +47,19 @@ static gpointer thread_func (gpointer nil)
|
|||||||
static void
|
static void
|
||||||
testcase (void)
|
testcase (void)
|
||||||
{
|
{
|
||||||
|
/* On smcv's laptop, 1e4 iterations didn't always exhibit the bug, but 1e5
|
||||||
|
* iterations exhibited it 10/10 times in practice. YMMV.
|
||||||
|
*
|
||||||
|
* If running with `-m slow` we want to try hard to reproduce the bug 10/10
|
||||||
|
* times. However, as of 2022 this takes around 240s on a CI machine, which
|
||||||
|
* is a long time to tie up those resources to verify that a bug fixed 10
|
||||||
|
* years ago is still fixed.
|
||||||
|
*
|
||||||
|
* So if running without `-m slow`, try 100× less hard to reproduce the bug,
|
||||||
|
* and rely on the fact that this is run under CI often enough to have a good
|
||||||
|
* chance of reproducing the bug in 1% of CI runs. */
|
||||||
|
const guint n_iterations = g_test_slow () ? 100000 : 1000;
|
||||||
|
|
||||||
g_test_bug ("https://bugzilla.gnome.org/show_bug.cgi?id=642026");
|
g_test_bug ("https://bugzilla.gnome.org/show_bug.cgi?id=642026");
|
||||||
|
|
||||||
mutex = g_mutex_new ();
|
mutex = g_mutex_new ();
|
||||||
@ -58,7 +67,7 @@ testcase (void)
|
|||||||
|
|
||||||
g_mutex_lock (mutex);
|
g_mutex_lock (mutex);
|
||||||
|
|
||||||
for (i = 0; i < ITERATIONS; i++)
|
for (i = 0; i < n_iterations; i++)
|
||||||
{
|
{
|
||||||
GThread *t1;
|
GThread *t1;
|
||||||
|
|
||||||
|
@ -753,7 +753,9 @@ test_mkdir_with_parents (void)
|
|||||||
g_assert_cmpint (g_mkdir_with_parents ("\\Windows\\b\\c", 0), ==, -1);
|
g_assert_cmpint (g_mkdir_with_parents ("\\Windows\\b\\c", 0), ==, -1);
|
||||||
#else
|
#else
|
||||||
g_assert_cmpint (g_mkdir_with_parents ("/usr/b/c", 0), ==, -1);
|
g_assert_cmpint (g_mkdir_with_parents ("/usr/b/c", 0), ==, -1);
|
||||||
g_assert_cmpint (errno, ==, EACCES);
|
/* EPERM may be returned if the filesystem as a whole is read-only */
|
||||||
|
if (errno != EPERM)
|
||||||
|
g_assert_cmpint (errno, ==, EACCES);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_assert_cmpint (g_mkdir_with_parents (NULL, 0), ==, -1);
|
g_assert_cmpint (g_mkdir_with_parents (NULL, 0), ==, -1);
|
||||||
|
Loading…
Reference in New Issue
Block a user