From: Collin Funk Date: Sun, 1 Mar 2026 02:36:34 +0000 (-0800) Subject: tests: wc,du: add additional --files0-from test cases X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=236df1fa6a980eccd2bab1ff892746d5e261d7f7;p=thirdparty%2Fcoreutils.git tests: wc,du: add additional --files0-from test cases * 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. --- diff --git a/tests/du/files0-from.pl b/tests/du/files0-from.pl index 6eb31aacc3..5bbc671cb4 100755 --- a/tests/du/files0-from.pl +++ b/tests/du/files0-from.pl @@ -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}, diff --git a/tests/wc/wc-files0-from.pl b/tests/wc/wc-files0-from.pl index 9bf2c62321..c7b7b39e75 100755 --- a/tests/wc/wc-files0-from.pl +++ b/tests/wc/wc-files0-from.pl @@ -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},