1728 Commits

Author SHA1 Message Date
Philip Withnall
dfb3517d37 gmessages: Error if g_log_set_writer_func() is called multiple times
Inspired by https://gitlab.gnome.org/GNOME/glib/-/issues/2638.

This requires moving the tests to subprocesses, so that
`g_log_set_writer_func()` is only called once per process.

It also adds a test for the new error.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-25 12:38:59 +01:00
Emmanuel Fleury
6eddfefbfc Expand tests on gbookmark file API 2022-04-19 16:38:41 +02:00
Emmanuel Fleury
b5c162635c Fix spelling mistake in filename when unlinking it after the test. 2022-04-17 08:08:30 +02:00
Emmanuel Fleury
9ed0dc5583 Clean the file "iochannel-test-outfile" after the test test_small_writes() 2022-04-17 08:08:30 +02:00
Emmanuel Fleury
8901898da2 Cleaning file 'filename' after the test in glib/tests/fileutils.c 2022-04-17 08:08:23 +02:00
Philip Withnall
41fcb33034 tests: Fix a minor leak in the unicode-normalize test
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Coverity CID: #1487904
2022-04-14 13:26:25 +01:00
Marc-André Lureau
f82f4776c0 tests: fix protocol test on win32
The pipe must be closed, or the child PID watch doesn't get triggered.

We should remove the message callback source on EOF, as EOF during main
loop run will reach a bad assert in the callback.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-04-14 15:38:47 +04:00
Chun-wei Fan
a8f1058d3b glib/tests/date.c: Fix 2-digit year test
...for certain Windows locales, since the formats accepted for
g_date_set_parse() will vary depending on the current system locale.  For
instance, g_date_set_parse(gdate, "dd/mm/yy") is accepted on locales such
as zh-HK (Chinese (Hong Kong SAR)) but is rejected on zh-TW (Chinese
(Taiwan)).

One can tell from the "date format" settings in the Windows system
control panel whether there is a "dd/MM/YYYY" or "dd/MM/YY" option from the
drop-down list of date formats to display for the locale, which will indicate
whether g_date_set_parse(gdate, "dd/mm/yy") is accepted, which is true for
zh-HK but is not true for zh-TW.

If g_date_set_parse(gdate, "dd/mm/yy") is not accepted, try again with
g_date_set_parse(gdate, "yy/mm/dd") thereafter for the 2-digit-year tests.
2022-04-13 00:02:57 +08:00
Philip Withnall
df80a224d7 tests: Use g_test_message() rather than fprintf()
This ensures that the output is redirected properly, and prefixed with
`#` when outputting in TAP mode, so that it doesn’t confuse the TAP
format parser.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-12 13:21:29 +01:00
Philip Withnall
ba9620f947 tests: Ensure NormalizationTest.txt is installed for installed-tests
This should fix the installed-tests CI failure:
https://gitlab.gnome.org/GNOME/glib/-/jobs/1946794

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-12 13:20:48 +01:00
Philip Withnall
fd79c8742b Merge branch 'onceinit_test' into 'main'
Move tests/onceinit.c to glib/tests/onceinit.c

See merge request GNOME/glib!2601
2022-04-12 12:00:27 +00: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
Philip Withnall
3515170461 tests: Make a string comparison on an error string more relaxed
It currently fails on FreeBSD with:
```
Bail out! GLib:ERROR:../glib/tests/spawn-test.c:111:test_spawn_basics: assertion failed (erroutput == "sort: cannot read: non-existing-file.txt: No such file or directory\n"): ("sort: No such file or directory\n" == "sort: cannot read: non-existing-file.txt: No such file or directory\n")
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-08 12:25:59 +01: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
Philip Withnall
be96ea9222 Merge branch 'wip/format_size_value_units' into 'main'
gutils: Add flags to g_format_size_full() to return only value or only units

See merge request GNOME/glib!2545
2022-04-08 10:54:45 +00:00
Milan Crha
05a8ef6647 gutils: Add flags to g_format_size_full() to return only value or only units
This allows to split the formatted size into the value and into the units,
when can be shown differently in the UI.

Relate to https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1391
2022-04-08 11:36:03 +01: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
762ed2e82b Move tests/spawn-test.c -> glib/tests/spawn-test.c
Related to issue #1434
2022-04-07 18:36:45 +02:00
Sebastian Dröge
c80ff2474f Merge branch 'wip/pwithnall/2625-clang-cxx' into 'main'
gatomic: Add a C++ variant of g_atomic_int_compare_and_exchange()

Closes #2625

See merge request GNOME/glib!2578
2022-04-06 10:08:35 +00:00
Philip Withnall
14717e4f41 Merge branch 'cleanup-warnings-split-9' into 'main'
Cleanup warnings split 9

See merge request GNOME/glib!2498
2022-04-05 11:19:51 +00: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
Loic Le Page
19280e2166 Fix non-initialized variable in gio/tests/date.c 2022-04-04 17:39:59 +01:00
Philip Withnall
16d1bc49cc tests: Add C++ tests for typechecking with atomic compare and exchanges
The tests have to be conditional on C++11 being enabled, as the default
C++ standard on macOS is (for some reason), C++97 (`__cplusplus` is
defined as `199711L`).

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

Helps: #2625
2022-04-01 17:22:33 +01:00
Philip Withnall
4e65bcda0c tests: Fix a typo in a test skip message
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-01 17:22:31 +01:00
Loic Le Page
704c65228f Fix global variable name hidden by local variables in glib/tests/asyncqueue.c 2022-04-01 00:18:40 +01:00
Loic Le Page
29c15bc325 Fix global variable name hidden by local variables in glib/tests/base64.c 2022-04-01 00:18:40 +01:00
Loic Le Page
7c138574bd Fix global variable name hidden by local variables in glib/tests/cond.c 2022-04-01 00:18:40 +01:00
Emmanuele Bassi
136dc8afff Merge branch 'fix-deprecation-build' into 'main'
tests: Fix compilation when GLIB_DISABLE_DEPRECATION_WARNINGS is defined

See merge request GNOME/glib!2567
2022-03-30 15:26:54 +00:00
Marc-André Lureau
743cd659f4 tests/filutils: remove an mkdir expected to fail test on win32
When running under msys2 (and supposedly cygwin), the root path is
remapped and permissions are permissive, the test doesn't fail.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-23 16:08:42 +00:00
Marc-André Lureau
bd45147077 tests/io-channel: skip a "unimplemented" error on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-23 16:08:42 +00:00
Marc-André Lureau
0ca9edd15f glib/tests: fix foo=bar=baz environment test
The handling of that case isn't well specified, and system dependent.

However if the system decided that "foo=bar" was the key, then don't
expect "foo" is set.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-23 16:08:42 +00:00
Marc-André Lureau
4403704826 glib/tests: fix test_turkish_strupdown
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-23 16:08:40 +00:00
Marc-André Lureau
44adc6ca8e glib/tests: fix casemap_and_casefold test on win32
Both environment variables and GetThreadLocale() may interefere with the
glib case conversion logic.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-23 16:08:05 +00: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
Philip Withnall
84940a56fd tests: Fix compilation when GLIB_DISABLE_DEPRECATION_WARNINGS is defined
This should fix the Coverity build, which runs with
`-DGLIB_DISABLE_DEPRECATION_WARNINGS` defined in the environment (see
`.gitlab-ci.yml`).

See: https://gitlab.gnome.org/GNOME/glib/-/jobs/1907625
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-22 10:15:40 +00:00
Carlos Garnacho
16fcd0814e glib: Add tests for far away GDateTimes
Poke near the limits (years 9 and 9990) to ensure these also
result in a correct ISO8601 format.
2022-03-21 12:56:42 +00:00
Philip Withnall
2e940e125f Merge branch 'w32-skips' into 'main'
Various win32 tests skip & fixes

See merge request GNOME/glib!2540
2022-03-21 12:19:24 +00:00
Philip Withnall
48a3e8f7f2 Merge branch 'move_g_basename_test' into 'main'
Move unit test on g_basename() function to glib/tests/fileutils.c

See merge request GNOME/glib!2558
2022-03-21 12:14:59 +00:00
Philip Withnall
47f905d2f6 Merge branch 'move_relation_tests' into 'main'
Move tests/relation-test.c to glib/tests/relation.c

See merge request GNOME/glib!2559
2022-03-21 12:12:38 +00:00
Marc-André Lureau
0bdd37b7ff glib/tests: disable a racy check on mainloop test
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-18 00:16:38 +04:00
Marc-André Lureau
56405a2fda glib/tests: skip a failing test with a FIXME
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-18 00:16:38 +04:00
Marc-André Lureau
20f8007f73 glib/tests: fix random failure due to rounding
GLib:ERROR:../glib/tests/timer.c:41:test_timer_basic: assertion failed (micros == ((guint64)(elapsed * 1e6)) % 1000000): (11 == 10)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-18 00:16:38 +04: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
7f7b5ba093 Move unit test on g_basename() function to glib/tests/fileutils.c
g_basename() function is defined in glib/gfileutils.c which is tested
by glib/tests/fileutils.c test set. Until now, g_basename() test was
in glib/test/utils.c. This patch move the unit test to the proper file.
2022-03-17 18:10:09 +01:00
Philip Withnall
7ab9359af0 gtimezone: Fix assertion failure when called with a huge offset
This looks like a regression from commit 3356934db5, but prior to that
commit there was always an assertion failure when calling
`g_time_zone_new_offset()` with an offset which is too large (such as 44
hours), ever since the function was added in commit cf24867b93.

It would be ideal if we could return a `NULL` timezone to indicate the
error, but that’s not part of the API for `g_time_zone_new_offset()`, so
we have to go with the dated and not-ideal approach of returning the UTC
timezone and letting the caller figure it out.

Another potential approach would be to reduce the `offset` modulo 24
hours. This makes the error less easily detectable than if returning
UTC, though, and still returns an invalid result: `+44:00` is not the
same timezone as `+20:00` (it’s one day further ahead).

Add a unit test.

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

Fixes: #2620
2022-03-16 12:52:13 +00:00
Philip Withnall
dbe34687d0 tests: Skip vasprintf() placeholder checks on FreeBSD and macOS
The `vasprintf()` version on those platforms seems to do less rigorous
checking of format placeholders.

See https://gitlab.gnome.org/GNOME/glib/-/jobs/1890001 and
https://gitlab.gnome.org/GNOME/glib/-/jobs/1890000.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-14 17:59:37 +00:00
Philip Withnall
c455d0efb7 tests: Correctly exit and join the worker threads in spawn-multithreaded
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-12 01:46:07 +00:00
Philip Withnall
3f753b0fa3 tests: Fix the prototype of a GChildWatchFunc in spawn-multithreaded
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-12 01:46:07 +00:00
Philip Withnall
ca99cf032d tests: Use separate GMainContext in thread in spawn-multithreaded
Otherwise the `start_thread()` threads and the main thread are competing
to iterate the global default context, which is probably not what was
intended.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-12 01:46:07 +00:00
Philip Withnall
54748d3b7c tests: Lower thread TTLs in spawn-multithreaded
Otherwise the test takes forever, for no discernible benefit.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-12 01:46:07 +00:00