Collin Funk [Tue, 3 Mar 2026 05:43:22 +0000 (21:43 -0800)]
tests: avoid false test failure when using address sanitizer
* tests/misc/warning-errors.sh: Skip commands which have been built with
sanitizers, since standard error will not be closed and checked for
errors.
Reported by Bruno Haible.
Collin Funk [Tue, 3 Mar 2026 06:16:21 +0000 (22:16 -0800)]
tests: avoid failure on systems without an optimized 'cksum' or 'wc -l'
* tests/misc/warning-errors.sh: Expect 'wc' and 'cksum' to exit
successfully if there is not an optimized 'wc -l' implementation or
CRC32 implementation.
Reported by Bruno Haible.
oech3 [Mon, 2 Mar 2026 11:56:23 +0000 (11:56 +0000)]
tests: shuf: ensure memory exhaustion is handled gracefully
* tests/shuf/shuf.sh: Ensure we exit 1 upon failure
to allocate memory.
https://github.com/uutils/coreutils/issues/11170
https://github.com/coreutils/coreutils/pull/209
Collin Funk [Sun, 1 Mar 2026 02:36:34 +0000 (18:36 -0800)]
tests: wc,du: add additional --files0-from test cases
* tests/wc/wc-files0-from.pl ($limits): New variable.
(@Tests): Prefer the error strings from getlimits over writing them by
hand. Add test cases for --files0-from listing missing files and
duplicate files.
* tests/du/files0-from.pl ($limits): New variable.
(@Tests): Prefer the error strings from getlimits over writing them by
hand. Add test cases for --files0-from listing missing files. Add tests
for --files0-from listing duplicate files with and without the -l option
also in use.
Paul Eggert [Sat, 28 Feb 2026 00:17:27 +0000 (16:17 -0800)]
id: avoid unnecessary buffer flushing
* src/groups.c (main):
* src/id.c (main, print_stuff):
Don’t flush stdout before testing for write error.
Do the test only when in a loop, as a one-shot will
test for write error soon anyway.
Paul Eggert [Sat, 28 Feb 2026 00:17:27 +0000 (16:17 -0800)]
cksum: prefer signed int
* src/cksum.c (min_digest_line_length, digest_hex_bytes)
(digest_length, md5_sum_stream, sha1_sum_stream)
(sha224_sum_stream, sha256_sum_stream, sha384_sum_stream)
(sha512_sum_stream, sha2_sum_stream, sha3_sum_stream)
(blake2b_sum_stream, sm3_sum_stream, problematic_chars)
(filename_unescape, valid_digits, bsd_split_3)
(algorithm_from_tag, split_3, digest_file, output_file)
(b64_equal, hex_equal, digest_check, main):
* src/cksum_avx2.c (cksum_avx2):
* src/cksum_avx512.c (cksum_avx512):
* src/cksum_crc.c (cksum_fp_t, cksum_slice8, crc_sum_stream)
(crc32b_sum_stream, output_crc):
* src/cksum_pclmul.c (cksum_pclmul):
* src/cksum_vmull.c (cksum_vmull):
* src/sum.c (bsd_sum_stream, sysv_sum_stream, output_bsd, output_sysv):
Prefer signed to unsigned int where either will do.
This allows better checking with -fsanitize=undefined.
It should also help simplify future patches, so that they
needn’t worry whether comparisons like ‘i < len - 2’ will misbehave.
Collin Funk [Fri, 27 Feb 2026 04:39:12 +0000 (20:39 -0800)]
stat: don't check QUOTING_STYLE when --printf %%N is used
* NEWS: Mention the fix.
* src/stat.c (main): Only check QUOTING_STYLE if there is a %N that is
not preceded by a percentage sign.
* tests/stat/stat-fmt.sh: Add some test cases.
Collin Funk [Thu, 26 Feb 2026 04:59:35 +0000 (20:59 -0800)]
id: promptly diagnose write errors
* NEWS: Mention the improvement.
* src/id.c (print_stuff): Call fflush for each listed user to check for
write errors.
* tests/misc/io-errors.sh: Add an invocation of 'id'.
Collin Funk [Thu, 26 Feb 2026 04:56:12 +0000 (20:56 -0800)]
groups: promptly diagnose write errors
* NEWS: Mention the improvement.
* src/groups.c (main): Call fflush for each listed user to check for
write errors.
* tests/misc/io-errors.sh: Add an invocation of 'groups'.
Pádraig Brady [Thu, 26 Feb 2026 20:06:29 +0000 (20:06 +0000)]
tests: ensure failure to write warnings is handled gracefully
* tests/misc/warning-errors.sh: Add a new test to ensure
failure to write warnings is diagnosed in the exit status.
* tests/local.mk: Reference the new test.
oech3 [Thu, 26 Feb 2026 12:04:56 +0000 (21:04 +0900)]
tests: shuf: ensure randomization doesn't depend solely on ASLR
* tests/shuf/shuf.sh: Use setarch --addr-no-randomize to disable
ASLR, and show the output is still random.
https://github.com/coreutils/coreutils/pull/198
* tests/factor/factor.pl: Verify that embedded NULs
on stdin terminate the _number_.
* tests/numfmt/numfmt.p: Verify that embedded NULs
on stdin terminate the _line_.
https://github.com/coreutils/coreutils/pull/196
Pádraig Brady [Tue, 24 Feb 2026 15:44:41 +0000 (15:44 +0000)]
tests: fix "Hangup" termination of non-interactive runs
This avoids the test harness being terminated like:
make[1]: *** [Makefile:24419: check-recursive] Hangup
make[3]: *** [Makefile:24668: check-TESTS] Hangup
make: *** [Makefile:24922: check] Hangup
make[2]: *** [Makefile:24920: check-am] Hangup
make[4]: *** [Makefile:24685: tests/misc/usage_vs_refs.log] Error 129
...
This happened sometimes when the tests were being run non interactively.
For example when run like:
setsid make TESTS="tests/timeout/timeout.sh \
tests/tail/overlay-headers.sh" SUBDIRS=. -j2 check
Note the race window can be made bigger by adding a sleep
after tail is stopped in overlay-headers.sh
The race can trigger the kernel to induce its job control
mechanism to prevent stuck processes.
I.e. where it sends SIGHUP + SIGCONT to a process group
when it determines that group may become orphaned,
and there are stopped processes in that group.
* tests/tail/overlay-headers.sh: Use setsid(1) to keep the stopped
tail process in a separate process group, thus avoiding any kernel
job control protection mechanism.
* tests/timeout/timeout.sh: Use setsid(1) to avoid the kernel
checking the main process group when sleep(1) is reparented.
Fixes https://bugs.gnu.org/80477
Collin Funk [Sun, 22 Feb 2026 22:20:30 +0000 (14:20 -0800)]
doc: tee: avoid the use of gpg cleartext signatures in an example
Cleartext signatures have many gotchas. Therefore, the use of detached
signatures is recommended where possible. See:
<https://gnupg.org/blog/20251226-cleartext-signatures.html>.
* doc/coreutils.texi (tee invocation): Adjust gpg invocation to produce
a detached signature.
oech3 [Mon, 23 Feb 2026 10:22:44 +0000 (19:22 +0900)]
tests: whoami, logname: verify error handling
* tests/df/no-mtab-status-masked-proc.sh: Tweak unshare check.
* tests/local.mk: Reference new test.
* tests/misc/user.sh: Add new test using unshare -U, to verify
that whoami and logname diagnose failure correctly.
https://github.com/coreutils/coreutils/pull/195
* NEWS: Mention the performance improvement.
* src/shuf.c (write_permuted_numbers, write_random_numbers): Prefer
fputs and fputc which may be unlocked over printf which locks standard
output.
Collin Funk [Wed, 18 Feb 2026 08:03:05 +0000 (00:03 -0800)]
wc: add aarch64 Neon optimization for wc -l
Here is an example of the performance improvement:
$ yes abcdefghijklmnopqrstuvwxyz | head -n 100000000 > input
$ time ./src/wc-prev -l < input 100000000
real 0m0.793s
user 0m0.630s
sys 0m0.162s
$ time ./src/wc -l < input 100000000
real 0m0.230s
user 0m0.065s
sys 0m0.164s
* NEWS: Mention the performance improvement.
* gnulib: Update to the latest commit.
* configure.ac: Check the the necessary intrinsics and functions.
* src/local.mk (noinst_LIBRARIES) [USE_NEON_WC_LINECOUNT]: Add
src/libwc_neon.a.
(src_libwc_neon_a_SOURCES, wc_neon_ldadd, src_libwc_neon_a_CFLAGS)
[USE_NEON_WC_LINECOUNT]: New variables.
(src_wc_LDADD) [USE_NEON_WC_LINECOUNT]: Add $(wc_neon_ldadd).
* src/wc.c [USE_NEON_WC_LINECOUNT]: Include sys/auxv.h and asm/hwcap.h.
(neon_supported) [USE_NEON_WC_LINECOUNT]: New function.
(wc_lines) [USE_NEON_WC_LINECOUNT]: Use neon_supported and
wc_lines_neon.
* src/wc.h (wc_lines_neon): Add declaration.
* src/wc_neon.c: New file.
* doc/coreutils.texi (Hardware Acceleration): Document the "-ASIMD"
hwcap and the variable used in ./configure to override detection of Neon
instructions.
* tests/wc/wc-cpu.sh: Also add "-ASIMD" to disable the use of Neon
instructions.
Pádraig Brady [Sat, 14 Feb 2026 12:15:15 +0000 (12:15 +0000)]
maint: tests: avoid EPERM specific handling
* tests/dd/fail-ftruncate-fstat.sh: Use $EPERM rather than
mapping specific strings to the Linux $EPERM.
* tests/mkdir/smack-no-root.sh: Use $EPERM rather than hardcoding.
Collin Funk [Wed, 18 Feb 2026 02:45:33 +0000 (18:45 -0800)]
maint: expr: reduce variable scope
* src/expr.c (mbs_logical_cspn, main, trace, docolon, eval7, eval6)
(eval5, eval4, eval3, eval2, eval1, eval): Declare variables where they
are used instead of at the start of the function.
Chris Down [Mon, 16 Feb 2026 05:06:31 +0000 (13:06 +0800)]
pwd: fix heap buffer overflow in file_name_prepend
file_name_prepend works by right-aligning path data in a growing buffer.
When the buffer is too small, it then allocates a new buffer via
xpalloc() and copies existing data to the end of the new buffer.
Unfortunately, the memcpy destination is computed as buf + p->n_alloc -
n_free, but xpalloc has already updated p->n_alloc to the new (larger)
allocation size while n_free still reflects the old state. This places
the data at too high an offset, writing past the end of the buffer.
Update to properly calculate the destination offset.
Fixes: v9.5-171-g61ab25c35 ("pwd: prefer xpalloc to xnrealloc")
oech3 [Thu, 12 Feb 2026 17:07:30 +0000 (17:07 +0000)]
tests: coreutils: remove redundant validity check
* tests/misc/coreutils.sh: Remove the check for non-empty coreutils.h,
as the existing `print_ver_ coreutils` is sufficient to determine
support for single binary mode.
https://github.com/coreutils/coreutils/pull/189
Pádraig Brady [Sun, 8 Feb 2026 19:41:41 +0000 (19:41 +0000)]
tests: determine errno string more efficiently
* tests/misc/read-errors.sh: Use getlimits_ determined EIO error string,
rather than inferring the string from bash's output.
See https://bugs.gnu.org/80353
Pádraig Brady [Sun, 8 Feb 2026 19:34:13 +0000 (19:34 +0000)]
tests: getlimits: output error strings
* src/getlimits.c (main): Iterate over defined errnos,
and output shell compatible error strings.
* tests/Coreutils.pm: Adjust so shell quotes are stripped.
Collin Funk [Tue, 10 Feb 2026 06:30:48 +0000 (22:30 -0800)]
maint: pinky: reduce variable scope
* src/pinky.c (create_fullname, idle_string, print_entry)
(print_long_entry, main): Declare variables where they are used instead
of at the start of the function. Initialize variables where they are
declared.
Collin Funk [Sat, 7 Feb 2026 19:15:23 +0000 (11:15 -0800)]
nl: support multi-byte section delimiters
* NEWS: Mention the improvement.
* src/nl.c: Include mcel.h.
(DEFAULT_SECTION_DELIMITERS): Resize to fit 2 multi-byte characters.
(section_del_len): New variable.
(check_section): Compare against section_del_len instead of 2.
(main): Support multi-byte characters for the -d option.
* tests/nl/multibyte.sh: New file.
* tests/nl/nl.sh: New file, moved from tests/misc/nl.sh.
* tests/local.mk (all_tests): Add the new test. Adjust the existing
tests file name.
* cfg.mk (exclude_file_name_regexp--sc_space_tab): Adjust Adjust the
existing tests file name.
Sam James [Sun, 8 Feb 2026 00:25:40 +0000 (00:25 +0000)]
build: fix --enable-single-binary=hardlinks with dash
With dash as /bin/sh, you get the error
```
checking for sys/capability.h... yes
./configure: 95775: test: no: unexpected operator
checking for working fork... yes
```
* configure.ac: Use '=' in test for equality, not '==',
for POSIX shell compatibility.
* NEWS: Mention the build fix.