aboutsummaryrefslogtreecommitdiffstats
path: root/tests/ls (follow)
AgeCommit message (Collapse)AuthorFilesLines
2025-09-22tests: ls: avoid alignment check with non printable charactersPádraig Brady1-0/+6
* 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-08-31ls: fix alignment with locale formatted --sizePádraig Brady1-2/+19
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-04-21tests: fix false failure with constrained setfaclPádraig Brady1-1/+1
* 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-01-20tests: remove use of unprotected 'set'Pádraig Brady2-9/+9
* 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-19tests: fix typo in tests/ls/ls-time.shDaniel Hofstetter1-1/+1
* tests/ls/ls-time.sh: s/--sort-name -t/-t --sort=name/.
2025-01-18ls: fix crash with --contextPádraig Brady1-0/+3
* 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-15tests: avoid false failure with many mountpointsPádraig Brady1-1/+1
* tests/ls/readdir-mountpoint-inode.sh: Only take the first 64.
2025-01-01maint: update all copyright year number rangesPádraig Brady52-52/+52
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.
2024-11-24tests: avoid false failure with unicode decomposed file systemsPádraig Brady1-2/+2
* 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-12tests: ls: also test security context output for symlinksPádraig Brady1-12/+17
* tests/ls/selinux.sh: Test symlinks as well as files.
2024-11-12tests: avoid false failure with --disable-selinuxPádraig Brady2-15/+40
* 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-09ls: add test case for ls -Z bugPaul Eggert1-0/+15
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-10-20tests: improve ls --dired with symlink testingSylvestre Ledru1-1/+9
* tests/ls/dired.sh: Verify ls --dired with symlink.
2024-10-03tests: ls: don't always skip a capability testPádraig Brady1-2/+6
* 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-08-11ls: add support for explicit file name sortingPádraig Brady1-2/+4
Support overriding previous sorting options with an explicit --sort=name option. * doc/coreutils.texi (ls invocation): Document the new option. * src/ls.c (usage): Likewise. (sort_args): Add the "name" entry, and sort to be consistent with the ordering presented in --help. * tests/ls/ls-time.sh: Add test cases. * NEWS: Mention the new feature. Suggested by: Tzvetelin Katchov
2024-06-27ls: treat --time=mtime consistently with other time selectorsPádraig Brady1-10/+20
* src/ls.c: Track if --time=mtime is explicitly specified, so that we can apply the GNU extension of sorting by the specified time, when not displaying (-l not specified), and not explicitly sorting (-t not specified). * tests/ls/ls-time.sh: Add / Update test cases. Fixes https://bugs.gnu.org/71803
2024-03-25tests: avoid triggering obsolete tail option processingPádraig Brady1-1/+1
* tests/ls/dired.sh: With 2 options, the latter is taken as a file name on some systems. This avoids a false failure on Solaris and FreeBSD at least.
2024-03-25tests: remove debugging from a testPádraig Brady1-1/+1
* tests/ls/dired.sh: Remove temp debugging output.
2024-01-10tests: ls: add a test to verify that '+' is addedSylvestre Ledru1-0/+40
* tests/ls/acl.sh: Add a new test. * tests/local.mk: Reference the new test.
2024-01-01maint: update all copyright year number rangesPádraig Brady50-50/+50
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: Manually update copyright year, until we fully sync with gnulib at a later stage. * tests/sample-test: Adjust to use the single most recent year.
2023-11-03ls: fix recent regression in size alignmentPádraig Brady1-0/+32
* src/ls.c (print_long_format): Use correct column width, introduced due to a copy/paste error in commit v9.4-2-gcbb6dfec5 * tests/ls/size-align.sh: Add a test. * tests/local.mk: Reference the new test. Fixes https://bugs.gnu.org/66919
2023-09-17ls: --dired now implies long format with hyperlinks disabledSylvestre Ledru1-3/+5
Currently --dired is silently ignored with conflicting output formats * src/ls.c (decode_switches): Set default format and hyperlink mode when the --dired option is specified. * tests/ls/dired.sh: Check that formats are implied / overridden. * NEWS: Mention the change in behavior. * doc/coreutils.texi (ls invocation): Adjust --dired description.
2023-09-15tests: improve ls --dired testingSylvestre Ledru1-1/+36
* tests/ls/dired.sh: Verify ls --dired output against varying offsets.
2023-08-28maint: spelling fixes, including author namesPaul Eggert3-3/+3
Most of this just affects commentary and documentations. The only significant behavior change is translating author names via proper_name_lite rather than proper_name_utf8, or not translating them at all. proper_name_lite is good enough for coreutils and avoids the bloat that had coreutils not using Gnulib proper_name. * bootstrap.conf (gnulib_modules): Use propername-lite instead of propername. (XGETTEXT_OPTIONS): Look for proper_name_lite instead of for proper_name_utf8. * cfg.mk (local-checks-to-skip): Remove sc_proper_name_utf8_requires_ICONV, since we no longer use proper_name_utf8. (old_NEWS_hash): Update. (sc_check-I18N-AUTHORS): Remove; no longer needed.
2023-06-19tests: move tests to a directory per utilitySylvestre Ledru2-0/+520
* cfg.mk: Adjust syntax check exclusion paths. * tests/local.mk: Adjust for renamed tests.
2023-06-07ls: display command line symlinks that return ELOOPPádraig Brady1-0/+35
* src/ls.c (gobble_file): Ensure we lstat() a symlink specified on the command line, if we receive ELOOP from stat(). * tests/ls/symlink-loop.sh: Add a new test. * tests/local.mk: Reference the new test. * NEWS: Mention the bug fix. Fixes https://bugs.gnu.org/63931
2023-03-19tests: avoid false failure on systems without statxPádraig Brady2-4/+6
* tests/ls/stat-free-symlinks.sh: Filter out syscalls that return ENOSYS, as that was seen with statx() on Debian 10.13 on mips64, and resulted in overcounting of stat calls.
2023-03-13ls: --color: honor separate sequences for extension casesPádraig Brady1-1/+45
Following on from commit v8.29-45-g24053fbd8 which unconditionally used case insensitive extension matching, support selective case sensitive matching when there are separate extension cases defined with different display sequences. * src/dircolors.hin: Document how file name suffixes are matched. Note this is displayed with `dircolors --print-database` which the texi info recommends to use for details. * src/ls.c (parse_ls_color): Postprocess the list to mark entries for case sensitive matching, and also adjust so that unmatchable entries are more quickly ignored. (get_color_indicator): Use exact matching rather than case insensitive matching if so marked. * tests/ls/color-ext.sh: Add test cases. * NEWS: Mention the change in behavior. Addresses https://bugs.gnu.org/33123
2023-01-01maint: update all copyright year number rangesPádraig Brady46-46/+46
Update to latest gnulib with new copyright year. Run "make update-copyright" and then... * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Manually update copyright year, until we fully sync with gnulib at a later stage. * tests/sample-test: Adjust to use the single most recent year.
2022-11-15maint: avoid new grep -q syntax-check failuresPádraig Brady2-2/+2
* cfg.mk: Exclude NEWS from the check. * init.cfg: s/grep -q/grep >/dev/null/. * tests/ls/hyperlink.sh: Likewise. * tests/ls/symlink-quote.sh: Likewise.
2022-01-02maint: update all copyright year number rangesPádraig Brady46-46/+46
Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
2021-12-24doc: colorize -> colorPaul Eggert5-5/+5
Living so close to Hollywood I know that "colorize" means adding color to something that was already monochrome, whereas "color" means to give color to something. Coreutils apps color text instead of colorizing it.
2021-09-17tests: port removed-directory test to FreeBSDPádraig Brady1-1/+1
* tests/ls/removed-directory.sh: On FreeBSD 9.1 at least, one gets ENOENT when trying to traverse the current removed dir with ../, so instead reference the parent dir directly.
2021-09-12tests: stat-vs-dirent.sh: avoid a false failurePádraig Brady1-1/+2
* tests/ls/stat-vs-dirent.sh: Skip the test if we can't stat(1), as the file may have been removed, or have a malformed name due to '\n' etc. in the file name.
2021-07-28tests: augment new ls --zero test casesPádraig Brady1-1/+9
* tests/ls/zero-option.sh: Check for the disabled, disallowed, and allowed option combinations.
2021-07-27ls: rename --null to --zero (Bug#49716)Paul Eggert1-2/+2
* NEWS, doc/coreutils.texi (General output formatting): * src/ls.c (usage): Document this. * src/ls.c (ZERO_OPTION): Rename from NULL_OPTION. All uses changed. (long_options): Rename --null to --zero. (dired_dump_obstack, main, print_dir): Use '\n' instead of eolbyte where eolbyte must equal '\n'. (decode_switches): Decode --zero instead of --null. --zero also implies -1, -N, --color=none, --show-control-chars. Use easier-to-decipher code to set ‘format’ and ‘dired’. Reject attempts to combine --dired and --zero. * tests/local.mk: Adjust to test script renaming. * tests/ls/zero-option.sh: Rename from tests/ls/null-option.sh, and test --zero instead of --null.
2021-07-26ls: add --null option (Bug#49716)Paul Eggert1-0/+33
* NEWS, doc/coreutils.texi (General output formatting): * src/ls.c (usage): Document this. * src/ls.c (NULL_OPTION): New constant. (long_options): Add --null. (eolbyte): New static var. (dired_dump_obstack, main, print_dir, print_current_files) (print_many_per_line, print_horizontal, print_with_separator): Output eolbyte instead of '\n'. (decode_switches): Decode --null. * tests/ls/null-option.sh: New file. * tests/local.mk (all_tests): Add it.
2021-04-22tests: fix FP in ls/stat-free-color.shBernhard Voelker1-4/+6
On newer systems like Fedora 34 and openSUSE Tumbleweed, ls(1) calls newfstatat(STDOUT_FILENO, ...), but only when there is something to output. * tests/ls/stat-free-color.sh: Add -a option to the reference invocation of ls, thus enforcing something gets output.
2021-04-11ls: add --sort=width option to sort by file name widthCarl Edquist1-0/+41
This helps identify the outliers for long filenames, and also produces a more compact display of columns when listing a directory with many entries of various widths. * src/ls.c (sort_type, sort_types, sort_width): New sort_width sort type. (sort_args): Add "width" sort arg. (cmp_width, fileinfo_width): New sort function and helper for file name width. (quote_name_width): Add function prototype declaration. (usage): Document --sort=width option. * doc/coreutils.texi: Document --sort=width option. * tests/ls/sort-width-option.sh: New test for --sort=width option. * tests/local.mk: Reference new test. * NEWS: Mention the new feature.
2021-01-01maint: update all copyright year number rangesPádraig Brady44-44/+44
Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
2020-11-11ls: fix crash printing SELinux context for unstatable filesPádraig Brady1-2/+8
This crash was identified by Cyber Independent Testing Lab: https://cyber-itl.org/2020/10/28/citl-7000-defects.html and was introduced with commit v6.9.90-11-g4245876e2 * src/ls.c (gobble_file): Ensure scontext is initialized in the case where files are not statable. * tests/ls/selinux-segfault.sh: Renamed from proc-selinux-segfault.sh, and added test case for broken symlinks. * tests/local.mk: Adjust for the renamed test. * NEWS: Mention the bug fix.
2020-05-23tests: fix removed-directory testBernhard Voelker1-10/+9
The previous attempt to skip that test on NFS (commit 4181fc518362) made the test fail; it introduced two problems: a) In the good case, i.e., when the subshell returns with exit status 0, the test ran into framework_failure_. b) As the subshell also runs with 'set -x', the later comparison of /dev/null with 'err' would fail. * tests/ls/removed-directory.sh: Revert to the style without subshell, and add 'test -d .' to verify that 'ls' can read the removed dir.
2020-05-20ls: port removed-directory test to NFSPaul Eggert1-5/+10
* tests/ls/removed-directory.sh: Port test to NFS, where one gets a stale file handle when looking at a removed directory.
2020-04-27ls: allow --classify to be ignored for non tty outputJason Kim1-0/+63
Have the `ls` `--classify` option take an optional argument for when to classify ("always", "auto", "never"), just like the optional argument for `--color`. When the optional argument is not specified, default to "always" for backwards compatibility. * src/ls.c (usage): Update help text. (decode_switches): Support an optional argument for --classify. * tests/ls/classify.sh: Add a new test. * tests/local.mk: Reference the new test. * NEWS: Mention the new feature.
2020-03-07ls: improve removed-directory testPaul Eggert1-9/+4
* tests/ls/removed-directory.sh: Remove host_triplet test. Skip this test if one cannot remove the working directory. From a suggestion by Bernhard Voelker (Bug#39929).
2020-03-07ls: restore 8.31 behavior on removed directoriesPaul Eggert1-8/+2
* NEWS: Mention this. * src/ls.c: Do not include <sys/sycall.h> (print_dir): Don't worry about whether the directory is removed. * tests/ls/removed-directory.sh: Adjust to match new (i.e., old) behavior.
2020-03-01tests: improve test coverage for ls stat checksPádraig Brady2-19/+44
* tests/ls/stat-free-color.sh: Check for the availability of various stat calls individually, and add statx() and fstatat64() to the list to check. Fix the stat counting logic to ignore lines like "+++ exited with 0 +++". * tests/ls/stat-free-symlinks.sh: Check syscalls other than stat().
2020-02-29tests: fix incorrect `|| fail` pattern in testsPádraig Brady1-1/+1
* tests/ls/stat-free-symlinks.sh: s/|| fail/|| fail=1/. * tests/misc/tee.sh: Likewise. * tests/touch/relative.sh: Likewise. * cfg.mk (sc_prohibit_or_fail): A new syntax-check to avoid this.
2020-02-27ls: issue error message on removed directoryColin Watson1-0/+45
If the current directory has been removed, then "ls" confusingly produced no output and no error message, indistinguishable from running on an empty directory. * src/ls.c (print_dir): Report ENOENT on GNU/Linux if readdir finds no directory entries at all, not even "." or "..", and a recheck with the getdents syscall returns ENOENT. We recheck with getdents() as POSIX states that "The directory entries for dot and dot-dot are optional". * tests/ls/removed-directory.sh: New file. * tests/local.mk (all_tests): Add new test. * NEWS: Mention the change in behavior. Reported by Owen Thomas.
2020-02-03ls: support --time=creation to show/sort birth timePádraig Brady1-0/+27
* src/ls.c (usage): Reorganize help for --time, and add description for --time=birth. (do_statx): Store btime in mtime if available. (get_stat_btime): A new function to read the creation time from the appropriate stat structure member. (cmp_btime): A new function to compare birth time. (print_long_format): Output '?' when birth time unavailable. * doc/coreutils.texi: Document --time={birth,creation}. * tests/local.mk: Reference the new test. * tests/ls/birthtime.sh: Add a new test. * NEWS: Mention the new feature.