Commit Graph
566 Commits
Author SHA1 Message Date
Pádraig Brady 9aeb2eeb0f tests: ls: fix false failure on non GLIBC systems
* tests/ls/line-separator.sh: Skip on systems that treat
U+2028 (LINE SEPARATOR), and U+2029 (PARAGRAPH SEPARATOR)
as printable.  Also since we're requiring our printf now,
use that to decouple the test from the particular shell-escape
quoting form used.
Reported by Bruno Haible.
2026-11-10 16:48:39 +00:00
Sylvestre Ledru 40d9fe3e03 tests: ls: check a too long file name is reported as "cannot access"
* tests/ls/ls-misc.pl (name-too-long): New test.
https://github.com/uutils/coreutils/pull/15699

Link: https://github.com/coreutils/coreutils/pull/456
2026-11-09 00:24:53 +00:00
Sylvestre Ledru 99ba5d505a tests: ls: check U+2028 and U+2029 are escaped or hidden
* tests/ls/line-separator.sh: New test.
* tests/local.mk (all_tests): Reference it.
https://github.com/uutils/coreutils/pull/16040

Link: https://github.com/coreutils/coreutils/pull/457
2026-11-09 00:24:52 +00:00
Pádraig Brady 4188d50eb4 tests: use more robust user and group matching
* tests/chgrp/from.sh: Force numeric lookup.
* tests/chmod/setgid.sh: Likewise.
* tests/chown/basic.sh: Likewise.
* tests/chown/preserve-root.sh: Likewise.
* tests/install/install-C-immutable.sh: Likewise.
* tests/install/install-C-root.sh: Likewise.
* tests/ls/nameless-uid.sh: Likewise.
* tests/misc/traversal-missing.sh: Likewise.
* tests/misc/user.sh: Likewise.
* tests/chown/deref.sh: Likewise.  Also avoid
name lookup which may fail if they contain spaces.
* tests/chown/verbose-dangling-symlink.sh: Likewise.
* tests/chgrp/verbose-dangling-symlink.sh: Likewise.
2026-11-08 15:29:10 +00:00
Sylvestre Ledru ddcabc55b5 tests: ls: ensure --block-size=0 is rejected despite later size options
Reported at https://github.com/uutils/coreutils/issues/16008

* tests/ls/ls-misc.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/420
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 9cad3af5ce tests: ls: check -s rounds block counts up
* tests/ls/block-size.sh: Ensure ls -s rounds a partly used block up
when the block size does not divide the allocation, and that the
total scales the sum of the allocations once.
https://github.com/uutils/coreutils/pull/14330

Link: https://github.com/coreutils/coreutils/pull/395
2026-10-24 16:15:03 +01:00
Pádraig Brady 402bce6637 ls: fix missing ACL indicators or capability colors
On systems where the security context reports as unsupported,
and we encountered a file without ACLs, no further lookups
would be performed.  Introduced in commit v9.5-156-gb857d66b5.
This fix is along similar lines as commit v9.6-40-gcb2abbac7.

* src/ls.c (file_has_aclinfo_cache): Don't mark file system as
unsupported if there might be ACLs or capabilities present.
* tests/ls/acl-cache.sh: Add a new test.
* tests/local.mk: Reference the new test.
* tests/ls/acl.sh: Add a check.
* NEWS: Mention the bug fix.
2026-10-13 11:32:41 +01:00
Pádraig Brady ce0f62f608 tests: avoid skipping a test on non SELinux builds
* tests/ls/getxattr-speedup.sh: Add listxattr calls into the list
to trace/fail so that the test also works on non-SELinux builds.
Also adjust the test to compare call counts with varying number
of files, rather than checking a particular call count limit,
as that is a bit coupled with the implementation.

Link: https://github.com/coreutils/coreutils/pull/368
2026-10-12 20:55:24 +01:00
oech3 19ebb3e1a7 tests: ls: replace LD_PRELOAD of getxattr-speedup.sh with strace
* tests/ls/getxattr-speedup.sh: Replace LD_PRELOAD by strace
to support static executables.

Link: https://github.com/coreutils/coreutils/pull/368
2026-10-08 19:27:42 +01:00
Collin Funk 98c8b158b6 tests: make checks for $LOCALE_FR and $LOCALE_FR_UTF8 consistent
* tests/cp/non-utf8-name.sh: Check for $LOCALE_FR and $LOCALE_FR_UTF8
being empty or the string "none".
* tests/date/percent-percent.sh: Likewise.
* tests/du/block-size.sh (test_unit): Likewise.
* tests/ls/non-utf8-hidden.sh: Likewise.
* tests/mktemp/bad-unicode.sh: Likewise.
* tests/sort/sort-unique.sh: Likewise.
* tests/df/problematic-chars.sh:  Check for $LOCALE_FR_UTF8 being empty
or the string "none".
* tests/expand/mb.sh: Likewise.
* tests/fold/fold-characters.sh: Likewise.
* tests/fold/fold-nbsp.sh: Likewise.
* tests/fold/fold-spaces.sh: Likewise.
* tests/fold/fold-zero-width.sh: Likewise.
* tests/join/join-utf8.sh: Likewise.
* tests/misc/sleep.sh: Likewise.
* tests/nl/multibyte.sh: Likewise.
* tests/paste/multi-byte.sh: Likewise.
* tests/printf/printf-mb.sh: Likewise.
* tests/printf/printf-quote.sh: Likewise.
* tests/sort/sort-debug-keys.sh: Likewise.
* tests/unexpand/mb.sh: Likewise.
2026-10-04 15:31:59 -07:00
Sylvestre Ledru 1ac51052c4 tests: ls: cover -u/-c sorting in a long listing
In a long listing, -u and -c only choose which timestamp is shown;
the entries stay sorted by name, and time order is selected by -t
(or by asking for a format that is not long).  This was only ever
exercised for short listings, so the rule went untested for every
long listing, including the ones requested with something other
than -l.
Identified here: https://github.com/uutils/coreutils/pull/14573

* tests/ls/ls-time.sh: Check that -u and -c keep name order for each
of -l, -g, -o, -n, --full-time and --dired, and that -t still gives
time order in a long listing.

Link: https://github.com/coreutils/coreutils/pull/354
2026-09-15 12:58:48 +01:00
Ismail Ramzi 25792e3763 ls: fix use-after-free reading LS_COLORS ln=target
parse_ls_color stores color_indicator[C_LINK].string as a pointer into
the color_buf buffer, then frees color_buf on the unparsable-value path.
The "ln=target" check after the parse loop still read that freed buffer,
e.g. with LS_COLORS='ln=target:x'.  Skip it on the failure path, where
color output is disabled anyway and the buffer is gone.
* src/ls.c (parse_ls_color): Return after freeing color_buf on failure,
so the color_indicator[C_LINK] check only runs when the buffer is live.
* tests/ls/color-symlink-target.sh: New test.
* tests/local.mk (all_tests): Add it.
* NEWS: Mention the fix.

Link: https://github.com/coreutils/coreutils/pull/352
2026-09-14 03:07:54 +01:00
Pádraig Brady b3cdc09344 tests: avoid hangs with strace on cygwin
`strace -e tee true` will run the tee command on cygwin,
rather than filtering for the tee syscall.
Reported by Bruno Haible on Cygwin 2.9.0

* init.cfg: Use -e trace=foo where foo might be a command,
so that strace probes will fail rather than invoke foo on Cygwin.
* tests/cat/cat-distinct-err.sh: Likewise.
* tests/cat/splice.sh: Likewise.
* tests/ls/no-cap.sh: Likewise.
* tests/misc/yes.sh: Likewise.
* tests/mv/atomic.sh: Likewise.
* tests/mv/atomic2.sh: Likewise.
* tests/nproc/nproc-quota.sh: Likewise.
* tests/pwd/pwd-long.sh: Likewise.
* tests/stty/stty.sh: Likewise.
* tests/tail/debug.sh: Likewise.
* tests/tail/inotify-only-regular.sh: Likewise.
2026-09-10 16:40:06 +01:00
Pádraig Brady 0acbfaf972 ls: protect newlines for non terminal output
Add extra protection for newlines that might be output to log files etc.

* doc/coreutils.texi (ls invocation): Expand --literal description.
* src/ls.c (quote_name_buf): Replace '\n' with '?' if appropriate.
* tests/ls/dired.sh: Add a negative test case.
* tests/ls/zero-option.sh: Likewise.
* tests/ls/m-option.sh: Likewise. Also add a positive test case.
* NEWS: Mention the improvement.
2026-08-01 12:38:28 +01:00
Pádraig Brady 04590790d4 ls: with -m, quote names containing commas when appropriate
* src/ls.c (decode_switches): Flag ',' for quoting when needed.
* tests/ls/m-option.sh: Add a test case.
* NEWS: Mention the improvement.
2026-08-01 12:38:28 +01:00
Sylvestre Ledru fc426cc142 tests: ls: cover quoting in the C.UTF-8 locale
The quoting characters and the printability of a multibyte character are
selected by the locale's codeset, not by its language, but no test
covered a locale that has a UTF-8 codeset and no language.

* tests/ls/quoting-utf8.sh: Check that in C.UTF-8 the locale/clocale
styles use the Unicode quotes and that literal/escape/shell-escape pass
a multibyte character through unaltered, whereas the plain C locale
octal-escapes it or replaces it with '?'.

Link: https://github.com/coreutils/coreutils/pull/323
2026-07-27 13:52:51 +01:00
Pádraig Brady 8f7ed6cf50 maint: refactor stat syscall determination
* init.cfg (+get_stat_syscalls_): Refactor from ...
* tests/ls/stat-free-color.sh: ... here.
* tests/ls/stat-free-symlinks.sh: ... here.
* tests/misc/traversal-missing.sh: ... here.
* tests/shred/fifo.sh: .. here.
2026-07-24 13:19:23 +01:00
Sylvestre Ledru 440fe62502 tests: ls: check that an invalid --tabsize is diagnosed
* tests/ls/ls-misc.pl: Add tests, generated by a loop over invalid
values, verifying that a negative (-9), non-numeric (zz), or
fractional (0.5) --tabsize argument is rejected with
"invalid tab size" and exit status 2.
https://github.com/uutils/coreutils/pull/13278

Link: https://github.com/coreutils/coreutils/pull/311
2026-07-06 14:23:58 +01:00
Sylvestre Ledru 7dd7fd17b9 tests: ls: check C1 control char escaping in UTF-8 quoting
* tests/ls/quoting-utf8.sh: A non-ASCII C1 control character (U+0085
NEL) is not printable, so locale/clocale quoting must octal-escape its
bytes (\302\205) rather than emit them literally.  Add a file named
with U+0085 and verify the escaped form for both styles.
gap identified here: https://github.com/uutils/coreutils/pull/13150

Link: https://github.com/coreutils/coreutils/pull/306
2026-06-30 18:21:36 +01:00
Sylvestre Ledru a04250cf3b tests: ls: cover two-line --time-style format assignment
* tests/ls/ls-time.sh: Check that with a "FORMAT1 NEWLINE FORMAT2"
  --time-style, FORMAT1 is used for non-recent (old) files and FORMAT2
  for recent files.
  Identified here: https://github.com/uutils/coreutils/issues/12676
Closes https://github.com/coreutils/coreutils/pull/281
2026-06-09 14:38:15 +01:00
Pádraig Brady bbbd14c6d8 maint: tests: remove extraneous "&& :"
* tests/cp/symlink-slash.sh: && : is always redundant.
* tests/ls/symlink-slash.sh: Likewise.
2026-06-06 11:46:43 +01:00
Sylvestre Ledru 8da9f0c815 tests: ls: also check a trailing '/.' dereferences a symlink arg
* tests/ls/symlink-slash.sh: A symlink-to-directory argument written as
'symlink/.' denotes the directory itself, just like a trailing slash, so
'ls -l symlink/.' must list the directory contents rather than show the
symlink.
See https://github.com/uutils/coreutils/issues/7873
and https://github.com/uutils/coreutils/issues/6467
https://github.com/coreutils/coreutils/pull/280
2026-06-06 11:35:10 +01:00
Sylvestre Ledru e32eaee1f0 tests: ls: verify in-group ordering with --group-directories-first
* tests/ls/group-dirs.sh: Check that entries within each group remain
alphabetically sorted, and that equal-size files keep a deterministic
order when combined with --sort=size.
https://github.com/uutils/coreutils/issues/11997
https://github.com/coreutils/coreutils/pull/267
2026-05-29 19:29:10 +01:00
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
Sylvestre Ledru 3a9901daad tests: ls: add quoting-utf8 test for Unicode quotes in UTF-8 locales
* tests/ls/quoting-utf8.sh: New test verifying that
--quoting-style=locale and --quoting-style=clocale use Unicode
left/right single quotation marks in UTF-8 locales, and that
embedded apostrophes and double quotes are not escaped when the
delimiters are different characters.
Also check C locale fallback to ASCII quotes.
* tests/local.mk: Reference the new test.
https://github.com/coreutils/coreutils/pull/243
2026-04-06 16:29:15 +01:00
Pádraig Brady c1346460d1 tests: ls: fix false failure on FreeBSD
* tests/ls/non-utf8-hidden.sh: Avoid sorting in ls, to avoid:
ls: cannot compare file names ...: Illegal byte sequence
seen on FreeBSD 14.
Reported by Bruno Haible.
2026-03-16 22:25:42 +00:00
Sylvestre Ledru 826c15a330 tests: ls: treat invalid UTF-8 paths starting with a dot as hidden
* tests/ls/non-utf8-hidden.sh: Add the test case.
https://github.com/uutils/coreutils/pull/11135
https://github.com/coreutils/coreutils/pull/202
2026-02-28 20:18:57 +00:00
Collin Funk ec77664a31 tests: avoid failures if 'ulimit -n' cannot set file descriptor limits
This fixes test failures seen on Haiku.

* tests/ls/recursive.sh: Run 'ls' even if ulimit fails.
* tests/split/r-chunk.sh: Run 'split' even if ulimit fails.
* tests/sort/sort-merge-fdlimit.sh: Skip test if 'ulimit -n' cannot set
file descriptor limits.
Reported by Bruno Haible.
2026-01-24 11:20:56 -08:00
Pádraig Brady dfeb32f6e2 ls: --hyperlink: switch to more standard delimiters
* src/ls.c (quote_name): Use ST (ESC \) rather than BEL,
as that's the only terminator mentioned in at least
ECMA-48, DEC STD 070, and EK-VT520-RM.
* NEWS: Mention the change in behavior.
* tests/ls/hyperlink.sh: Adjust accordingly.

Suggested by Egmont Koblinger.
2026-01-21 14:05:48 +00:00
Collin Funk 73d3a49f45 maint: run 'make update-copyright' 2026-01-01 10:56:16 -08:00
Collin Funk cfd78d0877 tests: ls: use a larger file descriptor limit
OpenBSD and Alpine Linux /bin/sh cannot handle a file descriptor limit
of 7.

* tests/ls/recursive.sh: Create 30 directories and use a file descriptor
limit of 20. Don't check the output since we have coverage for that
elsewhere.
Reported by Bruno Haible.
2025-12-13 18:37:18 -08:00
Pádraig Brady 2692d599ec tests: fix non-portable use of printf '\x..'
* tests/dd/conv-case.sh: Use octal instead.
* tests/ls/hyperlink.sh: Likewise.
* tests/sort/sort-locale.sh: Likewise.
2025-12-08 22:32:48 +00:00
Collin Funk 8787601bbe tests: ls: check that 'ls -R' doesn't run out of file descriptors
* tests/ls/recursive.sh: Add a test where the file descriptor limit is
less than the number of directories we visit recursively.
2025-12-04 18:00:49 -08:00
Pádraig Brady 2d07c26d95 tests: ls --hyperlink: add more escaping test cases
* tests/ls/hyperlink.sh: Add tests for anchors, colons,
utf8, and invalid utf8 characters.
2025-12-02 13:17:51 +00:00
Pádraig Brady b8b486dc32 tests: ls: avoid alignment check with non printable characters
* tests/ls/block-size.sh: Skip the case where there are
non-printable characters in ls' output, which is the case
with NBSP thousands separators on FreeBSD 11 and 12.
We may drop the MBSW_REJECT_UNPRINTABLE in future from
ls and numfmt, but for now avoid these characters in the test.
Reported by Bruno Haible.
2025-09-22 11:23:50 +01:00
Pádraig Brady ebd670e7eb ls: fix alignment with locale formatted --size
Fix allocated size alignment in locales with multi-byte grouping chars.
Tested with: LC_ALL=sv_SE.utf8 ls --size --block-size=\'k

* src/ls.c (print_file_name_and_frills): Don't rely on
printf("%*s", width, string) to pad multi-byte strings appropriately.
Instead work out the padding required and use:
printf("%*s%s", padding, "", string) to pad multi-byte appropriately.
* tests/ls/block-size.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/79347
2025-08-31 19:25:38 +01:00
Pádraig Brady 948f4713fd tests: fix false failure with constrained setfacl
* tests/ls/acl.sh: In constrained environments, like with
setxattr() disabled for example, require_acl_ does not
check for the required functionality, so use the more
stringent require_setfacl_ instead.
Reported at https://github.com/NixOS/nixpkgs/issues/394953
2025-04-21 11:48:33 +01:00
Pádraig Brady dcc896e6c3 tests: remove use of unprotected 'set'
* cfg.mk (sc_prohibit_bare_set): A new syntax check to
ensure we protect use of set with '--', so that args
beginning with '-' are not interpreted as options,
and if no args are present, all existing args are cleared.
* tests/cp/symlink-slash.sh: Add -- to unprotected use of set.
* tests/ls/ls-time.sh: Likewise.
* tests/ls/symlink-slash.sh: Likewise.
* tests/mkdir/perm.sh: Likewise.
* tests/mkdir/selinux.sh: Likewise.
* tests/mkdir/smack-no-root.sh: Likewise.
* tests/mkdir/smack-root.sh: Likewise.
* tests/mv/part-hardlink.sh: Likewise.
* tests/nice/nice.sh: Likewise.
* tests/stty/stty-row-col.sh: Likewise.
2025-01-20 15:21:58 +00:00
Daniel Hofstetter e6117526c3 tests: fix typo in tests/ls/ls-time.sh
* tests/ls/ls-time.sh: s/--sort-name -t/-t --sort=name/.
2025-01-19 16:36:59 +00:00
Pádraig Brady 915004f403 ls: fix crash with --context
* src/ls.c (main): Flag that we need to stat()
if we're going to get security context (call file_has_aclinfo_cache).
(file_has_aclinfo_cache): Be defensive and only lookup the device
for the file if the stat has been performed.
(has_capability_cache): Likewise.
* tests/ls/selinux-segfault.sh: Add a test case.
* NEWS: Mention the bug fix.
Reported by Bruno Haible.
2025-01-18 13:14:29 +00:00
Pádraig Brady 4bb1fc2445 tests: avoid false failure with many mountpoints
* tests/ls/readdir-mountpoint-inode.sh: Only take the first 64.
2025-01-15 17:07:19 +00:00
Pádraig Brady 28b176085f maint: update all copyright year number ranges
Update to latest gnulib with new copyright year.
Run "make update-copyright" and then...

* gnulib: Update included in this commit as copyright years
are the only change from the previous gnulib commit.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.
2025-01-01 09:33:08 +00:00
Pádraig Brady cb2774501d tests: avoid false failure with unicode decomposed file systems
* tests/ls/dired.sh: macOS normalizes unicode characters to decomposed
(NFD) form when storing names in the file system, which breaks the
round-trip comparison employed by the test.  So instead use a character
which does not decompose; verified with:
  echo æ | uconv -f utf8 -t utf8 -x nfd | od -Ax -tx1z
2024-11-24 12:59:42 +00:00
Pádraig Brady fc0ea5cb87 tests: ls: also test security context output for symlinks
* tests/ls/selinux.sh: Test symlinks as well as files.
2024-11-12 11:43:45 +00:00
Pádraig Brady 8f4fce1751 tests: avoid false failure with --disable-selinux
* tests/ls/selinux-segfault.sh: Move recent addition to ...
* tests/ls/selinux.sh: ... this new test that uses require_selinux_
to skip appropriately when we've built without selinux support.
Also add a non root test that checks we output '.' along with the
mode for files, to indicate a security context is present.
* tests/local.mk (Reference the new test).
2024-11-12 11:20:47 +00:00
Paul Eggert 45ba6c6f54 ls: add test case for ls -Z bug
Problem reported by Pádraig Brady <https://bugs.gnu.org/73418#35>.
This bug was fixed by the recent gnulib update.
* tests/ls/selinux-segfault.sh:
Also test for ls -Z on broken symlinks.
2024-11-09 16:51:26 -08:00
Sylvestre Ledru f082cb8284 tests: improve ls --dired with symlink testing
* tests/ls/dired.sh: Verify ls --dired with symlink.
2024-10-20 14:10:30 +01:00
Pádraig Brady 96100139fc tests: ls: don't always skip a capability test
* tests/ls/no-cap.sh: Move to being a root only test, since
commit v9.5-132-g2a6bed933 we now need to call setcap
to make the test effective.  Otherwise we would have always
just skipped the test.
2024-10-03 12:41:37 +01:00