[PATCH 06/17] rcutorture: Compare console version counters exactly

From: Kunwu Chan

Date: Tue Dec 01 2026 - 11:20:25 EST


Compare unsigned decimal counters as strings so awk can distinguish
adjacent 64-bit version numbers. Test progress and regression at the
double-precision boundary, digit-count growth and a decreasing
counter.

Signed-off-by: Kunwu Chan <kunwu.chan@xxxxxxxxx>
---
.../bin/parse-console-progress-test.sh | 11 ++++++++++
.../selftests/rcutorture/bin/parse-console.sh | 21 ++++++++++++++++---
2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/parse-console-progress-test.sh b/tools/testing/selftests/rcutorture/bin/parse-console-progress-test.sh
index bc51b598291c..b9603ce04fce 100755
--- a/tools/testing/selftests/rcutorture/bin/parse-console-progress-test.sh
+++ b/tools/testing/selftests/rcutorture/bin/parse-console-progress-test.sh
@@ -68,5 +68,16 @@ check legacy-regression fail 'BAD SEQ' < <(stats 107 ''; stats 106 '')
check legacy-nonnumeric fail 'BAD SEQ' < <(stats 106 ''; stats broken '')
check legacy-initial-zero fail 'BAD SEQ|GP HANG' < <(stats 0 ''; stats 1 '')

+check double-adjacent-progress pass < <(stats 9007199254740992 ''; stats 9007199254740993 '')
+check double-adjacent-regression fail 'BAD SEQ' < <(
+ stats 9007199254740993 ''
+ stats 9007199254740992 ''
+)
+check digit-growth-progress pass < <(stats 9 ''; stats 10 '')
+check large-version-regression fail 'BAD SEQ' < <(
+ stats 18446744073709551615 'wgps: 1'
+ stats 18446744073709551614 'wgps: 2'
+)
+
echo "1..$nchecks"
test "$nfailed" -eq 0
diff --git a/tools/testing/selftests/rcutorture/bin/parse-console.sh b/tools/testing/selftests/rcutorture/bin/parse-console.sh
index be1e943ca4d5..d63fa43864ad 100755
--- a/tools/testing/selftests/rcutorture/bin/parse-console.sh
+++ b/tools/testing/selftests/rcutorture/bin/parse-console.sh
@@ -69,24 +69,39 @@ then
sed -e 's/^(initramfs)[^]]*] //' -e 's/^\[[^]]*] //' |
sed -e 's/^.*ver: //' |
awk '
+ # Compare decimal counters exactly.
+ function countcmp(a, b) {
+ sub(/^0+/, "", a);
+ sub(/^0+/, "", b);
+ if (length(a) != length(b))
+ return length(a) > length(b) ? 1 : -1;
+ if ("x" a == "x" b)
+ return 0;
+ return "x" a > "x" b ? 1 : -1;
+ }
+
BEGIN {
ver = 0;
badseq = 0;
}

{
- if (!badseq && ($1 + 0 != $1 || $1 <= ver)) {
+ sub(/\r$/, "");
+ vcmp = countcmp($1, ver);
+ if (!badseq && ($1 !~ /^[0-9]+$/ || vcmp <= 0)) {
badseqno1 = ver;
badseqno2 = $1;
badseqnr = NR;
+ badseq_invalid = $1 !~ /^[0-9]+$/;
badseq = 1;
}
- ver = $1
+ ver = $1;
}

END {
if (badseq) {
- if (badseqno1 == badseqno2 && badseqno2 == ver)
+ if (!badseq_invalid && countcmp(badseqno1, badseqno2) == 0 &&
+ countcmp(badseqno2, ver) == 0)
print "GP HANG at " ver " torture stat " badseqnr;
else
print "BAD SEQ " badseqno1 ":" badseqno2 " last:" ver " version " badseqnr;
--
2.43.0