Commit Graph

26259 Commits

Author SHA1 Message Date
Thomas Haller
d5dc7d266f gstdio: fail assertion in g_close() for invalid file descriptor (EBADF)
An application must keep track of the file descriptors that it
has. Closing an invalid, non-negative file descriptor is usually
a bug, because it indicates somebody messed up the tracking.

On a single threaded application it may be fine, but EBADF is always a bug
in a multi threaded application because another thread might race
reusing the bad file descriptor. With GDBus and other glib API, it is very
common that your application has multiple threads running and this is
in fact a bug.

The assertion failure does not necessarily indicate that the bug
is in the caller. It could have been another part of the application
that wrongly closed the file descriptor.
2022-10-18 13:57:14 +01:00
Emmanuele Bassi
52917f57ca Merge branch 'wip/pwithnall/2781-desktop-app-info-proc-bsd' into 'main'
tests: Temporarily disable desktop-app-info terminal test on FreeBSD

See merge request GNOME/glib!2972
2022-10-18 12:33:20 +00:00
Philip Withnall
47ab384fd9 Merge branch 'leaks' into 'main'
Fix GIOModule regression from !2959

See merge request GNOME/glib!2970
2022-10-18 11:06:40 +00:00
Marc-André Lureau
d95cf75bf0 gio/module: ignore module leak
A module must exist forever after it is loaded. If it's not referenced
anywhere, as with some gio tests, ASAN will report direct leaks. Silence
those.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-18 14:31:31 +04:00
Philip Withnall
3235eee0e2 tests: Temporarily disable desktop-app-info terminal test on FreeBSD
It’s often (but not always) failing on the CI machines with a timeout
which looks like the FD sharing via `/proc` isn’t reliably working.

Disable this test (but not the whole `desktop-app-info` test suite) on
FreeBSD until someone who has access to a FreeBSD machine can debug it.

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

Helps: #2781
2022-10-18 10:35:17 +01:00
Marc-André Lureau
3967d1da56 Revert "gio/module: fix leak when there is no cache"
This reverts commit ad0fd6c5d9.

The type system actually keeps a weak reference on the module/plugin.
g_type_module_unuse() documentation is explicit "Once a #GTypeModule is
initialized, it must exist forever."

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-18 10:53:38 +04:00
Philip Withnall
1c42e2da25 tests: Fix minor race in desktop-app-info terminals test
The implementation of `g_desktop_app_info_launch_uris()` will spawn the
exec file once for each URI unless the desktop file has a placeholder in
its Exec line which supports multiple URIs at once.

The fake terminal doesn’t have such a placeholder, so the fake terminal
script is spawned twice in quick succession, once for each URI. Since it
was making two separate printf calls (one to print the output to the
pipe, and one to terminate it with a newline), it’s possible that two
invocations of the script could interleave their printf calls, resulting
in pipe input along the lines of `URI1 URI2 newline newline` rather than
`URI1 newline URI2 newline`.

This would cause the test to fail.

Fix that by making the script atomic by moving the newline into the
first printf call.

See: https://gitlab.gnome.org/GNOME/glib/-/jobs/2339109:
```
\# Fake 'nxterm' terminal created as: /tmp/bin-path-R6GWT1/nxterm
\# 'nxterm' called with arguments: '-e true nxterm-argument /tmp/bin-path-R6GWT1-e true nxterm-argument /tmp/test_desktop-app-info_CO92T1/desktop-app-info/launch-uris-with-terminal/nxterm/.dirs/data'
Bail out! GLib-GIO:ERROR:../gio/tests/desktop-app-info.c:1294:test_launch_uris_with_terminal: assertion failed (g_strv_length (output_args) == 4): (7 == 4)
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-10-17 17:40:53 +01:00
Philip Withnall
eef6ea9b3b Merge branch '2726-fuse-remote' into 'main'
glocalfile: Support marking fuse.sshfs filesystems as remote

Closes #2726

See merge request GNOME/glib!2966
2022-10-17 16:17:30 +00:00
Philip Withnall
2715e91ee9 Merge branch 'fix-visibility' into 'main'
Fix include order of glib-visibility.h

See merge request GNOME/glib!2957
2022-10-17 16:15:40 +00:00
Philip Withnall
ea33d941d3 Merge branch '2622-srv-records' into 'main'
gthreadedresolver: Comment on name expansion for SRV targets

Closes #2622

See merge request GNOME/glib!2962
2022-10-17 16:13:53 +00:00
Philip Withnall
a55c0dc403 Merge branch '2754-sort-locale' into 'main'
tests: Don’t rely on output locale of sort in spawn-test

Closes #2754

See merge request GNOME/glib!2943
2022-10-17 16:12:46 +00:00
Philip Withnall
bcb5eee0ea glocalfile: Support marking fuse.sshfs filesystems as remote
This requires checking the type of a filesystem using `/proc/mounts`
rather than `statfs()`, since `statfs()` doesn’t give the subtype of the
mount. So it only returns `fuse` rather than `fuse.sshfs`.

This commit changes the output of `gio info -f ./path/to/local/sshfs/mount`
from `filesystem::remote: FALSE` to `filesystem::remote: TRUE`.

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

Fixes: #2726
2022-10-17 16:05:58 +01:00
Xavier Claessens
0db49cc57b Fix include order of glib-visibility.h
It uses macros from glibconfig.h, gmacros.h and gversionmacros.h, makes
sure it is included after them.
2022-10-17 15:17:32 +02:00
Philip Withnall
360fc4cda3 tests: Don’t rely on output locale of sort in spawn-test
Otherwise the test will fail when run in a non-English locale.

Fix suggested by Simon McVittie.

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

Fixes: #2754
2022-10-17 13:51:34 +01:00
Emmanuel Fleury
c7f24df744 Check for prefix/suffix smaller than string and check for non-inlined function
* Add a test to check that smaller string than prefix/suffix are
  handled in g_str_has_*() functions.

* Add a tests on macro prefixed function and ensure that function
  itselves are tested as well.
2022-10-17 14:40:32 +02:00
Emmanuel Fleury
bbd3ad8c00 Optimize g_str_has_*() functions to detect const arguments at compile-time
Compilers can emit optimized code for str|strn|mem)cmp(str,"literal")
at compile-time. This commit use the preprocessor to introduce this
kind of optimization for the functions g_str_has_prefix() and
g_str_has_suffix().

Original work by Ben @bdejean

Closes issue #24
2022-10-17 14:40:31 +02:00
Philip Withnall
06ff700ad8 tests: Fix checks for line endings in spawn-test on Windows
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-10-17 13:06:36 +01:00
Philip Withnall
be9e268c6a tests: Use g_assert_*() rather than g_assert() in unix-streams
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-10-17 13:03:26 +01:00
Philip Withnall
0c1fa95827 tests: Fix race condition on cancellation in unix-streams test
The cancellable may be cancelled just after the operation succeeds in a
different thread. So instead of checking whether the cancellable is
cancelled, check whether the operation returned a `CANCELLED` error, and
*then* assert that the cancellable is cancelled.

This should fix
https://pwithnall.pages.gitlab.gnome.org/-/glib/-/jobs/2338552/artifacts/_build/meson-logs/testlog.txt:
```
ok 1 /unix-streams/basic
Bail out! GLib-GIO:ERROR:../gio/tests/unix-streams.c:149:main_thread_skipped: assertion failed (err == (g-io-error-quark, 19)): err is NULL
stderr:
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-10-17 13:02:02 +01:00
Philip Withnall
09459fa44d gthreadedresolver: Comment on name expansion for SRV targets
See the commit contents. This clarifies the existing code’s behaviour
and doesn’t change it.

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

Fixes: #2622
2022-10-17 12:46:01 +01:00
Philip Withnall
b7f2b09c30 Merge branch 'leaks' into 'main'
Some leaks fixes

See merge request GNOME/glib!2959
2022-10-17 10:46:52 +00:00
Marc-André Lureau
ad0fd6c5d9 gio/module: fix leak when there is no cache
GIOModule is a helper object, we keep it around when there is a cache,
but we should free it otherwise.

Found thanks to ASAN.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-17 14:32:15 +04:00
Marc-André Lureau
60b8916fee tests/gmenumodel: fix various leaks
Found thanks to ASAN.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-17 14:11:36 +04:00
Philip Withnall
292c117b98 Merge branch 'w32-tests' into 'main'
Various win32 test fixes

See merge request GNOME/glib!2952
2022-10-17 09:53:44 +00:00
Marc-André Lureau
8c0fa77a71 tests/gobject-query.py: make it work on msys2/win32
For unclear reasons, universal_newlines=True doesn't seem to set the
text encoding correctly. Even if I set only encoding='utf-8', the test
fails. The combination here works for me, \o/.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-17 11:01:53 +04:00
Marc-André Lureau
fdfe94fb16 tests/gobject-query: it is not a script (anymore?)
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-17 11:01:51 +04:00
Marc-André Lureau
30e7a00017 tests/contenttype: icon name text/plain doesn't have text-x-generic on win32
The g_content_type_get_icon() function for win32 can lookup the
DefaultIcon associated with .txt and return a different result.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-17 11:01:00 +04:00
Marc-André Lureau
99847d36ed tests/thread-pool-slow: do not pass confusing value to sort function
That value isn't used by the callback.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-17 10:56:24 +04:00
Marc-André Lureau
2df5acf60a tests/thread-pool-slow: change num-threads limit check
There is no guarantee that the thread pool will reach its limit afaict,
it depends how the system schedule the various threads. This fixes
random test failure on win32.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-17 10:55:05 +04:00
Marc-André Lureau
f23d8a9087 gio/locafileinfo: fix set_mtime_atime on win32
Use a similar behaviour as the utime()/posix implementation and query
the current times to allow modifying only usec/nsecs parts.

Fixes tests/g-file-info on win32.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-17 10:52:11 +04:00
Marc-André Lureau
52a49eb9c2 tests/assert-msg-test: fix opening temporary file in GDB
On Win32, the file cannot be opened a second time, it must be closed
first.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-17 10:49:19 +04:00
Marc-André Lureau
6dcd7fe5e8 tests/assert-msg-test: abort() exit code is 3 on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-17 10:45:06 +04:00
Marc-André Lureau
0a4dc17f28 tests/assert-msg-test: it is not a script (anymore?)
Fixes running the program on win32.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-17 10:45:01 +04:00
Marc-André Lureau
789fd5dfc0 tests/assert-msg-test: add exe extension on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-17 10:45:00 +04:00
Marc-André Lureau
c3494ce5dc tests/file-thumbnail: make it work with win32 paths
On Win32, we get paths with mixed \\ and /, use GFile to resolve and
normalize the paths before comparing.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-17 10:43:59 +04:00
Philip Withnall
5215463a03 Merge branch 'wip/chergert/g_set_str' into 'main'
strfuncs: add g_set_str()

Closes #2747

See merge request GNOME/glib!2927
2022-10-15 22:30:18 +00:00
Philip Withnall
4bc284fca6 Merge branch 'wip/smcv/deprecated-prop-followup' into 'main'
Run tests with G_ENABLE_DIAGNOSTIC=1

See merge request GNOME/glib!2889
2022-10-15 21:31:29 +00:00
Philip Withnall
9daa0b60c0 Merge branch 'ebassi/object-allocator' into 'main'
Use the system allocator on UNIX when creating GTypeInstances

See merge request GNOME/glib!2799
2022-10-15 20:20:26 +00:00
Emmanuele Bassi
2bf3b7c314 Merge branch 'fix-style-check' into 'main'
tools: Fix code style warnings in gen-visibility-macros.py

See merge request GNOME/glib!2954
2022-10-14 17:55:42 +00:00
Philip Withnall
f8981e9b49 tools: Reformat gen-visibility-macros.py with black
This satisfies the style-check CI job.
2022-10-14 18:15:25 +01:00
Philip Withnall
24aaff658b tools: Disable line length flake8 warnings in gen-visibility-macros.py
It contains a lot of C templates, and line wrapping them to satisfy
`flake8` would make them unreadable.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-10-14 18:15:12 +01:00
Philip Withnall
552e01e177 Merge branch 'bookmarkfile-copy' into 'main'
gbookmarkfile: Add copy function and define it as boxed type for introspection

See merge request GNOME/glib!2942
2022-10-14 16:54:38 +00:00
Marco Trevisan (Treviño)
60c935a9c4 gboxed: Add GBookmarkFile as Boxed types
Now that we've a copy function we can define it as a boxed type, making
it fully introspectable.
2022-10-14 16:40:56 +01:00
Marco Trevisan (Treviño)
2e8375daa0 gbookmarkfile: Add copy function
GBookmarkFile has everything for being introspectable, but it lacks a
GType, because it can't be copied. So provide a copy function that
deeply copies all the bookmark structures.

Add tests for this.
2022-10-14 16:39:20 +01:00
Marco Trevisan (Treviño)
5f604460ef gbookmarkfile: Do not try to write invalid modified stamp
In some bookmarks that we load the modified value may be not set, while
this may lead to a load error, we still can dump such file and this
would fail as we try to get a string from an invalid time.

Avoid this, because it would also lead to not writing a valid count
value, given that we'd pass NULL to g_strconcat too early.
2022-10-14 16:39:20 +01:00
Philip Withnall
870fc6763e Merge branch 'mcatanzaro/plain-build-cast-checks' into 'main'
Disable cast checks in plain builds

See merge request GNOME/glib!2894
2022-10-14 15:34:22 +00:00
Michael Catanzaro
631e99667e Disable cast checks in plain builds 2022-10-14 15:34:22 +00:00
Philip Withnall
1e9cf21b30 Merge branch 'desktop-app-info-terminal-tests' into 'main'
tests/desktop-app-info: Add tests to verify if launching with terminal works

See merge request GNOME/glib!2884
2022-10-14 15:30:04 +00:00
Philip Withnall
6fab8a8cd9 Merge branch 'macos-gio-modules' into 'main'
giomodule: Automatically detect modules on macOS

See merge request GNOME/glib!2848
2022-10-14 15:29:04 +00:00
Philip Withnall
f946e45a0c Merge branch 'mcatanzaro/cast-checks' into 'main'
Automatically disable cast checks when building with optimization

See merge request GNOME/glib!2850
2022-10-14 15:26:35 +00:00