]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: tests: avoid ERANGE specific handling
authorPádraig Brady <P@draigBrady.com>
Tue, 17 Feb 2026 22:50:00 +0000 (22:50 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 18 Feb 2026 18:31:49 +0000 (18:31 +0000)
* tests/fmt/base.pl: Verify ERANGE is diagnosed.
* tests/od/od.pl: Adjust determination of ERANGE.

tests/fmt/base.pl
tests/od/od.pl

index db3da900e71ea0310f7cfd08f05f2e0db960e353..9fb63704eee8bb5abb553448637da440c33bd86c 100755 (executable)
@@ -18,8 +18,9 @@
 
 use strict;
 
+my $limits = getlimits ();
+
 (my $program_name = $0) =~ s|.*/||;
-my $normalize_strerror = "s/': .*/'/";
 
 my @Tests =
     (
@@ -27,11 +28,10 @@ my @Tests =
       {IN=> "ça\nçb\n"},
       {OUT=>"ça b\n"}],
      ['wide-1', '-w 32768',
-      {ERR => "fmt: invalid width: '32768'\n"}, {EXIT => 1},
-      {ERR_SUBST => $normalize_strerror}],
+      {ERR => "fmt: invalid width: '32768': $limits->{ERANGE}\n"}, {EXIT => 1}],
      ['wide-2', '-w 2147483647',
-      {ERR => "fmt: invalid width: '2147483647'\n"}, {EXIT => 1},
-      {ERR_SUBST => $normalize_strerror}],
+      {ERR => "fmt: invalid width: '2147483647': $limits->{ERANGE}\n"},
+      {EXIT => 1}],
      ['bad-suffix', '-72x',    {IN=> ''},
       {ERR => "fmt: invalid width: '72x'\n"}, {EXIT => 1}],
      ['no-file', 'no-such-file',
index 0dffc780f55c0f6db6fd250b3728d315b17882d2..1e515c0269fafda59036dbe6eb70b03429fe0bfa 100755 (executable)
@@ -18,6 +18,8 @@
 
 use strict;
 
+my $limits = getlimits ();
+
 (my $program_name = $0) =~ s|.*/||;
 
 # Turn off localization of executable's output.
@@ -25,9 +27,6 @@ use strict;
 
 my $prog = 'od';
 
-use Errno qw(ERANGE);
-my $ERANGE = do { local $! = ERANGE; "$!" };
-
 # Use a file in /proc whose size is not likely to
 # change between the wc and od invocations.
 my $proc_file = '/proc/version';
@@ -79,11 +78,11 @@ my @Tests =
 
      # Overflowing traditional offsets should be diagnosed.
      ['overflow-off-1', '-', '7' x 255, {IN_PIPE=>""}, {EXIT=>1},
-      {ERR=>"od: ".('7' x 255).": $ERANGE\n"}],
+      {ERR=>"od: ".('7' x 255).": $limits->{ERANGE}\n"}],
      ['overflow-off-2', '-', ('9' x 254).'.', {IN_PIPE=>""}, {EXIT=>1},
-      {ERR=>"od: ".('9' x 254).".: $ERANGE\n"}],
+      {ERR=>"od: ".('9' x 254).".: $limits->{ERANGE}\n"}],
      ['overflow-off-3', '-', '0x'.('f' x 253), {IN_PIPE=>""}, {EXIT=>1},
-      {ERR=>"od: 0x".('f' x 253).": $ERANGE\n"}],
+      {ERR=>"od: 0x".('f' x 253).": $limits->{ERANGE}\n"}],
 
      # Ensure that a large width does not cause trouble.
      # From coreutils-7.0 through coreutils-8.21, these would print