Commit Graph

2392 Commits

Author SHA1 Message Date
Philip Withnall
e46184205f tests: Use g_assert_*() rather than g_assert() in socket tests
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-18 14:23:03 +00:00
Philip Withnall
309f5384ca tests: Clear up freeing of test data in socket test
The same struct was reused across multiple tests, but without a shared
way of freeing its members. Refactor to add one.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-18 14:23:03 +00:00
Philip Withnall
91c82b046e tests: Re-format codegen.py with black
This is just the result of running `black $(git ls-files '*.py')`.

For some reason, the `sh-and-py-check` CI job didn’t run on merge
request !3751, so this non-standard formatting slipped through onto
`main`.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3754#note_1939914

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-11 16:53:44 +00:00
Philip Withnall
b96778ee43 tests: Use textwrap.dedent to indent expected strings pleasingly
This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-11 16:52:07 +00:00
Philip Withnall
b014d622ee Merge branch 'fix_new_rst_anchors' into 'main'
Fix generated RST anchors for methods, signals and properties

See merge request GNOME/glib!3751
2023-12-11 14:19:44 +00:00
Michael Olbrich
19a6742fc2 gdbusconnection: don't cache G_IO_ERROR_CANCELLED errors
It can cause failures for shared connection objects.

What can currently happen is this:
1. A user starts to asynchronously create a proxy object
2. A user starts to asynchronously create another proxy object

At this point, the asynchronous initialization for the two proxy objects
share the not yet initialized connection object.

3. While the shared connection objected is created, the user cancels the
   creation with the supplied cancellable from the fist proxy object.
4. initable_init caches the canceled error and marks the connection as
   initialized.
5. The initialization of the second proxy object fails with the same
   canceled error.

To avoid this, clear the error in this case and destroy any member
variables that may have been created before the creation was canceled.

This way, the initialization of the second proxy object will restart the
connection initialization and with probably succeed.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-12-11 14:17:14 +00:00
Philip Withnall
cecc5ef778 tests: Add more tests of header validation in D-Bus message serialisation
See the previous commit. These additions were kept in a separate commit
to make the changes to the existing tests in the previous commit
clearer.

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

Helps: #3093
2023-12-11 12:50:52 +00:00
Philip Withnall
fb60ebb0df gdbusmessage: Validate the types of all known message headers
Previously, the code only validated the types of *required* message
headers, and did not validate optional ones.

Now, the headers are validated in one step, and a subsequent step checks
whether the required ones are present.

The existing tests have been updated to match the new error message
wording. More tests will be added to test the new behaviour in a
subsequent commit.

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

Fixes: #3093
2023-12-11 12:50:52 +00:00
tytan652
605be9a1e9 tests: Add tests for gdbus-codegen generated RST
Those tests check if methods, signals and properties documentation are
properly generated.
2023-12-11 13:48:43 +01:00
Philip Withnall
e646c631b2 tests: Assert there no errors first in gdbus-test-codegen
Before checking the properties of `*_proxy`, assert that there were no
errors in constructing the proxy first. Otherwise the property checks
will crash on `NULL` pointer dereferences.

The test is still intermittently buggy somewhere, but at least this
commit will cause a relevant error message to be printed on failure.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-05 15:58:45 +00:00
Philip Withnall
96c317418a gdbusconnection: Support matching object paths with arg0 matching
GDBus has always supported matching strings with arg0 matching
(`G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_PATH`). In D-Bus 1.5, support was added
to the spec for also matching object paths. This got forgotten about and
was never added to GDBus, meaning that
`G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_PATH` won’t match against a signal arg0
of type `o`.

Fix that, and add a unit test.

To do so, we need to add a new `g_dbus_message_get_arg0_path()` API to
complement the existing `g_dbus_message_get_arg0()` API. The approach of
letting `g_dbus_message_get_arg0()` return an object-path *or* a string
would not work, as it’s also called in the implementation of
`G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE`, which must only match
string-typed arg0 values and not object-path-typed ones.

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

Fixes: #3183
2023-11-28 14:42:41 +00:00
Philip Withnall
c406c6de6b Merge branch '3148-stream-test' into 'main'
tests: Use a pipe rather than a socketpair in stream-rw_all test

Closes #3148

See merge request GNOME/glib!3691
2023-11-28 11:43:51 +00:00
Aleksandr Mezin
c03c983d94 gapplicationcommandline: add .done() method
Fixes #596
2023-11-27 14:15:36 +00:00
Philip Withnall
059618956b Merge branch 'muslc-ci' into 'main'
add muslc ci

See merge request GNOME/glib!3524
2023-11-21 14:55:29 +00:00
Ondrej Holy
30e102518a gcontenttype: Make filename valid utf-8 string before processing
The `g_content_type_guess_for_tree` function segfaults currently when
processing filenames that are not valid unicode strings. Let's use the
`g_filename_to_utf8` and `g_utf8_make_valid` functions before other
processing to prevent that.

Let's also add a test for it to avoid this in future.

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/3168
2023-11-13 12:14:01 +00:00
Pablo Correa Gómez
8901ffeffe
ci: add muslc CI 2023-11-12 15:39:14 +01:00
Philip Withnall
d59bac3f32 tests: Fix gio-tool.py test on macOS
Content types are different on macOS.

This fixes commit 9028c9bdf.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3158
2023-11-08 10:29:43 +00:00
Emmanuele Bassi
85d93fb581 Merge branch 'codegen-deps-fixes' into 'main'
meson: Add missing dependencies for utility files for gdbus-codegen

See merge request GNOME/glib!3689
2023-11-07 15:21:27 +00:00
Philip Withnall
e87f8e9c5a Merge branch '3158-info-critical' into 'main'
gio-tool-info: Fix critical warning when --attributes are specified and add basic unit tests

Closes #3158

See merge request GNOME/glib!3684
2023-11-07 14:37:11 +00:00
Philip Withnall
9028c9bdf3 gio-tool-info: Fix critical warning when --attributes are specified
When `--attributes` is specified and doesn’t include `standard::name` in
its list, `gio` would print a critical warning from the (mandatory) call
to `g_file_info_get_name()`.

Fix that by making the call to `g_file_info_get_name()` optional.

Add a unit test too.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Fixes: #3158
2023-11-07 13:51:56 +00:00
Philip Withnall
3e0a99a059 tests: Add a very basic test suite for gio-tool
It gives nowhere near full coverage, but it’s something we can build on
in future.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3158
Helps: #2950
2023-11-07 13:51:56 +00:00
Philip Withnall
077104e63b tests: Run processes under test with G_DEBUG=fatal-warnings
Modify all the similar Python test wrappers to set
`G_DEBUG=fatal-warnings` in the environment of the program being tested,
so we can catch unexpected warnings/criticals.

Adding this because I noticed it was missing, not because I noticed a
warning/critical was being ignored.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-07 13:51:56 +00:00
Philip Withnall
120e0ee649 tests: Set a default timeout value for GIO Python tests
Otherwise every test has to set one explicitly, which is a bit tedious.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-07 13:51:56 +00:00
Sergey Bugaev
6b7b211338 gio: Add G_IO_ERROR_DESTINATION_UNSET
...and map EDESTADDRREQ to it.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-11-06 15:04:01 +03:00
Philip Withnall
c37bf851e5 tests: Use g_assert_*() rather than g_assert() in stream-rw_all tests
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-02 17:49:31 +00:00
Philip Withnall
a0de4963e8 tests: Use a pipe rather than a socketpair in stream-rw_all test
The test only needs a unidirectional channel, and a pipe is sufficient
for that.

This may simplify things when running the test on Hurd; see
https://gitlab.gnome.org/GNOME/glib/-/issues/3148#note_1874198.

Additionally, set `O_NONBLOCK` on the pipe since the test seems to
expect that partial writes will succeed and that writes to a full buffer
will fail rather than block.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3148
2023-11-02 17:47:53 +00:00
Philip Withnall
1fdbc06385 meson: Add missing dependencies for utility files for gdbus-codegen
Various parts of the build (such as `objectmanager-rst-gen`) depend on
running `gdbus-codegen` after it’s been built, but they currently only
encode a dependency to the main codegen Python file and not the
supporting files. This can cause `gdbus-codegen` to fail with an
`ImportError` if the build races so that `objectmanager-rst-gen` is
built before the codegen supporting files.

Example failure here: https://gitlab.gnome.org/pwithnall/glib/-/jobs/3266471
```
FAILED: gio/tests/gdbus-object-manager-example/objectmanager-rst-gen-org.gtk.GDBus.Example.ObjectManager.Animal.rst gio/tests/gdbus-object-manager-example/objectmanager-rst-gen-org.gtk.GDBus.Example.ObjectManager.Cat.rst
/usr/bin/python3 gio/gdbus-2.0/codegen/gdbus-codegen --interface-prefix org.gtk.GDBus.Example.ObjectManager. --generate-rst objectmanager-rst-gen --output-directory gio/tests/gdbus-object-manager-example ../gio/tests/gdbus-object-manager-example/gdbus-example-objectmanager.xml
Traceback (most recent call last):
  File "/builds/pwithnall/glib/_build/gio/gdbus-2.0/codegen/gdbus-codegen", line 53, in <module>
    from codegen import codegen_main
  File "/builds/pwithnall/glib/_build/gio/gdbus-2.0/codegen/codegen_main.py", line 29, in <module>
    from . import dbustypes
  File "/builds/pwithnall/glib/_build/gio/gdbus-2.0/codegen/dbustypes.py", line 22, in <module>
    from . import utils
ImportError: cannot import name 'utils' from 'codegen' (/builds/pwithnall/glib/_build/gio/gdbus-2.0/codegen/__init__.py)
```

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-02 14:26:31 +00:00
Zander Brown
d33752b5ce
gtask: Add g_task_return_prefixed_error()
An equivalent to g_propagate_prefixed_error, but for errors sent though
GTask, allowing tasks to easily provide extra context to callers.
2023-11-02 02:55:55 +00:00
Simon McVittie
76148fc6db tests: Don't assume that sh optimizes simple commands into exec
Depending on the operating system, /bin/sh might either be bash (for
example on Fedora or Arch) or dash (for example on Debian or Ubuntu)
or some other POSIX shell.

When bash is asked to run a simple command with no shell keywords or
metacharacters, like this one, it replaces itself with the program
via execve(), but dash does not have that optimization and treats it
like any other program invocation in a larger script: it will fork,
exec the program in the child, and wait for the child in the parent.

This seems like it conflicts with sleep_and_kill() assuming that it can
use the subprocess's process ID as the sleep(1) process ID. Specifically,
if it sends SIGKILL, it will go to the sh(1) process and not the sleep(1)
child, which could result in the sh(1) process being terminated and
its sleep(1) child being leaked.

To get the bash-like behaviour portably, explicitly use the exec builtin
to instruct the shell to replace itself with sleep(1), so that the
process ID previously used for the shell becomes the process ID of the
sleep process.

This appears to resolve an intermittent hang and test timeout on Debian
machines (especially slower ones), although I'm not 100% clear on the
mechanics of how it happens.

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/3157
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-11-01 17:56:48 +00:00
Philip Withnall
a61888bceb tests: Fix dependency of test.gresource on test-generated.txt
`test-generated.txt` is listed in `test.gresource.xml`, so it needs to
be specified as a dependency in the `custom_target()` which uses
`test.gresource.xml`.

Fixes intermittent build failures like:
```
FAILED: gio/tests/test.gresource
/builds/GNOME/glib/_build/gio/glib-compile-resources --compiler=gcc --target=gio/tests/test.gresource --sourcedir=/builds/GNOME/glib/gio/tests --sourcedir=/builds/GNOME/glib/_build/gio/tests --internal ../gio/tests/test.gresource.xml
../gio/tests/test.gresource.xml: Failed to locate test-generated.txt in any source directory.
```

See !3671 and #3163.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-01 11:24:17 +00:00
Philip Withnall
9695ddfc70 Revert "gio/tests: Add test generated txt as the resources test dependency"
This reverts commit 0b9900e4e7.

The dependency was added in the wrong place: `test-generated.txt` is
needed when compiling `test.gresource`, not when compiling the test
which ultimately uses that gresource.

See !3671 and #3163.
2023-11-01 11:10:39 +00:00
Marco Trevisan (Treviño)
0b9900e4e7 gio/tests: Add test generated txt as the resources test dependency
This is required by the resources used in some tests, however we did not
depend on it so we had some random build failures:
  https://gitlab.gnome.org/3v1n0/glib/-/jobs/3253787
2023-10-27 18:41:51 +02:00
Alessandro Bono
168de73a73 meson: Improve PTRACE_O_EXITKILL presence check
The PTRACE_O_EXITKILL symbol in sys/ptrace.h is an enum member, not
a macro. The #ifdef check added to the GSubprocess test-case in
272ec5dbca will not detect it.

Use cc.has_header_symbol() to properly detect it. According to the
documentation: "Symbols here include function, variable, #define,
type definition, etc.".

Fixes: 272ec5dbca
Closes: https://gitlab.gnome.org/GNOME/glib/-/issues/3156
2023-10-26 10:54:34 +02:00
Philip Withnall
4ce58df854 build: Change configure_file() to fs.copyfile() when copy is set
Meson has preferred `fs.copyfile()` since 0.62. This fixes a set of
Meson warnings.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-10-25 11:20:36 +01:00
Philip Withnall
8629024243 tests: Skip appinfo/associations test if update-*-database not installed
If `update-desktop-database` or `update-mime-database` are not
installed, there are a few `GAppInfo` methods for modifying file
associations which will print a `g_warning()` when called. Something
like:
```
GLib-GIO-FATAL-WARNING: Failed to execute child process ‘update-desktop-database’ (No such file or directory)
```

(Example: https://gitlab.gnome.org/zamaudio/glib/-/jobs/3190053)

This will cause the appinfo/associations test to fail, as warnings are
fatal.

If that’s going to happen, skip the test. We can’t hard-depend on these
tools as they are external to GLib and only needed for a few operations.
Instead we have a soft runtime dependency on them; that should be
reflected in the tests.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3148
2023-10-22 23:34:00 +01:00
Damien Zammit
f25a9ca10c Initial test of Hurd CI - (run_tests.sh status ignored) 2023-10-18 23:33:04 +00:00
Philip Withnall
21c6ebf65b Merge branch 'wip/kabus/new-mtime' into 'main'
gio: add a file copy flag for default modification time

Closes #3140

See merge request GNOME/glib!3643
2023-10-18 14:45:49 +00:00
Philip Withnall
fa165204ae Merge branch 'fix-warnings-clang-windows' into 'main'
Fix warnings with Clang on Windows and enable --Werror in CI

See merge request GNOME/glib!3635
2023-10-16 21:29:09 +00:00
Khalid Abu Shawarib
db01c11540 gio: add tests for default modification time flag
Add test cases for the G_FILE_COPY_TARGET_DEFAULT_MODIFIED_TIME
file copy flag.
2023-10-16 18:12:49 +03:00
Emmanuele Bassi
ccc36a2fde build: Simplify MIPS test check
Make the condition more readable, and easy to extend if necessary.

Follow-up to: !3640
2023-10-16 13:11:27 +01:00
Philip Withnall
0a6e19feee Merge branch 'test5-no-mips' into 'main'
GIO/tests: skip test_resources_binary on MIPS platforms

See merge request GNOME/glib!3640
2023-10-16 12:05:06 +00:00
YunQiang Su
8105916998 GIO/tests: skip test_resources_binary on MIPS platform
There are some flavors of MIPS ABIs, such like r6 vs legacy,
nan2008 vs nan1985 etc.

The `cc -r` may not produce the correct elf binaries.
So let's skip this test for MIPS.
2023-10-16 07:20:21 -04:00
Philip Withnall
481839c190 Merge branch 'win32-unicode-api' into 'main'
Windows: Compile with the UNICODE / _UNICODE macros

See merge request GNOME/glib!3623
2023-10-16 08:58:41 +00:00
Luca Bacci
8264b13737 tests/cxx: Do not assume that NULL is a pointer type starting with C++11
Many toolchain did not change the definition of NULL to avoid introducing
breaking changes in existing codebases. For example, on Windows NULL is
0 (int) regardless of the C++ standard in use.

Fixes the following warnings on CLang when compiling for Windows:

  ../glib/glib/tests/cxx.cpp:539:34: warning: missing sentinel in function call [-Wsentinel]
    g_test_init (&argc, &argv, NULL);
                                   ^
                                   , nullptr
  ../glib/glib/gtestutils.h:298:9: note: function has been explicitly marked sentinel here
  void    g_test_init                     (int            *argc,
          ^

  ../glib/gio/tests/cxx.cpp:62:34: warning: missing sentinel in function call [-Wsentinel]
    g_test_init (&argc, &argv, NULL);
                                   ^
                                   , nullptr
  ../glib/glib/gtestutils.h:298:9: note: function has been explicitly marked sentinel here
  void    g_test_init                     (int            *argc,
          ^
2023-10-12 11:45:03 +02:00
Luca Bacci
337912072a Windows: Compile with the UNICODE / _UNICODE macros
It's the recommended way to build C/C++ projects on Windows, see
https://learn.microsoft.com/en-us/windows/win32/intl/conventions-for-function-prototypes
2023-10-12 11:32:03 +02:00
Philip Withnall
57b41b8fec Merge branch 'g-once-enter-ptr' into 'main'
gthread: introduce g_once_init_{enter,leave}_pointer

See merge request GNOME/glib!3577
2023-10-04 22:22:54 +00:00
Alex Richardson
5ecd3cbe52 gobject: use g_once_init_enter_pointer for GType initializers
GType is either an integer or a pointer, so we have to use the _pointer
version here to support architectures such as Morello.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
See also: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3578
2023-10-04 14:50:54 +01:00
Philip Withnall
e00ca9967f tests: Drop unnecessary include from gsubprocess-testprog.c
It’s not actually needed on any platform, and causes compilation
problems on platforms where it’s not available.

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

Fixes: #3111
2023-10-04 10:06:37 +01:00
Florian Müllner
794b18df34 gdesktopappinfo: Do not search Comment field
The Comment field provides a user-visible description of the app,
which usually contains generic words ("and", "or", "not", "is", ...)
that add noise when used for search.

It made some sense to match against the field as a fallback for
Keywords, before that key was well established. However that key
has been around for years now, so hopefully every app where additional
terms are helpful uses it by now.

With that, the downside of added noise outweighs the benefit, so
it's time to stop matching on comments.
2023-10-03 14:05:27 +02:00
Philip Withnall
c1528778e6 Merge branch 'fix_3116' into 'main'
glocalfileinfo: Preserve microseconds for access/modify times

Closes #3116

See merge request GNOME/glib!3587
2023-10-03 10:00:55 +00:00
Lukáš Tyrychtr
0e8e941e95 glocalfileinfo: Preserve microseconds for access/modify times
When setting the file time using utimensat, don't ignore
microseconds for access/modify times. By doing that, they're preserved
when using g_file_info_set_modification_date_time and then setting the file's
attributes from it.

Fixes #3116
2023-10-03 09:32:44 +01:00
Nelson Benítez León
40f567aa2a GDesktopAppInfo: prioritize match_type over match_category when searching apps
Commit 9e2ad88455 improved app search results by allowing to differentiate
their match_type: prefix match or substring match; while giving more priority
to prefix matches over substring matches, but only when they are in the same
match_category[1].

This was a step forward but, as outlined in #3082, still not enough to get
most relevant results first to the user, because apparently (and for the
specific case of desktop app searching) a prefix match in a lower category
is more relevant to the user than a substring match in a higher category.

So that's what this commit implements, i.e. it makes sure prefix matches
are still preferred over substring matches but this time not only when
in the same category but also across different categories.

[1] Match category is the Desktop file key where the match happened.
    They are shown below from top to lesser priority.
      DESKTOP_KEY_Name
      DESKTOP_KEY_Exec
      DESKTOP_KEY_Keywords
      DESKTOP_KEY_GenericName
      DESKTOP_KEY_X_GNOME_FullName
      DESKTOP_KEY_Comment

Fixes #3082
2023-10-03 09:10:21 +01:00
Nelson Benítez León
3c22e2745c test: improvements for GAppInfo test
· Add a usage output that is printed when called with no argument
   or with '--help' argument. This is helpful as it avoids having
   to read the source code to know how to run the different options.

 · Adds new '--should-show-only' option to 'search' command, to
   better mimick the gnome-shell app search, by not returning
   apps with NoDisplay=true.

  Example for running a desktop app search with the new option from
  inside the GLib build dir:
    $ gio/tests/apps search --should-show-only settings
2023-10-03 09:10:21 +01:00
Emmanuele Bassi
1cd0dfa55b Merge branch '3107-use-portal' into 'main'
gio: Rename GTK_USE_PORTAL to GIO_USE_PORTALS

Closes #3107

See merge request GNOME/glib!3602
2023-10-02 17:27:36 +00:00
Philip Withnall
86fdb4c7bf Merge branch 'ebassi/issue-3130' into 'main'
Check for empty property name in GPropertyAction

Closes #3130

See merge request GNOME/glib!3599
2023-10-02 17:09:55 +00:00
Arjan Molenaar
e9f0259e5d tests: Add a test for initialising GPropertyAction with no name
Helps: #3130
2023-10-02 17:17:24 +01:00
Philip Withnall
5bc6c2035a gio: Rename GTK_USE_PORTAL to GIO_USE_PORTALS
The `GTK_USE_PORTAL` environment variable has started to be misused by
users, which is causing deployment issues (such as portal services
themselves ending up being forced to use portals, which is never going
to work).

Try and sidestep users’ broken configurations by renaming the
environment variable, and also separating it from the old GTK
environment variable, since the GLib one affects a lot more processes.
This environment variable is meant to be used for
debugging and development, and never in production.

GTK already renamed their environment variable in
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4829, so keeping the
`GTK_USE_PORTAL` name in GLib doesn’t make sense anyway.

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

Fixes: #3107
2023-10-02 15:00:23 +01:00
Alessandro Bono
272ec5dbca tests/gsubprocess: Don't rely on PTRACE_O_EXITKILL presence
The PTRACE_O_EXITKILL symbol was introduced in glibc 2.23. CentOS7
has glibc 2.17. Use the symbol only if it is defined.
2023-09-19 12:37:23 +02:00
Philip Withnall
137956e700 Merge branch '3061-dbus-name-crash' into 'main'
gdbusmessage: Validate required headers have the right type

Closes #3061

See merge request GNOME/glib!3539
2023-08-31 10:14:03 +00:00
Philip Withnall
ed03b1f3f6 gresourcefile: Fix crash if called with a badly escaped URI
Return an invalid `GFile` instead, as is the custom for VFS functions.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Fixes: #3090
2023-08-29 11:22:43 +01:00
Philip Withnall
7cca4b1590 gdbusmessage: Validate required headers have the right type
We already validated that the required headers for each type of D-Bus
message were present. However, we didn’t validate that they contained a
variant of the right type. This could lead to functions like
`g_dbus_message_get_path()` returning `NULL` unexpectedly.

This failure could only be hit when using GDBus in peer-to-peer mode, or
with a D-Bus server which didn’t validate the headers itself. The
reference D-Bus server does validate the headers, and doesn’t forward
invalid messages to clients.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Fixes: #3061
2023-08-28 11:11:37 +01:00
Michael Catanzaro
77a56b58ed Merge branch 'o-nonblock-more' into 'main'
glib-unix: Accept O_CLOEXEC as well as FD_CLOEXEC in g_unix_open_pipe()

See merge request GNOME/glib!3538
2023-08-16 18:13:13 +00:00
Philip Withnall
07c4b6c68e glib: Pass O_CLOEXEC rather than FD_CLOEXEC to g_unix_open_pipe()
See the previous commit.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-08-16 14:31:40 +01:00
Philip Withnall
954b15218c Merge branch 'mcatanzaro/l10n-time' into 'main'
gsettingsschema: fix l10n=time attribute

Closes #2575

See merge request GNOME/glib!2422
2023-08-16 13:24:18 +00:00
André
9a6ca0ef75
gdbus-codegen: preserve relative indentation in doc comments
This commit also changes the generators for rst, xml and dockbook
to preserve indentation.

Closes #3032
2023-08-14 23:46:09 -03:00
Philip Withnall
c00d7999b1 Merge branch 'th/use-getservbyname-r' into 'main'
gnetworkaddress: use reentrant getservbyname_r() if available

See merge request GNOME/glib!3526
2023-08-14 09:24:51 +00:00
Thomas Haller
adb3763592 tests: add case for getservbyname() during g_network_address_parse()
Add test cases that result in lookup of the port via
getservbyname().

As the result depends on "/etc/services", it's not reliably the same on
every system. It requires a workaround.
2023-08-14 09:32:43 +01:00
Philip Withnall
065069191c tests: Disable use of ptrace() in tests on BSD and macOS
Commit cf55c31170 added a new test which
uses `ptrace()` to check some `GSubprocess` behaviour. FreeBSD uses
different symbol names for ptrace symbols, and we haven’t tested whether
the test works (and reproduces the failure) on FreeBSD, so skip the test
for now.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-08-14 09:27:07 +01:00
Philip Withnall
65e7a10d2a Merge branch 'macos_ci' into 'main'
interim solution for macOS CI

See merge request GNOME/glib!3503
2023-08-12 22:52:57 +00:00
Jonas Ådahl
cf55c31170 gio/tests: Add test case for exit status when being ptraced
The test case will fail with the

    g_assert_false (g_subprocess_get_successful (proc));

assert failing. Without the fix, it'll hit sometimes, but rather
unreliably. When running `meson test --repeat 100`, it'll reproduce
anywhere between the first or much later, but mostly before the 20th
iteration on my system.

Helps: #3071
2023-08-12 19:30:00 +01:00
René de Hesselle
439204ed7d Re-enable macOS CI on a new self-hosted runner
Allow two more tests to fail on macOS for the time being:
https://gitlab.gnome.org/GNOME/glib/-/issues/3069
https://gitlab.gnome.org/GNOME/glib/-/issues/3070
2023-08-11 19:33:19 +02:00
Michael Catanzaro
306d4567d2 Replace setlocale() with uselocale() in GSettings l10n tests
It's not safe to use setlocale() to mutate the locale in a threaded
program. Lots of other tests still do this, and I'm not putting in the
effort to fix them comprehensively in the absense of actual failures on
CI, but I figured it'd be good to fix the tests that I was touching.
2023-08-03 09:45:58 -05:00
Michael Catanzaro
736000e49e Remove setenv() use from GSettings l10n tests
This definitely does not do anything on Linux. I bet it's not needed on
other platforms, either. It's unsafe and may crash; there is no safe way
to mutate the environment in threaded programs.
2023-08-03 09:16:27 -05:00
Michael Catanzaro
92de7298c8 Add test for l10n="time" gschema attribute
This is a copy of the existing test_l10n, modified to use LC_TIME
instead of LC_MESSAGES. It's not safe as each call to g_setenv() or
setlocale() could cause the test to crash; there is no safe way to
change a threaded process's environment, and a threaded process's locale
can only be safely changed using uselocale(), not with setlocale().

The calls to g_setenv() are definitely not needed on Linux. I wonder
whether removing these will break the test on other platforms?

The calls to setlocale() should be replaced by a dance of
uselocale() -> duplocale() -> newlocale() -> uselocale() on Linux. But
this is not portable and this is a cross-platform test. We would have to
make the test platform-specific to do this. macOS and at least FreeBSD
provide these functions via xlocale.h, but this isn't portable.
2023-08-03 09:16:26 -05:00
Philip Withnall
39864716d6 Merge branch 'fix_3050' into 'main'
Strip query sections from file: URIs

Closes #3050

See merge request GNOME/glib!3502
2023-07-28 12:52:36 +00:00
Lukáš Tyrychtr
b504cc0841 gfile: Strip query sections from file: URIs
According to https://url.spec.whatwg.org/#file-state
a file URI can have a fragment and query string, so just ignore them
and don't raise an invalid URI error.

Fixes: #3050
2023-07-28 15:04:49 +03:00
Philip Withnall
9b80774ca7 Merge branch 'fileinfo-filepath' into 'main'
gfileinfo: add file_path methods for language bindings

See merge request GNOME/glib!3461
2023-07-22 05:27:12 +00:00
Jason Francis
04b683c34f gfileinfo: add file_path methods for language bindings
Including some tests by Philip Withnall.
2023-07-21 21:24:50 +01:00
Michael Catanzaro
a552bf5694 Merge branch 'revert3356' into 'main'
Revert "build/gmodule-2.0.pc: Move compiler flags from Libs to Cflags"

See merge request GNOME/glib!3504
2023-07-20 15:20:58 +00:00
Philip Withnall
2b391227e6 tests: Fix pkg-config test for multiarch binaries on multiarch systems
The test was passing fine when `bindir` was equal to `multiarch_bindir`,
but not when they differ.

For example, on a Debian system, `gio-querymodules` is installed to
`/usr/lib/x86_64-linux-gnu/glib-2.0/gio-querymodules` rather than
`/usr/bin/gio-querymodules` as it is on (say) Fedora.

This was causing the pkg-config tests to fail on Debian.

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

Fixes: #3045
2023-07-20 13:30:34 +01:00
Harald van Dijk
6e29fbec2d
Revert "build/gmodule-2.0.pc: Move compiler flags from Libs to Cflags"
This reverts commit 004f48f4fc.

Per the discussion on #3356, this change was prompted by a
misunderstanding of ldflags/link_args, and it resulted in various other
packages using glib no longer getting symbols exported. This commit
restores the glib 2.76 behaviour.
2023-07-18 18:26:49 +01:00
Corey Berla
a1a00a3071 gdbus-codegen: Error on invalid dbus types
Introduce slightly modified (dbus specific) versions of
variant_is_signature and variant_type_string_scan in order to fail
early on bad type strings.
2023-07-12 15:33:22 -07:00
Marco Trevisan (Treviño)
27b7559c91 gdbus-codegen: Define only one marshaller per signature reusing across interfaces
Avoid generating more code than needed, so other than continuing using
the generic glib marshallers when possible, define once the custom ones
we need for each file we generate.

The marshallers are then re-used across all the interfaces defined
without duplicating the code size.
2023-06-30 23:40:03 +02:00
Marco Trevisan (Treviño)
23180d433e gdbus-codegen: Try to reuse default glib marshallers for simpler signals marshallers
If a signal signautre is simple enough we can just reuse the default
marshallers by simply creating a wrapper marshaller
2023-06-30 22:59:37 +02:00
Marco Trevisan (Treviño)
c5d9004236 gdbus-codegen: Use direct-access GValue macros for marshallers and GValues
This is the same we're doing in code generated by glib-genmarshaller and
what gmarshal does internally.

Since the generated gdbus C code can be considered private too, this is
safe to do, and will allow faster access to GValue objects.
2023-06-30 22:59:37 +02:00
Marco Trevisan (Treviño)
8943ceae6c gdbus-codegen: Generate marshallers for method handlers signals
Get rid completely of the usage of the generic marshaller in gdbus
generated code, using instead specific marshallers.

Code is not yet optimized fully since we may still have duplicated
functions to be generated.

Closes: https://gitlab.gnome.org/GNOME/glib/-/issues/3028
2023-06-30 22:59:37 +02:00
Marco Trevisan (Treviño)
6de362fcae gdbus-test-codegen: Add test to check that fd lists can be passed
Add a simple implementation to check that fd-passing works when using
generated code, this is going to be useful to test special marshalling
case.
2023-06-30 22:59:37 +02:00
Marco Trevisan (Treviño)
3d313147f0 gio/test-codegen: use valid interface name for FdPassing test
So that it can be ran for real, not only tested for generation
2023-06-30 22:59:37 +02:00
Marco Trevisan (Treviño)
7b750972e8 meson/gio: Increase timeout for the codegen python tests
It's adding more stuff, let's ensure it wont timeout for no reason in
some platforms.

As per this mark also it as 'slow'
2023-06-30 22:59:25 +02:00
Marco Trevisan (Treviño)
1cd5c5678a gdbus-codegen: Generate signal marshallers for each interface signal
We relied on g_cclosure_marshal_generic() to easily generate signal
marshallers, but this relies on inspecting each parameter type with ffi
and this implies a performance hit, other than breaking the stack-frame
unwinder used by Linux perf and so by sysprof.

Given that we know the types we work on, it's easy enough to generate
the marshallers ourself.

Helps with: https://gitlab.gnome.org/GNOME/glib/-/issues/3028
2023-06-30 22:17:46 +02:00
Marco Trevisan (Treviño)
51c023f189 tests/codegen: Add checks for signal emission enums
These are checked to be correct by code compilation, but let's ensure we
also have some kind of forma check on the expected syntax.
2023-06-30 22:17:46 +02:00
Marco Trevisan (Treviño)
1b345e411f meson: Add all the gdbus-codegen based tests to the proper suite
So it's easier to run them all with --suite=gdbus-codegen
2023-06-30 18:11:18 +02:00
Philip Withnall
8cad32a118 Revert "tests: Temporarily disable socket test due to a kernel bug"
This reverts commit 1507585869.

This should now be fixed:
https://gitlab.gnome.org/Infrastructure/Infrastructure/-/issues/981#note_1760399.

Fixes: #2879
2023-06-07 12:29:03 +01:00
Philip Withnall
1aefcf4e0e Merge branch 'ok/termux-build-issues' into 'main'
gio, tests: adaptations for building with bionic libc from termux

Closes #3008

See merge request GNOME/glib!3443
2023-05-30 13:04:17 +00:00
Richard Purdie
c63cf19d9a gio/tests/portal-support: Fix snap test ordering race
When the gnome test runner executes the tests, the test appear to execute in disk
order. This means it sometimes works and sometimes we see breakage in portal-support-snap
and portal-support-snap-classic.

The issue is that some tests create config files but some don't. If they run
in the wrong order, tests see config files they shouldn't and break.

Fix this by deleting the files after each test run, properly cleaning up after
themselves. The cleanup code is based upon gtestutils.c:rm_rf().

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-05-30 12:28:45 +01:00
Guido Günther
b3b23072f3 gactionmap: Add g_action_map_remove_action_entries()
Since we have a convenience method to add actions let's allow to remove
them just as easily. This makes resource cleanup as simple as initially
adding the entries.
2023-05-26 10:30:40 +01:00
Sonny Piers
0b73d72a44 gio: Add g_file_new_build_filenamev 2023-05-23 10:14:28 +00:00
Øyvind Kolås
786f379d78 gio/tests: avoid shadowing of libc names under bionic libc
Makes the tests compile using clang with meson directly under
termux on android, this build environment does not approve of
overloading libc symbols.

Fixes: #3008

foo
2023-05-22 22:44:52 +02:00
Carlos Garnacho
4641b02ca2 gio: Add test for local enumerator cancellation
Check that the enumerator is able to cancel if told so.
2023-05-19 11:53:18 +00:00
Philip Withnall
8a68b795c1 tests: Fix GIO file size tests as .desktop files have changed size
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-10 09:26:47 +01:00