Commit Graph

7909 Commits

Author SHA1 Message Date
Sonny Piers
29da935c28 Fix doc typo in g_dbus_connection_signal_subscribe 2022-11-28 11:33:09 +00:00
Philip Withnall
24e1bfba16 Merge branch 'snap-portal-support' into 'main'
portal: Check for snap plugs before accessing portals

See merge request GNOME/glib!3020
2022-11-24 19:49:07 +00:00
Marco Trevisan (Treviño)
92fae633a0 gio/tests: Add tests for flatpak infos
Support testing flatpak infos, we do it by faking /.flatpak-info file in
case we're building in test mode.
2022-11-24 20:03:39 +01:00
Marco Trevisan (Treviño)
e6eebfd9c3 gportalsupport: Force use /usr/bin/snapctl to get snap connection status
Do not search in path for snapctl to avoid it to be potentially
overridden by changing the PATH env variable.

Still allow testing by using an ifdef to check if we're building for the
test files or not.
2022-11-24 20:03:39 +01:00
Marco Trevisan (Treviño)
94ebd9f041 gio/tests/sandbox: Use test portal utils to create fake snap.yaml 2022-11-24 20:03:39 +01:00
Marco Trevisan (Treviño)
b1a2b64e94 gio/tests: Add tests for portal support functions
Test all the snap cases and the unknown sandbox one.

We need to use different test processes as we initialize the portal
type early enough that it can't be changed later.
2022-11-24 20:03:39 +01:00
Robert Ancell
216d7ba042 portal: Check for snap plugs before accessing portals
This is of particular use in the gsettings backend, which is currently using
dconf for all snaps.
Fully confined snaps should use the keyfile backend, as Flatpaks do.

Co-Authored-by: Marco Trevisan <mail@3v1n0.net>
2022-11-24 20:00:18 +01:00
Marco Trevisan (Treviño)
0e4dff445f gsandbox: Mark classic snaps as UNKNOWN sandbox type
Classic snaps are just a kind of packages with no sandbox at all, so
there's no point to mark them as sandboxed.

In this way we can just do IO checks once without having to multiply
them.

Co-Authored-by: Robert Ancell <robert.ancell@canonical.com>
2022-11-24 20:00:18 +01:00
Philip Withnall
66499d2199 Revert "build: Don’t define redundant built-in variables in pkgconfig calls"
This reverts commit 7e3e591d43.

The freedesktop SDK, which is used by gnome-build-meta, only has Meson
0.63. Bumping GLib’s Meson dependency to 0.64 means that, at the moment,
GLib is not buildable in gnome-build-meta and hence can’t be tested in
nightly pipelines against other projects, etc.

That’s bad for testing GLib.

It’s arguably bad that we’re restricted to using an older version of
Meson than shipped by Debian Testing, but that’s a separate discussion
to be had.

Revert the Meson 0.64 dependency until the freedesktop SDK ships Meson ≥
0.64. This also means reverting the simplifications to use of
`gnome.mkenum_simple()`.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3077#note_1601064
2022-11-24 12:10:03 +00:00
Philip Withnall
b4231844a2 Revert "build: Use fs.copyfile() instead of configure_file()"
This reverts commit 19353017a7.

The freedesktop SDK, which is used by gnome-build-meta, only has Meson
0.63. Bumping GLib’s Meson dependency to 0.64 means that, at the moment,
GLib is not buildable in gnome-build-meta and hence can’t be tested in
nightly pipelines against other projects, etc.

That’s bad for testing GLib.

It’s arguably bad that we’re restricted to using an older version of
Meson than shipped by Debian Testing, but that’s a separate discussion
to be had.

Revert the Meson 0.64 dependency until the freedesktop SDK ships Meson ≥
0.64. This also means reverting the simplifications to use of
`gnome.mkenum_simple()`.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3077#note_1601064
2022-11-24 12:09:55 +00:00
Philip Withnall
b646b1cab7 Revert "meson: Use gnome.mkenum_simple()"
This reverts commit 756b424cce.

The freedesktop SDK, which is used by gnome-build-meta, only has Meson
0.63. Bumping GLib’s Meson dependency to 0.64 means that, at the moment,
GLib is not buildable in gnome-build-meta and hence can’t be tested in
nightly pipelines against other projects, etc.

That’s bad for testing GLib.

It’s arguably bad that we’re restricted to using an older version of
Meson than shipped by Debian Testing, but that’s a separate discussion
to be had.

Revert the Meson 0.64 dependency until the freedesktop SDK ships Meson ≥
0.64. This also means reverting the simplifications to use of
`gnome.mkenum_simple()`.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3077#note_1601064
2022-11-24 12:06:10 +00:00
Marco Trevisan (Treviño)
660242af07 tests/sandbox: Use isolated-directories
So we don't have to bother to manually remove the created artifacts.
2022-11-24 05:38:32 +01:00
Robert Ancell
4ba188c906 portal: Rename function to not be flatpak specific
It will also read snap information
2022-11-24 05:38:32 +01:00
Simon McVittie
a241226f2e Merge branch 'gdbus-tests-isolate-dirs' into 'main'
tests: Add G_TEST_OPTION_ISOLATE_DIRS to almost all gdbus tests

See merge request GNOME/glib!3088
2022-11-23 17:20:44 +00:00
Xavier Claessens
756b424cce meson: Use gnome.mkenum_simple()
Meson now uses find_program() to get glib-mkenum from glib instead of
from system. That was already fixed at least in >=0.60 which is our
current minimum requirement.
2022-11-23 08:02:34 -05:00
Xavier Claessens
6dd5c5002a Merge branch 'wip/pwithnall/meson-0.64' into 'main'
build: Bump Meson dependency to 0.64.0

See merge request GNOME/glib!3077
2022-11-23 11:48:51 +00:00
Philip Withnall
fd27c8dc6e tests: Add G_TEST_OPTION_ISOLATE_DIRS to almost all gdbus tests
This is a spiritual follow-up to commit 8cff531520, which
added `G_TEST_OPTION_ISOLATE_DIRS` to the `gdbus-connection-flush` test
to avoid its D-Bus cookie lock file from being erroneously deleted by
other tests running in parallel.

The same failure mode could affect any of the other D-Bus tests which
connect to a bus. As an easy fix, enable `G_TEST_OPTION_ISOLATE_DIRS`
for all of them.

The only test it’s not (yet) enabled for is `gdbus-address-get-session`
as that messes around with `XDG_RUNTIME_DIR` to test finding the session
bus. It might be possible to use `G_TEST_OPTION_ISOLATE_DIRS` with it,
but that would take longer than I have right now.

In any case, the more tests (which try to connect to a bus) that this is
enabled for, the lower the chances of spurious test failure due to them
conflicting over shared resources.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-23 11:15:20 +00:00
Philip Withnall
19353017a7 build: Use fs.copyfile() instead of configure_file()
Because Meson complains about using `configure_file(copy: true)`.

Includes improvements by Xavier Claessens.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-23 10:40:32 +00:00
Philip Withnall
7e3e591d43 build: Don’t define redundant built-in variables in pkgconfig calls
This is deprecated since Meson 0.62.0, since Meson does this
automatically for us.

This fixes a Meson configure warning.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-23 10:39:58 +00:00
Marco Trevisan
291ca47bd5 Merge branch 'wait-for-nothing' into 'main'
tests: Remove a manual timeout from desktop-app-info test

See merge request GNOME/glib!3083
2022-11-22 17:58:04 +00:00
Marco Trevisan
8fba287c81 Merge branch 'wip/pwithnall/2777-zerosize' into 'main'
gio: Change content type of zero-sized files to application/x-zerosize

Closes #2777

See merge request GNOME/glib!3053
2022-11-22 17:52:47 +00:00
Philip Withnall
ebfbd9c56a tests: Remove a manual timeout from desktop-app-info test
It sometimes fails under valgrind, and is pointless: if the test is
wedged, it’s better to catch that with the timeout at the level of
`meson test`, which can be tailored (using `-t`) to the test environment
and wrapper.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2961#note_1600072

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-22 16:11:49 +00:00
Philip Withnall
0781e12f45 tests: Add additional assertions to gsubprocess test
This should quell a scan-build warning about passing `NULL` to
`strlen()`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-18 16:34:06 +00:00
Philip Withnall
5f51cc844c gapplicationcommandline: Fix a minor typo in the documentation
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-16 10:12:05 +00:00
Philip Withnall
fec865cb0c gapplicationcommandline: Add a missing transfer annotation
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-16 10:12:05 +00:00
Philip Withnall
73f445b099 tests: Add some missing error checks to actions test
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-16 10:12:05 +00:00
Philip Withnall
b836ed5c13 tests: Stop using GMainLoop in actions test
Instead, iterate the `GMainContext` directly. This allows tests on
asynchronously returned values to be done in the actual test function,
rather than a callback, which should make the tests a little clearer.

This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-16 10:12:05 +00:00
Philip Withnall
19eee4bc41 gtestdbus: Use g_timeout_add_seconds() rather than g_timeout_add()
This makes the code a little easier to understand and allows the kernel
a little bit more leeway in scheduling the callback, which is fine
because we don’t need high accuracy here.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-16 10:12:05 +00:00
Philip Withnall
e8c068db50 gnotificationbackend: Fix a GDBusConnection leak
`g_notification_backend_new_default()` adds a reference on
`backend->dbus_connection` (if non-`NULL`), but nothing ever unreffed
that.

Fix that by adding a dispose method.

In practice this is not really a problem, because the notification
backend is held alive by a `GApplication`, which lives as long as the
process. It’ll be a problem if someone is to ever add unit tests for
`GNotificationBackend`s though. So let’s fix it.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-16 10:12:05 +00:00
Philip Withnall
683c7d05a3 gnotification: Fix a couple of minor typos in a documentation comment
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-16 10:12:05 +00:00
Philip Withnall
18574d1ba9 gnotification: Improve docs around GVariant ownership
Add a few missing introspection annotations too.

This doesn’t change any of the ownership handling behaviour, just
documents what’s there. What’s there seems to be correct, to the extent
that I can see.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-16 10:12:05 +00:00
Philip Withnall
af6bf2dc02 ggtknotificationbackend: Fix a minor typo in a comment
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-15 17:59:36 +00:00
Philip Withnall
716189c4c7 gfdonotificationbackend: Improve internal docs around floating GVariants
The code is correct, but from a quick read-through it wasn’t entirely
clear to me how it handled floating `GVariant`s in object state or the
`parameter` argument.

Add an assertion and some comments to hopefully clarify things a little.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-15 17:59:36 +00:00
Philip Withnall
d470e7227a gaction: Improve documentation around floating GVariants
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-15 17:59:36 +00:00
Philip Withnall
4748db5fd3 gaction: Improve docs formatting for g_action_parse_detailed_name()
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-15 17:59:36 +00:00
Philip Withnall
5ac06ac8ea gaction: Add missing annotations to g_action_parse_detailed_name()
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-15 17:59:36 +00:00
Philip Withnall
55c1fc7dfc Merge branch 'wip/smcv/hidden-inotify' into 'main'
gio: Use hidden symbol visibility in static libraries

Closes #2811

See merge request GNOME/glib!3069
2022-11-14 13:21:51 +00:00
Alexander Kanavin
a9fa7589c6 tests: Work around Meson bug with using exe_wrapper
Do not use can_run_host_binaries() as it returns true even though
custom_target() does not currently correctly wrap target-built
tool binaries with exe_wrapper so they can be run on the host.

See https://github.com/mesonbuild/meson/issues/11029
2022-11-14 13:01:47 +00:00
Simon McVittie
c1ee1a99bc gio: Use hidden symbol visibility in static libraries
Building GLib 2.75.0 on Linux adds various inotify-related internal
symbols to the ABI, which doesn't seem to have been intentional.
I went through the other libraries in the build system, and it looks
as though the BSD kqueue backend would have the same problem.

GNU symbol visibility probably doesn't do anything for gio/win32, but
for completeness I've set that to use hidden symbols too, on the basis
that it'll be easier to get this right if we're consistent.

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/2811
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-14 12:36:22 +00:00
Xavier Claessens
b65d6f497d gio: Fix missing visibility header dependency 2022-11-12 10:20:49 -05:00
Philip Withnall
9b68c31b38 tests: Add a missing g_task_return_boolean() in gdbus-server-auth tests
Otherwise the task never returned a value.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/385

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-10 14:25:47 +00:00
Philip Withnall
fe89940572 gtask: Emit a debug message if a GTask is finalised without returning
This typically indicates a bug in the program, where a GTask has been
created, but a bug in the control flow has caused it to not return a
value.

There is one situation where it might be legitimate to finalise a GTask
without returning: if an error happens in your *_async() start function
after you’ve created a GTask, but before the async operation returns to
the main loop; and you report the error using g_task_report_*error()
rather than reporting it using the newly constructed GTask.

Another situation is where you are just using GTask as a convenient way
to move some work to another thread, without the complexity of creating
and running your own thread pool. GDBus does this with
g_dbus_interface_method_dispatch_helper(), for example.

In most other cases, it’s a bug. Emit a debug message about it, but not
a full-blown warning, as that would create noise in the legitimate
cases.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2022-11-10 14:25:47 +00:00
Ray Strode
4a00ac91c6 tests: Shorten internal codegen test timeout
the gio dbus codegen test has 10 test cases in it.
Each test case is given 100 seconds to complete.

That is far longer than they should need.

Furthermore, the entire test is only given 60s
to complete.

This commit makes the internal timeout more consistent
with the external timeout, by giving each of the 10
test cases 6 seconds instead of 100s.
2022-11-08 13:08:53 -05:00
Philip Withnall
e2b9e28ece Merge branch 'wip/3v1n0/meson-fix-tests-binary-dependencies' into 'main'
test/meson: Add tests dependencies on built programs, libraries and modules

See merge request GNOME/glib!3015
2022-11-08 12:30:53 +00:00
Philip Withnall
42c9e8218b gio: Change content type of zero-sized files to application/x-zerosize
That’s what xdgmime uses for zero-sized files (see `XDG_MIME_TYPE_EMPTY`).

Historically, GLib explicitly used `text/plain` for empty files, to
ensure they would open in a text editor. But `text/plain` is not really
correct for an empty file: the content isn’t text because there is no
content. The file could eventually become something else when written
to.

Text editors which want to be opened for new, empty files should add
`application/x-zerosize` to their list of supported content types.

Users who want to set a handler for `application/x-zerosize` on their
desktop should use
```sh
gio mime application/x-zerosize  # to see the current handler
gio mime application/x-zerosize org.gnome.gedit.desktop  # to set it
```

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

Fixes: #2777
2022-11-07 13:21:28 +00:00
Philip Withnall
5af339aedf gio: Check __APPLE__ in a few places instead of HAVE_COCOA
`HAVE_COCOA` should be used only in the places where we’re actually
depending on the Cocoa toolkit. It should not be used as a general way
of detecting building on a Darwin-based OS such as macOS.

Conversely, there are a few places in the code where we do want to
specifically detect the Cocoa toolkit (and others where we specifically
want to detect Carbon), so keep `HAVE_COCOA` and `HAVE_CARBON` around.

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

Helps: #2802
2022-11-07 11:30:32 +00:00
Philip Withnall
7b52ccbfc4 Revert "gio, glib: Use G_OS_DARWIN for code that is for such environments"
This reverts commit 476e33c3f3.

We’ve decided to remove `G_OS_DARWIN` in favour of recommending people
use `__APPLE__` instead. As per the discussion on #2802 and linked
issues,
 * Adding a new define shifts the complexity from “which of these
   platform-provided defines do I use” to “which platform-provided
   defines does G_OS_DARWIN use”
 * There should ideally be no cases where a user of GLib has to use
   their own platform-specific code, since GLib should be providing
   appropriate abstractions
 * Providing a single `G_OS_DARWIN` to cover all Apple products (macOS
   and iOS) hides the complexity of what the user is actually testing:
   are they testing for the Mach kernel, the Carbon and/or Cocoa user
   space toolkits, macOS vs iOS vs tvOS, etc

Helps: #2802
2022-11-07 11:30:32 +00:00
Michael Catanzaro
24f2cfba25 gtask: don't use g_task_set_static_name() unless allowed
Need to check GLIB_VERSION_MIN_REQUIRED before inlining use of something
newer.

Fixes #2805
2022-11-03 19:06:40 -05:00
Simon McVittie
32b0dd24e3 Add a SPDX LicenseRef for the license historically used for tests
Some of GLib's unit tests are under an apparently GLib-specific
permissive license, vaguely similar to the BSD/MIT family but with the
GPL's lack-of-warranty wording. This is not on SPDX's list of
well-known licenses, so we need to use a custom license name prefixed
with LicenseRef if we want to represent this in SPDX/REUSE syntax.

Most of the newer tests seem to be licensed under LGPL-2.1-or-later
instead.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-02 12:34:19 +00:00
Philip Withnall
7ee767213b Merge branch 'mcatanzaro/#2799' into 'main'
gproxyresolver: lookup_finish() should better parallel lookup_async()

Closes #2799

See merge request GNOME/glib!3045
2022-11-02 09:47:32 +00:00