Commit Graph

133 Commits

Author SHA1 Message Date
Jasper St. Pierre
edb40c7171 gobject: Allow passing %NULL for @data in g_object_remove_toggle_ref
gjs has some situations where it's not always aware of the @data that
was passed into g_object_add_toggle_ref, so allow passing %NULL to
just match on @notify.

Rebased and updated by Nitin Wartkar

Closes #817
2021-05-27 21:09:45 +05:30
Emmanuel Fleury
e952248dc2 Use G_OPTION_ENTRY_NULL to avoid missing initializer warnings 2021-05-13 20:16:46 +00:00
Emmanuel Fleury
7b78f0b8ce Fix signedness warnings in tests/gobject/performance-threaded.c
I did it wrong last time... my bad...

tests/gobject/performance-threaded.c: In function ‘main’:
tests/gobject/performance-threaded.c:361:21: warning: comparison of integer expressions of different signedness: ‘gsize’ {aka ‘long unsigned int’} and ‘int’
  361 |       for (k = 1; k < argc; k++)
      |                     ^
2021-05-04 16:13:41 +02:00
Emmanuel Fleury
0ddadf14cc Fix several signedness warnings in tests/gobject/performance-threaded.c
tests/gobject/performance-threaded.c: In function ‘run_test’:
tests/gobject/performance-threaded.c:302:19: error: comparison of integer expressions of different signedness: ‘guint’ {aka ‘unsigned int’} and ‘int’
  302 |     for (i = 0; i < n_threads; i++) {
      |                   ^
tests/gobject/performance-threaded.c:308:19: error: comparison of integer expressions of different signedness: ‘guint’ {aka ‘unsigned int’} and ‘int’
  308 |     for (i = 0; i < n_threads; i++) {
      |                   ^
tests/gobject/performance-threaded.c: In function ‘find_test’:
tests/gobject/performance-threaded.c:324:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’
  324 |   for (i = 0; i < G_N_ELEMENTS (tests); i++)
      |                 ^
tests/gobject/performance-threaded.c: In function ‘main’:
tests/gobject/performance-threaded.c:351:21: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’
  351 |       for (i = 0; i < G_N_ELEMENTS (tests); i++)
      |                     ^
tests/gobject/performance-threaded.c:369:21: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’
  369 |       for (i = 0; i < G_N_ELEMENTS (tests); i++)
      |                     ^
2021-05-04 08:44:44 +02:00
Emmanuel Fleury
7ddcc082e2 Fix signedness warnings in tests/gobject/timeloop-closure.c
tests/gobject/timeloop-closure.c: In function ‘read_all’:
tests/gobject/timeloop-closure.c:42:21: error: comparison of integer expressions of different signedness: ‘gsize’ {aka ‘long unsigned int’} and ‘int’
   42 |   while (bytes_read < len)
      |                     ^
tests/gobject/timeloop-closure.c: In function ‘write_all’:
tests/gobject/timeloop-closure.c:66:24: error: comparison of integer expressions of different signedness: ‘gsize’ {aka ‘long unsigned int’} and ‘int’
   66 |   while (bytes_written < len)
      |                        ^
2021-05-04 08:43:29 +02:00
Emmanuel Fleury
3b424d746c Fix signedness warnings in tests/gobject/performance.c
tests/gobject/performance.c: In function ‘find_test’:
tests/gobject/performance.c:1019:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’
 1019 |   for (i = 0; i < G_N_ELEMENTS (tests); i++)
      |                 ^
tests/gobject/performance.c: In function ‘main’:
tests/gobject/performance.c:1054:21: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’
 1054 |       for (i = 0; i < G_N_ELEMENTS (tests); i++)
      |                     ^
2021-05-04 08:43:22 +02:00
Emmanuel Fleury
b04ebbf67b Fix missing initializer warning in tests/gobject/defaultiface.c
tests/gobject/defaultiface.c: In function ‘test_dynamic_iface_register’:
tests/gobject/defaultiface.c:126:5: error: missing initializer for field ‘class_data’ of ‘GTypeInfo’ {aka ‘const struct _GTypeInfo’}
  126 |     };
      |     ^
2021-04-29 12:40:05 +02:00
Emmanuel Fleury
277d206d38 Fix multiple missing initializer warnings in tests/gobject/testcommon.h
tests/gobject/testmodule.c: In function ‘test_module_get_type’:
tests/gobject/testmodule.c:34:1: error: missing initializer for field ‘value_table’ of ‘GTypeInfo’ {aka ‘const struct _GTypeInfo’}
   34 | DEFINE_TYPE (TestModule, test_module,
      | ^~~~~~~~~~~

tests/gobject/defaultiface.c: In function ‘test_static_iface_get_type’:
tests/gobject/defaultiface.c:58:1: error: missing initializer for field ‘class_finalize’ of ‘GTypeInfo’ {aka ‘const struct _GTypeInfo’}
   58 | DEFINE_IFACE (TestStaticIface, test_static_iface,
      | ^~~~~~~~~~~~
2021-04-29 12:40:05 +02:00
Emmanuel Fleury
76af9efbff Fix several missing initializer in tests/gobject/testgobject.c
tests/gobject/testgobject.c: In function ‘test_iface_get_type’:
tests/gobject/testgobject.c:53:7: error: missing initializer for field ‘class_init’ of ‘GTypeInfo’ {aka ‘const struct _GTypeInfo’}
   53 |       };
      |       ^
tests/gobject/testgobject.c: In function ‘test_object_get_type’:
tests/gobject/testgobject.c:182:7: error: missing initializer for field ‘value_table’ of ‘GTypeInfo’ {aka ‘const struct _GTypeInfo’}
  182 |       };
      |       ^
tests/gobject/testgobject.c: In function ‘derived_object_get_type’:
tests/gobject/testgobject.c:349:7: error: missing initializer for field ‘value_table’ of ‘GTypeInfo’ {aka ‘const struct _GTypeInfo’}
  349 |       };
      |       ^
2021-04-29 12:40:05 +02:00
Philip Withnall
7cdb68713c tests: Drop unnecessary volatile qualifiers from tests
These variables were already (correctly) accessed atomically. The
`volatile` qualifier doesn’t help with that.

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

Helps: #600
2020-11-20 14:40:19 +00:00
Philip Withnall
00bfb3ab44 tree: Fix various typos and outdated terminology
This was mostly machine generated with the following command:
```
codespell \
    --builtin clear,rare,usage \
    --skip './po/*' --skip './.git/*' --skip './NEWS*' \
    --write-changes .
```
using the latest git version of `codespell` as per [these
instructions](https://github.com/codespell-project/codespell#user-content-updating).

Then I manually checked each change using `git add -p`, made a few
manual fixups and dropped a load of incorrect changes.

There are still some outdated or loaded terms used in GLib, mostly to do
with git branch terminology. They will need to be changed later as part
of a wider migration of git terminology.

If I’ve missed anything, please file an issue!

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-06-12 15:01:08 +01:00
Simon McVittie
44c004c84e Normalize C source files to end with exactly one newline
Some editors automatically remove trailing blank lines, or
automatically add a trailing newline to avoid having a trailing
non-blank line that is not terminated by a newline. To avoid unrelated
whitespace changes when users of such editors contribute to GLib,
let's pre-emptively normalize all files.

Unlike more intrusive whitespace normalization like removing trailing
whitespace from each line, this seems unlikely to cause significant
issues with cherry-picking changes to stable branches.

Implemented by:

    find . -name '*.[ch]' -print0 | \
    xargs -0 perl -0777 -p -i -e 's/\n+\z//g; s/\z/\n/g'

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-06-10 09:48:02 +01:00
Sebastian Dröge
153ac4c82a Run the accumulator function for RUN_CLEANUP object handlers too
Closes issue #512
2019-08-25 19:31:48 +02:00
Philip Withnall
505f45ef95 tests: Remove redundant --tap options
Now that TAP output is used by default, passing `--tap` is unnecessary.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1619
2019-05-14 12:42:51 +01:00
Iain Lane
07a1a8031d
installed tests: Allow tests to set environment variables
It's necessary sometimes for installed tests to be able to run with a
custom environment. For example, the gsocketclient-slow test requires an
LD_PRELOADed library to provide a slow connect() (this is to be added in
a followup commit).

Introduce a variable `@env@` into the installed test template, which we
can override as necessary when generating `.test` files, to run tests
prefixed with `/usr/bin/env <LIST OF VARIABLES>`.

As the only test that requires this currently lives in `gio/tests/`, we
are only hooking this up for that directory right now. If other tests in
future require this treatment, then the support can be extended at that
point.
2019-02-13 09:43:49 +00:00
Philip Withnall
b3efef5b6f build: Drop autotools support
So long, and thanks for everything. We’re a Meson-only shop now.

glib-2-58 will remain the last stable GLib release series which is
buildable using autotools.

We continue to install autoconf macros for autotools-using projects
which depend on GLib; they are stable API.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-15 15:11:43 +00:00
Simon McVittie
13e206aaeb meson: Centralize test timeout values
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-01 19:13:21 +00:00
Xavier Claessens
24d7a73b93 Meson: Bump dependency to 0.48.0 2018-09-27 16:01:41 -04:00
Simon McVittie
129512b67c Autotools: Always run glib-genmarshal, even if cross-compiling
glib-genmarshal is now written in Python rather than C, so we can
always run it directly, even if we're cross-compiling for an
architecture whose binaries we can't run. This matches the behaviour
of the Meson build system.

Fixes: https://gitlab.gnome.org/GNOME/glib/issues/1546
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=908334
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-09-26 16:57:57 +01:00
Simon McVittie
cbc7fbbf7d meson: Run build-time tests with --tap where supported
This makes it easier to debug test failures, by ensuring that g_debug()
and g_test_message() are printed as TAP diagnostics.

Fixes: https://gitlab.gnome.org/GNOME/glib/issues/1528
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-09-24 23:37:12 +01:00
Xavier Claessens
178b943be7 Meson: Install timeloop-closure test 2018-09-24 11:21:27 -04:00
Xavier Claessens
8391219e4c Meson: Run in TAP mode installed tests that support it 2018-09-23 13:44:15 -04:00
Xavier Claessens
4b5bc3f459 Meson: build and install remaining tests 2018-09-21 08:45:54 -04:00
Philip Withnall
2a69cdb1cd build: Stop distributing generated files in autotools tarballs
It is a bug if we distribute files which are generated at build time —
they should be built on the machine which is compiling GLib, not be
shipped in the tarball.

This brings the autotools-generated tarball in line with the
ninja-generated one, with the exception of man pages and gtk-doc HTML
output.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-30 19:58:24 +01:00
Emmanuele Bassi
7e5db31d36 Deprecate g_type_class_add_private()
It's been 4 years and 8 development cycles since we introduced
G_ADD_PRIVATE and offset-based private data access. It is now
time to finally deprecate the old mechanism.

Closes: #699
2018-06-14 11:33:53 +01:00
Emmanuele Bassi
16d1a3d28c Classify the tests
Meson has the ability to classify tests according to "suites", a list of
tags. This is especially useful when we want to run specific sets of
tests — e.g. only GLib's tests — instead of the whole test suite. It
also allows us to classify special tests, like "slow" ones, so that we
can only run them when needed.
2018-06-10 15:33:06 +01:00
Xavier Claessens
27ec1469ab Remove developer script not needed in git repository 2018-06-04 22:27:22 -04:00
Xavier Claessens
b04cf01934 Remove old tests not being built since 2012
Those tests are failing and are not built since commit d6a075b
2018-06-04 22:18:02 -04:00
Philip Withnall
cc4de801c9 gobject: Reimplement g_param_values_cmp() for GParamSpecVariant
The existing implementation was completely incorrect (despite the fix in
commit 566e64a66) — it always compared GVariants by pointer, rather than
by value.

Reimplement it to compare them by value where possible, depending on
their type. The core of this implementation is g_variant_compare(). See
the documentation and tests for further details of the new sort order.

This adds documentation and tests.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=795735
2018-05-04 18:17:59 +01:00
Emmanuele Bassi
94d4e8b2fb Initialize variables before using them
Avoid a compiler warning when using the average, minimum, and maximum
elapsed variables without initializing them.

https://bugzilla.gnome.org/show_bug.cgi?id=794732
2018-03-28 11:49:59 +01:00
Christian Hergert
f44472e715 gobject: fix typecasts via g_object_ref
Now that g_object_ref() propagates the parameter type to the
return value, we need to cast to ensure the result is warning
free.

https://bugzilla.gnome.org/show_bug.cgi?id=790697
2017-12-04 11:42:58 +00:00
Philip Withnall
f2c093f657 build: Drop --enable-rebuilds configure option
It is outdated and no longer effectively used. It was originally in
place to prevent rebuilding generated files (from a tarball) if the
right build tools (awk, Perl, indent) were not available. However, we no
longer use indent, we have hard-required awk for a while, and the only
places the @REBUILD@ substitution was still used were for
glib-genmarshal, which has recently been rewritten in Python (so no
longer depends on whether Perl is available).

Drop the whole lot.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=694723
2017-11-17 15:11:47 +00:00
Emanuele Aina
e73831d808 tests: Re-wire the testgobject test program to the build system
After the build system rework in commit f9eb9e testgobject fell through
the cracks and was not built since then.

Re-enable it, even if it is currently failing due to commit 31fde56.

(Tweaked by Philip Withnall to add meson.build support.)

https://bugzilla.gnome.org/show_bug.cgi?id=701156
2017-11-17 12:27:10 +00:00
Emanuele Aina
edcabe1a4e tests: Don't assume that private data follows the instance data
Commit 31fde56 changed the way the private data is laid out in memory by
putting it *before* the instance data to keep the offsets fixed
regardless of the number of many subclasses.

This means that the invariant testgobject was verifying is no longer
true and the failing tests can be safely dropped.

https://bugzilla.gnome.org/show_bug.cgi?id=701156
2017-11-17 12:26:23 +00:00
Philip Withnall
5cddde1fb2 Consistently save errno immediately after the operation setting it
Prevent the situation where errno is set by function A, then function B
is called (which is typically _(), but could be anything else) and it
overwrites errno, then errno is checked by the caller.

errno is a horrific API, and we need to be careful to save its value as
soon as a function call (which might set it) returns. i.e. Follow the
pattern:
  int errsv, ret;
  ret = some_call_which_might_set_errno ();
  errsv = errno;

  if (ret < 0)
    puts (strerror (errsv));

This patch implements that pattern throughout GLib. There might be a few
places in the test code which still use errno directly. They should be
ported as necessary. It doesn’t modify all the call sites like this:
  if (some_call_which_might_set_errno () && errno == ESOMETHING)
since the refactoring involved is probably more harmful than beneficial
there. It does, however, refactor other call sites regardless of whether
they were originally buggy.

https://bugzilla.gnome.org/show_bug.cgi?id=785577
2017-08-03 10:21:13 +01:00
Emmanuele Bassi
a45bf85ce5 tests: Do not use gnome.genmarshal()
We are providing glib-genmarshal; using the gnome module in Meson does
not call the just built glib-genmarshal tool.
2017-07-17 13:59:20 +01:00
Emmanuele Bassi
3c03cc8f68 meson: Simplify the use of built tools
The Meson build has fallen a bit behind the Autotools one, when it comes
to the internally built tools like glib-mkenums and glib-genmarshals.

We don't need to generate gmarshal.strings any more, and since the
glib-genmarshal tool is now written in Python it can also be used when
cross-compiling, and without indirection, just like we use glib-mkenums.

We can also coalesce various rules into a simple array iteration, with
minimal changes to glib-mkenums, thus making the build a bit more
resilient and without unnecessary duplication.
2017-07-17 11:05:07 +01:00
Tim-Philipp Müller
2e9fd74b25 meson: add tests/gobject and tests/refcount 2017-07-13 19:03:39 -04:00
Sébastien Wilmet
f6c44ec3e4 tests/: LGPLv2+ -> LGPLv2.1+
gen-casefold-txt.pl and gen-casemap-txt.pl are licensed under GPLv2+, so
they are not touched by this commit.

A lot of *.c files in tests/ don't have a license header.

https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-29 19:53:35 +02:00
Philip Withnall
a05b64a0cb build: Use AM_TESTS_ENVIRONMENT rather than TESTS_ENVIRONMENT
TESTS_ENVIRONMENT is reserved for the user to be able to set when
running the tests. AM_TESTS_ENVIRONMENT is for the tests’ Makefile to
set itself.

https://www.gnu.org/software/automake/manual/html_node/Scripts_002dbased-Testsuites.html

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=782996
2017-05-23 13:29:40 +01:00
Emmanuele Bassi
f952fdf3fc Drop trailing semi-colon from G_DEFINE_ macro
It's unnecessary, and only adds visual noise; we have been fairly
inconsistent in the past, but the semi-colon-less version clearly
dominates in the code base.

https://bugzilla.gnome.org/show_bug.cgi?id=669355
2017-04-10 10:38:31 +01:00
Emmanuele Bassi
5ce70917df Drop binary checks when cross-compiling
We don't need to run binaries we just built in order to successfully
build GLib and friends any more.

Since commit b74e2a7, we don't need to run glib-genmarshal when building
GIO; since commit f9eb9eed, all our tests (including the ones that do
need to run binaries we just built) are only built when running "make
check", instead of unconditionally at every build.

This means that we don't need to check for existing, native binaries
when cross-compiling, and fail the configuration step if they are not
found — which also means that you don't need to natively build GLib for
your toolchain, in order to cross-compile GLib.

We can also use the cross-compilation conditional, and skip those tests
that require a binary we just built in order to build.

https://bugzilla.gnome.org/show_bug.cgi?id=753745
2015-09-01 10:40:24 -04:00
Alexander Larsson
2266f6b743 tests/gobject/performance: Clean up and add refcount performance test 2014-07-30 12:10:30 +02:00
Daniel Mustieles
078dbda148 Updated FSF's address 2014-01-31 14:31:55 +01:00
Michael Haubenwallner
b1af471a3f build: Give internal libraries higher precedence
Linking local libraries too late may cause preinstalled libraries to
get found earlier, due to external library paths in .la files.

https://bugzilla.gnome.org/show_bug.cgi?id=712314
2013-11-19 08:11:35 -05:00
Stef Walter
aa7ec15091 Revert "defaultiface: Fix leak in test"
This reverts commit fd7b2faa64.

This required another patch to be commited first. Will put this
back in bugzilla.
2013-11-11 17:06:38 +01:00
Stef Walter
fd7b2faa64 defaultiface: Fix leak in test
https://bugzilla.gnome.org/show_bug.cgi?id=711779
2013-11-11 07:27:22 +01:00
Stef Walter
bac4179476 timeloop-closure: Fix leaks in test
https://bugzilla.gnome.org/show_bug.cgi?id=711779
2013-11-11 07:27:15 +01:00
Stef Walter
d8722441d1 signals: Fix leak in test
https://bugzilla.gnome.org/show_bug.cgi?id=711779
2013-11-11 07:27:01 +01:00
Stef Walter
1b9662046f paramspec-test: Fix leaks in tests
https://bugzilla.gnome.org/show_bug.cgi?id=711779
2013-11-11 07:26:53 +01:00