]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: wc,du: add additional --files0-from test cases
authorCollin Funk <collin.funk1@gmail.com>
Sun, 1 Mar 2026 02:36:34 +0000 (18:36 -0800)
committerCollin Funk <collin.funk1@gmail.com>
Sun, 1 Mar 2026 02:36:34 +0000 (18:36 -0800)
* 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.

tests/du/files0-from.pl
tests/wc/wc-files0-from.pl

index 6eb31aacc303b5f5341cc5fee85e4ce28017a1be..5bbc671cb408aae5f3cae257e10e7caefe7009c4 100755 (executable)
@@ -23,6 +23,8 @@ use strict;
 
 my $prog = 'du';
 
+my $limits = getlimits ();
+
 # Turn off localization of executable's output.
 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
 
@@ -36,9 +38,21 @@ my @Tests =
     ],
 
    # missing input file
-   ['missing', '--files0-from=missing', {EXIT=>1},
+   ['missing1', '--files0-from=missing', {EXIT=>1},
     {ERR => "$prog: cannot open 'missing' for reading: "
-     . "No such file or directory\n"}],
+     . "$limits->{ENOENT}\n"}],
+
+   # Input file listing missing files.
+   ['missing2', '--files0-from=-', '<', {IN=>"missing\0missing\0"}, {EXIT=>1},
+    {ERR => "$prog: cannot access 'missing': $limits->{ENOENT}\n" x 2}],
+
+   # Input file listing duplicate files.
+   ['duplicate1', '--files0-from=-', '<', {IN=>"g\0g\0"}, {AUX=>{g=>''}},
+    {OUT=>"0\tg\n"}, {OUT_SUBST=>'s/^\d+/0/'}],
+
+   # Input file listing duplicate files, using the -l option.
+   ['duplicate2', '-l --files0-from=-', '<', {IN=>"g\0g\0"}, {AUX=>{g=>''}},
+    {OUT=>"0\tg\n" x 2}, {OUT_SUBST=>'s/^\d+/0/'}],
 
    # input file name of '-'
    ['minus-in-stdin', '--files0-from=-', '<', {IN=>{f=>'-'}}, {EXIT=>1},
index 9bf2c62321b211ee5ff4bd8466a25df374bbc05a..c7b7b39e75976a0007e7144fb4a6450a996a0752 100755 (executable)
@@ -23,6 +23,8 @@ use strict;
 
 my $prog = 'wc';
 
+my $limits = getlimits ();
+
 # Turn off localization of executable's output.
 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
 
@@ -36,9 +38,18 @@ my @Tests =
     ],
 
    # missing input file
-   ['missing', '--files0-from=missing', {EXIT=>1},
+   ['missing1', '--files0-from=missing', {EXIT=>1},
     {ERR => "$prog: cannot open 'missing' for reading: "
-     . "No such file or directory\n"}],
+     . "$limits->{ENOENT}\n"}],
+
+   # Input file listing missing files.
+   ['missing2', '--files0-from=-', '<', {IN=>"missing\0missing\0"}, {EXIT=>1},
+    {OUT=>"0 0 0 total\n"},
+    {ERR => "$prog: missing: $limits->{ENOENT}\n" x 2}],
+
+   # Input file listing duplicate files.
+   ['duplicate1', '--files0-from=-', '<', {IN=>"g\0g\0"}, {AUX=>{g=>''}},
+    {OUT=>"0 0 0 g\n" x 2 . "0 0 0 total\n"}],
 
    # input file name of '-'
    ['minus-in-stdin', '--files0-from=-', '<', {IN=>{f=>'-'}}, {EXIT=>1},