]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: numfmt: fix false failures on some systems
authorPádraig Brady <P@draigBrady.com>
Tue, 26 Mar 2024 19:17:16 +0000 (19:17 +0000)
committerPádraig Brady <P@draigBrady.com>
Tue, 26 Mar 2024 20:09:35 +0000 (20:09 +0000)
* tests/misc/numfmt.pl: Verify that printf field width specs
count characters and not bytes before enabling locale tests.
This was seen on FreeBSD 14.0 and Solaris 11 OpenIndiana.
Reported by Bruno Haible

tests/misc/numfmt.pl

index 7abcb39ce043b38526742e0e96c515fff1d20e3a..94f9ec58e7d69ff807147503698f76b6510612dd 100755 (executable)
@@ -1070,13 +1070,15 @@ if ($locale ne 'C')
   {
     # Reset locale to 'C' if LOCALE_FR_UTF8 doesn't output as expected
     # as determined by the separate printf program.
-    open(LOC_NUM, "env LC_ALL=$locale printf \"%'d\" 1234|")
-      or die "Can't fork command: $!";
+    my $printf_cmd = "env LC_ALL=$locale printf \"%'06.f\" 1234;" .
+                     "env LC_ALL=$locale printf \"%'6.f\"  1234;";
+    open(LOC_NUM, "$printf_cmd|") or die "Can't fork command: $!";
     my $loc_num = <LOC_NUM>;
     close(LOC_NUM) || die "Failed to read grouped number from printf";
-    if ($loc_num ne "1${lg}234")
+    my $loc_match = "01${lg}234 1${lg}234";
+    if ($loc_num ne $loc_match)
       {
-        warn "skipping locale grouping tests as 1234 groups like $loc_num\n";
+        warn "skipping locale grouping tests as $loc_num != $loc_match\n";
         $locale = 'C';
       }
   }