Commit Graph

2085 Commits

Author SHA1 Message Date
Luca Bacci
a1737ece06 Fix GCancellable tests for Windows 64bit
Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/2703
2022-08-03 20:33:46 +02:00
madmurphy
b295c53769 gfileinfo: Implement xattr attribute removal
Fixes: #1187
2022-07-26 07:58:32 +00:00
Emmanuele Bassi
09234b50fe Introduce G_APPLICATION_DEFAULT_FLAGS
Enumeration members should either have the name of the type as their
prefix, or they should all have the same prefix.

The "default flags" enumeration member for GApplicationFlags is
unfortunately named G_APPLICATION_FLAGS_NONE, while every other member
of the same type has a G_APPLICATION prefix. The result is that the nick
name of the enumeration member is "flags-none", and that language
bindings will have to use something like
Gio.ApplicationFlags.FLAGS_NONE.

To fix this API wart, we can deprecate the FLAGS_NONE member, and add a
new DEFAULT_FLAGS.
2022-07-25 22:30:22 +01:00
Simon McVittie
6751392934 tests: Avoid using deprecated meson.build_root
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-25 01:00:53 +02:00
Simon McVittie
d0967c1d4a Revert "gdesktopappinfo: Use sh rather than gio-launch-desktop"
A shell one-liner was enough to set GIO_LAUNCHED_DESKTOP_FILE_PID,
but ideally we also want to do the equivalent of sd_journal_stream_fd()
to set up its standard output and standard error streams.

Ideally we would call sd_journal_stream_fd() in a process that will
exec the real program, otherwise it will report the wrong process ID
in the Journal, but we can't easily do that in a forked child when
using posix_spawn() for subprocesses.

This reverts commit 2b533ca99a.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-25 01:00:53 +02:00
Simon McVittie
32b226d1b1 gdbus: Allow cross-namespace connections to Linux session and system buses
The dominant implementations of the well-known session and system
message buses are the reference implementation from the dbus project
(dbus-daemon) and the sd-bus-based reimplementation dbus-broker, both
of which have correct implementations for EXTERNAL authentication with
an unspecified authorization identity.

This makes it reasonably safe to assume that the well-known message
buses can cope with the unspecified authorization identity, even if we
cannot make the same assumption for custom servers such as the ones
used in ibus and gvfs (which might have been started with an older
GLib version before upgrading GLib in-place).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-24 14:07:02 +01:00
Philip Withnall
55928d6ac0 Merge branch 'more-atomic-ops' into 'main'
Use atomic exchange operations more

See merge request GNOME/glib!2759
2022-07-23 11:35:08 +00:00
Simon McVittie
0c24039874 tests: Add a test for GDBusServer with various simulated clients
Instead of using a GDBusConnection, this does the handshake at a lower
level using specific strings in the SASL handshake, to verify that we
will interoperate with various clients including sd-bus, libdbus and
older versions of GDBus.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-18 19:39:41 +01:00
Philip Withnall
c3a80a7142 Merge branch 'non-registered-extension-point' into 'main'
Add missing extension point register for various settings backends

See merge request GNOME/glib!2813
2022-07-15 21:25:58 +00:00
Ryan Hope
7c4e6032c6 Add tests for GMemorySettingsBackend and GNullSettingsBackend 2022-07-15 22:07:03 +02:00
James Hilliard
d0b9ebbaac meson: fix build without cpp toolchain
We don't need a cpp toolchain for building glib so lets just
automatically disable tests requiring one when not available.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2022-07-15 12:58:41 -06:00
Marco Trevisan (Treviño)
ecaa5b5b7a gio/tests/desktop-app-info: Wait until the callback is called
The test was flacky because we were only relying on the presence of a
file, while the callback could have not been called yet, while ensure
for both assumptions to be true before stop iterating the loop.
2022-07-12 17:33:15 +02:00
Philip Withnall
59fc26cbaa gio: Add some missing license and copyright headers
These headers have all been written manually, by looking through the git
log for each file and noting the copyright of each significant
contribution.

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

Helps: #1415
2022-07-05 12:30:46 +01:00
Philip Withnall
41691cc4c8 Merge branch 'more-spdx' into 'main'
Add more SPDX license headers

See merge request GNOME/glib!2706
2022-07-05 11:06:49 +00:00
Philip Withnall
bd56345f23 Merge branch 'move_assert-msg-test' into 'main'
Convert tests/assert-msg-test* to glib/tests/assert-msg-test*

Closes #1434

See merge request GNOME/glib!2767
2022-06-28 10:41:59 +00:00
Philip Withnall
164d3759fb Merge branch 'mcatanzaro/#2597' into 'main'
Avoid crashing when GProxyResolver returns weird results, and related fixes

Closes #2597

See merge request GNOME/glib!2742
2022-06-28 10:33:33 +00:00
Emmanuel Fleury
5699b7b169 Fix some coding style issues in python tests pointed out by black and flake8 2022-06-28 11:19:21 +01:00
Michael Catanzaro
1738fad172 proxyaddressenumerator: set error parameter more thoughtfully
It doesn't make sense for a proxy resolver to return NULL without an
error on the first call. Whereas a DNS resolver would do this to
indicate that a query completed successfully but found no results, a
proxy resolver should return "direct://" instead. Therefore, if we are
going to return NULL, we ought to have an error as well. Let's make sure
this actually happens by adding some fallback errors just in case
GProxyResolver feeds us weird results.

Additionally, we should not return any errors except
G_IO_ERROR_CANCELLED after the very first iteration. This is an API
contract of GSocketAddressEnumerator. Let's add some checks to ensure
this.

Note that we have inadequate test coverage for GProxyAddressEnumerator.
It's tested here only via GSocketClient. We could do a bit better by
testing it directly as well. For example, I've added tests to see what
happens when GProxyResolver returns both a valid and an invalid URI, but
it's not so interesting here because GSocketClient always uses the valid
result and ignores the error from GProxyAddressEnumerator.

Fixes #2597
2022-06-27 15:10:05 -05:00
Michael Catanzaro
4667f5980a proxy-test: fix check for simple:// URI scheme
This has no practical impact, since it's only a test, and none of the
test code would have hit this bug, but the GTestProxyResolver's check to
see if the URI scheme is simple:// currently only compares the first
four bytes of the string, so it's actually only checking for the "simp"
and would match anything else after that, e.g. "simpleton://". This is
surely not intended.
2022-06-27 14:23:51 -05:00
Philip Withnall
087272777b tests: Fix incorrect basename comparison in gsubprocess test
This was causing intermittent failures on macOS, depending on whether
the tmpdir ended with a `/` or `/some-dir`. `g_strrstr()` is not the
right function to use to extract a basename from a path, for this
reason.

When it failed, the macOS test was failing with:
```
ok 16 /gsubprocess/env
Bail out! GLib-GIO:ERROR:../gio/tests/gsubprocess.c:1507:test_cwd: assertion failed (basename == tmp_lineend_basename): ("/T\n" == "/\n")
```

The test now passes reliably, which means that it can be removed from
the list of expected failures on macOS.

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

Helps: #1392
2022-06-27 15:02:55 +01:00
Philip Withnall
059a5fd4da tests: Skip various default handler tests on macOS
They are not currently supported by `gosxappinfo.m`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-24 12:43:18 +01:00
Philip Withnall
a98bd895d5 tests: Fix a path comparison in the file tests
On macOS the comparison was failing as one of the paths had a trailing
slash while the other didn’t.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-24 12:27:45 +01:00
Marco Trevisan (Treviño)
e7269a26e4 gio/tests: Ensure that a cancellable hangs if reset from cancellable callback 2022-06-23 20:01:12 +02:00
Marco Trevisan (Treviño)
e218371f19 gio/tests: Ensure that cancellable is cancelled when emitting the signal
Use a race between threads resetting and cancelling a cancellable and
ensure that when we call the callback the cancellable is cancelled
2022-06-23 20:01:12 +02:00
Marco Trevisan (Treviño)
62192925b6 gio/tests: Add tests for cancellable pollfd and cancellation callbacks 2022-06-23 20:01:12 +02:00
Philip Withnall
191923ce61 Merge branch 'wip/smcv/none-flags' into 'main'
Add a NONE or DEFAULT member to most flags-sets

See merge request GNOME/glib!2576
2022-06-23 16:09:38 +00:00
Philip Withnall
5655af6ada Merge branch 'more-async-gfile' into 'main'
gfile (and GAppInfo): Add some missing async APIs and ensure async calls always use them

See merge request GNOME/glib!2717
2022-06-23 11:49:55 +00:00
Simon McVittie
cc528f6c2e giomodule test: Don't pass a magic number to g_test_trap_subprocess()
This worked, but seems like bad style.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:47:19 +01:00
Simon McVittie
de8672fe0b gtestutils: Add G_TEST_SUBPROCESS_DEFAULT, G_TEST_TRAP_DEFAULT
This makes calls to test subprocesses with default behaviour more
self-documenting.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:47:13 +01:00
Marco Trevisan (Treviño)
8a880e1379 GAppInfo: Make g_app_info_launch_default_for_uri_async fully async
Despite the name, we still used blocking calls to get the default app
for URI, now that we have an async implementation of the API to get the
default implementation for URI scheme, we can remove the blocking calls.
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
8aee5fc628 GAppInfo: Add async API to get default Application for URI scheme
Make possible to fetch the default application for URI scheme in a
thread without using blocking I/O.
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
73b29e8f6e gio/tests: Add test case for g_app_info_launch_default_for_uri
We did not check whether this function worked before, so add a simple
test case for it, providing some test functions to make it possible to
reply the same behavior
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
6fef60b65c GDesktopAppInfo: Ensure that URI scheme is a valid argument 2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
44dbd43170 GAppInfo: Add async API to get default Application for content type
Make possible to fetch the Application for default content type in a
thread without using blocking I/O.
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
abae8c1f05 gio/tests: Add test cases for g_file_query_default_handler[_async]
Simulating having default handlers, however this is tested only in unix
as windows may behave differently, so let's just skip it for now.
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
22e951e6ac gfile: Add Async API to create a temporary directory and return as GFile
While it's possible to create a directory synchronously via
g_dir_make_tmp(), there's no such API that performs it asynchronously.

So implement it using GFile, using a thread to perform such task.
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
fa24391529 gfile: Add API to create a new temporary file asynchronously
Make possible to create a new gfile with a temporary name in async
way, using the same API of g_file_new_tmp().
2022-06-22 20:07:30 +02:00
Marco Trevisan (Treviño)
b64fd312da gerror: Add an utility function to get the GIO Error from GFileError
When GIO functions are using GLib file utils functions we expect to
return a GIO Error, so provide a way to map such error values.
2022-06-22 20:07:25 +02:00
Philip Withnall
75a39114d8 tests: Fix non-TAP output from socket test
This was breaking strict TAP parsers, such as Meson’s.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-21 12:50:31 +01:00
Philip Withnall
8dde15a5b3 tests: Fix gengiotypefuncs.py helper script
It seems this script has potentially never worked properly under Python
3. It’s supposed to list all the `_get_type()` functions it can find in
the GIO headers, but since the regex string passed to `re.search()` was
not a Python regex, nothing was matching.

Fix that, and do another few small cleanups to the script.

This makes the `defaultvalue` test not skip all the types.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-21 12:50:31 +01:00
Philip Withnall
f977ddf34f tests: Fix non-TAP output from debugcontroller test
When running under a strict TAP parser this was previously producing
problematic non-conforming output.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-21 12:50:31 +01:00
Marco Trevisan (Treviño)
e5841beba6 gioerror: Map ENOSYS to G_IO_ERROR_NOT_SUPPORTED
If a wrong syscall is used, we can assume that such feature is not
supported at higher level.
2022-06-15 20:44:10 +02:00
Marco Trevisan (Treviño)
587f5f25d0 gioerror: Map ENETDOWN to G_IO_ERROR_NETWORK_UNREACHABLE 2022-06-15 20:44:10 +02:00
Marco Trevisan (Treviño)
3d6f843097 gioerror: Map ENOMSG, EBADMSG and ENODATA to G_IO_ERROR_INVALID_DATA 2022-06-15 20:44:10 +02:00
Marco Trevisan (Treviño)
19417b1a67 gioerror: Map ENFILE to G_IO_ERROR_TOO_MANY_OPEN_FILES
ENFILE stands for "Too many open files in system", so we can definitely
group it together with EMFILE ("Too many open files").
2022-06-15 20:44:10 +02:00
Marco Trevisan (Treviño)
6bc6b7ef30 gioerror: Map ETXTBSY to G_FILE_ERROR_BUSY
It's a busy text file, but we don't care much about specifics so we
can just return the generic busy error.
2022-06-15 20:44:10 +02:00
Marco Trevisan (Treviño)
d2ca48ad97 gioerror: Add G_IO_ERROR_NO_SUCH_DEVICE to map ENODEV 2022-06-15 20:43:56 +02:00
Marco Trevisan (Treviño)
9e09894414 gioerror: Handle EMLINK error as too-many-links error
This used to be a FreeBSD only error but it's actually defined also in
linux.
2022-06-15 20:41:53 +02:00
Marco Trevisan (Treviño)
35c6c5c663 tests: Add unit test for GIOErrorEnum conversion functions 2022-06-15 20:41:52 +02:00
Marco Trevisan (Treviño)
04718a9692 gfile: Implement interface API to make symbolic links asynchronously
The interface was ready for this API but it was not provided.

So implement this, using a thread that calls the sync API for now.

Add tests.

Helps with: GNOME/glib#157
2022-06-15 19:49:38 +02:00
Marco Trevisan (Treviño)
fe9e35624a gfile: Check that using NULL symlink_value as a programmer error
And also ensure that a null strings gives an error.
2022-06-15 19:49:38 +02:00
Benjamin Otte
51840393b2 liststore: Add tests for n-items property 2022-06-09 17:08:42 +02:00
Philip Withnall
3b87740e3e tests: Fix defined-but-not-used variables if HAVE_OPENPTY is undefined
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-07 19:12:46 +01:00
Philip Withnall
14f4b38fb1 tests: NULL-initialise some variables to help scan-build
Dynamically, these will only ever be used after they’ve been initialised
due to correct checking of `use_udp` throughout the test. However,
that’s a global variable and the static analyser is assuming it might
change value. So help it out by NULL-initialising the variables so they
can never be used uninitialised.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-07 11:04:25 +01:00
Simon McVittie
36da11550c Merge branch 'leak-fixes' into 'main'
tests: Various small test fixes for valgrind

See merge request GNOME/glib!2711
2022-06-01 17:23:02 +00:00
Philip Withnall
33f36af489 tests: Remove an unnecessary timeout in gnotification test
This is a fallback timeout to abort the test if the expected number of
messages aren’t seen in time. However, when running the test under
valgrind it will take longer and sometimes spuriously trigger the
timeout.

There’s no point in having an abort timeout inside the test: the test
runner (Meson) already provides one for us, which we can adjust with a
multiplier when running under valgrind.

So removes the timeout from within the test. This should fix the
gnotification test under valgrind.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-01 15:20:38 +01:00
Philip Withnall
4282f22102 tests: Fix leaks in new GDateTime file info tests
From b7b10cc7e0. My fault!

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-01 15:19:59 +01:00
Philip Withnall
972df061a7 Merge branch 'wip/pwithnall/fix-pollable-test' into 'main'
tests: Fix a potential race condition in pollable test

See merge request GNOME/glib!2702
2022-06-01 13:15:32 +00:00
Philip Withnall
26409f19cd Add SPDX license headers for LGPL-2.1-or-later to various files
These have all been added manually, as I’ve finished all the files which
I can automatically detect.

All the license headers in this commit are for LGPL-2.1-or-later, and
all have been double-checked against the license paragraph in the file
header.

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

Helps: #1415
2022-06-01 12:44:23 +01:00
Philip Withnall
95c1d656e2 tests: Fix a potential race condition in pollable test
This may have been causing an intermittent failure of the pollable test
on BSD, where updating the readable status of a socket takes a bit
longer than on Linux.

```
GLib-GIO-DEBUG: 16:06:41.235: GSocketClient: Starting application layer connection
GLib-GIO-DEBUG: 16:06:41.235: GSocketClient: Connection successful!
Bail out! GLib-GIO:ERROR:../gio/tests/pollable.c:73:check_source_readability_callback: assertion failed (readable == expected): (0 == 1)
```

I have not debugged the test on BSD, though, so this is only a guess.

See https://gitlab.gnome.org/GNOME/glib/-/jobs/2022087

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-31 13:14:15 +01:00
Philip Withnall
4daa3ca33e tests: Remove global variables from pollable test
This should make each unit test a bit more self-contained and easier to
verify that they’re independent.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-31 13:12:06 +01:00
Philip Withnall
ac322a1205 tests: Use g_assert_*() rather than g_assert() in pollable
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-31 12:57:46 +01:00
Philip Withnall
e5a691e84a tests: Add a test for GFileMonitor deadlocks
This test is opportunistic in that it’s not possible to detect whether
the race condition has been hit (other than by hitting a deadlock).

So the only approach we can take for testing is to loop over the code
which has previously been known to cause a deadlock a number of times.

The number of repetitions is chosen from running the test with the
deadlock fix reverted.

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

Helps: #1941
2022-05-31 12:24:13 +01:00
Philip Withnall
18c0088678 tests: Fix a memory leak when abandoning a file creation time test
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-27 17:45:03 +01:00
Philip Withnall
b7b10cc7e0 tests: Add additional tests for nanosecond precision file timestamps
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #369
2022-05-27 17:45:03 +01:00
nitinosiris
b33ef610de Add functionality to preserve nanosecond timestamps
file copy doesn't preserve nanosecond timestamps

Closes #369
2022-05-27 17:03:35 +01:00
Philip Withnall
caf6d99fbe Merge branch 'win32-fd' into 'main'
gio: various unix/fd-related enablement on win32

See merge request GNOME/glib!2656
2022-05-18 14:01:43 +00:00
Philip Withnall
c613d32b92 tests: Add SPDX license headers automatically
Add SPDX license (but not copyright) headers to all files which follow a
certain pattern in their existing non-machine-readable header comment.

This commit was entirely generated using the command:
```
git ls-files gio/tests/*.c | xargs perl -0777 -pi -e 's/\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/\n \*\n \* SPDX-License-Identifier: LGPL-2.1-or-later\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/igs'
```

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

Helps: #1415
2022-05-18 09:20:07 +01:00
Marc-André Lureau
984103b0e7 gio/tests: add gdbus-peer test to win32
Because we can :)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-17 17:34:06 +02:00
Marc-André Lureau
7886283750 gio/tests: unescape the nonce_file value
The raw value is escaped according to D-Bus rules. This is probablematic
for Windows backslashed paths. We can use URI unescaping, it seems
that's what gdbusaddress.c is doing too.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-17 17:34:06 +02:00
Marc-André Lureau
b5c97b1016 gio/tests: add basic fd-list unit test to unix-fd
To cover win32 support.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-17 17:34:06 +02:00
Marc-André Lureau
c9b5b1fb94 gio/tests: switch to g_close()
For the better behaviour and portability.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-17 16:37:39 +02:00
Marc-André Lureau
b8eb64b350 gio/tests: add unix-fd test to win32
The "/unix-fd/scm" test is quite Unix-specific, the next patch is going
to add a portable test.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-17 16:37:39 +02:00
Marc-André Lureau
277657eacc glib/win32: introduce private g_win32_handle_is_socket()
Used in following commits, including in some GIO experiments.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-12 18:54:11 +02:00
Marc-André Lureau
c4a7ddbf67 gio/tests/unix-fd: rename test
Use a prefix matching the binary, rename the test "scm", as it involves
SocketControlMessage.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-12 18:48:59 +02:00
Marc-André Lureau
18d98e30f9 gio/tests: close leaked fd
Also fixes some of the test on win32, since it won't delete files that
are opened.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-12 18:48:59 +02:00
TestingPlant
a5e7156a9b Replace single quotes in gio/tests/codegen.py
This makes the formatting more consistent.
2022-05-12 00:29:44 +00:00
Philip Withnall
bd1781a356 build: Stop using Meson features deprecated in Meson <0.60
This clears some Meson warnings.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-06 13:55:28 +01:00
Xavier Claessens
374be41433 meson: Use meson.can_run_host_binaries()
It is not only shorter than `not meson.is_cross_build() or
meson.has_exe_wrapper()` but also handle the case of cross compiling to
a compatible arch such as building for i386 on an amd64.
2022-05-06 13:17:11 +01:00
Sebastian Dröge
0c6a1af9d6 Merge branch 'gdbus-threading-test-fix-maybe' into 'main'
tests: Reduce wakeup interval in gdbus-threading

See merge request GNOME/glib!2604
2022-04-29 08:05:52 +00:00
Sebastian Dröge
ef8e0035a5 Merge branch 'fix-gdbus-peer-object-manager-test' into 'main'
tests: Use G_TEST_OPTION_ISOLATE_DIRS in gdbus-peer-object-manager

See merge request GNOME/glib!2603
2022-04-29 08:04:33 +00:00
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
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
Philip Withnall
77416fc023 tests: Use g_assert_*() rather than g_assert() in gdbus-peer-object-manager
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-12 13:29:19 +01:00
Philip Withnall
20c3ab9e51 tests: Use G_TEST_OPTION_ISOLATE_DIRS in gdbus-peer-object-manager
This might fix a recent test failure:
https://gitlab.gnome.org/GNOME/glib/-/jobs/1929015. Unfortunately
there’s not much debug information in the logs to go on, and I can’t
reproduce it locally. All I have is:
```
192/272 glib:gio / gdbus-peer-object-manager    FAIL     0.43 s (killed by signal 11 SIGSEGV)

--- command ---
GIO_MODULE_DIR='' G_TEST_BUILDDIR='/builds/GNOME/glib/_build/gio/tests' G_TEST_SRCDIR='/builds/GNOME/glib/gio/tests' /builds/GNOME/glib/_build/gio/tests/gdbus-peer-object-manager
--- stdout ---
\# random seed: R02Seee9b7325ecd7c19249a3412397aed9b
1..2
\# Start of gdbus tests
\# Start of peer-object-manager tests
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-12 13:29:19 +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
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