Commit Graph

7494 Commits

Author SHA1 Message Date
Philip Withnall
58f54e8303 tests: Reduce wakeup interval in gdbus-threading
When checking that the connection has the expected number of refs, the
test would block on a `GMainContext` iteration for up to 3s before
waking up and failing (if the refcount was still not as expected).

This check was written in the expectation that changing the refcount of
the connection would only happen due to dispatching a source on
`GMainContext` — hence the `GMainContext` would wake up as the refcount
changed.

That’s probably not actually true though. It might be the case that the
connection’s refcount is changed on from the GDBus worker thread, which
would not cause any wakeups on the main thread’s `GMainContext`.

In this case, the `GMainContext` iteration in
`assert_connection_has_one_ref()` would block for the full 3s, and then
wake up and notice the refcount is correct (then the test would
proceed).

That’s fine, apart from the fact that `test_threaded_singleton()` does
this 1000 times. If the slow case is hit on a significant number of
those test runs, the test will take around 3000s to complete, which is
significantly more than meson’s test timeout of 360s. So the test fails
with something like:
```
220/266 glib:gio+slow / gdbus-threading         TIMEOUT 360.07 s

--- command ---
G_TEST_SRCDIR='/builds/GNOME/glib/gio/tests' GIO_MODULE_DIR='' G_TEST_BUILDDIR='/builds/GNOME/glib/_build/gio/tests' /builds/GNOME/glib/_build/gio/tests/gdbus-threading
--- stdout ---
\# random seed: R02S83fe8de22db4d4f376e6d179e2bdd601
1..3
\# Start of gdbus tests
ok 1 /gdbus/delivery-in-thread
ok 2 /gdbus/method-calls-in-thread
\# GLib-GIO-DEBUG: refcount of 0x5602de913660 is not right (3 rather than 1) in test_threaded_singleton(), sleeping
\# GLib-GIO-DEBUG: refcount of 0x5602de913660 is not right (3 rather than 1) in test_threaded_singleton(), sleeping
\# GLib-GIO-DEBUG: refcount of 0x5602de913c60 is not right (3 rather than 1) in test_threaded_singleton(), sleeping
\# GLib-GIO-DEBUG: refcount of 0x5602de913c60 is not right (3 rather than 1) in test_threaded_singleton(), sleeping
\# GLib-GIO-DEBUG: refcount of 0x5602de913260 is not right (3 rather than 1) in test_threaded_singleton(), sleeping
\# GLib-GIO-DEBUG: refcount of 0x5602de913260 is not right (3 rather than 1) in test_threaded_singleton(), sleeping
```

From this log, it can be seen that the sleep is happening on a different
`GMainContext` every other time, so the test *is* making progress.

Assuming this is a correct diagnosis (it’s a lot of guessing), this
commit tries to fix the test by adding a wakeup timeout to the
`GMainContext` in `assert_connection_has_one_ref()`, which will wake it
up every 50ms to re-check the exit condition.

This polling approach has been taken because it doesn’t seem feasible to
make sure that every `g_object_ref()`/`g_object_unref()` call on a
`GDBusConnection` causes the main context to wake up.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-12 14:39:43 +01:00
Marc-André Lureau
2a925f273b gio/tests: DuplicateHandle() is inappropriate for SOCKET 2022-04-07 11:22:55 +00:00
Sebastian Dröge
86a24bb19a Merge branch 'wip/pwithnall/converter-stream-debugging' into 'main'
tests: Remove an incorrect assertion in converter-stream

See merge request GNOME/glib!2591
2022-04-06 13:15:01 +00:00
Jason Francis
a85246af3b gio: Add g_list_store_find_with_equal_func_full()
Fixes: #2447
2022-04-05 18:34:39 +01:00
Philip Withnall
aec5d17d77 tests: Remove an incorrect assertion in converter-stream
While the assertion always turned out to be true on Linux, it frequently
caused spurious test failures on FreeBSD.

After some remote debugging, I *think* the cause is as written up in the
comment in the code in this commit. However, I cannot be certain, as the
more debugging messages I added, the harder the failure was to
reproduce; and I don’t have access to a FreeBSD machine.

This fixes failures like:
```
Bail out! GLib-GIO:ERROR:../gio/tests/converter-stream.c:1043:test_converter_pollable: assertion failed (error == NULL): Resource temporarily unavailable (g-io-error-quark, 27)
```

It’s succeeded 1000 times in a row on the FreeBSD CI now; previously
it was failing one time in three:
https://gitlab.gnome.org/GNOME/glib/-/jobs/1936395.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-05 18:19:23 +01:00
Philip Withnall
82ad0510d2 tests: Don’t exit gdbus-method-invocation test early on connection close
There’s (deliberately) a bit of race in implementing/handling
`CloseBeforeReturning()` in `gdbus-method-invocation.c`. If the server
closes the D-Bus connection early, the client may exit with `SIGTERM` if
`GDBusConnection:exit-on-close` is set. We don’t want that, as the test
is trying to check that the default handling of a D-Bus method return
after a connection has closed works.

See https://gnome.pages.gitlab.gnome.org/-/glib/-/jobs/1935191/artifacts/_build/meson-logs/testlog.txt

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-05 14:43:16 +01:00
Philip Withnall
bae0a3c751 Merge branch 'badcel/gunixfdlist-only-unix' into 'main'
GUnixFDList: Include only in unix build

See merge request GNOME/glib!2585
2022-04-05 12:12:19 +00:00
Philip Withnall
259c86909f Merge branch 'fix-trashing-sandboxed-directories' into 'main'
Fix trashing sandboxed directories

Closes #2629

See merge request GNOME/glib!2583
2022-04-05 11:58:33 +00:00
badcel
c9874f817b
GUnixFDList: Include only in unix build 2022-04-04 20:30:22 +02:00
Loic Le Page
c6a5021f48 Fix redefinition of local variable in gio/gdbusobjectmanagerclient.c 2022-04-04 17:39:59 +01:00
Loic Le Page
5223863922 Fix redefinition of local variable in gio/gdbusserver.c 2022-04-04 17:39:59 +01:00
Loic Le Page
af69d438ed Fix unused variable and remove finalize vfunc in gio/tests/gdbus-example-proxy-subclass.c
G_GNUC_UNUSED does perfectly its job with gcc compiler but the warning
still remains with msvc compiler.

Once the unused variable removed, the finalize vfunc can be removed as
it's doing the same job as the parent function.
2022-04-04 17:39:59 +01:00
Loic Le Page
4e3f704d49 Fix global variable name hidden by local variables in gio/tests/pollable.c 2022-04-04 17:39:58 +01:00
Loic Le Page
25ab7f1e74 Fix global variable name hidden by local variables in gio/tests/proxy.c 2022-04-04 17:39:42 +01:00
Loic Le Page
13710c3699 Fix global variable name hidden by local variables in gio/tests/resolver.c 2022-04-04 17:39:42 +01:00
Matthias Clasen
724df43616 Fix trashing sandboxed directories
We must not open the fd with O_PATH|O_NOFOLLOW,
since the portal rejects that combination. Leaving
out O_NOFOLLOW is fine in this case - we know it
is a directory, we just received EISDIR.

Fixes: #2629
2022-04-04 10:26:13 -04:00
Philip Withnall
6c31ef6f18 Merge branch 'cleanup-warnings-split-8' into 'main'
Cleanup warnings split 8

See merge request GNOME/glib!2497
2022-04-01 15:13:32 +00:00
Loic Le Page
e372ed3413 Fix cast pointer to int warning in gio/tests/socket.c 2022-04-01 15:10:50 +02:00
Loic Le Page
7bd79b112d Fix non-initialized variable in gio/tests/socket-client.c 2022-04-01 15:10:50 +02:00
Loic Le Page
027e3769ee Fix global variable name hidden by local variables in gio/tests/socket-server.c 2022-04-01 15:10:50 +02:00
Loic Le Page
7178e10cd5 Fix redefinition of local variable in gio/tests/testfilemonitor.c 2022-04-01 15:10:50 +02:00
Loic Le Page
c324ce5c2a Fix redefinition of local variable in gio/gactiongroupexporter.c 2022-04-01 15:10:50 +02:00
Loic Le Page
3214a0f333 Fix redefinition of local variable in gio/gapplicationimpl-dbus.c 2022-04-01 15:10:50 +02:00
Loic Le Page
0c1619227c Fix redefinition of local variable in gio/gdbus-tool.c 2022-04-01 15:10:50 +02:00
Loic Le Page
4bcb7bc631 Fix redefinition of local variable in gio/gdbusauth.c 2022-04-01 15:10:50 +02:00
Loic Le Page
eb157bfa1b Fix redefinition of local variable in gio/gdbusauthmechanismsha1.c 2022-04-01 15:10:41 +02:00
Loic Le Page
bf68e8606b Fix non-initialized variable and remove obsolete usage of inet_addr in gio/gsocket.c 2022-04-01 00:18:40 +01:00
Loic Le Page
7bde242707 Fix redefinition of local variable in gio/gsocks5proxy.c 2022-04-01 00:18:40 +01:00
Loic Le Page
bd5d867320 Fix global variable name hidden by local variables in gio/gthreadedresolver.c 2022-04-01 00:18:40 +01:00
Loic Le Page
49d0c5a90b Fix redefinition of local variable in gio/gtlscertificate.c 2022-04-01 00:18:40 +01:00
Loic Le Page
84dabcf274 Fix global and local variables hidden by local variables and non-initialized variables in gio/gwin32appinfo.c 2022-04-01 00:18:40 +01:00
Loic Le Page
155657de3e Fix redefinition of local variable in gio/gwin32file-sync-stream.c 2022-04-01 00:18:40 +01:00
Philip Withnall
f8302d29f1 Merge branch 'wip/smcv/simplify-openpty-linking' into 'main'
tests: Call openpty (if available) without using dlsym

See merge request GNOME/glib!2562
2022-03-31 15:09:46 +00:00
Loic Le Page
6888f9e17e Fix too small array definition in gio/gdummyfile.c (no room for the '\0') 2022-03-31 13:10:26 +01:00
Loic Le Page
5ec3a425d2 Fix non-initialized variable in gio/gfile.c 2022-03-31 13:10:25 +01:00
Loic Le Page
397ccd833b Fix global variable name hidden by local variables in gio/gfileinfo.c 2022-03-31 13:10:25 +01:00
Loic Le Page
cbdddf82c0 Fix global variable name hidden by local variables in gio/gio-tool-info.c 2022-03-31 13:10:25 +01:00
Loic Le Page
72cc5b3910 Fix global variable name hidden by local variables in gio/gio-tool-list.c 2022-03-31 13:10:25 +01:00
Loic Le Page
71de9553ca Fix global variable name hidden by local variables in gio/gio-tool-mount.c 2022-03-31 13:10:25 +01:00
Loic Le Page
c0dabdd8df Fix global variable name hidden by local variables in gio/gio-tool-save.c 2022-03-31 13:10:25 +01:00
Loic Le Page
781231d556 Fix global variable name hidden by local variables in gio/gio-tool-trash.c 2022-03-31 13:10:25 +01:00
Loic Le Page
a30ae2497d Fix redefinition of local variable in gio/giomodule.c 2022-03-31 13:10:25 +01:00
Loic Le Page
94264e6190 Fix redefinition of local variable in gio/giowin32-private.c 2022-03-31 13:10:25 +01:00
Sebastian Dröge
1fc402b33b Merge branch '2614-bye-bye-gamin' into 'main'
gio: Remove fam file monitor support

Closes #2614

See merge request GNOME/glib!2570
2022-03-23 16:45:04 +00:00
Philip Withnall
6aa210e6af gio: Remove fam file monitor support
libgamin was last released in 2007 and is dead
[upstream](https://gitlab.gnome.org/Archive/gamin). Distributions may
still ship it (although Fedora no longer does), but we want people to
use inotify on Linux since it’s actively supported.

BSDs use kqueue. Windows uses win32filemonitor.

FAM might still be used on some commercial Unix distributions, but there
are no contributors from those distributions, and certainly no CI for
them to prevent regressions.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2614
2022-03-23 15:41:54 +00:00
Philip Withnall
2759dd71be gio: Remove remaining references to fen file monitor
It used to exist on Solaris, but GLib’s support for it was mostly
removed in 2015 in commit 21ab660cf8.

Remove the final few references.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-23 15:40:41 +00:00
Marc-André Lureau
517bd62840 gio/win32: TIME_CREATED_USEC is u32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-23 19:34:32 +04:00
Philip Withnall
f9ef3bec68 gthreadedresolver: Only declare private test APIs on Unix
They’re only defined on Unix anyway. `GThreadedResolver` has an entirely
different code path for handling DNS replies on Windows.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-22 12:41:08 +00:00
Philip Withnall
e8e8aebcbe resolver: Add SRV support to manual resolver test
This allows for tests like:
```
resolver -t SRV _http._tcp.mxtoolbox.com
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-22 12:40:12 +00:00
Philip Withnall
33204fe127 tests: Add tests for parsing specific DNS record types
Success and failure tests. This massively increases test coverage for
parsing DNS records, although it doesn’t get it to 100%.

It should now be useful enough to do more fuzzing on, without
immediately getting trivial failures from the fuzzer.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-22 12:40:12 +00:00