]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: sort-NaN-infloop: augment testing for recent fix
authorPádraig Brady <P@draigBrady.com>
Mon, 2 May 2022 13:27:34 +0000 (14:27 +0100)
committerPádraig Brady <P@draigBrady.com>
Mon, 2 May 2022 20:26:59 +0000 (21:26 +0100)
* tests/misc/sort-NaN-infloop.sh: Add test case from
https://unix.stackexchange.com/a/700967/37127
* src/sort.c: Avoid syntax-check failure.

src/sort.c
tests/misc/sort-NaN-infloop.sh

index b2a465cf53e42477c9450fe71d6a2f9a64cc6712..8af356c663f8b6f644916b1e11b2fb5e1d9a3855 100644 (file)
@@ -2006,7 +2006,7 @@ numcompare (char const *a, char const *b)
 static int
 nan_compare (long double a, long double b)
 {
-  char buf[2][sizeof "-nan()" + CHAR_BIT * sizeof a];
+  char buf[2][sizeof "-nan""()" + CHAR_BIT * sizeof a];
   snprintf (buf[0], sizeof buf[0], "%Lf", a);
   snprintf (buf[1], sizeof buf[1], "%Lf", b);
   return strcmp (buf[0], buf[1]);
index 93cf9bd77e32f97d27839b48cf8d9a26f65bbd5b..cc1c583cdfa8f03fe48ea97f89e5cea75b853530 100755 (executable)
@@ -23,6 +23,9 @@ echo nan > F || framework_failure_
 printf 'nan\nnan\n' > exp || framework_failure_
 timeout 10 sort -g -m F F > out || fail=1
 
+# This was seen to infloop on some systems until coreutils v9.2 (bug 55212)
+yes nan | head -n128095 | timeout 60 sort -g > /dev/null || fail=1
+
 compare exp out || fail=1
 
 Exit $fail