Commit Graph

1062 Commits

Author SHA1 Message Date
Emmanuel Fleury
647506966d Move tests/thread-test.c to glib/tests/thread-deprecated.c
Helps issue #1434
2022-05-06 10:50:40 +02:00
Philip Withnall
208ae36596 Merge branch 'threadpool_test' into 'main'
Move tests/threadpool-test.c to glib/test/thread-pool-slow.c

See merge request GNOME/glib!2634
2022-05-05 12:45:37 +00:00
Emmanuel Fleury
611a020308 Move tests/threadpool-test.c to glib/test/thread-pool-slow.c
Helps issue #1434
2022-05-05 10:51:16 +02:00
Emmanuel Fleury
cc41af57c3 Convert tests/threadpool-test.c to glib test framework 2022-05-05 10:47:05 +02:00
Emmanuel Fleury
fd8424a974 Removing unused tests/timeloop.c and tests/timeloop-basic.c
Remove unused tests/timelooop.c and tests/timeloop-basic.c because
these programs are manual performance tests which are no more relevant
for glib. They were used for the writing of GMainLoop but since then
they haven't not much been used in 22 years, it is safe to remove them.

Helps issue #1434
2022-04-26 20:20:03 +02:00
Emmanuel Fleury
49ecdd1dba Move tests/onceinit.c to glib/tests/onceinit.c
Related to issue #1434
2022-04-11 15:26:40 +02:00
Emmanuel Fleury
91dddb0641 Convert onceinit.c to glib test framework 2022-04-11 15:26:33 +02:00
Philip Withnall
690e64afef Merge branch 'unicode-normalize-test' into 'main'
Move test tests/unicode-normalize.c to glib/tests/

See merge request GNOME/glib!2586
2022-04-08 10:54:57 +00:00
Emmanuel Fleury
b25eb3808d Move unicode-normalize test from tests/ to glib/tests/
Helps issue #1434
2022-04-08 11:27:13 +02:00
Emmanuel Fleury
2c37b92dfa Enable and convert tests/unicode-normalize.c to glib test framework 2022-04-08 11:24:43 +02:00
Emmanuel Fleury
762ed2e82b Move tests/spawn-test.c -> glib/tests/spawn-test.c
Related to issue #1434
2022-04-07 18:36:45 +02:00
Emmanuel Fleury
5a7a69bd99 Convert tests/spawn-test.c to glib test framework 2022-04-07 18:36:14 +02:00
Emmanuel Fleury
795952cb8d Move tests/unicode-encoding.c to glib/tests/unicode-encoding.c
Related to issue #1434
2022-04-04 18:51:30 +02:00
Emmanuel Fleury
43759ca951 Convert tests/unicode-encoding.c to glib test framework 2022-04-04 18:51:24 +02:00
Emmanuel Fleury
5931ed8c2b Move test files on slices from tests/ to glib/tests/
slice-color.c and slice-concurrent.c are moved from tests/ to glib/tests/

Related to issue #1434
2022-03-22 11:42:33 +00:00
Emmanuel Fleury
1f2f3d7f37 Convert tests/slice-concurrent.c to glib test framework 2022-03-22 11:42:33 +00:00
Emmanuel Fleury
6211971c41 Convert tests/slice-color.c to glib test framework 2022-03-22 11:42:33 +00:00
Emmanuel Fleury
495508cf84 Enabling disabled slice-color test case 2022-03-22 11:42:33 +00:00
Emmanuel Fleury
2d6dc9ff2e Move tests/relation-test.c to glib/tests/relation.c
Related to issue #1434
2022-03-17 18:36:58 +01:00
Emmanuel Fleury
372b63bf1a Convert test/relation-test.c to glib test framework 2022-03-17 18:32:31 +01:00
Philip Withnall
d497bdebc0 Merge branch 'remove_type-test' into 'main'
Move tests/type-test.c to glib/tests/types.c

See merge request GNOME/glib!2527
2022-03-04 18:39:40 +00:00
Emmanuel Fleury
208dfe9ddc Move tests/type-test.c to glib/tests/types.c
Helps issue #1434
2022-03-04 16:24:20 +00:00
Emmanuel Fleury
9933e2b54c Convert tests/type-test.c to g_test framework 2022-03-04 16:24:20 +00:00
Emmanuel Fleury
78f6507196 Remove unused test tests/testgdateparser.c
Helps issue #1434
2022-02-23 18:34:44 +01:00
Emmanuel Fleury
16f0438bc6 Remove old test file tests/testglib.c 2022-02-22 18:48:01 +00:00
Philip Withnall
5ac86e21b3 Merge branch 'cleanup-warnings-split-2' into 'main'
Cleanup warnings split 2

See merge request GNOME/glib!2491
2022-02-18 13:39:25 +00:00
Loic Le Page
5f5a4a74b4 Fix non-initialized variable and pointer casted to int in tests/gio-test.c 2022-02-18 10:48:39 +01:00
Loic Le Page
2d5c6fc520 Fix global variable name hidden by local variables in tests/mapping-test.c 2022-02-18 10:25:33 +01:00
Philip Withnall
5b7383c544 tests: Merge iochannel-test into io-channel tests in glib directory
We’re trying to eliminate the legacy `tests/` directory. This commit
moves the code from `tests/iochannel-test.c` into
`glib/tests/io-channel.c` and ports it to the latest GLib test coding
standards:
 * Change `g_assert()` to `g_assert_*()`
 * Print verbose messages with `g_test_message()`
 * Rename some variables to conform to modern conventions
 * Use `GTest`

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

Helps: #1434
2022-02-17 21:42:35 +00:00
Emmanuel Fleury
e5cb2e9bbf Remove tests/testgdate.c from tests
Related to issue #1434
2022-02-03 15:18:05 +01:00
Emmanuel Fleury
849d3812c9 Move tests/file-test.c to glib/tests/fileutils.c 2022-01-26 15:18:40 +01:00
Loic Le Page
42c77c7ac7 Enable full-static build on Windows
Glib cannot be built statically on Windows because glib, gobject and gio
modules need to perform specific initialization when DLL are loaded and
cleanup when unloaded. Those initializations and cleanups are performed
using the DllMain function which is not called with static builds.

Issue is known for a while and solutions were already proposed but never
merged (see: https://gitlab.gnome.org/GNOME/glib/-/issues/692). Last
patch is from version 2.36.x and since then the
"constructor/destructor" mechanism has been implemented and used in
other part of the system.

This patch takes back the old idea and updates it to the last version of
glib to allow static compilation on Windows.

WARNING: because DllMain doesn't exist anymore in static compilation
mode, there is no easy way of knowing when a Windows thread finishes.
This patch implements a workaround for glib threads created by calling
g_thread_new(), so all glib threads created through glib API will behave
exactly the same way in static and dynamic compilation modes.
Unfortunately, Windows threads created by using CreateThread() or
_beginthread/ex() will not work with glib TLS functions. If users need
absolutely to use a thread NOT created with glib API under Windows and
in static compilation mode, they should not use glib functions within
their thread or they may encounter memory leaks when the thread finishes.

This should not be an issue as users should use exclusively the glib API
to manipulate threads in order to be cross-platform compatible and this
would be very unlikely and cumbersome that they may mix up Windows native
threads API with glib one.

Closes #692
2022-01-26 10:14:02 +01:00
Philip Withnall
ce45b88b90 Merge branch 'unicode_caseconv_tests' into 'main'
Merge test/unicode-caseconv.c into glib/tests/unicode.c

See merge request GNOME/glib!2432
2022-01-19 15:54:19 +00:00
Emmanuel Fleury
b9f07a458a Merge test/unicode-caseconc.c into glib/tests/unicode.c
Related to issue #1434
2022-01-19 16:21:01 +01:00
Philip Withnall
6d2dc3f8c2 Merge branch 'remove_paramspec_test' into 'main'
Merge tests/gobject/paramspec-test.c into gobject/tests/param.c

See merge request GNOME/glib!2431
2022-01-17 22:25:28 +00:00
Philip Withnall
eefba53845 Merge branch 'tests_unicode-collate' into 'main'
Remove a disabled test case that was covered by glib/tests/collate.c

See merge request GNOME/glib!2434
2022-01-17 21:03:09 +00: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
cddce179f5 Remove a disabled test case that was covered by glib/tests/collate.c
Related to issue #1434
2022-01-15 13:44:15 +01: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
Sophie Herold
68eab1d999 utils: Add XDG_STATE_HOME support 2021-12-24 20:11:39 +00:00
Philip Withnall
ca6cf3c64a Merge branch 'fix_warnings' into 'main'
Fix several cosmetic warnings

Closes #2559

See merge request GNOME/glib!2401
2021-12-23 12:51:19 +00:00
Emmanuel Fleury
3887de12a9 Fix old_mem_chunk_new() does not match original declaration warning in tests/slice-test.c
tests/slice-test.c:30:17: warning: type of ‘old_mem_chunk_new’ does not match original declaration
2021-12-17 16:35:45 +01:00
Emmanuel Fleury
20c8ea1bc6 Move tests/env-test.c into glib/tests/environment.c 2021-12-16 16:32:26 +01:00
Emmanuel Fleury
9f760a7cc1 Moving tests/dirname-test.c to glib/tests/fileutils.c
Helps issue #1434
2021-12-16 10:41:13 +00:00
Emmanuel Fleury
241b9f41b4 Merging tests/child-test.c into glib/tests/spawn-multithreaded.c
Helps issue #1434
2021-12-15 23:12:59 +01:00
Philip Withnall
2c07c17840 Merge branch 'datetime_tests' into 'main'
Removing unnecessary test on gdatetime.c

See merge request GNOME/glib!2393
2021-12-14 15:25:40 +00:00
Philip Withnall
f493d3fd24 Merge branch 'cxx-test' into 'main'
Removing redundant cxx test tests/cxx-test.cpp

See merge request GNOME/glib!2391
2021-12-14 15:23:16 +00:00
Emmanuel Fleury
ae345e56c2 Distribute cxx test tests/cxx-test.cpp to each module tests directory
tests/cxx-test.cpp is removed and splitted into gio/tests/cxx.cpp,
gmodule/tests/cxx.cpp and gobject/tests/cxx.cpp.

Helps issue #1434
2021-12-14 14:43:03 +01:00
Emmanuel Fleury
6a17b114b6 Removing unnecessary test on gdatetime.c
Helps issue #1434
2021-12-14 13:46:06 +01:00
Emmanuel Fleury
cde56cfc70 Move tests/completion-test.c to glib/tests/completion.c
Helps issue #1434
2021-12-13 17:42:23 +01:00
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