Commit Graph

26749 Commits

Author SHA1 Message Date
Marco Trevisan
113d7263c6 Merge branch 'wip/pwithnall/more-macos-test-fixes' into 'main'
tests: Fix incorrect basename comparison in gsubprocess test

See merge request GNOME/glib!2785
2022-06-28 01:26:31 +00:00
Peter Bloomfield
8a43ae71c8 dataset: Document some logic
Add comments to clarify how the 'old' array is allocated and used.
2022-06-27 17:53:25 -04:00
Peter Bloomfield
8bd63258a5 dataset: Improve readability
Improve the readability by using a temporary variable
2022-06-27 17:42:11 -04:00
Michael Catanzaro
8e29865112 gproxyresolver: add asserts to ensure error is set
This will catch buggy implementations of GProxyResolver before they are
able to return bogus results to higher level code. In particular, if
g_proxy_resolver_lookup() returns NULL, it'd better set an error to
explain why.
2022-06-27 15:10:25 -05: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
6f83f45db4 gsimpleproxyresolver: ensure default proxy is valid
It should be either a valid URI, or NULL. Passing empty strings or other
invalid URIs is no bueno.
2022-06-27 14:23:51 -05:00
Michael Catanzaro
8a1f087a31 gsimpleproxyresolver: default_proxy should be consistently nullable
Currently it's nullable in g_simple_proxy_resolver_new(), but not in
g_simple_proxy_resolver_set_default_proxy() nor the property. Fix these.
2022-06-27 14:23:51 -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
03ea524188 ci: Add libpcre2 dependencies and subproject
This is in preparation for porting `GRegex` to libpcre2, which is
happening in !2529. It’s a big port, though, and specially rebuilding
the CI images to add libpcre2 for it is a pain.

Add libpcre2, and then !2529 can drop the old libpcre dependencies when
the port lands.

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

Helps: #1085
2022-06-27 15:53:55 +01:00
Philip Withnall
5e00b30a29 ci: Add gdb to some CI images
This will be useful in general, for manually debugging failures if we
need (without having to rebuild the CI images to do so).

It will also be useful for the `assert-msg-test` test, which is being
reworked in !2767.

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

Helps: #1434
2022-06-27 15:53:55 +01: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
6d381c9668 Merge branch 'getfsent_lock' into 'main'
Add lock in _g_get_unix_mount_points() around *fsent() functions

See merge request GNOME/glib!1717
2022-06-27 11:20:49 +00:00
Philip Withnall
3c47fa6e20 Merge branch 'getfsent_lock2' into 'main'
_g_get_unix_mount_points(): reduce syscalls inside loop

See merge request GNOME/glib!2783
2022-06-27 11:14:01 +00:00
Philip Withnall
eec8171dab Merge branch 'wip/smcv/more-figure-spaces' into 'main'
gdatetime test: Consistently expect %k to generate a figure space

See merge request GNOME/glib!2773
2022-06-27 11:09:26 +00:00
Simon McVittie
6a599e0349 gdatetime test: Consistently expect %k to generate a figure space
This part of test_non_utf8_printf() was missed while converting other
test expectations to look for a figure space, probably because it is
only run if a legacy ja_JP.eucjp locale exists. Debian generates a fairly
comprehensive set of locales (including some that are non-UTF-8) while
running GLib's installed-tests, so this was caught by CI.

Fixes: 7074122 "gdatetime: Pad numbers with numeric space"
Signed-off-by: Simon McVittie <smcv@debian.org>
2022-06-27 09:29:35 +01:00
Michael Catanzaro
6e81c21a8b Merge branch 'wip/smcv/revert-fa8c7c0d' into 'main'
Revert "gobject: Use g_datalist_id_remove_multiple"

See merge request GNOME/glib!2784
2022-06-26 17:16:51 +00:00
Simon McVittie
d4043eced5 Revert "gobject: Use g_datalist_id_remove_multiple"
This reverts commit fa8c7c0 "gobject: Use g_datalist_id_remove_multiple"
(or more specifically the parts of it that were not already reverted
in 01ac1d9 "gobject: Fix crash when disposing a GtkAccelGroup".

Workaround for https://gitlab.gnome.org/GNOME/glib/-/issues/2676

Bug: https://gitlab.gnome.org/GNOME/glib/-/issues/2676
2022-06-26 18:00:52 +01:00
Aleksandr Melman
f3838e517b Update Russian translation 2022-06-25 18:40:19 +00:00
Rozhuk Ivan
f43cf34151 [PATCH] Add lock in _g_get_unix_mount_points() around *fsent() functions 2022-06-25 19:22:06 +03:00
Rozhuk Ivan
02d0d6497b [PATCH] _g_get_unix_mount_points(): reduce syscalls inside loop 2022-06-25 19:01:30 +03:00
Simon McVittie
99a7c6351c Merge branch 'wip/pwithnall/more-macos-fixes' into 'main'
tests: Fix macOS failures in the file tests

See merge request GNOME/glib!2779
2022-06-25 10:23:49 +00: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
dbdc9ca995 gosxappinfo: Correctly return an error from create_from_commandline()
Creating a `GAppInfo` from a commandline isn’t currently supported on
macOS, but the implementation was incorrectly returning `NULL` without
setting the `GError`.

This was being caught by the new tests in `gio/tests/file.c`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-24 12:27:45 +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
Yuri Chornoivan
468e096983 Update Ukrainian translation 2022-06-24 06:36:19 +00:00
Peter Bloomfield
e95a6bdd7d glib/tests/dataset: Use existing code
`destroy_index` duplicates `destroy_count`, and `foreach_func()`
essentially duplicates `notify()`.
2022-06-23 21:08:41 -04:00
Peter Bloomfield
a437a97ffd dataset: Rename i as destroy_index and move it out of destroy_func(), so that it can be checked to confirm that destroy_func() was called three times. 2022-06-23 22:17:13 +00:00
Peter Bloomfield
42826576a8 glib/tests/dataset: Test id_remove_multiple
Test that destroy-funcs are called in the order that the keys are
specified, not the order that they are found in the datalist.

Helps https://gitlab.gnome.org/GNOME/glib/-/issues/2672
2022-06-23 17:41:55 -04:00
Peter Bloomfield
a4fa456e67 gdataset: Preserve destruction order
In `g_data_remove_internal()`, call the `GDataElt:destroy` functions in the
order that they appear in `keys`, instead of the order that they are found in
`datalist`.

Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/2672
2022-06-23 17:41:55 -04:00
Peter Bloomfield
ac113c1ed2 In test_datalist_id_remove_multiple(), verify that the data list contains 3 items before calling g_datalist_id_remove_multiple(). 2022-06-23 17:41:55 -04:00
Peter Bloomfield
ad0f7199f1 glib/tests/dataset: Add a test
Test that `g_datalist_id_remove_multiple()` removes all the keys it is given.

Helps https://gitlab.gnome.org/GNOME/glib/-/issues/2672
2022-06-23 17:41:55 -04:00
Peter Bloomfield
8c4598aab3 dataset: Do not increment
Do not increment the `data` pointer when it points to an item that has
not been inspected.

Helps https://gitlab.gnome.org/GNOME/glib/-/issues/2672
2022-06-23 17:41:55 -04:00
Hugo Carvalho
44bb5c26fc Update Portuguese translation 2022-06-23 21:39:02 +00:00
Philip Withnall
ac898b8e67 Merge branch 'fix-macos-again' into 'main'
tests: Fix type mismatches in new atomic tests when compiling with clang

See merge request GNOME/glib!2774
2022-06-23 18:44:13 +00:00
Marco Trevisan (Treviño)
00f3f0d407 gthread: Use atomic pointer exchange to check value set on g_init_leave 2022-06-23 20:01:12 +02:00
Marco Trevisan (Treviño)
2c322f2a65 gmain: Do atomic addition before checking the old value on ref
So we avoid working on a value that is not been updated yet.
2022-06-23 20:01:12 +02:00
Marco Trevisan (Treviño)
bfd77693ce gresource: Use atomic pointer exchange operations to nullify and check 2022-06-23 20:01:12 +02:00
Marco Trevisan (Treviño)
9c32cfbaaa gfileattribute: Do atomic addition before checking the old value on ref
So we avoid working on a value that is not been updated yet.
2022-06-23 20:01:12 +02:00
Marco Trevisan (Treviño)
576e5f2f87 cancellable: Use more atomic exchanges operations
We used to do get and set atomic operations pair, but these may be
unsafe in some cases as threads may rely on data that is changed in
in between them, however this is not a problem if we do exchange the
pointers.

So just use exchange ops, in this way we can avoid lock/unlock mutex
dances
2022-06-23 20:01:12 +02:00
Marco Trevisan (Treviño)
920f54e795 gatomicarray: Use atomic exchange for data value
We can use pointer exchange now to avoid doing two operations to switch
to the new data pointer.

Since we're asserting in case of invalid data, we can just do this check
at later point, without involving any different behavior.

This changes in the unlikely case that G_DISABLE_ASSERT is defined, as in such
case we should undo the operation.
2022-06-23 20:01:12 +02: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
b5231ed003 Merge branch 'gthread-initial-cleanups' into 'main'
gthread: Some code cleanups and fixes

See merge request GNOME/glib!2775
2022-06-23 17:07:09 +00: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
Marco Trevisan (Treviño)
8d98617297 gthread-posix: Use named states to manage the mutex states
We used to use raw numbers to control the mutex state, we can use a
nicer enum to avoid dealing with pure numbers.
2022-06-23 17:50:12 +02:00
Marco Trevisan (Treviño)
15d2053122 glib/tests/autoptr: Also ensure that GRecMutexLocker can re-lock a mutex
It's native in the actual GRecMutex, but better to check that again.
2022-06-23 17:48:44 +02:00
Marco Trevisan (Treviño)
e2d2db6433 glib/tests/autoptr: Release the acquired locks on GRecMutex 2022-06-23 17:48:44 +02:00
Marco Trevisan (Treviño)
9dffecf5f5 gthread: Fix Since tag typo in documentation for some methods 2022-06-23 17:45:04 +02:00
Philip Withnall
35c4b640bb tests: Fix type mismatches in new atomic tests when compiling with clang
Clang seems to apply more rigorous type checks across the different
arguments to the atomic builtins. Fix various
`-Wincompatible-pointer-types`, `-Wpointer-sign` and `-Wint-conversion`
warnings.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-23 15:56:07 +01:00