summaryrefslogtreecommitdiff
path: root/glib/tests
Commit message (Collapse)AuthorAgeFilesLines
* gstring: add g_string_new_takePeter Eisenmann2023-05-161-0/+36
| | | | | Adds a GString constructor that takes over ownership of an existing, dynamically allocated, string.
* tests: Fix assertion failures when running fileutils test as roothanhuihui2023-05-111-4/+17
|
* tests: Move a function to allow looking at CAP_DAC_OVERRIDEhanhuihui2023-05-111-40/+40
| | | | | This introduces no functional changes but allows `CAP_DAC_OVERRIDE` to be used in a subsequent commit.
* Merge branch 'fix-group-comment' into 'main'Philip Withnall2023-05-101-2/+73
|\ | | | | | | | | | | | | gkeyfile: Fix group comment management Closes #104 and #2927 See merge request GNOME/glib!3380
| * gkeyfile: Fix group comment managementGaël Bonithon2023-04-201-2/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes the `comment` member of the GKeyFileGroup structure, which seemed intended to distinguish comments just above a group from comments above them, separated by one or more blank lines. Indeed: * This does not seem to match any specification in the documentation, where blank lines and lines starting with `#` are indiscriminately considered comments. In particular, no distinction is made between the comment above the first group and the comment at the beginning of the file. * This distinction was only half implemented, resulting in confusion between comment above a group and comment at the end of the preceding group. Instead, the same logic is used for groups as for keys: the comment above a group is simply the sequence of key-value pairs of the preceding group where the key is null, starting from the bottom. The addition of a blank line above groups when writing, involved in bugs #104 and #2927, is kept, but: * It is now added as a comment as soon as the group is added (since a blank line is considered a comment), so that `g_key_file_get_comment()` returns the correct result right away. * It is always added if comments are not kept. * Otherwise it is only added if the group is newly created (not present in the original data), in order to really keep comments (existing and not existing). Closes: #104, #2927
* | Merge branch 'wip/p3732/timeout-seconds-once' into 'main'Philip Withnall2023-05-091-0/+20
|\ \ | | | | | | | | | | | | add g_timeout_add_seconds_once See merge request GNOME/glib!3383
| * | add g_timeout_add_seconds_oncePeter Eisenmann2023-05-021-0/+20
| | | | | | | | | | | | | | | Add a new call combing behaviors of g_timeout_add_seconds and g_timeout_add_once.
* | | tests: Zero the rlimit in standalone tests which are expected to abortPhilip Withnall2023-05-022-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This should hopefully stop the kernel spending a lot of memory and disk bandwidth creating coredumps for them unnecessarily, which slows down the rest of the tests and generally wastes resources. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: #2939
* | | tests: Add copyright/licensing header to assert-msg-testPhilip Withnall2023-05-021-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is put together through git archaeology: ``` git log -- glib/tests/assert-msg-test.c tests/assert-msg-test.c ``` The following commits were too trivial to have meaningful copyright: - 8e59d8602ca5921d78245f5d2b405b517a5e7cf9 - 44c004c84e9080040ff4e0e90b322dda0561cf85 - 207b8cb8a50d68e207d28b59e588311a5cbd9772 - a1bee97d4f093db01dee834bf3292eabd5b13d17 Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: #1415
* | | tests: Reformat assert-msg-test.c to follow coding stylePhilip Withnall2023-05-021-3/+6
|/ / | | | | | | Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
* | Merge branch 'gmain-less-locks' into 'main'Philip Withnall2023-04-241-0/+70
|\ \ | | | | | | | | | | | | gmain: Avoid some lock/unlock dance during g_main_context_iterate See merge request GNOME/glib!3235
| * | gmain: Do not dead-look if calling g_main_loop_run from a GSourceMarco Trevisan (Treviño)2023-04-191-0/+70
| | | | | | | | | | | | | | | | | | | | | This should fail and warn but not leaving the context acquired and locked. Add tests.
* | | glib/tests/[rec-]mutex: Allow each thread to workMarco Trevisan (Treviño)2023-04-202-2/+2
| | | | | | | | | | | | | | | | | | | | | In non-perf mode, we were making only one thread to win the race to increase the value, but since we're launching more threads anyways let's allow more of them to have a chance to do something, to make the test more valuable, even if it's still quick enough.
* | | Merge branch 'valgrind-variable' into 'main'Marco Trevisan2023-04-171-0/+31
|\ \ \ | | | | | | | | | | | | | | | | meson: Add glib_valgrind_suppressions variable to glib pkg-config file See merge request GNOME/glib!3361
| * | | meson: Add tests for generated pkg-config filesMarco Trevisan (Treviño)2023-04-171-0/+31
| | | | | | | | | | | | | | | | Ensure things are generated as we expect and avoid we regress on that.
* | | | Merge branch 'no-usleep-on-0' into 'main'Philip Withnall2023-04-171-0/+24
|\ \ \ \ | |_|_|/ |/| | | | | | | | | | | gtimer: Avoid doing anything on g_usleep (0) See merge request GNOME/glib!3381
| * | | gtimer: Avoid doing anything on g_usleep (0)Marco Trevisan (Treviño)2023-04-141-0/+24
| |/ / | | | | | | | | | | | | It's unlikely to happen, but still could be the case, so avoid do anything.
* | | Merge branch 'work-around-ucrt-spawn-env-issue' into 'main'Philip Withnall2023-04-141-1/+150
|\ \ \ | | | | | | | | | | | | | | | | Work around an UCRT issue with _wspawn() functions taking an envp block See merge request GNOME/glib!3289
| * | | Add test for UCRT issue workaroundLuca Bacci2023-04-141-1/+150
| | | |
* | | | Merge branch 'normalize-utf8-bounds-checking' into 'main'Philip Withnall2023-04-141-0/+38
|\ \ \ \ | |/ / / |/| | | | | | | | | | | g_utf8_normalize: don't read past the end of the buffer See merge request GNOME/glib!3341
| * | | Test g_utf8_normalize() handling of invalid UTF-8 inputsTodd Carson2023-04-141-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add three classes of test case for which g_utf8_normalize() should safely return NULL: - Strings ending with a truncated multibyte character which would extend past the NUL terminator - Strings ending with a multibyte character which extends past the length limit provided by the max_len argument - Strings containing an invalid multibyte character in any position
* | | | Merge branch '2307-mainloop-test-asan' into 'main'Philip Withnall2023-04-141-5/+0
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tests: Re-enable mainloop test under AddressSanitizer Closes #2307 See merge request GNOME/glib!3329
| * | | | tests: Re-enable mainloop test under AddressSanitizerPhilip Withnall2023-03-171-5/+0
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a partial revert of commit f378352051. The leak of a `GMainLoop` which prompted it has been fixed by commit 4f5da8338127e25e5ebb54f5a4a95ffc2e40adcc in merge request !2535. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> See: #2598 Fixes: #2307
* | | | Merge branch '95-markup-docs' into 'main'Emmanuele Bassi2023-04-132-0/+169
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | docs: Add simple GMarkup parser example Closes #95 See merge request GNOME/glib!3364
| * | | | docs: Add simple GMarkup parser exampleDavid King2023-04-112-0/+169
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on an initial parser by Luc Pionchon. Tweaked to update to the latest coding standards by Philip Withnall. Fixes: #95
* | | | | Merge branch 'libicu-tests' into 'main'Emmanuele Bassi2023-04-131-0/+52
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | unicode: add tests for g_utf8_normalize() and empty strings See merge request GNOME/glib!3326
| * | | | | glib: unicode: add some empty string testsGuillaume Desmottes2023-03-151-0/+12
| | | | | |
| * | | | | glib: unicode: add tests for g_utf8_normalize()Guillaume Desmottes2023-03-151-0/+40
| | |_|/ / | |/| | | | | | | | | | | | | | | | | | Test corner cases and some examples from Unicode Standard Annex #15 http://unicode.org/reports/tr15/
* | | | | Merge branch 'update-unicode-normalisation-tests' into 'main'Emmanuele Bassi2023-04-131-5/+87
|\ \ \ \ \ | |_|/ / / |/| | | | | | | | | | | | | | tests: Update Unicode normalisation tests from Unicode 15 See merge request GNOME/glib!3351
| * | | | tests: Update Unicode normalisation tests from Unicode 15Philip Withnall2023-03-241-5/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The file comes from https://www.unicode.org/Public/UCD/latest/ucd/NormalizationTest.txt. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
* | | | | Merge branch 'drop-gitignore' into 'main'Marco Trevisan2023-04-051-89/+0
|\ \ \ \ \ | |/ / / / |/| | | | | | | | | | | | | | build: Drop old .gitignore files from test directories See merge request GNOME/glib!3333
| * | | | build: Drop old .gitignore files from test directoriesPhilip Withnall2023-03-201-89/+0
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | They just listed built files. Since the move to Meson, these are all kept in a separate build directory, not the source tree, so don’t need to be ignored. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
* | | | tests: Check a few results in strfuncs testsPhilip Withnall2023-03-201-0/+10
|/ / / | | | | | | | | | | | | | | | This fixes some written-but-never-read warnings from `scan-build`. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
* | | Merge branch 'queue-test' into 'main'Philip Withnall2023-03-161-162/+182
|\ \ \ | | | | | | | | | | | | | | | | tests: Reduce number of iterations in queue test See merge request GNOME/glib!3324
| * | | tests: Simplify a helper function in queue testPhilip Withnall2023-03-161-18/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove an unnecessary intermediate variable. This introduces no functional changes. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
| * | | tests: Fix signed/unsigned comparisons and assignments in queue testPhilip Withnall2023-03-161-25/+27
| | | | | | | | | | | | | | | | | | | | | | | | This introduces no functional changes. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
| * | | tests: Reduce number of iterations in queue testPhilip Withnall2023-03-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unless `-m thorough` is passed to the tests, reduce the number of iterations in the random test. This one test case takes the bulk of the time to run the `queue` test suite, and is sometimes causing timeouts when running on CI (particularly under valgrind). Reduce it to a fifth. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
| * | | tests: Add copyright/licensing header to queue testsPhilip Withnall2023-03-161-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is put together through git archaeology: ``` git log glib/tests/queue.c git log -- tests/queue-test.c ``` The following commits were too trivial to have meaningful copyright: - 8f02fac4ad1e846f3075ae8b057b387e6365c0ca - d81ac5339fcf9537a3731ebb5770238f4fa69d59 - 29f2ced8eb32d9001da8082c4530f017decb8267 - 1a2c5e155deacb7ebeb8d0ca2c800a97a90a7ab9 - 8a90f5e9f6da778743aaec365ee4ceb62b717130 - 45dae4b5063f9af7de8211ced95dd73cc770a86e - 2aa71ab63b4457324c53700ab38ed83c3ccf7d5e - 3a74ad128eb9a3431c54a88fa36269cb41e11c3e Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: #1415
| * | | tests: Use g_assert_*() rather than g_assert() in queue testsPhilip Withnall2023-03-161-121/+128
| |/ / | | | | | | | | | | | | | | | It won’t get compiled out with `G_DISABLE_ASSERT`. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
* | | Merge branch 'xry111/issue2936' into 'main'Philip Withnall2023-03-161-0/+32
|\ \ \ | |/ / |/| | | | | | | | | | | | | | gstrfuncs: Improve inline version of g_strdup() to avoid breaking C++ code Closes #2936 See merge request GNOME/glib!3322
| * | gstrfuncs: Improve inline version of g_strdup() to avoid breaking C++ codeXi Ruoyao2023-03-151-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Wrap the logic into a G_ALWAYS_INLINE function, instead of using a complex statement-expression which is not allowed in braced initializer lists and expanded into some bad thing when it's used as `::g_strdup(...)`. We cannot use `__builtin_constant_p (str)` because GCC documentation clearly states that it always produces 0 when str is a const char * argument of an inline function. But `__builtin_constant_p (!str)`, `__builtin_constant_p (!!str)`, and `__builtin_constant_p (strlen (str))` functions properly with `-O1` or above enabled. Fixes #2936.
* | | Merge branch 'bookmarkfile-timings' into 'main'Marco Trevisan2023-03-131-1/+1
|\ \ \ | | | | | | | | | | | | | | | | tests: Change the time function used in the bookmark tests See merge request GNOME/glib!3315
| * | | tests: Change the time function used in the bookmark testsPhilip Withnall2023-03-061-1/+1
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current comparison has been seen to fail on vs2017-x86 (https://gitlab.gnome.org/pwithnall/glib/-/jobs/2643197): ``` not ok /bookmarks/deprecated - GLib:ERROR:../glib/tests/bookmarkfile.c:921:test_deprecated: assertion failed (t >= now): (1678122080 >= 1678122081) ``` I guess this is caused by a mismatch between the system clock as used by `time (NULL)` and `g_get_real_time ()` (which is ultimately what `g_bookmark_file_set_added()` uses) on Windows. Attempt to fix that by using `g_get_real_time()` in the test harness too, so the clock being used is consistent. If that doesn’t work, my next guess is that some of the code in `test_deprecated()` is being reordered by the compiler. But that shouldn’t happen, because the `time()` call has side-effects, and `g_bookmark_file_set_added()` has side-effects, so they shouldn’t be reordered with respect to each other. And certainly not so that the latter one (in code order) ends up being called 1s after the other. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
* | | tests: only build messages-low-memory if RTLD_NEXT is availableChristoph Reiter2023-03-121-1/+1
|/ / | | | | | | | | This fixes the build under cygwin which doesn't have RTLD_NEXT. Use the existing have_rtld_next to skip the test program in that case.
* | tests: Skip assert-msg-test.py if gdb failsMatt Turner2023-03-021-3/+3
| | | | | | | | | | | | | | Similar to commit 6e44151bf74d, skip the test if gdb is unable to read /proc/PID/mem, which gdb does as a fallback if ptrace is unavailable. This allows the test to skip when run under Gentoo's sandbox.
* | tests: Add some missing g_thread_join() calls to onceinit testPhilip Withnall2023-02-231-1/+7
| | | | | | | | | | | | | | Running the test under asan was failing as the threads were being leaked. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
* | Merge branch 'w-sign-conversion' into 'main'Emmanuele Bassi2023-02-222-36/+41
|\ \ | | | | | | | | | | | | tests: Add a -Wsign-conversion test for gstring.h See merge request GNOME/glib!3275
| * | tests: Use g_assert_*() rather than g_assert() in string testsPhilip Withnall2023-02-161-30/+30
| | | | | | | | | | | | | | | | | | It won’t get compiled out with `G_DISABLE_ASSERT`. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
| * | tests: Add a -Wsign-conversion test for gstring.hPhilip Withnall2023-02-161-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While it’s not possible to build GLib with `-Wsign-conversion` enabled (there are too many warnings), it would be useful to check that GLib’s public headers can be used with `-Wsign-conversion` enabled, as some projects want to do that. For example, dnf5 is built that way (see issue #2919). Add a simple regression test for this, by re-building the `gstring` tests with `-Wsign-conversion` enabled. Since they include `glib.h`, this will test all the public libglib headers by proxy. Since this is a compile-only test, it doesn’t need to be installed. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: #2919
| * | tests: Fix some sign-conversion warnings in the GString testsPhilip Withnall2023-02-161-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | This will be useful for the next commit. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: #2919