Commit Graph

25205 Commits

Author SHA1 Message Date
Philip Withnall
606bdcdb18 Merge branch 'main' into 'main'
Fix the annotation of g_utf8_strncpy()

See merge request GNOME/glib!2621
2022-04-26 10:23:27 +00:00
Hodong
797bcf3224 Fix the annotation of g_utf8_strncpy() 2022-04-26 18:54:57 +09:00
Sebastian Dröge
fa55f37a88 Merge branch 'log-writer-checks' into 'main'
gmessages: Error if g_log_set_writer_func() is called multiple times

See merge request GNOME/glib!2617
2022-04-26 07:41:56 +00:00
Philip Withnall
862e250eaa Merge branch 'fixes_in_tests' into 'main'
Fixes in tests

See merge request GNOME/glib!2608
2022-04-25 17:30:54 +00:00
Philip Withnall
b56f10c890 Revert "glib/gstdio: simplify GStatBuf macro condition for win64"
This reverts commit ae1cccaa0a.

It broke ABI on 64-bit builds with MSVC, as discussed here:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2449#note_1430571.

Fixes: #2633
2022-04-25 17:58:04 +01:00
Philip Withnall
8a498fa989 gversion: Clarify that GLIB_CHECK_VERSION is a >= check
The documentation body makes it sound like it might be a `==` check;
only the ‘returns’ line previously clarified this.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-25 15:20:16 +01:00
Philip Withnall
6dc7b100f5 Merge branch 'gbookmarkfile_tests' into 'main'
Expand tests on gbookmark file API

See merge request GNOME/glib!2610
2022-04-25 13:37:43 +00:00
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
Philip Withnall
a44a0c07bd Merge branch 'gtype-boxed-type-macro' into 'main'
docs: Expand G_DEFINE_BOXED_TYPE docs with more detailed example

See merge request GNOME/glib!2612
2022-04-25 10:39:27 +00:00
Logan Rathbone
3a4f0746f5 docs: Expand G_DEFINE_BOXED_TYPE docs with more detailed example 2022-04-25 10:39:27 +00:00
Philip Withnall
cc99d6ee97 Merge branch 'gio-windows' into 'main'
Meson: Fix gio-windows-2.0 override name

See merge request GNOME/glib!2615
2022-04-25 10:30:11 +00:00
Philip Withnall
231a4bb9cb Merge branch 'update-inout-annotations' into 'main'
Add inout annotations for g_iconv

See merge request GNOME/glib!2614
2022-04-25 10:28:39 +00:00
Philip Withnall
7ab50b9e29 Merge branch 'gtestutils-add-stdlib' into 'main'
gtestutils: Include stdlib.h for exit function

See merge request GNOME/glib!2613
2022-04-25 10:27:15 +00:00
Xavier Claessens
199ff2a841 Meson: Fix gio-windows-2.0 override name
The override name must match the pkgconfig name.
2022-04-24 21:29:26 -04:00
TestingPlant
39378b2581 Add inout annotations for g_iconv 2022-04-24 19:15:53 +00:00
Bruce Cowan
444fc6ccda Update British English translation
(cherry picked from commit 82feda1ccf)
2022-04-24 10:31:01 +00:00
Biswapriyo Nath
3c841f18c1 gtestutils: Include stdlib.h for exit function
This fixes warning: implicit declaration of function 'exit'
2022-04-23 14:02:10 +05:30
Milo Ivir
497aba96f1 Update Croatian translation 2022-04-20 17:46:52 +00:00
Emmanuel Fleury
6eddfefbfc Expand tests on gbookmark file API 2022-04-19 16:38:41 +02:00
Ask Hjorth Larsen
d147c36bc6 Updated Danish translation 2022-04-18 19:25:00 +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
Enrico Nicoletto
15d6558ea2 Update Brazilian Portuguese translation 2022-04-15 17:07:22 +00: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
Philip Withnall
d987146fe1 Merge branch 'w32-tests' into 'main'
Fix test suite on Windows

See merge request GNOME/glib!2449
2022-04-14 12:16:19 +00:00
Marc-André Lureau
e9f46d3529 gio/tests: fix socket /socket/credentials/unix_socketpair on win32
When I enabled unix socketpair test on win32, I left the existing
g_close(fds[1]), but _g_win32_socketpair() returns native sockets
descriptors that must be closed with closesocket() on win32.

Let GSocket handle the socket pair cleanup.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-04-14 15:38:47 +04:00
Marc-André Lureau
89539d9ae0 gio/tests: GStatBuf.st_size is 64 bits on win64
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-04-14 15:38:47 +04:00
Marc-André Lureau
ae1cccaa0a glib/gstdio: simplify GStatBuf macro condition for win64
As noted by Charlie Barto: "both mingw64 and msvc define _WIN64 in
64-bit mode, and both are LLP64, and both have struct _stat64 defined
the same way."

https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2449#note_1372190

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-04-14 15:38:47 +04: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
Philip Withnall
a072c84d95 Merge branch 'gdate-no-dst' into 'main'
GDate: Fix tests on Windows on certain locales

See merge request GNOME/glib!2600
2022-04-13 21:12:46 +00: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
Chun-wei Fan
697d3112b0 gdate.c: Use standard name if no daylight saving exists
We should normally have a standard name for the time zone even if we don't
have daylight saving in the time zone, so use the standard name also when
GetTimeZoneInformation() returns TIME_ZONE_ID_UNKNOWN[1][2].

[1]: https://docs.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-gettimezoneinformation
[2]: https://docs.microsoft.com/zh-tw/windows/win32/api/timezoneapi/nf-timezoneapi-settimezoneinformation
2022-04-12 23:43:16 +08:00
Philip Withnall
58f54e8303 tests: Reduce wakeup interval in gdbus-threading
When checking that the connection has the expected number of refs, the
test would block on a `GMainContext` iteration for up to 3s before
waking up and failing (if the refcount was still not as expected).

This check was written in the expectation that changing the refcount of
the connection would only happen due to dispatching a source on
`GMainContext` — hence the `GMainContext` would wake up as the refcount
changed.

That’s probably not actually true though. It might be the case that the
connection’s refcount is changed on from the GDBus worker thread, which
would not cause any wakeups on the main thread’s `GMainContext`.

In this case, the `GMainContext` iteration in
`assert_connection_has_one_ref()` would block for the full 3s, and then
wake up and notice the refcount is correct (then the test would
proceed).

That’s fine, apart from the fact that `test_threaded_singleton()` does
this 1000 times. If the slow case is hit on a significant number of
those test runs, the test will take around 3000s to complete, which is
significantly more than meson’s test timeout of 360s. So the test fails
with something like:
```
220/266 glib:gio+slow / gdbus-threading         TIMEOUT 360.07 s

--- command ---
G_TEST_SRCDIR='/builds/GNOME/glib/gio/tests' GIO_MODULE_DIR='' G_TEST_BUILDDIR='/builds/GNOME/glib/_build/gio/tests' /builds/GNOME/glib/_build/gio/tests/gdbus-threading
--- stdout ---
\# random seed: R02S83fe8de22db4d4f376e6d179e2bdd601
1..3
\# Start of gdbus tests
ok 1 /gdbus/delivery-in-thread
ok 2 /gdbus/method-calls-in-thread
\# GLib-GIO-DEBUG: refcount of 0x5602de913660 is not right (3 rather than 1) in test_threaded_singleton(), sleeping
\# GLib-GIO-DEBUG: refcount of 0x5602de913660 is not right (3 rather than 1) in test_threaded_singleton(), sleeping
\# GLib-GIO-DEBUG: refcount of 0x5602de913c60 is not right (3 rather than 1) in test_threaded_singleton(), sleeping
\# GLib-GIO-DEBUG: refcount of 0x5602de913c60 is not right (3 rather than 1) in test_threaded_singleton(), sleeping
\# GLib-GIO-DEBUG: refcount of 0x5602de913260 is not right (3 rather than 1) in test_threaded_singleton(), sleeping
\# GLib-GIO-DEBUG: refcount of 0x5602de913260 is not right (3 rather than 1) in test_threaded_singleton(), sleeping
```

From this log, it can be seen that the sleep is happening on a different
`GMainContext` every other time, so the test *is* making progress.

Assuming this is a correct diagnosis (it’s a lot of guessing), this
commit tries to fix the test by adding a wakeup timeout to the
`GMainContext` in `assert_connection_has_one_ref()`, which will wake it
up every 50ms to re-check the exit condition.

This polling approach has been taken because it doesn’t seem feasible to
make sure that every `g_object_ref()`/`g_object_unref()` call on a
`GDBusConnection` causes the main context to wake up.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-12 14:39:43 +01:00
Philip Withnall
77416fc023 tests: Use g_assert_*() rather than g_assert() in gdbus-peer-object-manager
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-12 13:29:19 +01:00
Philip Withnall
20c3ab9e51 tests: Use G_TEST_OPTION_ISOLATE_DIRS in gdbus-peer-object-manager
This might fix a recent test failure:
https://gitlab.gnome.org/GNOME/glib/-/jobs/1929015. Unfortunately
there’s not much debug information in the logs to go on, and I can’t
reproduce it locally. All I have is:
```
192/272 glib:gio / gdbus-peer-object-manager    FAIL     0.43 s (killed by signal 11 SIGSEGV)

--- command ---
GIO_MODULE_DIR='' G_TEST_BUILDDIR='/builds/GNOME/glib/_build/gio/tests' G_TEST_SRCDIR='/builds/GNOME/glib/gio/tests' /builds/GNOME/glib/_build/gio/tests/gdbus-peer-object-manager
--- stdout ---
\# random seed: R02Seee9b7325ecd7c19249a3412397aed9b
1..2
\# Start of gdbus tests
\# Start of peer-object-manager tests
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-12 13:29:19 +01: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
Simon McVittie
bb04fdc013 Merge branch 'wip/pwithnall/fix-bsd-spawn-test' into 'main'
tests: Make a string comparison on an error string more relaxed

See merge request GNOME/glib!2597
2022-04-11 15:16:20 +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
Emmanuel Fleury
91dddb0641 Convert onceinit.c to glib test framework 2022-04-11 15:26:33 +02:00
Aleksandr Melman
382244631c Update Russian translation 2022-04-09 15:34:12 +00:00
Yuri Chornoivan
51c7215c50 Update Ukrainian translation 2022-04-08 11:43:26 +00:00
Philip Withnall
403edad934 ci: Combine style-check-diff and check-todos jobs into one
They are functionally quite similar, and combining them saves around 1
minute of CI runner time per pipeline, which is a nice saving for very
little downside.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-08 12:37:08 +01: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
Philip Withnall
900b945988 Merge branch 'spawn_test' into 'main'
Move tests/spawn-test.c -> glib/tests/spawn-test.c

See merge request GNOME/glib!2575
2022-04-08 10:38:36 +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