Commit Graph

1951 Commits

Author SHA1 Message Date
Philip Withnall
c02890645b tests: Drop redundant store
This fixes a scan-build warning:
```
../../../../source/glib/gio/tests/gdbus-tests.c:146:3: warning: Value stored to 'watch_id' is never read [deadcode.DeadStores]
  watch_id = 0;
  ^
```

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

Helps: #1767
2022-04-28 10:43:13 +01:00
Marc-André Lureau
e9f46d3529 gio/tests: fix socket /socket/credentials/unix_socketpair on win32
When I enabled unix socketpair test on win32, I left the existing
g_close(fds[1]), but _g_win32_socketpair() returns native sockets
descriptors that must be closed with closesocket() on win32.

Let GSocket handle the socket pair cleanup.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-04-14 15:38:47 +04:00
Marc-André Lureau
89539d9ae0 gio/tests: GStatBuf.st_size is 64 bits on win64
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-04-14 15:38:47 +04: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
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
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
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
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
Philip Withnall
81193c5aac gthreadedresolver: Don’t warn on unrecognised record types
Otherwise the code isn’t forwards-compatible, and may be DOSed by
servers returning unknown records, if `G_DEBUG=fatal-warnings` is
enabled for some reason.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-22 12:40:12 +00:00
Philip Withnall
51f70fe62e tests: Add tests for invalid DNS response header parsing
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-22 12:40:12 +00:00
Patrick Griffis
5cdacced3f tests: Add basic test framework for GResolver DNS parsing
Split out from https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2134
by Philip Withnall so it can be used in advance of HTTPS DNS record
support landing.

Reworked to no longer use test fixtures, as it’s simple enough to build
the response header in each test.

The tests are built on Unix only, as they test the parsing code in
`g_resolver_records_from_res_query()`, which is Unix-specific. The
Windows DNS APIs provide much more structured results which don’t need
parsing.
2022-03-22 12:40:12 +00:00
Philip Withnall
2e940e125f Merge branch 'w32-skips' into 'main'
Various win32 tests skip & fixes

See merge request GNOME/glib!2540
2022-03-21 12:19:24 +00:00
Simon McVittie
1726e150f4 tests: Call openpty (if available) without using dlsym
The SONAME of libutil varies between architectures, so the logic to find
the SONAME of libutil was only correct for native builds (Linux on
Linux), not for cross-builds. The regular expression was also not
sufficiently broad to match the SONAME used on the alpha architecture,
which is apparently libutil.so.1.1.

Instead of screen-scraping the output of ldconfig and using that to
dlopen the library that contains openpty, it seems more reliable to
emit a link-time reference to openpty and let the linker do its job.
It's also less code.

Bug-Debian: https://bugs.debian.org/1007946
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-03-19 14:10:51 +00:00
Sebastian Dröge
73f918b376 Merge branch 'gdbus-method-invocation-leak' into 'main'
gdbusmethodinvocation: Fix a leak on an early return path

See merge request GNOME/glib!2557
2022-03-18 09:25:28 +00:00
Marc-André Lureau
e38e92e37b gio/tests/codegen: skip tests that require /dev/stdout on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-18 00:20:14 +04:00
Marc-André Lureau
b3d6946c27 tests/socket: skip a test if AF_UNIX is not supported on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-18 00:16:38 +04:00
Marc-André Lureau
e014b9272a gio/tests: skip filemonitor tests on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-18 00:16:38 +04:00
Marc-André Lureau
cfc47558fc tests: enable defaultvalue and debugcontroller on win32
The test still requires dbus-daemon.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-18 00:16:38 +04:00
Marc-André Lureau
e9d9edde82 tests: skip appmonitor test on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-18 00:16:14 +04:00
Philip Withnall
a7750cd020 tests: Add unit tests for GDBusMethodInvocation
These should cover everything to do with returning a value or error from
a `GDBusMethodInvocation` object.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-17 19:17:41 +00:00
Philip Withnall
4ef27174af tests: Use g_strv_contains() rather than a home-grown version
The public `g_strv_contains()` API didn’t exist at the time this code
was originally written. Now, happily, it does.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-17 16:28:41 +00:00
Philip Withnall
9b77b75f2d Merge branch 'w32-contenttype' into 'main'
Various contenttype-related test fixes on win32

See merge request GNOME/glib!2499
2022-03-17 15:14:14 +00:00
Philip Withnall
1756dde873 Merge branch '2312-codegen-test-leak-fix' into 'main'
tests: Fix a leak in gdbus-test-codegen test

Closes #2312

See merge request GNOME/glib!2546
2022-03-17 15:12:08 +00:00
Philip Withnall
96caca2b7a tests: Explicitly close stream in converter-stream
When the test has finished writing all the expanded content into the
socket, explicitly close the output stream, which should make the input
stream readable and non-blocking.

The code intended to do this before, but only as a side-effect of
dropping its last reference to `right`. If another reference was being
held to `right` somewhere else, it wouldn’t end up being closed, which
would lead to failures like
https://gitlab.gnome.org/GNOME/glib/-/jobs/1890000:
```
(/var/tmp/gitlab_runner/builds/Ff4WDDRj/0/GNOME/glib/_build/gio/tests/converter-stream:56570): GLib-GIO-DEBUG: 12:56:23.280: GSocketClient: Connection successful!
Bail out! GLib-GIO:ERROR:../gio/tests/converter-stream.c:1042:test_converter_pollable: assertion failed (error == NULL): Resource temporarily unavailable (g-io-error-quark, 27)
stderr:
```

This is a bit of a guess (I’m not sure it’ll fix the intermittent test
error, as I haven’t been able to reproduce that locally), but it’s worth
a try.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-14 17:59:37 +00:00
Philip Withnall
8cff531520 tests: Isolate directory access for gdbus-connection-flush test
When multiple tests were run in parallel, this would race on its access
to `~/.dbus-keyrings` to authenticate with the D-Bus server, since the
keyring directory was not appropriately sandboxed to the unit test.

Use `G_TEST_OPTION_ISOLATE_DIRS` to automatically isolate each unit
test’s directory usage.

This should hopefully fix the failure seen in
https://gitlab.gnome.org/GNOME/glib/-/jobs/1849524, where the following
was in the log for a test executed in parallel:
```
GDBus-DBUS_COOKIE_SHA1: Deleted stale lock file '/home/user/.dbus-keyrings/org_gtk_gdbus_general.lock'
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-12 00:03:05 +00:00
Philip Withnall
a3c768732d tests: Isolate directory access for gdbus-non-socket test
When multiple tests were run in parallel, this would race on its access
to `~/.dbus-keyrings` to authenticate with the D-Bus server, since the
keyring directory was not appropriately sandboxed to the unit test.

Use `G_TEST_OPTION_ISOLATE_DIRS` to automatically isolate each unit
test’s directory usage.

This should hopefully fix the failure seen in
https://gitlab.gnome.org/pwithnall/glib/-/jobs/1879558.
```
228/266 glib:gio / gdbus-non-socket             FAIL     8.64 s (killed by signal 6 SIGABRT)
…
--- stderr ---
GDBus-DBUS_COOKIE_SHA1: Deleted stale lock file '/home/user/.dbus-keyrings/org_gtk_gdbus_general.lock'
**
GLib-GIO:ERROR:../gio/tests/gdbus-non-socket.c:253:test_non_socket: assertion failed (error == NULL): Exhausted all available authentication mechanisms (tried: EXTERNAL, DBUS_COOKIE_SHA1) (available: EXTERNAL, DBUS_COOKIE_SHA1) (g-io-error-quark, 0)
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-11 23:56:18 +00:00
Philip Withnall
404d5d40e0 tests: Ensure timeout source is removed in gdbus-auth test
If the whole set of tests takes more than 5 seconds, the failure timeout
from the first test could still trigger, causing an incorrect failure.

Ensure the timeout is removed at the end of each test.i

This will hopefully fix the CI failure seen here:
https://gitlab.gnome.org/pwithnall/glib/-/jobs/1879558.
```
204/266 glib:gio / gdbus-auth                   FAIL     9.21 s (killed by signal 5 SIGTRAP)
…
ok 1 /gdbus/auth/client/EXTERNAL
Bail out! GLib-GIO-FATAL-ERROR: Timeout waiting for client
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-11 23:47:22 +00:00
Philip Withnall
bed82b807f tests: Re-enable address sanitizer for gdbus-test-codegen
Now that the leaks are fixed, this test can be run under the sanitizer
again.

This is a partial revert of commit
f378352051.

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

Helps: #2312
2022-03-09 14:21:22 +00:00
Philip Withnall
9499aeb8bf tests: Wait for signal unsubscriptions in gdbus-test-codegen
When destroying `GDBusProxy`s in a custom `GMainContext`, the context
must be iterated enough after finalisation of the proxies that any
pending D-Bus traffic, and the signal subscription data, can be freed.

See the documentation for `g_dbus_connection_signal_unsubscribe()`.

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

Fixes: #2312
2022-03-09 14:21:20 +00:00
Marc-André Lureau
b0c53559c0 tests: skip check anything is octet-stream
Like on Mac, the contenttype database can't say that much yet.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-09 11:41:30 +04:00
Marc-André Lureau
7fa4999457 tests: skip test_tree on win32
Currently it simply crashes, because types == NULL.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-09 11:41:30 +04:00
Marc-André Lureau
5f1bae1594 gio/tests: fix test_icon on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-09 11:41:30 +04:00
Marc-André Lureau
452d64a03b tests: use Windows mime type for executable
According to https://stackoverflow.com/a/43916291/1277510

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-09 11:41:30 +04:00
Marc-André Lureau
ab0c00bd7e gio/tests: fix various content type guesses on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-09 11:41:30 +04:00
Marc-André Lureau
529e091bb5 gio/tests: fix content type guess for directory on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-09 11:41:30 +04:00
Philip Withnall
0239ae7122 tests: Fix a leak in gdbus-test-codegen test
The `ay` property has type `string` (see the generated code) since it’s
not been annotated to force accepting a `GVariant`.

This means the GObject property machinery expects a string, and calls
`g_strdup()` on the passed-in pointer, rather than sinking the
`GVariant`.

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

Helps: #2312
2022-03-08 20:08:43 +00:00
Emmanuele Bassi
618d6873fd Merge branch 'wip/pwithnall/ci-fixes' into 'main'
Various unit test fixes

See merge request GNOME/glib!2538
2022-03-07 09:24:10 +00:00
Philip Withnall
4d237daf32 tests: Add more debug output to gdbus-threading test
It periodically hangs due to the `GDBusConnection` having more than 1
ref (and never losing them), so there’s potentially a leaking ref
somewhere:
```
(/builds/alexander.klauer/glib/_build/gio/tests/gdbus-threading:17767): GLib-GIO-DEBUG: 13:18:12.268: refcount of 0x55fe85b1a260 is not right, sleeping
\# GLib-GIO-DEBUG: refcount of 0x55fe85b1a260 is not right, sleeping
```

Add some more debug output to try and track the problem down.

See: https://gitlab.gnome.org/alexander.klauer/glib/-/jobs/1865968

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-04 19:53:04 +00:00