Commit Graph
21 Commits
Author SHA1 Message Date
Sylvestre Ledru 1e50b1b0dd tests: stat: check %#a adds a single leading 0
* tests/stat/stat-fmt.sh: Check %#a with various precisions and
widths, including for a mode of 0.

https://github.com/uutils/coreutils/pull/16393

Link: https://github.com/coreutils/coreutils/pull/463
2026-11-15 16:17:39 +00:00
Sylvestre Ledru d66f7dc609 tests: stat: check an empty --format or --printf
* tests/stat/stat-printf.pl (f-empty, f-empty2, f-empty-terse)
(p-empty, fs-empty): New tests, ensuring an empty format is used
rather than the default one.

https://github.com/uutils/coreutils/pull/16451

Link: https://github.com/coreutils/coreutils/pull/464
2026-11-15 16:17:39 +00:00
Sylvestre Ledru 2da43a03b6 tests: stat: check the 0 flag with a precision
* tests/stat/stat-fmt.sh: Ensure an integer conversion with a
precision ignores the 0 flag, as printf does.

https://github.com/uutils/coreutils/pull/16368

Link: https://github.com/coreutils/coreutils/pull/462
2026-11-15 16:17:39 +00:00
Sylvestre Ledru 9fb2a03a63 tests: stat: ensure the last of stat's --printf and --format wins
Reported at https://github.com/uutils/coreutils/issues/15993

* tests/stat/stat-printf.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/436
2026-11-07 12:35:10 +00:00
Pádraig Brady 7659e41552 tests: stat: avoid false failure with LeakSanitizer
* tests/stat/stat-mount.sh: LeakSanitizer requires /proc access
for instrumented binaries, so ensure we're checking coreutils
binaries, rather than shell builtins.
2026-09-08 17:50:18 +01:00
Sylvestre Ledru 31634dbc2e tests: stat: check output preceding an invalid directive
* tests/stat/stat-printf.pl: The format is interpreted as it is printed,
so whatever precedes an invalid directive is written before the
diagnostic, and --format adds no trailing newline when it stops early.
The existing err-1 and err-2 cases put the directive at the start of the
format, so nothing covered this.
See https://github.com/uutils/coreutils/issues/14101

Link: https://github.com/coreutils/coreutils/pull/333
2026-08-26 12:12:46 +01:00
Collin Funk 24e485a883 tests: stat: fix a test failure on FreeBSD
* tests/stat/stat-nanoseconds.sh: Don't assume that we can create a file
with timestamps before the epoch.
Reported by Bruno Haible.
2026-08-25 19:34:52 -07:00
Sylvestre Ledru 0b8fff44cb tests: stat: check nanosecond precision away from the Epoch
The existing checks all use a timestamp only 67413 seconds after the
Epoch, which a double can still represent exactly to the nanosecond, so
they do not detect a formatter that goes through floating point.  They
also never look at a timestamp before the Epoch, where the fraction has
to be truncated towards minus infinity.

* tests/stat/stat-nanoseconds.sh: Also check %Y, %.Y, %.3Y and %.9Y on a
2026 timestamp and on a timestamp shortly before the Epoch.
Link: https://github.com/uutils/coreutils/pull/13976

Link: https://github.com/coreutils/coreutils/pull/331
2026-08-20 16:15:02 +01:00
Pádraig Brady 5d3f03b4fb stat: use quoted file names with --terse
* src/stat.c: Use %Qn rather than a bare %n by default,
so output is maintained on a single line for parsing.
2026-06-04 13:48:05 +01:00
Pádraig Brady 49f3b66719 stat: support %Qn format to output quoted file name
%N also outputs the target of a symlink
so support %Qn to give more control over quoted names.

* src/stat.c (print_it): Validate %Qn.
(print_stat): Output quoted file name with %Qn.
(usage): Add %Qn description.
* doc/coreutils.texi (stat invocation): Likewise.
* tests/stat/stat-fmt.sh: Add a test case.
2026-06-04 13:14:27 +01:00
Pádraig Brady 641422abad stat: honor QUOTING_STYLE in default file name quoting
This is safer to output to terminal with malicious file names,
with multiple lines or control characters etc.

* src/stat.c: Quote the file name in the default output format
in the default quoting style, or as selected with QUOTING_STYLE.
Reported by Michał Majchrowicz and Marcin Wyczechowski.
2026-06-04 13:14:27 +01:00
Sylvestre Ledru cec863ff08 tests: stat: cover %N escaping of control characters
The default shell-escape quoting style escapes control characters in
file names (e.g. newlines) as $'...' sequences, but no test exercised
this; only the single-quote character was covered.
referenced here: https://github.com/uutils/coreutils/issues/9925

* tests/stat/stat-fmt.sh: Add a case with a file name containing
contiguous and separated newlines.
https://github.com/coreutils/coreutils/pull/271
2026-05-29 19:19:36 +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 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
Paul Eggert d53203b316 stat: handle %%%N too
* src/stat.c (main): Fix incorrect counting of '%'s before 'N'.
* tests/stat/stat-fmt.sh: Test for the bug.
2026-02-27 16:50:36 -08:00
Collin Funk 803bfa01e1 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.
2026-02-26 21:20:37 -08:00
Collin Funk 73d3a49f45 maint: run 'make update-copyright' 2026-01-01 10:56:16 -08: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
Paul Eggert 65a46e9e21 tests: port to noatime file systems
On these file systems the atime is always zero.
Problem found with ZFS on Ubuntu 24.04 LTS.
* tests/stat/stat-birthtime.sh (check_timestamps_updated):
* tests/stat/stat-nanoseconds.sh:
Work even if atimes are always zero.
* tests/stat/stat-nanoseconds.sh:
Fix typo: print_ver_ called before init.sh sourced.
2024-07-16 01:54:20 +00:00
Pádraig Brady a966dcdb69 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: 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.
2024-01-01 13:27:23 +00:00
Sylvestre Ledru 15925d0e5b tests: move tests to a directory per utility
* cfg.mk: Adjust syntax check exclusion paths.
* tests/local.mk: Adjust for renamed tests.
2023-06-19 13:12:37 +01:00