Commit Graph

26224 Commits

Author SHA1 Message Date
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
Philip Withnall
cbf17c9422 Merge branch 'wip/3v1n0/support-can-fail-tests' into 'main'
meson, ci: Support tests that can fail under certain conditions

See merge request GNOME/glib!2987
2022-10-31 14:28:02 +00:00
Marco Trevisan (Treviño)
584a4f64c9 glib/tests/meson: Ignore another new windows tests failure 2022-10-31 14:08:31 +01:00
Marco Trevisan (Treviño)
94273b0ebf ci: Remove not-printable chars from generated junit file
Under windows we get some invalid chars that are causing gitlab not to
be able to parse the xml files

See: https://github.com/mesonbuild/meson/issues/9894
2022-10-31 14:08:31 +01:00
Marco Trevisan (Treviño)
be665cdce0 glib,gio/tests: Mark some spawn tests as flaky under windows
It a may fail at times, but it generally works:

 See: https://gitlab.gnome.org/GNOME/glib/-/jobs/2346261
 See: https://gitlab.gnome.org/GNOME/glib/-/jobs/2346262
2022-10-31 14:08:31 +01:00
Marco Trevisan (Treviño)
832dd0805a meson: Add basic summary
It can nicely provide information about how glib is configured
2022-10-31 14:08:31 +01:00
Marco Trevisan (Treviño)
9e649debbe meson: Use default test multiplier to define timeouts
So that we don't have to care about the default, being always set to 1m
2022-10-31 14:08:31 +01:00
Marco Trevisan (Treviño)
3d497b8f5b ci: Show commands run from the test scripts
It allows better debugging in case of failures.
2022-10-31 14:08:31 +01:00
Marco Trevisan (Treviño)
3c56d661d8 meson: Use test setup environment instead of repeating it everywhere 2022-10-31 14:08:31 +01:00
Marco Trevisan (Treviño)
3e227fb528 glocalfileinfo: Define errsv only if it's used 2022-10-31 14:08:31 +01:00
Marco Trevisan (Treviño)
b30430970a tests: Mark should_fail tests as can_fail
Even if they are expected to fail, we should not use an inverse logic
for treating their return codes.
2022-10-31 14:08:31 +01:00
Marco Trevisan (Treviño)
8d5ae3ae83 ci: Mark failing mingw tests as can-fail and do not ignore test failures 2022-10-31 14:08:31 +01:00
Marco Trevisan (Treviño)
54a9e797fe ci: Mark failing windows tests as can-fail and do not ignore test failures 2022-10-31 14:08:31 +01:00
Marco Trevisan (Treviño)
b9e085537d meson: Expose library build type as global variables
Given that it can be computed using an error-prone strings comparisons it
is better to provide a variable everywhere, so that we don't have the
risk of comparing values that are always false.
2022-10-31 14:08:31 +01:00
Marco Trevisan (Treviño)
914bb06ab4 gio: mark codegen test as can-fail in freebsd
See: https://gitlab.gnome.org/GNOME/glib/-/issues/2764
2022-10-31 14:08:31 +01:00
Marco Trevisan (Treviño)
62dca6c1cf meson, ci: Support tests that can fail under certain conditions
We have tests that are failing in some environments, but it's
difficult to handle them because:
 - for some environments we just allow all the tests to fail: DANGEROUS
 - when we don't allow failures we have flacky tests: A CI pain

So, to avoid this and ensure that:
 - New failing tests are tracked in all platforms
 - gitlab integration on tests reports is working
 - coverage is reported also for failing tests

Add support for `can_fail` keyword on tests that would mark the test as
part of the `failing` test suite.
Not adding the suite directly when defining the tests as this is
definitely simpler and allows to define conditions more clearly (see next
commits).

Now, add a default test setup that does not run the failing and flaky tests
by default (not to bother distributors with testing well-known issues) and
eventually run all the tests in CI:
 - Non-flaky tests cannot fail in all platforms
 - Failing and Flaky tests can fail

In both cases we save the test reports so that gitlab integration is
preserved.
2022-10-31 14:08:29 +01:00
Marco Trevisan
4339df0583 Merge branch 'portal-support-missing-guards' into 'main'
portal: Fix broken header guard

See merge request GNOME/glib!3035
2022-10-31 12:31:01 +00:00
Philip Withnall
9931696eca Merge branch 'wip/3v1n0/sys-64-clang' into 'main'
gatomic: Cast the oldval pointer type to the atomic value type, and add msys2-clang64 scheduled CI job

Closes #2798

See merge request GNOME/glib!3031
2022-10-31 12:24:10 +00:00
Robert Ancell
0239417935 portal: Fix broken header guard
This wouldn't have caused an issue with the current header contents, but could have triggered a future bug.
2022-10-31 12:08:41 +01:00
Emmanuele Bassi
7457566fb8 Merge branch 'wip/smcv/sized-integers' into 'main'
docs: Soft-deprecate sized integer types in favour of (u)intN_t

Closes #1484

See merge request GNOME/glib!3006
2022-10-31 11:05:38 +00:00
Marco Trevisan (Treviño)
dd422a0588 gio/tests/win32-streams: Avoid doing sign casting when we can
the offset can be just an unsigned parameter so that we don't have to cast
the sizeof (DATA) result.
2022-10-31 12:02:57 +01:00
Marco Trevisan (Treviño)
69f7aa5747 meson: Ignore -Wstring-plus-int in C
It's not really a problem for us, it would be only in c++.
2022-10-31 12:02:57 +01:00
Marco Trevisan (Treviño)
126b822137 gfileutils: Use correct type comparison for length
length is defined as an unsigned size value, so can't compare it with a
signed one
2022-10-31 12:02:57 +01:00
Marco Trevisan (Treviño)
7dc19632f3 glib/tests/cxx: Ensure NULL is always casted to a pointer type
Otherwise it may not be recognized as valid sentinel
2022-10-31 12:02:55 +01:00
Marco Trevisan (Treviño)
d7a6305ba4 glib/gnulib/meson: Disable some warnings on clang windows builds
We have gnulib warnings in windows under clang:
  ../glib/gnulib/vasnprintf.c:2429:21: warning: variable 'flags' set but not
    used [-Wunused-but-set-variable]
                int flags = dp->flags;
                    ^

  ../glib/gnulib/vasnprintf.c:4853:19: warning: unannotated fall-through
    between switch labels [-Wimplicit-fallthrough]
                  case TYPE_LONGINT:
                  ^

See: https://gitlab.gnome.org/3v1n0/glib/-/jobs/2361750
2022-10-31 12:00:53 +01:00
Marco Trevisan (Treviño)
e320149c39 ci: Add an msys2-clang64 job to run only on schedules
It has enough particularities to require a job to monitor failures
2022-10-31 12:00:53 +01:00
Marco Trevisan (Treviño)
345fbe0666 ci/test-msys2: use $MINGW_PACKAGE_PREFIX 2022-10-31 12:00:53 +01:00
Marco Trevisan (Treviño)
fdaa8a334a ci: Set CFLAGS on msys2-mingw32 in yaml file as it happens for other jobs
Be consistent, and based on this also perform the lcov job or not
2022-10-31 12:00:53 +01:00
Marco Trevisan (Treviño)
e2560d1681 gatomic: Cast the oldval pointer type to the atomic value type
If glib_typeof is defined we can try to cast the old value to the atomic
value type to check if it's compatible with the pointer one.

Closes: #2798
2022-10-31 12:00:53 +01:00
Philip Withnall
6cb10c86c8 Merge branch 'ci-add-issue-bot' into 'main'
ci: Open issues when scheduled pipelines fail

See merge request GNOME/glib!3034
2022-10-31 10:10:47 +00:00
Philip Withnall
d2d97ffc48 Merge branch 'always-use-nullptr-in-c++' into 'main'
glib/gmacros: Always define NULL as nullptr in C++11 and newer

See merge request GNOME/glib!3033
2022-10-31 10:10:10 +00:00
Marco Trevisan (Treviño)
f8fa9d3a2b ci: Open issues when scheduled pipelines fails
It's hard to track failures on scheduled pipelines, so make gitlab open
an issue for us if that happens.
2022-10-31 02:51:40 +01:00
Marco Trevisan (Treviño)
0ca5254c5d glib/gmacros: Always define NULL as nullptr in C++11 and newer 2022-10-31 01:00:06 +01:00
Simon McVittie
bb7d7c4616 docs: Soft-deprecate sized integer types in favour of (u)intN_t
C99 does not actually guarantee that the platform has 8-, 16-, 32- and
64-bit types, but it does guarantee that if the platform has them, then
(u)intN_t are defined to be examples of those types.

GLib goes beyond what C99 guarantees, and requires 8-, 16-, 32- and
64-bit types; combining that with C99's requirements means we can
assume that int8_t, uint64_t, etc. all exist.

Unfortunately, we cannot guarantee that GLib and the C99 toolchain have
chosen the *same* fixed-size type: for example, on a typical ILP32
or LLP64 platform like Windows or 32-bit Linux, each 32-bit type could
either be int or long, while on a LP64 platform like 64-bit Linux,
each 64-bit type could either be long or long long. The in-memory
representation is the same either way, but the choice of underlying type
matters when building printf format strings or issuing compiler warnings.
As a result, we can't just typedef gint32 as int32_t and so on.

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/1484
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-28 11:08:33 +01:00
Simon McVittie
6a8f96510b docs: Clarify relationship between goffset and POSIX off_t
The important thing here is that we can't arbitrarily mix these, even if
they will often have the same in-memory representation.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/1484
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-28 11:04:49 +01:00
Philip Withnall
9635fd4e40 Merge branch 'wip/smcv/sizes-and-pointers' into 'main'
Improve documentation and static assertions around g(s)size, g(u)intptr

See merge request GNOME/glib!3001
2022-10-28 09:18:51 +00:00
Philip Withnall
9f10881574 Merge branch 'wip/smcv/autofd' into 'main'
gstdio: Silence "Not available before" warnings for inline functions

Closes #2796

See merge request GNOME/glib!3026
2022-10-27 21:55:09 +00:00
Simon McVittie
da3fc59544 glib-init: Add more static assertions for gintptr, guintptr
Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/1484
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 19:54:26 +01:00
Simon McVittie
589f29e005 docs: Soft-deprecate g(u)intptr in favour of (u)intptr_t
These have a status similar to size_t: they're Standard C types and
straightforward to use in portable code this decade, but we can't
guarantee that we have chosen the same underlying type that the platform
uses.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/1484
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 19:54:24 +01:00
Simon McVittie
43d8545045 glib-init: Add more static assertions about gsize
Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/1484
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 19:54:23 +01:00
Simon McVittie
de2602736d docs: Clarify the relationship between gssize, ssize_t and SSIZE_T
This is similar to the relationship between gsize and size_t, except
that size_t is a Standard C type but ssize_t is platform-specific
(specifically, ssize_t is a POSIX type, and on Windows the equivalent
is SSIZE_T), making it more awkward to use in portable code. As a
result, continuing to use gssize is more useful than continuing to use
gsize.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/1484
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 19:54:20 +01:00
Simon McVittie
9f19eb454b docs: Soft-deprecate gsize in favour of standard size_t
We have chosen the underlying type that implements gsize to be the same
size as the standard C89 size_t (the top-level meson.build sets this up).

Unfortunately, we cannot guarantee that GLib and the C toolchain have
chosen the *same* fixed-size type: for example, on a typical ILP32
platform like 32-bit Windows or Linux, each of gsize and size_t
can either be int or long, while on a LP64 platform like 64-bit Linux,
each could either be long or long long. meson.build tries to choose the
same type to reduce compiler warnings, but it can only do this if the
compiler implements `-Werror`.

The in-memory representation is the same either way, but the choice of
underlying type matters when building printf format strings or issuing
compiler warnings, and can affect the C++ ABI of GLib-based software.
As a result, we can't just typedef gsize as size_t.

I've expanded the doc-comment to say a bit more about the implications
of the different types here, so that I can point to it from the
doc-comments of other types without repeating myself too much.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/1484
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 19:54:08 +01:00
Marco Trevisan
d0b3021f7f Merge branch 'nirbheek/gmodule-suffix-deprecation' into 'main'
Improve g_module_open(), deprecate G_MODULE_SUFFIX

Closes #520 e #1413

See merge request GNOME/glib!2950
2022-10-27 16:27:42 +00:00
Nirbheek Chauhan
958d0f9b9b tests: Fix resources test on macOS
The content type detection is not very specific on macOS.
2022-10-27 20:26:53 +05:30
Nirbheek Chauhan
9fa3915236 tests: Fix fileutils test on macOS
It can return EROFS instead of EPERM too.
2022-10-27 20:26:53 +05:30
Nirbheek Chauhan
d941558ee9 Improve g_module_open(), deprecate G_MODULE_SUFFIX
G_MODULE_SUFFIX is deprecated now because you will get the wrong
results using it most of the time:

1. The suffix on macOS is usually 'dylib', but it's 'so' when using
   Autotools, so there's no way to get the suffix correct using
   a pre-processor macro.
2. Prefixes also vary in a platform-specific way. You may or may not have
   a 'lib' prefix for the name on Windows and on Cygwin the prefix is
   'cyg'.
3. The library name itself can vary per platform. For instance, you may
   want to load foo-1.dll on Windows and libfoo.1.dylib on macOS. This
   is for libraries, not modules, but that is still a use-case that
   people use the GModule API for.

g_module_build_path() does take care of (2) on Cygwin, but it
fundamentally cannot handle the possibility of multiple options for
the module name, since it does not do any I/O. Hence, it is also
deprecated.

Instead, g_module_open() has been improved so that it takes care of
all this by searching the filesystem for combinations of possible
suffixes and prefixes on each platform. Along the way, the
documentation for it was also improved to make it clearer what it
does.

Closes https://gitlab.gnome.org/GNOME/glib/-/issues/520

Closes https://gitlab.gnome.org/GNOME/glib/-/issues/1413
2022-10-27 20:26:53 +05:30
Simon McVittie
a62dd272d8 tests: Test that we can include all headers with an old MAX_VERSION
In principle we could script this so that each max-version.c is compiled
26 times, once per possible MAX_VERSION, but I haven't implemented
that here: just pinning to the oldest possible version is sufficient to
reproduce #2796.

These aren't included in the installed-tests, since they don't really
do anything at runtime (the important thing is that they compile
without warnings).

Reproduces: #2796
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 14:50:48 +01:00
Marco Trevisan
aed8e231c0 Merge branch 'variant-byteswap-fuzzing' into 'main'
fuzzing: Add a new fuzz test for g_variant_byteswap()

See merge request GNOME/glib!3025
2022-10-27 12:43:42 +00:00
Simon McVittie
c59d553890 gstdio: Silence "Not available before" warnings for inline functions
Whenever a static inline calls a GLib function that was added since
we started tracking versions, we need to silence the "Not available
before" warnings, otherwise compiling code that includes this header
with GLIB_VERSION_MAX_ALLOWED set to an old version will emit warnings,
even if the static inline is never actually called.

If the static inline is API, we also need to ensure it is annotated with
GLIB_AVAILABLE_STATIC_INLINE_IN_2_76 or similar, so that callers get
the appropriate "Not available before" warnings to alert them to their
unintended use of newer API.

g_clear_fd() calls a function that was introduced in 2.36. It already
issues its own warning if called with GLIB_VERSION_MAX_ALLOWED less
than 2.76.

Similarly, g_autofd uses internal function _g_clear_fd_ignore_error
which calls g_clear_fd(), but it issues its own warning if used with
GLIB_VERSION_MAX_ALLOWED less than 2.76.

Fixes: b3934133 "gstdio: Add g_clear_fd() and g_autofd"
Resolves: #2796
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 13:14:25 +01:00
Simon McVittie
d0ff4055af gstdio: Warn if g_autofd is used with GLIB_VERSION_MAX_ALLOWED < 2.76
Fixes: b3934133 "gstdio: Add g_clear_fd() and g_autofd"
Helps: #2796
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 13:13:48 +01:00