Commit Graph

1062 Commits

Author SHA1 Message Date
Philip Withnall
fc25f8d7ef gfileutils: Correctly reset start value when canonicalising paths
If a path starts with more than two slashes, the `start` value was
previously incorrect:
 1. As per the `g_path_skip_root()` call, `start` was set to point to
    after the final initial slash. For a path with three initial
    slashes, this is the character after the third slash.
 2. The canonicalisation loop to find the first dir separator sets
    `output` to point to the character after the first slash (and it
    overwrites the first slash to be `G_DIR_SEPARATOR`).
 3. At this point, with a string `///usr`, `output` points to the second
    `/`; and `start` points to the `u`. This is incorrect, as `start`
    should point to the starting character for output, as per the
    original call to `g_path_skip_root()`.
 4. For paths which subsequently include a `..`, this results in the
    `output > start` check in the `..` loop below not skipping all the
    characters of a preceding path component, which is then caught by
    the `G_IS_DIR_SEPARATOR (output[-1])` assertion.

Fix this by resetting `start` to `output` after finding the final slash
to keep in the output, but before starting the main parsing loop.

Relatedly, split `start` into two variables: `after_root` and
`output_start`, since the variable actually has two roles in the two
parts of the function.

Includes a test.

This commit is heavily based on suggestions by Sebastian Wilhemi and
Sebastian Dröge.

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

oss-fuzz#41563
2021-12-02 17:50:17 +00:00
Philip Withnall
17ffe7b303 Merge branch 'move_bit-test' into 'main'
Merging tests/bit-test.c into glib/tests/utils.c

See merge request GNOME/glib!2379
2021-12-02 09:45:37 +00:00
Emmanuel Fleury
dd47df80e1 Merging tests/bit-test.c into glib/tests/utils.c 2021-12-01 14:10:44 +01:00
Philip Withnall
b5b3327636 Merge branch 'move_test_sources' into 'main'
GSource: move test to glib/tests/

See merge request GNOME/glib!2376
2021-12-01 11:39:46 +00:00
Nishal Kulkarni
70a8811ccc GSource: move test to glib/tests/
Previously tests existed in two places,
`$top_srcdir/tests/sources.c` contained additional tests,
they have now been moved to `$top_srcdir/glib/tests/mainloop.c`
and `$top_srcdir/tests/sources.c` was deleted.

Related to: #1434
2021-12-01 14:04:46 +05:30
Philip Withnall
9bd3ae856e Merge branch '2541-canonicalize-performance' into 'main'
gfileutils: Improve performance of g_canonicalize_filename()

Closes #2541

See merge request GNOME/glib!2374
2021-11-30 09:59:13 +00:00
Emmanuel Fleury
074d0a79d9 Removing tests/asyncqueue-test.c from tests/
Tests on async queues are already performed in a more extensive way in
glib/tests/asyncqueue.c. This test file can be safely removed without
any loss.
2021-11-29 16:46:13 +01:00
Nishal Kulkarni
279a610018 gqsort: Move test to glib/tests/
Previously tests existed in two places,
`$top_srcdir/tests/qsort-test.c` contained a similar test
to the one in `$top_srcdir/glib/tests/sort.c` called `test_sort_basic()`

The test for checking with zero elements was additional added to
`$top_srcdir/glib/tests/sort.c` and `$top_srcdir/tests/qsort-test.c`
was deleted.

Related to: #1434
2021-11-27 02:16:22 +05:30
Sebastian Wilhelmi
9a30a495ec gfileutils: Improve performance of g_canonicalize_filename()
Improve the performance of canonicalising filenames with many `..` or
`.` components, by modifying the path inline rather than calling
`memmove()`.

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

Fixes: #2541
2021-11-26 14:07:10 +00:00
Nishal Kulkarni
1c7936b368 slice-test: Use new g_newa0() function
Replace old `g_alloca()` and `memset()` with `g_newa0()`
2021-11-26 12:24:23 +00:00
Philip Withnall
8e963e0e31 Port internal uses to use g_source_set_static_name()
This should reduce allocations.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-07-26 11:01:07 +01:00
Philip Withnall
be012a8067 giomodule: Port to new g_module_open_full() API
Port all existing calls in GLib to the new API so that they can receive
more detailed error information (although none of them actually make use
of it at the moment).

This also serves to test the new API better through use.

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

Helps: #203
2021-07-21 21:54:35 +01:00
Michael Catanzaro
0818da5308 testgdate: fix -Wmisleading-indentation warning
No behavior changes. Just reindent the existing code to avoid a GCC
warning spam.

I considered changing the code to not run fflush() on every iteration of
the loop, but I doubt it matters much, so I left it be.
2021-06-16 12:22:28 -05: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
a369efd207 Fix missing initializer warning in tests/slice-threadinit.c
tests/slice-threadinit.c:34:30: warning: missing field 'sample' initializer
} pages[N_PAGES] = { { NULL, }, };
                             ^
2021-05-27 10:16:52 +02:00
Emmanuel Fleury
e952248dc2 Use G_OPTION_ENTRY_NULL to avoid missing initializer warnings 2021-05-13 20:16:46 +00:00
Emmanuel Fleury
00a15152f3 Fix signedness warning in tests/memchunks.c
tests/memchunks.c: In function ‘old_mem_chunk_new’:
tests/memchunks.c:140:35: error: comparison of integer expressions of different signedness: ‘gulong’ {aka ‘long unsigned int’} and ‘gint’ {aka ‘int’}
  140 |   g_return_val_if_fail (area_size >= atom_size, NULL);
      |                                   ^~
2021-05-06 22:54:53 +02:00
Emmanuel Fleury
53157f32b9 Fix several signedness warnings in tests/unicode-encoding.c
tests/unicode-encoding.c: In function ‘process’:
tests/unicode-encoding.c:140:38: error: comparison of integer expressions of different signedness: ‘glong’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’}
  140 |       if (!ucs4_result || items_read == strlen (utf8))
      |                                      ^~
tests/unicode-encoding.c:161:15: error: comparison of integer expressions of different signedness: ‘glong’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’}
  161 |    items_read != strlen (utf8) ||
      |               ^~
tests/unicode-encoding.c:198:18: error: comparison of integer expressions of different signedness: ‘glong’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’}
  198 |    items_written != strlen (utf8))
      |                  ^~
tests/unicode-encoding.c:260:22: error: comparison of integer expressions of different signedness: ‘glong’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’}
  260 |       if (items_read != strlen (utf8) ||
      |                      ^~
tests/unicode-encoding.c:294:18: error: comparison of integer expressions of different signedness: ‘glong’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’}
  294 |    items_written != strlen (utf8))
      |                  ^~
2021-05-06 22:54:53 +02:00
Emmanuel Fleury
951105fae5 Fix several signedness warnings in tests/threadpool-test.c
tests/threadpool-test.c: In function ‘test_thread_sort’:
tests/threadpool-test.c:283:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  283 |   for (i = 0; i < limit; i++) {
      |                 ^
tests/threadpool-test.c:296:50: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  296 |   g_assert (g_thread_pool_get_max_threads (pool) == max_threads);
      |                                                  ^~
glib/gmacros.h:941:25: note: in definition of macro ‘G_LIKELY’
  941 | #define G_LIKELY(expr) (expr)
      |                         ^~~~
tests/threadpool-test.c:296:3: note: in expansion of macro ‘g_assert’
  296 |   g_assert (g_thread_pool_get_max_threads (pool) == max_threads);
      |   ^~~~~~~~
tests/threadpool-test.c:297:50: error: comparison of integer expressions of different signedness: ‘guint’ {aka ‘unsigned int’} and ‘gint’ {aka ‘int’}
  297 |   g_assert (g_thread_pool_get_num_threads (pool) == g_thread_pool_get_max_threads (pool));
      |                                                  ^~
glib/gmacros.h:941:25: note: in definition of macro ‘G_LIKELY’
  941 | #define G_LIKELY(expr) (expr)
      |                         ^~~~
tests/threadpool-test.c:297:3: note: in expansion of macro ‘g_assert’
  297 |   g_assert (g_thread_pool_get_num_threads (pool) == g_thread_pool_get_max_threads (pool));
      |   ^~~~~~~~
tests/threadpool-test.c: In function ‘test_thread_idle_time’:
tests/threadpool-test.c:355:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  355 |   for (i = 0; i < limit; i++) {
      |                 ^
2021-05-06 22:54:53 +02:00
Emmanuel Fleury
3951ccffae Fix signedness warning in tests/thread-test.c
tests/thread-test.c: In function ‘test_g_static_private’:
tests/thread-test.c:214:60: error: comparison of integer expressions of different signedness: ‘int’ and ‘guint’ {aka ‘unsigned int’}
  214 |     g_assert (GPOINTER_TO_INT (g_thread_join (threads[i])) == i * 3);
      |                                                            ^~
glib/gmacros.h:941:25: note: in definition of macro ‘G_LIKELY’
  941 | #define G_LIKELY(expr) (expr)
      |                         ^~~~
tests/thread-test.c:214:5: note: in expansion of macro ‘g_assert’
  214 |     g_assert (GPOINTER_TO_INT (g_thread_join (threads[i])) == i * 3);
      |     ^~~~~~~~
2021-05-06 22:54:53 +02:00
Emmanuel Fleury
5299ee541a Fix signedness warning in tests/unicode-collate.c
tests/unicode-collate.c: In function ‘main’:
tests/unicode-collate.c:77:11: error: comparison of integer expressions of different signedness: ‘int’ and ‘guint’ {aka ‘unsigned int’}
   77 |  if (argc > i)
      |           ^
2021-05-06 14:35:46 +02:00
Emmanuel Fleury
1d02b96655 Fix signedness warnings in tests/gio-test.c
tests/gio-test.c: In function ‘recv_message’:
tests/gio-test.c:172:24: error: comparison of unsigned expression in ‘>= 0’ is always true
  172 |       g_assert (nbytes >= 0 && nbytes < BUFSIZE);
      |                        ^~
glib/gmacros.h:941:25: note: in definition of macro ‘G_LIKELY’
  941 | #define G_LIKELY(expr) (expr)
      |                         ^~~~
tests/gio-test.c:172:7: note: in expansion of macro ‘g_assert’
  172 |       g_assert (nbytes >= 0 && nbytes < BUFSIZE);
      |       ^~~~~~~~
tests/gio-test.c:188:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘guint’ {aka ‘unsigned int’}
  188 |    for (j = 0; j < nbytes; j++)
      |                  ^
tests/gio-test.c:189:30: error: comparison of integer expressions of different signedness: ‘char’ and ‘guint’ {aka ‘unsigned int’}
  189 |             g_assert (buf[j] == ' ' + ((nbytes + j) % 95));
      |                              ^~
glib/gmacros.h:941:25: note: in definition of macro ‘G_LIKELY’
  941 | #define G_LIKELY(expr) (expr)
      |                         ^~~~
tests/gio-test.c:189:13: note: in expansion of macro ‘g_assert’
  189 |             g_assert (buf[j] == ' ' + ((nbytes + j) % 95));
      |             ^~~~~~~~
2021-05-06 14:35:20 +02:00
Emmanuel Fleury
4d3c741ddb Fix several signedness warnings in tests/testglib.c
tests/testglib.c: In function ‘gnode_test’:
tests/testglib.c:302:34: error: comparison of integer expressions of different signedness: ‘char’ and ‘guint’ {aka ‘unsigned int’}
  302 |       g_assert (P2C (node->data) == ('C' + i));
      |                                  ^~
glib/gmacros.h:941:25: note: in definition of macro ‘G_LIKELY’
  941 | #define G_LIKELY(expr) (expr)
      |                         ^~~~
tests/testglib.c:302:7: note: in expansion of macro ‘g_assert’
  302 |       g_assert (P2C (node->data) == ('C' + i));
      |       ^~~~~~~~
tests/testglib.c:306:76: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  306 |     g_assert (g_node_child_position (node_G, g_node_nth_child (node_G, i)) == i);
      |                                                                            ^~
glib/gmacros.h:941:25: note: in definition of macro ‘G_LIKELY’
  941 | #define G_LIKELY(expr) (expr)
      |                         ^~~~
tests/testglib.c:306:5: note: in expansion of macro ‘g_assert’
  306 |     g_assert (g_node_child_position (node_G, g_node_nth_child (node_G, i)) == i);
      |     ^~~~~~~~
tests/testglib.c: In function ‘test_arrays’:
tests/testglib.c:1316:41: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
 1316 |     if (g_array_index (garray, gint, i) != i)
      |                                         ^~
tests/testglib.c:1324:41: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
 1324 |     if (g_array_index (garray, gint, i) != (100 - i - 1))
      |                                         ^~
2021-05-06 14:21:40 +02:00
Emmanuel Fleury
65d93a16ab Fix several signedness warnings in tests/testglib.c
tests/testglib.c: In function ‘glist_test’:
tests/testglib.c:90:30: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
   90 |       if (*((gint*) t->data) != (9 - i))
      |                              ^~
tests/testglib.c:95:54: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
   95 |     if (g_list_position (list, g_list_nth (list, i)) != i)
      |                                                      ^~
tests/testglib.c:112:30: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  112 |       if (*((gint*) t->data) != i)
      |                              ^~
tests/testglib.c:130:30: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  130 |       if (*((gint*) t->data) != (9 - i))
      |                              ^~
tests/testglib.c:150:30: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  150 |       if (*((gint*) t->data) != (9 - i))
      |                              ^~
tests/testglib.c: In function ‘gslist_test’:
tests/testglib.c:170:31: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  170 |       if (*((gint*) st->data) != (9 - i))
      |                               ^~
tests/testglib.c:188:31: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  188 |       if (*((gint*) st->data) != i)
      |                               ^~
tests/testglib.c:206:31: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  206 |       if (*((gint*) st->data) != (9 - i))
      |                               ^~
tests/testglib.c:226:31: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  226 |       if (*((gint*) st->data) != (9 - i))
      |                               ^~
2021-05-04 16:13:41 +02:00
Emmanuel Fleury
249f46ac76 Fix signedness warning in tests/timeloop.c
tests/timeloop.c: In function ‘read_all’:
tests/timeloop.c:41:21: error: comparison of integer expressions of different signedness: ‘gsize’ {aka ‘long unsigned int’} and ‘int’
   41 |   while (bytes_read < len)
      |                     ^
tests/timeloop.c: In function ‘write_all’:
tests/timeloop.c:65:24: error: comparison of integer expressions of different signedness: ‘gsize’ {aka ‘long unsigned int’} and ‘int’
   65 |   while (bytes_written < len)
      |                        ^
2021-05-04 16:13:41 +02:00
Emmanuel Fleury
026611b5a9 Fix several signedness warnings in tests/slice-threadinit.c
tests/slice-threadinit.c: In function ‘main’:
tests/slice-threadinit.c:77:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’
   77 |   for (j = 0; j < N_MAGAZINE_PROBES; j++)
      |                 ^
tests/slice-threadinit.c:108:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’
  108 |   for (j = 0; j < N_MAGAZINE_PROBES; j++)
      |                 ^
tests/slice-threadinit.c:113:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’
  113 |   for (j = 0; j < N_MAGAZINE_PROBES; j++)
      |                 ^
tests/slice-threadinit.c:131:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’
  131 |   for (j = 0; j < N_MAGAZINE_PROBES; j++)
      |                 ^
tests/slice-threadinit.c:139:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’
  139 |   for (j = 0; j < N_MAGAZINE_PROBES; j++)
      |                 ^
tests/slice-threadinit.c:161:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’
  161 |   for (j = 0; j < N_MAGAZINE_PROBES; j++)
      |                 ^
2021-05-04 16:13:41 +02: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
c339e29d46 Fix signedness warning in tests/mainloop-test.c
tests/mainloop-test.c: In function ‘cleanup_crawlers’:
tests/mainloop-test.c:358:15: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  358 |   for (i=0; i < crawler_array->len; i++)
      |               ^
2021-05-04 08:46:10 +02:00
Emmanuel Fleury
dcd3af7023 Fix signedness warning in tests/dirname-test.c
tests/dirname-test.c: In function ‘main’:
tests/dirname-test.c:105:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  105 |   for (i = 0; i < n_dirname_checks; i++)
      |                 ^
2021-05-04 08:45:56 +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
7c69a1d5f6 Fix signedness warnings in tests/refcount/objects.c
tests/refcount/objects.c: In function ‘main’:
tests/refcount/objects.c:133:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘const unsigned int’}
  133 |   for (i = 0; i < n_threads; i++) {
      |                 ^
tests/refcount/objects.c:149:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘unsigned int’
  149 |   for (i = 0; i < 2 * n_threads; i++) {
      |                 ^
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
b419761189 Fix signedness warning in tests/onceinit.c
tests/onceinit.c: In function ‘stress_concurrent_initializers’:
tests/onceinit.c:267:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’
  267 |   for (i = 0; i < G_N_ELEMENTS (initializers); i++)
      |                 ^
2021-04-29 12:40:05 +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
Simon McVittie
d499c53158 threadpool test: Don't leak the thread pool
Detected by AddressSanitizer.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-29 20:26:05 +00:00
Sebastian Dröge
fa8a39c6c6 Merge branch 'py-fixes' into 'master'
Python formatting improvements

See merge request GNOME/glib!1757
2020-11-20 18:10:40 +00:00
Philip Withnall
1a7f0002a0 tests: Fix non-atomic access to some shared variables
And drop the `volatile` qualifier from the variables, as that doesn’t
help with thread safety.

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

Helps: #600
2020-11-20 14:40:19 +00: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
d270b6c3db py: Various flake8 cleanups
None of these are particularly significant, but they do get the CI
output clean.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-11-17 15:50:07 +00:00
Philip Withnall
905b22a17e py: Reformat all Python files consistently
This commit is the unmodified results of running
```
black $(git ls-files '*.py')
```
with black version 19.10b0. See #2046.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-11-17 15:50:07 +00:00
Frederic Martinsons
e817a049f0 Correct shellcheck errors (and ignore world splitting when we want it)
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-11-15 17:34:27 +01:00
Maciej S. Szmigiero
6569529e18 GLib test: test GTree "lower bound" and "upper bound" operations
"lower bound" and "upper bound" operations have been recently added to
GTree.
Let's add some tests for them where other GTree tests live.

Since adding keys in-order doesn't exercise the GTree insertion code very
well let's make sure they are inserted in a random order instead.

Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
2020-10-06 11:07:11 +01: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
Philip Withnall
a19e554517 glib: Update Unicode Character Database to version 13.0.0
Using commands:
```
glib/gen-unicode-tables.pl -both 13.0.0 path/to/UCD
tests/gen-casefold-txt.py 13.0.0 path/to/UCD/CaseFolding.txt \
   > tests/casefold.txt
tests/gen-casemap-txt.py 13.0.0 path/to/UCD/UnicodeData.txt \
   path/to/UCD/SpecialCasing.txt > tests/casemap.txt
```

Using UCD release https://www.unicode.org/Public/zipped/13.0.0/UCD.zip

With some manual additions to `GUnicodeScript` for the 4 new scripts
added in 13.0, using the first assigned character in each block in
`glib/tests/unicode.c`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-03-18 14:50:36 +00:00
Philip Withnall
c5d661b4c4 build: Fix shellcheck warnings in various old build and test scripts
Most of these scripts can probably just be deleted (see issue #2045),
but for now it was easier to just mechanically fix the shellcheck
warnings in them, rather than think about whether we actually needed the
script.

Fixes done using shellcheck 0.7.0 with default options. I haven’t tested
any of the changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-27 10:33:45 +00:00
Marco Trevisan (Treviño)
d407b9e705 testgdate: Exit with failure if there are not passed tests 2019-12-10 17:58:16 +01:00
Sebastian Dröge
4dcad56fb2 Merge branch '1750-more-atomic-intrinsics' into 'master'
gatomic: Use new __atomic_*() intrinsics for all atomic operations

Closes #1750

See merge request GNOME/glib!1123
2019-11-14 13:40:47 +00:00
Philip Withnall
543a0c4091 tests: Fix unused variable in the threadpool-test
It looks like `continue_timeout` should be returned here, rather than
being set and never read. Spotted by `scan-build`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-30 15:24:08 +00:00
Jonas Ådahl
15e3b6f136 gmessages: Add g_warning_once()
In many places the pattern

    static gboolean warned_once = FALSE;
    if (!warned_once)
      {
        g_warning ("This and that");
        warned_once = TRUE;
      }

is used to not spam the same warning message over and over again. Add a
helper in glib for this, allowing the above statement to be changed to

    g_warning_once ("This and that");
2019-10-09 16:39:31 +02:00
Philip Withnall
30dd30d05a tests: Remove redundant old atomic test
The test in `glib/tests/atomic.c` does everything this test did, and
more.

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

Helps: #1434
2019-10-08 12:10:20 +01:00
Tom Schoonjans
036f6ca7e3 gmodule: write test for shared libraries 2019-09-06 19:03:31 +01:00
Philip Withnall
12bd86a2ee Merge branch 'G_SIGNAL_RUN_CLEANUP_do_not_call_accumulate' into 'master'
Run the accumulator function for RUN_CLEANUP object handlers too

Closes #512

See merge request GNOME/glib!1053
2019-08-26 06:19:07 +00: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
Christoph Reiter
6095b9bd3c win32: don't assume the format specifier for the stdlib printf/scanf like functions
When using the mingw printf shims for C99 compat the msvc format specifiers don't work
and the build fails.

Ideally we would use glib functions which abstract this away, but in the error handler context
we shouldn't call back into glib. And for scanf we don't have a glib wrapper.

Instead call the "secure" versions provided by the win32 API (_snprintf_s/fprintf_s/sscanf_s)
which mingw doesn't replace.
2019-08-10 21:56:33 +02:00
Chun-wei Fan
dbea8d5449 Fix module tests on Visual Studio builds
On Visual Studio, Meson builds modules as xxxx.dll, not libxxxx.dll when
xxxx is specified as the name for the shared_module() build directive.

This means that in the test programs if we expect for libxxxx for the
module name, the test will fail as there is no libxxxx.dll but there is
xxxx.dll.  This makes the test program look for the module files
correctly.
2019-06-24 10:58:58 +08:00
Philip Withnall
e62e89f2f8 Fix various deprecation warnings in code and tests
This code uses, or tests, deprecated functions, types or macros; so
needs to be compiled with deprecation warnings disabled.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01: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
Philip Withnall
64ddd32b79 glib: Update Unicode Character Database to version 12.1.0
Using commands:
```
glib/gen-unicode-tables.pl -both 12.1.0 path/to/UCD
tests/gen-casefold-txt.py 12.1.0 path/to/UCD/CaseFolding.txt \
   > tests/casefold.txt
tests/gen-casemap-txt.py 12.1.0 path/to/UCD/UnicodeData.txt \
   path/to/UCD/SpecialCasing.txt > tests/casemap.txt
```

Using UCD release https://www.unicode.org/Public/zipped/12.1.0/UCD.zip.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-08 13:07:55 +01:00
Philip Withnall
87014c8e97 glib: Update Unicode Character Database to version 12.0.0
Using commands:
   glib/gen-unicode-tables.pl -both 12.0.0 path/to/UCD
   tests/gen-casefold-txt.py 12.0.0 path/to/UCD/CaseFolding.txt \
     > tests/casefold.txt
   tests/gen-casemap-txt.py 12.0.0 path/to/UCD/UnicodeData.txt \
      path/to/UCD/SpecialCasing.txt > tests/casemap.txt
plus some manual additions of the new G_UNICODE_SCRIPT_* symbols to
gunicode.h, guniprop.c and glib/tests/unicode.c.

Using UCD release https://www.unicode.org/Public/zipped/12.0.0/UCD.zip.

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

Fixes: #1713
2019-04-29 14:16:12 +01:00
Michael Gratton
6b61395c2d build: Remove */.gitignore files
Since out-of-source-tree builds are now used after switching to meson,
we don't need .gitignore files in the source directories to ignore
build artifacts.

This fixes build errors when doing a meson build after an autotools
build, because generated files such as gio/xdp-dbus.c won't show up in
a `git status`, or be removed by a `git clean -f`, and so it won't be
obvious that such files need to be removed for the meson build to
succeed.
2019-04-22 22:17:43 +10:00
Philip Withnall
d89f18bb22 build: Add -UG_DISABLE_ASSERT when building tests
In order to allow GLib itself to be built with G_DISABLE_ASSERT defined,
we need to explicitly undefine it when building the tests, otherwise
g_test_init() turns into an abort.

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

Fixes: #1708
2019-03-08 19:46:20 +00:00
Philip Withnall
aeb7dbad30 Merge branch 'tsan' into 'master'
Fix thread safety issues

See merge request GNOME/glib!690
2019-03-05 11:46:33 +00:00
Philip Withnall
c96bfd57af build: Move tests/refcount/closures to gobject/tests/closure-refcount
One step towards removing the top-level tests/ directory.

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

Helps: #1434
2019-02-27 11:48:29 +00:00
Tomasz Miąsko
d75605e866 tests: Synchronize access to stopping flag 2019-02-25 14:29:35 +01:00
Philip Withnall
c5c9b29b9d Merge branch 'w32-testsuite-fixes-general' into 'master'
General fixes to W32 test suite

Closes #875

See merge request GNOME/glib!665
2019-02-13 10:40:11 +00: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
Руслан Ижбулатов
1e74b5872e GLib test: Adjust to follow the implementation
Canonicalization converts slashes to backslashes on Windows (most
of the time). This is a horrible design decision, but that's what
it does, and it's too late to change that. The test shouldn't expect
anything else.
2019-02-13 08:49:42 +00:00
Руслан Ижбулатов
3ffa7ed0b6 GDate test: Disable Julian epoch test on Windows
Windows uses FILETIME, which starts counting from 1st Jan of year 1601 and,
unlike time_t, can't be negative, so Windows simply has no way
to do timestamp-math for dates before then. SYSTEMTIME (an equivalent
of struct tm) can, obviously, represent almost arbitrary date starting
from 1st Jan of year 0 (it's unsigned...), but GetDateFormatW() converts it
to FILETIME at some point in its implementation, and fails.
Unless the whole strftime() implementation of GDate is replaced by
something that doesn't rely on WinAPI, this part of the test will
never pass.
2019-02-13 08:49:42 +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
Vasily Galkin
50cb4f221c gspawn, tests: extend spawn_test, run it on win32
The spawn_test is enabled on win32 meson build, both msys and msvc.

Some modifications to make it useful for auto-testing on win32:
- use own argv0 to find helper win32-specific subprogram
- helper subprogram and conditions changed, so testing is fully
automated instead of manually checking contents of some MessageBoxes

Redirection test checks "sort" output for locale-independent string
instead of relying on "netstat" locale-dependent string.
Also with "sort" it become usable on unix, so enabled there too.
Currently this fails on win32 with coverage since
some coverage-realted error output from gpawn-win32-helper
is unexpectedly treated as executed subprocess output.


Added test checking "sort" with error-only redirection. This also fails
on win32 by now, due to a typo in gspawn-win32.c (checks for stdout
redirection instead of stderr)
2018-12-26 23:45:47 +03:00
Will Thompson
6debbbfd73
gio-test: use g_debug rather than #define VERBOSE 2018-11-26 15:47:14 +00:00
Will Thompson
b45d911cc6
gio-test: fix leak & maybe-uninitialized warning
GCC 8 on F29 complains:

../tests/gio-test.c: In function ‘main’:
../tests/gio-test.c:375:7: warning: ‘id’ may be used uninitialized in this function [-Wmaybe-uninitialized]
       g_free (id);
       ^~~~~~~~~~~

In the normal case, when run without arguments, 'id' will be assigned
exactly once, so all is fine. If run with argument '0', 'id' will never
be assigned, so the warning is legit; but in that case the test program
will never exit. If run with any argument greater than 1, 'id' will be
assigned more than once but only the last incarnation will be freed.

Tweak the scope of the variable to match its use, and arrange for it to
be freed when its watch is destroyed.
2018-11-26 15:46:54 +00:00
Philip Withnall
e0148985f3 Merge branch 'tests-tsan' into 'master'
tests: Fix some data races in tests

See merge request GNOME/glib!453
2018-11-13 13:12:38 +00:00
Simon McVittie
cb98e37357 closures test: Avoid timeout on ARM64 CPUs
Closures use a 16-bit atomic reference count, which is really slow
on certain ARM64 CPUs such as the Cortex-A57 (glib#1316). This is
non-trivial to solve, since the public struct field cannot be enlarged
to 32-bit while preserving ABI, and 16-bit atomic operations would be new
(and rather niche) API.

Until this can be solved properly (hopefully in GLib 2.59.x), cut down
the number of signal emission cycles and bump up the timeout in the
Meson build system, so that builds won't time out. We can't just take
another zero off the number of signal emission cycles, as was done in the
original version of this patch in Debian, because if we do that it can
result in test failures when the main thread starves the other threads.

ARM64 CPUs are backwards-compatible with 32-bit ARM, and the same
slowdown can be seen when building and testing 32-bit code on these
CPUs, so check for both 32- and 64-bit ARM.

Bug-Debian: https://bugs.debian.org/880883
Co-authored-by: Iain Lane <laney@debian.org>
Signed-off-by: Simon McVittie <smcv@debian.org>
2018-11-06 13:48:34 +00:00
Tomasz Miąsko
1cc7457870 tests: Fix data races in refcount/signals.c 2018-11-04 17:28:51 +01:00
Tomasz Miąsko
83221671ea tests: Fix data races in refcount/closures.c 2018-11-04 17:28:43 +01: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
Philip Withnall
664fb6303b Revert "gdatetime: Enable compile time check of g_date_time_format() format"
This reverts commits:
 • 9ddcc79502ae02adc3c3

g_date_time_format() supports a few non-standard format placeholders:
 • %:z
 • %::z
 • %:::z

These are all gnulib strtime() extensions, and hence are not recognised
by the compiler when the function is annotated with G_GNUC_STRFTIME.
However, this wasn’t noticed when we originally merged this change
because the errors were disabled in the tests which covered those
placeholders.
2018-11-01 16:12:32 +00:00
Christian Persch
ae02adc3c3 gdatetime: Enable compile time check of g_date_time_format() format
By annotating it with G_GNUC_STRFTIME.

https://gitlab.gnome.org/GNOME/glib/issues/1575
2018-10-31 11:50:07 +01:00
Tomasz Miąsko
88f36a1d6f mainloop-test: Fix race conditions
* Wait for adder threads before deallocating crawler_array and
  context_array to avoid use after-free and data race.
* Handle spurious wakeups around g_cond_wait.
* Avoid starting recurser_idle without context.

Fixes issue #1530.
2018-10-30 00:55:14 +01:00
Xavier Claessens
24d7a73b93 Meson: Bump dependency to 0.48.0 2018-09-27 16:01:41 -04:00
Simon McVittie
6b0b4381bf Tests: Mark printf wrappers with G_GNUC_PRINTF
If we tell clang that we're passing the arguments on to a compatible
printf call, it can see that we're doing it right, and won't warn us
about -Wformat-nonliteral. This follows up from commit abac67c0.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-09-27 09:21:32 +01: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
Xavier Claessens
7c8e1f15cc Meson: Do not run tests/refcount with --tap
This is a partial revert of a change introduced in cbc7fbbf7.
2018-09-25 09:33:15 -04: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
abac67c050 Tests: Fix -Wformat-nonliteral causing build failure with clang 2018-09-21 08:45:54 -04:00
Руслан Ижбулатов
3ae1244ba1 tests W32: ifdef a variable not used on Windows 2018-09-21 08:45:54 -04:00
Руслан Ижбулатов
665677ce5e tests W32: Move timeloop test to the non-Windows section
It just doesn't work on Windows, and that can't be fixed with a quick patch.
2018-09-21 08:45:54 -04:00
Руслан Ижбулатов
4c91334412 tests W32: ugly fix for sscanf() format
As we recently established, G_G*_FORMAT macros are for glib
functions *only*. It's not guaranteed that they will work for
C runtime printf() or scanf() variants, and indeed - in this case
they do not (GCC thinks that MSVCRT sscanf() requires %I64 prefix
for 64-bit values; whether that is true or not is irrelevant at this
point - we need to make the werror go away).
2018-09-21 08:45:54 -04:00
Руслан Ижбулатов
d2c9543f2e tests W32: include process.h for getpid()
At least, MinGW has POSIX names. No idea if this works in MSVC.
2018-09-21 08:45:54 -04:00
Руслан Ижбулатов
190ea6ed10 tests W32: Fix Windows values casting
LPARAM is LONG_PTR which is the same as INT_PTR on Windows.
WPARAM is UINT_PTR.
HWND is a pointer.
(%p prints pointers without 0x prefix, hence the extra 0x).
2018-09-21 08:45:54 -04:00
Руслан Ижбулатов
3cdce16668 tests W32: Cast the MSG struct as (gchar *) for g_io_channel_read 2018-09-21 08:45:54 -04:00
Xavier Claessens
ef1bcc5a04 Rename cxx-test.C to cxx-test.cpp
Meson checks file extension case-insentively, and compiles ".C" as C
source instead of C++.
2018-09-21 08:45:54 -04:00
Xavier Claessens
4b5bc3f459 Meson: build and install remaining tests 2018-09-21 08:45:54 -04:00
Philip Withnall
18456b74a6 tests: Mark two more tests as slow
These keep on taking just longer than 30s on my local machine when run
in parallel with the rest of the tests (i.e. with `ninja test`). Testing
them individually, they do terminate correctly.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-09-20 17:51:18 +01: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
Rico Tzschichholz
359b27d441 unicode: Update test data files for unicode 11.0.0
Fixes https://gitlab.gnome.org/GNOME/glib/issues/1407
2018-07-18 14:26:51 +02:00
Xavier Claessens
f456e311cd Meson: Use environment() for test_env 2018-07-16 15:04:03 -04:00
Philip Withnall
3e74d587cf tests: Mark refcount/properties2 test as slow
It often takes a bit more than 30s to run on my local machine.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-06 15:01:58 +01:00
Philip Withnall
ffb1c3cb74 tests: Various minor leak fixes in the GObject tests
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-06-29 12:13:32 +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
Christoph Reiter
a580185cdc tests: Port gen-casefold-txt.pl and gen-casemap-txt.pl to Python 3. See #1332
I've tried to keep the code structure roughly the same.
2018-06-12 22:18:03 +02: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
Xavier Claessens
4a369a0b6c Remove tests/gio-ls.c that never has been built 2018-06-04 21:53:00 -04:00
Iain Lane
51d566ba6e test_paths: Reindent to avoid tripping -Wmisleading-indentation
This fixes:

glib/tests/testglib.c: In function ‘test_paths’:
glib/tests/testglib.c:955:3: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
   if (g_test_verbose ())
   ^~
glib/tests/testglib.c:958:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
     {
     ^

https://bugzilla.gnome.org/show_bug.cgi?id=796385
2018-05-30 10:07:35 +01:00
Christoph Reiter
e894534314 tests: Increase the timeout of the 'objects2' and 'sequence' tests. Fixes #1393
These two still fail occasionally due to timeouts, so increase it a bit.
2018-05-26 20:19:53 +02: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
Georges Basile Stavracas Neto
b9b642de06 fileutils: Add g_canonicalize_filename
Getting the canonical filename is a relatively common
operation when dealing with symbolic links.

This commit exposes GLocalFile's implementation of a
filename canonicalizer function, with a few additions
to make it more useful for consumers of it.

Instead of always assuming g_get_current_dir(), the
exposed function allows passing it as an additional
parameter.

This will be used to fix the GTimeZone code to retrieve
the local timezone from a zoneinfo symlink.

(Tweaked by Philip Withnall <withnall@endlessm.com> to drop g_autofree
usage and add some additional tests.)

https://bugzilla.gnome.org/show_bug.cgi?id=111848
2018-04-30 21:54:31 +01:00
Philip Withnall
9b4c50f63d all: Remove trailing newlines from g_message()/g_warning()/g_error()s
All those logging functions already add a newline to any message they
print, so there’s no need to add a trailing newline in the message
passed to them.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-27 16:46:19 +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
Ernestas Kulik
03e86d000f Remove HAVE_CONFIG_H defs and uses
Since GLib files are only meant to be built as part of GLib, config.h
always exists, so the checks are more or less pointless.

https://bugzilla.gnome.org/show_bug.cgi?id=793399
2018-02-21 13:57:10 +00: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
82adf7b5da tests: Work around a gdb bug in assert-msg-test
It seems that when GLib is compiled without CFLAGS=-g, gdb can’t work
out the size of __glib_assert_msg, so assumes it’s 4 bytes — even on
64-bit systems. This causes it to not read the most significant 4 bytes
of the assertion message pointer, and hence it can’t print the stored
assertion message. This causes assert-msg-test to fail.

The upstream gdb bug is
https://sourceware.org/bugzilla/show_bug.cgi?id=22501.

Work around that by referencing and dereferencing __glib_assert_msg so
that gdb treats it as a pointer of sizeof(char*) rather than of the size
it incorrectly calculated from the library’s symbol table (or through
some other mystical process).

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

https://bugzilla.gnome.org/show_bug.cgi?id=782057
2017-11-27 11:44:08 +00:00
Nirbheek Chauhan
bd22bb9898 meson: Use files() for gio sources and headers
This allows them to be fetched with subproject().get_variable(). Needed
for generating Gio-2.0.gir in the gobject-introspection meson port.
2017-11-23 23:03:57 +05:30
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
Руслан Ижбулатов
4a77eb16ce Replace all instances of ssize_t with gssize
ssize_t is supported widely, but not universally, so use gssize instead.
Currently only one piece of code actually *needs* this change to be compilable
with MSVC, the rest are mostly in *nix parts of the code, but these are changed
too, for symmetry.

https://bugzilla.gnome.org/show_bug.cgi?id=788180
2017-10-11 12:56:11 +01: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
Philip Withnall
a131134918 build: Drop nmake/MSC build system for GLib
It hasn’t been seriously maintained for the best part of 10 years and is
very outdated. The recommended way to build GLib on Windows is now
Visual Studio:

https://wiki.gnome.org/Projects/GTK%2B/Win32/MSVCCompilationOfGTKStack#GLib

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

https://bugzilla.gnome.org/show_bug.cgi?id=722047
2017-07-10 11:22:40 +01:00
Rico Tzschichholz
8e23a514b0 unicode: Update test data files for unicode 10.0.0
https://bugzilla.gnome.org/show_bug.cgi?id=784456
2017-07-05 17:53:07 +02: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
Sébastien Wilmet
6231b1abc9 License headers: replace current FSF address by a link to gnu.org
Even if the address is correct, it's far more convenient to have a link
to a website.

https://bugzilla.gnome.org/show_bug.cgi?id=776586
2017-01-04 19:12:57 +01:00
Simon McVittie
0d28ee458f type-test: do not rely on signed integer overflow wrapping around
Signed integer overflow is undefined behaviour: if a compiler
detects signed integer overflow, it is free to compile it to absolutely
anything.

Signed-off-by: Simon McVittie <smcv@debian.org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=775510
Reviewed-by: Colin Walters
2016-12-02 19:10:47 +00:00
Ross Burton
11a6e19e07 tests/refcount/signals: don't shadow rand()
rand() is in the C library and some C libraries (uclibc, for example) end up
with rand() defined even if stdlib.h isn't included explicitly.

https://bugzilla.gnome.org/show_bug.cgi?id=774421
2016-11-14 18:33:32 +00:00
Rico Tzschichholz
1ff79690fb unicode: Update test data files for unicode 9.0.0
https://bugzilla.gnome.org/show_bug.cgi?id=771591
2016-09-21 18:31:10 +02:00
Matthias Clasen
3624e70508 Update Unicode test data for Unicode 8
These files are used by the unicode-caseconv test.
2015-10-06 06:49:48 -04:00
Matthias Clasen
e773acfe9a tests: Don't test g_utf8_to_ucs4_fast too rigorously
The function is documented to assume valid input, and doesn't
guarantee behavior with invalid input. So don't test that.

https://bugzilla.gnome.org/show_bug.cgi?id=754636
2015-09-07 15:01:16 -04:00
Matthias Clasen
db3ffe5bf1 unicode-encoding test: Differentiate error messages
Spitting out the same error for different cases in not helpful.
2015-09-07 15:01:16 -04: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
Simon McVittie
45dae4b506 tests: replace most g_print() with g_printerr()
I searched all files that mention g_test_run, and replaced most
g_print() calls. This avoids interfering with TAP. Exceptions:

* gio/tests/network-monitor: a manual mode that is run by
  "./network-monitor --watch" is unaffected
* glib/gtester.c: not a test
* glib/gtestutils.c: not a test
* glib/tests/logging.c: specifically exercising g_print()
* glib/tests/markup-parse.c: a manual mode that is run by
  "./markup-parse --cdata-as-text" is unaffected
* glib/tests/testing.c: specifically exercising capture of stdout
  in subprocesses
* glib/tests/utils.c: captures a subprocess's stdout
* glib/tests/testglib.c: exercises an assertion failure in g_print()

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=725981
Reviewed-by: Colin Walters <walters@verbum.org>
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-11 20:24:56 +01:00
Simon McVittie
0a9d91ab7b testglib: my_hash_callback_remove_test: actually fail the test
The test is to remove all the odd values with my_hash_callback_remove(),
then iterate over all values and verify that they are even. However,
failing this check would just print "bad!" instead of failing the test.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=725981
Reviewed-by: Colin Walters <walters@verbum.org>
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-11 20:24:50 +01:00
Alexander Larsson
2266f6b743 tests/gobject/performance: Clean up and add refcount performance test 2014-07-30 12:10:30 +02:00
Christian Persch
b39b19ca20 unicode: Update test data files for unicode 7.0.0
https://bugzilla.gnome.org/show_bug.cgi?id=731929#c2
2014-06-29 20:18:48 +02:00
Ryan Lortie
dce88768dc all: remove use of 'register' keyword
We should have done this a decade ago...

https://bugzilla.gnome.org/show_bug.cgi?id=730293
2014-06-28 13:07:52 -04:00
Daniel Macks
93d0c63232 assert-msg-test: Explicitly quit gdb session to avoid zombie
gdb is run in batch mode, and can leave leave the program being
executed/debugged running when the batchfile is finished. Explicitly
"quit"ing the subprocess prevents it from leaving the stray subprocess
when gdb finishes.

https://bugzilla.gnome.org/show_bug.cgi?id=731366
2014-06-10 08:57:54 -04:00
Matthias Clasen
367dbdce36 Fix the mapping test in continuous
It turns out that due to a recent gdm change, the inherited
signal mask has SIGUSR1 blocked - which is bad news for
tests using SIGUSR1. Fix the test by explicitly checking the
signal mask before using SIGUSR1.
2014-05-30 10:22:35 -04:00