5495 Commits

Author SHA1 Message Date
Sylvestre Ledru d719413160 tests: ls: verify correct alignment with ACLs
* tests/ls/acl.sh: Check that the gap between the '+' indicator and
the link count is the same whether the listing contains one or
several ACL entries.
https://github.com/coreutils/coreutils/pull/251
2026-05-05 15:33:55 +01:00
Pádraig Brady e636811481 ls: exclude newline from consideration in line width
* src/ls.c (calculate_columns): Treat width as inclusive max.
(print_with_separator): Likewise.  Also handle commas explicitly,
since they're not catered for by an implicit newline in the count.
* tests/ls/w-option.sh: Adjust exact-fit column tests.
Note this change also makes the existing `ls -w4 -x -T0 a b` test
behave consistently with other output width limits.
Also add the test case from:
https://github.com/coreutils/coreutils/pull/213
* tests/ls/m-option.sh: Add a test case to ensure appropriate
wrapping when trailing comma at the line limit.
* NEWS: Mention the change in behavior.
2026-05-04 23:58:12 +01:00
Pádraig Brady 13b8c11275 ls: fix too few display columns edge case
In the edge case where the right most column would
consist of only files taking 1 or 2 cells, we accounted
for 3 cells, which would result in using 1 column too few.
This should have been part of commit v8.24-59-ge71be1292

* src/ls.c (init_column_info): Don't account for separator
in the the final column.
* tests/ls/w-option.sh: Add a test case.
2026-05-04 23:57:48 +01:00
Pádraig Brady dce828c3d6 tests: fix false failure with spaces in hierarchy
* tests/sort/sort-buffer-size.sh: Use `pwd` rather than $PWD,
and quote appropriately.
Reported by Bruno Haible.
2026-05-04 23:38:51 +01:00
Pádraig Brady a0b4ac0fa2 tests: tee: ensure tee is non buffered
* tests/tee/tee.sh: tests/misc/responsive.sh only confirms
responsiveness to lines, so add a test for non line terminated.
https://github.com/coreutils/coreutils/pull/259
2026-05-03 11:31:27 +01:00
Collin Funk 3f650f6924 tests: all: ensure closed stdin is handled appropriately
* tests/misc/close-stdin.sh: New file.
* tests/local.mk (all_tests): Add the new test.
2026-05-02 14:23:11 -07:00
Collin Funk 2de1a28bcf sum,cksum: consistently emit detailed write errors
Previously the string from strerror would only be printed for some
algorithms:

    $ cksum -a sha2 -l 256 /dev/null > /dev/full
    cksum: write error: No space left on device
    $ cksum -a sysv /dev/null > /dev/full
    cksum: write error

This patch fixes it so that the error information is always printed:

    $ ./src/cksum -a sha2 -l 256 /dev/null > /dev/full
    cksum: write error: No space left on device
    $ ./src/cksum -a sysv /dev/null > /dev/full
    cksum: write error: No space left on device

* src/cksum.c (output_file): Don't check for a write error here.
(main): Check for it here instead.
* tests/misc/io-errors.sh: Add a 'cksum' invocation for each supported
algorithm.
https://github.com/coreutils/coreutils/issues/258
2026-04-30 17:59:38 -07:00
Pádraig Brady b60a159fdc unexpand: fix heap overflow
* src/unexpand.c (unexpand): Use xinmalloc() to gracefully
handle overflow.  Also use the runtime locale specific MB_CUR_MAX
rather than the worst case MB_LEN_MAX.
* tests/unexpand/mb.sh: Add a test case that fails in a default
glibc build with either MB_CUR_MAX or MB_LEN_MAX.
* NEWS: Mention the bug fix.
Reported by Michał Majchrowicz.
2026-04-29 13:16:43 +01:00
Pádraig Brady 00cd91288c unexpand: consolidate error messages
* src/unexpand.c (main): Use the same error
as in parse_tab_stops().
2026-04-29 13:16:21 +01:00
Pádraig Brady 38cf97c1ff sort: use more dynamic memory allocation with pipes
The default memory allocation with pipes was too passive/static,
resulting in not allocating enough memory to enable threading.
By dynamically reallocating the buffer when reading from
unknown sized inputs we better use available memory and threads.

  $ time seq 10000000 -1 0 | sort-old >/dev/null
  real	0m16.523s
  user	0m16.900s
  sys	0m0.167s

  $ time seq 10000000 -1 0 | sort-old -S1G >/dev/null
  real	0m12.263s
  user	0m29.646s
  sys	0m0.527s

  $ time seq 10000000 -1 0 | sort-new >/dev/null
  real	0m12.994s
  user	0m31.266s
  sys	0m0.716s

It also avoids the overhead of writing to temp files
for modestly sized inputs. For example the following
input would induce interaction with temp storage:

  $ seq 125000 | wc -c
  763895

* src/sort.c (sort_buffer_size): Rename to ...
(sort_buffer_policy): ... here, and adjust to set
an initial size and limit, rather than just a size.
(fillbuf): Add a POLICY parameter, and use that
to call maybe_growbuf() as needed.
(maybe_growbuf): Return true if POLICY dictates we
should grow the buffer, and try_growbuf() was
able to reallocate the larger buffer.
* tests/sort/sort-buffer-size.sh: Add a new test.
* tests/local.mk: Reference new test.
* NEWS: Mention the improvement.
Related to https://bugs.gnu.org/10877
2026-04-29 13:16:21 +01:00
Paul Eggert d64e35a8a4 uniq: fix read overrun with -w
Problem reported by Michał Majchrowicz.
* src/uniq.c (find_field): Fix typo.
* tests/uniq/uniq.pl (add_z_variants): Test for the bug.
2026-04-28 11:25:41 -07:00
Pádraig Brady 0f85d79ed6 tests: avoid false failure with perl-IO-Tty >= 1.24
* tests/misc/tty-eof.pl: https://bugzilla.redhat.com/2463168
2026-04-27 11:15:44 +01:00
Pádraig Brady 85efb0f63c tests: all: ensure closed stdout is handled appropriately
* tests/misc/io-errors.sh: Add a check to ensure we diagose
writing to closed stdout.  Also ensure we exit with failure
in other cases.
* tests/misc/write-errors.sh: Likewise.
2026-04-25 16:18:24 +01:00
Pádraig Brady b2c4224048 tests: tail: avoid a rare false failure
I noticed a single failure on cfarm29 (Linux 6.12 ppc64le),
where the output was missing:
-tail: directory containing watched file was removed
-tail: inotify cannot be used, reverting to polling
-tail: 'dir/file' has appeared;  following new file

* tests/tail/inotify-dir-recreate.sh: Leverage the new tail --debug
output to sync to a point where we know the inotify watches are in
place.  Also normalize the file argument quoting a bit.
2026-04-24 14:20:42 +01:00
Pádraig Brady 4bf753a801 dd: avoid recursive parsing of multipliers
* src/dd.c (parse_integer): Use iterative rather than recursive parsing,
to avoid potential stack overflow.
* tests/dd/bytes.sh: Add a test case.
https://github.com/coreutils/coreutils/issues/254
2026-04-23 13:58:46 +01:00
Collin Funk c5ddd417aa comm: don't close standard input twice
* NEWS: Mention the bug fix.
* src/comm.c (usage): Remove mention that FILE1 and FILE2 cannot both be
standard input.
(compare_files): Only close standard input once.
* doc/coreutils.texi (comm invocation): Document the behavior of
'comm - -' which is not portable to all implementations.
* tests/comm/dash-dash.sh: New file.
* tests/misc/comm.pl: Move to tests/comm/comm.pl.
* tests/local.mk (all_tests): Add the new test. Rename the existing
test.
2026-04-22 19:12:44 -07:00
Bruno Haible 46f856156f tests: reinstate logname error verification
* tests/misc/user.sh: Modify the "unshare -U logname" test, so that it
does not fail on glibc versions (< 2.28, >= 2.38) that do a fallback
lookup based on the tty.
2026-04-17 16:15:08 +01:00
Pádraig Brady 15211db43f tests: fix false failure with dash
* tests/date/date-locale-hour.sh: Just strip the char before the last x,
assuming it's going to be the newline output by `locale`.
dash doesn't support $'' within ${}.
2026-04-17 13:24:46 +01:00
Collin Funk 70293149b5 tests: Avoid accidental matching of the vendor field of $host, part 2
* tests/local.mk (TESTS_ENVIRONMENT): Remove host_triplet.
* tests/chgrp/basic.sh: Use $host_os instead of $host_triplet.
* tests/misc/io-errors.sh: Likewise.
2026-04-16 21:16:08 -07:00
Collin Funk 8cefb65e12 tests: mktemp: test the behavior when writing to standard output fails
* tests/mktemp/write-error.sh: New file.
* tests/local.mk (all_tests): Add the test.
2026-04-16 20:05:36 -07:00
Collin Funk 1603c75d74 tests: avoid a failure on musl
* tests/misc/io-errors.sh: Allow a generic error string on musl since
the first line is emitted immediately instead of being buffered as
expected.
Reported by Bruno Haible.
2026-04-16 22:20:49 +01:00
Pádraig Brady 1c1ccadf66 test: avoid false failure on OpenBSD
* tests/numfmt/numfmt.pl: Use standard getopt error map,
needed on OpenBSD.
Reported by Bruno Haible.
2026-04-16 21:41:40 +01:00
Pádraig Brady 54e9fcb640 tests: avoid false failure with hidden /proc on Guix
* tests/stat/stat-mount.sh: Don't try our stat under unshare
unless mount(8) exits gracefully.
Reported by Bruno Haible.
2026-04-16 21:28:44 +01:00
Pádraig Brady 04c77e27a7 tests: avoid failure on Manjaro Linux
* tests/misc/user.sh: Comment out part of test.
Reported by Bruno Haible.
2026-04-16 21:07:46 +01:00
Pádraig Brady 0b7d8620f7 tests: fix false failure due to ulimit usage
* tests/dd/no-allocate.sh: Run getlimits_ to ensure
we have $SSIZE_MAX etc. available.  Also give some buffer
for the configured ulimit to leave space for returns_ to work.
2026-04-16 19:03:13 +01:00
Pádraig Brady ad4a9fb82a tests: avoid failure on older Centos 7
* tests/cp/sparse-perf.sh: Old Centos 7 can give EINVAL
from SEEK_DATA on sparse files being copied from /dev/shm.
Avoid this failure as it's not practical to fix.
2026-04-16 18:35:26 +01:00
Pádraig Brady e245adbbc7 tests: fix false failure on Centos 7
* tests/date/date-locale-hour.sh: Ensure `locale date_fmt`
is propagated exactly, even when it contains trailing new lines,
as was seen with Serbian locales on Centos 7.
2026-04-16 17:44:05 +01:00
Pádraig Brady bc79ba83ac tests: avoid intermittent false failures with ksh
As noted in https://bugs.gnu.org/9089
ksh gives intermittent ECONNRESET errors with closed pipes.
This can be seen reliably on Linux with:
ksh -c 'yes | (sleep .1; head -n10 >/dev/null)'

* tests/misc/io-errors.sh: Avoid part of test on ksh.
* tests/misc/write-errors.sh: Likewise.
2026-04-15 15:34:19 +01:00
Pádraig Brady cb093b20db tests: use more accurate ulimit with $SHELL -c
* tests/misc/write-errors.sh: Use a more accurate ulimit determination
when we're using $SHELL -c.
2026-04-15 15:24:26 +01:00
Pádraig Brady d58ea74d01 tests: avoid $SHELL -c "ulimit ..." pattern
As described in commit v9.10-283-g5cb0cca3b
avoid using ulimit with $SHELL -c, and explict
invocation of the shell like that can require lots of memory,
often due to loading the locale archive.
* tests/basenc/bounded-memory.sh: Avoid $SHELL -c with ulimit.
* tests/cut/bounded-memory.sh: Likewise.
* tests/expand/bounded-memory.sh Likewise.
* tests/pr/bounded-memory.sh Likewise.
* tests/unexpand/bounded-memory.sh Likewise.
* tests/fold/fold-zero-width.sh: Bring the ulimit bound
down to the standard 6M over the determined limit.
2026-04-15 15:08:27 +01:00
Pádraig Brady 49febd6cbd tests: fix false failure due to race
* tests/misc/tty-eof.pl: Fix a race that commit v9.10-269-gf312af49a
made more apparent, and resulted in intermittent failure like:
"... (with input) didn't produce expected output".
Now Instead of waiting for overlapping echo and output,
just wait for EOF, and if received, use exp->before()
to inspect the accumulated output.
2026-04-15 13:40:13 +01:00
Lukáš Zaoral f6fda635bd df: improve detection of duplicate entries
Do not compare only with the latest entry for given device id but also
all previously saved entries with the same id.

* src/df.c (struct devlist): Add next_same_dev struct member.
(filter_mount_list): Iterate over next_same_dev to find duplicates.
* tests/df/skip-duplicates.sh: Add test cases.
* NEWS: Mention the improvement.
https://redhat.atlassian.net/browse/RHEL-5649
2026-04-15 12:56:16 +01:00
Pádraig Brady 5cb0cca3b8 tests: fix false failure under some shells
Verified with:
  make -j4 PREFERABLY_POSIX_SHELL=/bin/ksh SUBDIRS=. check

* tests/fold/fold-zero-width.sh: Don't timeout $SHELL -c ...
as the ulimit induces a failure in the subshell depending
on the order of the allocations it does.  The main issue is
disparity between the probed ulimit and that needed by $SHELL -c.
Such subshells load the often very large locale archive, thus
if there are any allocations done after the now too low ulimit is set,
then the $SHELL command fails. Note we timeout fold rather than
the whole pipeline so any 124 exit status is propagated.
2026-04-12 11:41:31 +01:00
Pádraig Brady 5dec936897 tests: validate error handling when reading multiple files
* tests/misc/read-errors.sh: Validate that commands which read multiple
files, read all files on error, and exit with appropriate status.
2026-04-11 22:43:33 +01:00
Pádraig Brady b48ec50b50 tests: validate command responsiveness
* tests/misc/responsive.sh: Test commands that should output immediately
upon receiving input, and that there is no unecessary buffering.
* cfg.mk: Avoid false failure in sc_prohibit_test_backticks.
* tests/local.mk: Reference the new test.
2026-04-10 17:49:01 +01:00
Pádraig Brady 57cea2bb6c tests: stat: ensure independence from /proc/
* tests/stat/stat-mount.sh: Ensure stat -c '%a'
is independent from /proc.
https://github.com/coreutils/coreutils/pull/250
2026-04-10 14:55:07 +01:00
Pádraig Brady dcc33b9e67 tests: cut: ensure separate read paths checked
* tests/misc/read-errors.sh: Use cut -b as that has a separate
read path to cut -c.
2026-04-10 11:24:58 +01:00
Bruno Haible e2e8d9f389 tests: Avoid accidental matching of the vendor field of $host
* tests/chgrp/basic.sh: Test $host_os, not $host_triplet.
* tests/chown/separator.sh: Likewise.
* tests/rm/r-root.sh: Likewise.
* tests/tail/pipe-f.sh: Likewise.
* tests/tail/tail-c.sh: Likewise.
* tests/tee/tee.sh: Likewise.
* tests/touch/dangling-symlink.sh: Likewise.
2026-04-10 11:09:10 +01:00
Pádraig Brady eef9ce5071 maint: move tty-eof.pl to misc directory
* tests/tty/tty-eof.pl: Rename to ...
* tests/misc/tty-eof.pl: ... this more general directory.
* tests/local.mk: Adjust accordingly.
2026-04-09 21:25:27 +01:00
Pádraig Brady e5912211de tests: tty-eof.pl: address FIXME re hardcoded Ctrl-d
* tests/tty/tty-eof.pl: Try to explicitly set EOF char to Ctrl-d
in case it's different.
2026-04-09 21:25:27 +01:00
Pádraig Brady 574d8660c7 tests: tty-eof.pl: make fully table driven
* tests/tty/tty-eof.pl: Remove command specific logic,
and adjust commands to support general input.
Also add cut -b, as cut_bytes has its own read loop.
2026-04-09 21:25:27 +01:00
Pádraig Brady f312af49a2 tests: all: check empty tty input is handled appropriately
* tests/tty/tty-eof.pl: Test all commands twice.
Once with input and once with empty input.
2026-04-09 21:25:27 +01:00
oech3 00ba75a02a tests: tee: ensure intermittent data is handled
* tests/tee/tee.sh: Add test case for input from pipe containing sleep.
https://github.com/coreutils/coreutils/pull/247
2026-04-09 12:08:57 +01:00
Pádraig Brady 745f4000fe tests: date: fix false failure on OpenBSD 7.8
* tests/date/date.pl: Set the max supported year to INT_MAX.
Most systems support INT_MAX+1900, but mktime() on OpenBSD 7.8
limits the passed tm_year to INT_MAX.
Reported by Bruno Haible.
2026-04-07 23:17:36 +01:00
Pádraig Brady 5b0cb4379a tests: numfmt: avoid false failure on systems without long double
* tests/numfmt/numfmt.pl: Move recently added test that depends
on long double support to the appropriately guarded set.
Also reduce the value to be in the definitely safe long double range.
Reported by Bruno Haible.
2026-04-07 21:47:21 +01:00
Pádraig Brady aaae9d0db6 tests: cat: avoid false failure on systems without splice
* tests/cat/splice.sh: Ensure splice is called multiple times
before we check specific invocation counts.
On Linux kernel 5.10 for example, splice from /dev/zero
returns EINVAL.
2026-04-07 12:20:10 +01:00
Collin Funk 457f88513a cat: use splice if operating on pipes or if copy_file_range fails
On a AMD Ryzen 7 3700X system:

    $ timeout 10 taskset 1 ./src/cat-prev /dev/zero \
        | taskset 2 pv -r > /dev/null
    [1.67GiB/s]
    $ timeout 10 taskset 1 ./src/cat /dev/zero \
        | taskset 2 pv -r > /dev/null
    [9.03GiB/s]

On a Power10 system:

    $ taskset 1 ./src/yes | timeout 10 taskset 2 ./src/cat-prev \
        | taskset 3 pv -r > /dev/null
    [12.9GiB/s]
    $ taskset 1 ./src/yes | timeout 10 taskset 2 ./src/cat \
            | taskset 3 pv -r > /dev/null
    [81.8GiB/s]

* NEWS: Mention the improvement.
* src/cat.c: Include isapipe.h, splice.h, and unistd--.h.
(splice_cat): New function.
(main): Use it.
* src/local.mk (noinst_HEADERS): Add src/splice.h.
* src/splice.h: New file, based on definitions from src/yes.c.
* src/yes.c: Include splice.h.
(pipe_splice_size): Use increase_pipe_size from src/splice.h.
(SPLICE_PIPE_SIZE): Remove definition, moved to src/splice.h.
* tests/cat/splice.sh: New file, based on some tests in
tests/misc/yes.sh.
* tests/local.mk (all_tests): Add the new test.
2026-04-06 21:57:07 -07:00
Sylvestre Ledru 374a14e841 tests: date: add large year test
* tests/date/date.pl: Add the test case.
Add test case for https://github.com/uutils/coreutils/issues/9774
to verify with large dates.
https://github.com/coreutils/coreutils/pull/237
2026-04-06 19:22:24 +01:00
Sylvestre Ledru 793f45e916 tests: expr: add short-circuit tests with parenthesized branches
* tests/expr/expr.pl: Add tests to verify that short-circuit
evaluation of | and & correctly skips parenthesized dead branches,
including nested parenthesized expressions containing division by zero.
https://github.com/uutils/coreutils/pull/11395
https://github.com/coreutils/coreutils/pull/238
2026-04-06 18:22:56 +01:00
Sylvestre Ledru 829593317d tests: split: verify non-UTF-8 bytes are preserved in filenames
* tests/split/non-utf8.sh: New test to ensure that non-UTF-8 bytes
in the prefix and --additional-suffix are preserved as-is in output
filenames, rather than being replaced by UTF-8 replacement characters.
* tests/local.mk: Register new test.
https://github.com/uutils/coreutils/pull/11397
https://github.com/coreutils/coreutils/pull/239
2026-04-06 17:53:45 +01:00