* 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    | 18 ++++++++++++++++--
 tests/wc/wc-files0-from.pl | 15 +++++++++++++--
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/tests/du/files0-from.pl b/tests/du/files0-from.pl
index 6eb31aacc..5bbc671cb 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 9bf2c6232..c7b7b39e7 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},
-- 
2.53.0


Reply via email to