Commit Graph

26429 Commits

Author SHA1 Message Date
Ray Strode
168fd4f2b3 gspawn: Don't use g_close when doing fdwalk to close potentially invalid fds
Some platforms (e.g., macOS) don't currently have a way
to close only open fds in preparation for exec. On these
platforms, glib just bites the bullet and calls g_close for
the whole fileno range.

g_close only allows valid fds to be given to it, though.

This commit ensures close is called instead of g_close on
those platforms by splitting the safe_fdwalk implementation
that operates on invalid fds off to its own function and
only using it as a fall back.
2022-11-02 09:36:26 -04:00
Ray Strode
ac4dbc82e1 gspawn: Make sure pipe fds end up at the right place
It's possible when gspawn sets up its pipes for standard io,
that the pipe fds themselves end up in the standard io range
reserved for stdin, stdout, stderr.

This commit protects against that problem by relocating the
fds up, outside of the range.

Closes: #16
2022-11-02 09:36:26 -04:00
Ray Strode
e3ae492550 tests: Add g_spawn_test for when stdio fd range is exposed
This commit adds a test to make sure GSpawn still works even
if fds 0, 1, and 2 are closed before it's run.
2022-11-02 09:36:26 -04:00
Ray Strode
2399585860 gspawn: Rename CHILD_DUP2_FAILED to CHILD_DUPFD_FAILED
The error code is already used for both F_DUPFD and dup2
already, and having dup2 in the name is oddly specific.

This renames the error code for clarity.
2022-11-02 09:06:34 -04:00
Ray Strode
e5782dcafc glib-unix: Add test to make sure g_unix_open_pipe will intrude standard range
Now that we know it's a bad idea to avoid the standard io fd range
when getting pipe fds for g_unix_open_pipe, we should test to make sure
we don't inadvertently try to do it again.

This commit adds that test.
2022-11-02 09:06:34 -04:00
Ray Strode
dad97d24d5 Revert "Handling collision between standard i/o file descriptors and newly created ones"
g_unix_open_pipe tries to avoid the standard io fd range
when getting pipe fds. This turns out to be a bad idea because
certain buggy programs rely on it using that range.

This reverts commit d9ba615090

Closes: #2795
Reopens: #16
2022-11-02 09:06:34 -04:00
Philip Withnall
451ed353f5 Merge branch 'wip/smcv/tests-license' into 'main'
Add a SPDX LicenseRef for the license historically used for tests

See merge request GNOME/glib!3049
2022-11-02 12:55:50 +00:00
Simon McVittie
2673b262aa custom-dispatch: Change SPDX-License-Identifier to match license grant
The SPDX-License-Identifier said LGPL-2.1-or-later, but the license
grant was a permissive license, which we now identify as
LicenseRef-old-glib-tests.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-02 12:35:45 +00: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
Philip Withnall
0e9e51767a Merge branch 'variant-docs' into 'main'
docs: Convert GVariant Specification to reStructuredText

See merge request GNOME/glib!3044
2022-11-02 09:40:24 +00:00
Xavier Claessens
f6edb52bda Merge branch 'wip/3v1n0/some-meson-fixmes' into 'main'
meson: Handle various build system FIXME's

See merge request GNOME/glib!3012
2022-11-01 23:36:04 +00:00
Michael Catanzaro
7f85fd126b gproxyresolver: lookup_finish() should better parallel lookup_async()
In g_proxy_resolver_lookup_async() we have some error validation that
detects invalid URIs and directly returns an error, bypassing the
interface's lookup_async() function. This is great, but when the
interface's lookup_finish() function gets called later, it may assert
that the source tag of the GTask matches the interface's lookup_async()
function, which will not be the case.

As suggested by Philip, we need to check for this situation in
g_proxy_resolver_lookup_finish() and avoid calling into the interface
here if we did the same in g_proxy_resolver_lookup_async(). This can be
done by checking the source tag.

I added a few new tests to check the invalid URI "asdf" used in the
issue report. The final case, using async GProxyResolver directly,
checks for this bug.

Fixes #2799
2022-11-01 13:40:35 -05:00
Emmanuele Bassi
c33edff7fa Apply 2 suggestion(s) to 1 file(s) 2022-11-01 17:38:22 +00:00
Patrick Monnerat
f2c590f494 tests/mkenums.py: add a test case for symbolic expression evaluation 2022-11-01 16:06:20 +01:00
Patrick Monnerat
96fa9752b2 glib-mkenums: evaluate private symbols too
This allows them to be referenced in other symbols value computation.

In addition, this fixes the automatically assigned value of a public
symbol that is preceded by a private one:

        typedef enum {
          /*< private >*/
          ENUM_VALUE_PRIVATE,
          /*< public >*/
          ENUM_VALUE_PUBLIC,                    <--- value is 1, not 0.
        } SomeExampleEnum;
2022-11-01 15:46:13 +01:00
Philip Withnall
993325400d Merge branch 'task-strdup-avoidance' into 'main'
task: Don't overwrite source names

See merge request GNOME/glib!2869
2022-11-01 13:26:17 +00:00
Philip Withnall
088df783c0 docs: Convert GVariant Specification to reStructuredText
This is a verbatim conversion of the GVariant Specification from
https://people.gnome.org/~desrt/gvariant-serialisation.pdf /
https://raw.githubusercontent.com/ostreedev/gvariant-rs/master/docs/gvariant-serialisation.pdf
to reStructuredText.

This is for several reasons:
 1. The canonical copy has gone offline due to people.gnome.org being
    shut down.
 2. GLib is the reference implementation of GVariant, so should probably
    host the specification (unless someone wants to host it on
    freedesktop-specs).
 3. Moving it out of a PDF and into reStructuredText should allow for
    amendments. The specification has a few problems, typos and
    oversights in its original form, and it would be good to canonically
    fix them without having to write a separate addendum document.

This conversion is verbatim, and does not change the content of the
document at all, even to fix typos and broken links (which there are a
small number of in the PDF).

This describes what I’m labelling as version 1.0 of the GVariant
serialisation format. Updates to the specification can bump this version
number, in subsequent commits.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-01 13:12:53 +00:00
Matthias Clasen
13e48ff963 tests: Tweak the task tests
Tweak the g_task_set_name test to use a non-literal string,
so we don't test g_task_set_static_name twice.
2022-11-01 11:48:52 +00:00
Matthias Clasen
525e3953ef tests: Add a test for g_task_set_static_name()
The test checks that the original string
is returned by g_task_get_name().
2022-11-01 11:48:46 +00:00
Matthias Clasen
99c7d60869 gtask: Add g_task_set_static_name()
Similar to g_source_set_static_name, this avoids
strdup overhead for debug-only information in
possibly hot code paths.

We also add a macro wrapper for g_task_set_name that
uses __builtin_constant_p to decide whether to use
g_task_set_name or g_task_set_static_name.
2022-11-01 11:48:38 +00:00
Matthias Clasen
794ee60306 gdbusconnection: Set a name on all sources
We already set names on most sources, this
one was just forgotten. This lets us set
a static name, and prevents g_task_attach_source
from setting a non-static one.
2022-11-01 11:48:33 +00:00
Matthias Clasen
01f2c5aec9 gtask: Don't overwrite source names
Only set a name in g_task_attach_source
if the source does not already have one.

Including a new test by Philip Withnall.
2022-11-01 11:48:08 +00:00
Philip Withnall
110cddb90c Merge branch 'wip/smcv/os-detect' into 'main'
docs: Mention platform-specific predefined macros

See merge request GNOME/glib!2997
2022-11-01 11:00:03 +00:00
Philip Withnall
debf3e4a87 Merge branch 'sandbox-check' into 'main'
gio: Create a sandbox checking function

See merge request GNOME/glib!3037
2022-11-01 10:45:05 +00:00
Simon McVittie
871237b9d5 docs: Mention platform-specific predefined macros
The platform-specific predefined macros provided by various compilers
sometimes capture subtle differences of meaning, like the distinction
between the Linux kernel and a glibc-based (GNU/Linux) user-space.
It would be difficult to capture those subtleties in GLib-specific
convenience macros, particularly for platforms that we don't use
ourselves.

Instead, recommend that anyone who is already writing platform-specific
code should use the platform-specific predefined macros directly.

Alternative to !2986.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-01 10:40:37 +00:00
Robert Ancell
bfd7074dfc gio: Fix formatting 2022-11-01 10:20:36 +00:00
Robert Ancell
5a83f384d1 Fix meson formatting 2022-11-01 10:20:36 +00:00
Robert Ancell
568763e776 gio: Create a sandbox checking function 2022-11-01 10:20:36 +00:00
Patrick Monnerat
0120cd772a glib-mkenums: feature use of previous symbols in evaluation
Enum symbols can be defined with a value computed from previously
defined enum symbols. The current evaluator does not support this and
requires a literal integer expression.

This commit introduces a C symbol namespace that is filled along
code generation and provided as a local namespace for new symbols
evaluation, effectively allowing definitions such as:

	typedef enum {
	  a = 4;
	  b = a + 2;
	}  myenum;

to be successfully processed.
2022-11-01 02:12:26 +01:00
Marco Trevisan (Treviño)
c6eddf897b ci: Do not use installed tests in debian-stable build
Setting installed_tests option enforces various test files to be
installed, this causes meson to build tools that might have not built
otherwise but that are still required for testing.

Also, disabling installed tests lead to slightly different code paths
when it comes to using test test files.

So, disable it for debian so that we can ensure that at test time we
have set all the dependencies between test programs and the used
resources (that can be libraries, external programs or modules).
2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
038ef36b99 gobject/tests/meson: Make gobject-query.py test depend on gobject-query util
The utility is used by the script, so we need to depend on it.
2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
a106ce4445 gobject/tests/meson: Add support to add extra depends args to python tests 2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
eef2b0b39e gmodule/tests/meson: Make tests depending on loaded libraries and modules 2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
82fc49fa10 glib/tests/meson: Add test programs dependencies to single tests
Various glib tests (such as the spawn ones) depend on local binaries
being built, this may not happen (especially when not using installed
tests), thus ensure such dependencies via the newly added extra_programs
key
2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
495017e2db glib/tests/meson: Compile tests extra programs using same strategy as gio
This allows also to keep track of targets and to make possible for a
test to depend on a particular test program
2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
c490e3c522 gio/tests/meson: Add resource plugin as test dependency 2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
407c45ddaf gio/tests/meson: Add fake-service-name as gdbus-names dependency
It uses a fake name owner that we didn't depend on
2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
ed013f9550 gio/tests/meson: Make giomodule test to depend on built modules
These are loaded dynamically so we need to ensure they're available at
test time
2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
ff195b6e0d gio/tests/meson: Add dbus-launch as dependency of gdbus-address-get-session 2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
fd2b4e4ca4 gio/tests/meson: Add glib-compile-schemas as dependency for gsettings test 2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
0525a32c09 gio/tests/meson: Add fake-document-portal as dependency of dbus-appinfo
It uses the portal, but it doesn't depend on it.
2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
cb85b26dd2 gio/tests/meson: Add gdbus-connection-flush-helper as dependency of connection tests 2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
01349e8e7f gio/tests/meson: Add gdbus-testserver prog as dependency of GDbus tests
Most gdbus tests launch the gdbus-testserver binary, so add it as
dependency of such tests.
2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
caf75d8f9c gio/tests/meson: Add basic-application as prerequisite of gapplication
It's currently commented code, but in any case it's better to build it
earlier
2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
97b0e96577 gio/tests/meson: Add gsubprocess-testprog as gsubprocess dependency
It launches such binary, so add it as prerequisite.
2022-11-01 01:56:20 +01:00
Marco Trevisan (Treviño)
e1e4084ecb gio/tests/meson: Add appinfo-test and apps as appinfo tests dependency
We need to make sure that such binaries are built and available at test time
or we may fail some tests requiring them (directly or through desktop file).

As per this, and because now generated desktop files are available both
at build and install time, don't skip some tests we were used to, but
actually enforce they are running.
2022-11-01 01:56:10 +01:00
Marco Trevisan (Treviño)
a1a0a9d75a gio/meson: Make possible for test to depend on extra programs
We have some test programs on which some tests depend on, for example
appinfo-test is a tool that is used by the desktop-app-info tests.

So test can now have an 'extra_programs' key where the extra program
names can be included.

This could have been handled manually via 'depends', but this allows
to avoid repeating code and be sure that all is defined when extra
programs targets are checked.
2022-11-01 01:56:09 +01:00
Marco Trevisan
02db6107ce Merge branch 'speed-up-desktop-test' into 'main'
tests: Remove an unnecessary sleep from desktop-app-info test

See merge request GNOME/glib!2961
2022-11-01 00:33:40 +00:00
Philip Withnall
176f66502d tests: Reduce an unnecessary sleep from desktop-app-info test
`g_app_info_launch_default_for_uri_async()` has already returned by this
point, so waiting a long time is not really going to help.

Wait for 3× as long as the successful case took, which should allow for
long enough to catch true negatives, with a bit of variance.

On my system, this means waiting for about 14ms, rather than the 100ms
which this previous slept for. This speeds the test up by about 5%.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-01 00:33:40 +00:00