Commit Graph

149 Commits

Author SHA1 Message Date
Philip Withnall
d463de05b1 tests: Move GObject performance tests to gobject/tests/performance/
This doesn’t change the tests’ behaviour, but moves them to a slightly
more logical location.

They are still not installed or run by default.

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

Helps: #1434
2022-06-08 11:30:31 +01:00
Philip Withnall
5d498f4d1c Merge branch 'move_testgobject' into 'main'
Move tests/gobject/testgobject.c to gobject/tests/basics-gobject.c

See merge request GNOME/glib!2696
2022-06-08 09:52:55 +00:00
Matthias Clasen
35d5f9488c Improve the GObject performance test
Make the 'complex construction' case more
realistic by adding a string property.

And mark the properties as G_PARAM_STATIC_STRINGS,
since this is commonly done, and doing so will
enable some optimizations.

Also, use g_object_class_install_properties,
to test optimizations that will be tied to using
that function.
2022-06-01 12:14:11 -04:00
Emmanuel Fleury
ee67ca43cd Move tests/gobject/testgobject.c to gobject/tests/basics-gobject.c
Helps issue #1434
2022-05-27 22:31:13 +02:00
Emmanuel Fleury
ccfabc0f99 Convert tests/gobject/testgobject.c to glib test framework 2022-05-27 22:19:42 +02:00
Emmanuel Fleury
4e02be948b Moving gobject tests from tests/gobjects to gobjects/tests
The test files concerned are:

- tests/gobjects/accumulator.c
- tests/gobjects/defaultiface.c
- tests/gobjects/deftype.c
- tests/gobjects/dynamictype.c
- tests/gobjects/override.c
- tests/gobjects/references.c
- tests/gobjects/signals.c
- tests/gobjects/singleton.c

Related to issue #1434
2022-05-26 19:13:19 +01:00
Emmanuel Fleury
a8baa8d0d8 Convert tests/gobject/singleton.c to glib test framework 2022-05-26 19:13:19 +01:00
Emmanuel Fleury
d0577293a2 Convert tests/gobject/signals.c to glib test framework 2022-05-26 19:13:19 +01:00
Emmanuel Fleury
2767e1614d Convert tests/gobject/references.c to glib test framework 2022-05-26 19:13:19 +01:00
Emmanuel Fleury
662d8458f5 Convert tests/gobject/override.c to glib test framework 2022-05-26 19:13:19 +01:00
Emmanuel Fleury
17ddf79e1d Convert tests/gobject/dynamictype.c to glib test framework 2022-05-26 19:13:16 +01:00
Emmanuel Fleury
b61d3edc33 Convert tests/gobject/defaultiface.c to glib test framework 2022-05-26 19:12:15 +01:00
Emmanuel Fleury
d378108b10 Convert tests/gobject/accumulator.c to glib test framework 2022-05-26 18:51:57 +01:00
Matthias Clasen
1c4f6da1f7 Add a finalization performance test 2022-05-23 08:49:04 -04:00
Emmanuel Fleury
66ebcbced4 Merge tests/gobject/paramspec-test.c into gobject/tests/param.c
Helps issue #1434
2022-01-17 20:43:27 +00:00
Emmanuel Fleury
86fedcfb93 Merge tests/gobject/gvalue-test.c with gobject/tests/value.c
Helps issue #1434
2022-01-12 21:51:05 +01:00
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