[PATCH 05/17] rcutorture: Add selftests for console writer progress
From: Kunwu Chan
Date: Tue Dec 01 2026 - 11:19:49 EST
Cover legacy writer-progress detection in parse-console.sh before
changing how it compares or interprets counters.
Require each parser invocation to exit successfully, then check the
diagnostic generated for that case. Clear any previous diagnostic so a
reused result directory cannot supply a stale expected failure.
Signed-off-by: Kunwu Chan <kunwu.chan@xxxxxxxxx>
---
.../bin/parse-console-progress-test.sh | 72 +++++++++++++++++++
1 file changed, 72 insertions(+)
create mode 100755 tools/testing/selftests/rcutorture/bin/parse-console-progress-test.sh
diff --git a/tools/testing/selftests/rcutorture/bin/parse-console-progress-test.sh b/tools/testing/selftests/rcutorture/bin/parse-console-progress-test.sh
new file mode 100755
index 000000000000..bc51b598291c
--- /dev/null
+++ b/tools/testing/selftests/rcutorture/bin/parse-console-progress-test.sh
@@ -0,0 +1,72 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Check writer progress through parse-console.sh and its diagnostic files.
+# Usage: parse-console-progress-test.sh [parse-console.sh [result-directory]]
+#
+# Author: Kunwu Chan <kunwu.chan@xxxxxxxxx>
+
+set -u
+
+bindir="$(cd -- "$(dirname -- "$0")" && pwd)"
+parser="${1:-$bindir/parse-console.sh}"
+if test "$#" -gt 1
+then
+ t="$2"
+ mkdir -p "$t"
+else
+ t="$(mktemp -d "${TMPDIR-/tmp}/parse-console-progress-test.XXXXXX")" || exit 1
+ trap 'rm -rf "$t"' EXIT
+fi
+mkdir -p "$t/tmp"
+t="$(cd -- "$t" && pwd)"
+nchecks=0
+nfailed=0
+
+stats () {
+ printf '[ %s] srcud-torture: rtc: ffff888012345678 ver: %s tfle: 0 %s\n' \
+ "${3:-5.000000}" "$1" "$2"
+}
+
+check () {
+ local name="$1" expected="$2" pattern="${3:-.}" actual status
+ local dir="$t/$name"
+
+ mkdir -p "$dir"
+ cat > "$dir/console.log"
+ printf 'srcud-torture: End of test: SUCCESS\n' >> "$dir/console.log"
+ rm -f -- "$dir/console.log.diags" || exit 1
+ # The parser reports these console failures through its diagnostics.
+ TORTURE_SUITE=rcu LC_ALL=C TMPDIR="$t/tmp" PATH="$bindir:$PATH" \
+ bash "$parser" "$dir/console.log" "$name" > "$dir/output" 2>&1
+ status=$?
+ printf '%s\n' "$status" > "$dir/exit-status"
+ actual=pass
+ if test -s "$dir/console.log.diags"
+ then
+ actual=fail
+ fi
+ nchecks=$((nchecks + 1))
+ if test "$status" -eq 0 && test "$actual" = "$expected" &&
+ { test "$expected" = pass || grep -Eq "$pattern" "$dir/console.log.diags"; }
+ then
+ echo "ok $nchecks - $name"
+ else
+ echo "not ok $nchecks - $name (parser exit $status, $actual, expected $expected)"
+ cat "$dir/output"
+ if test -f "$dir/console.log.diags"
+ then
+ cat "$dir/console.log.diags"
+ fi
+ nfailed=$((nfailed + 1))
+ fi
+}
+
+check legacy-progress pass < <(stats 106 ''; stats 107 '')
+check legacy-stall fail 'GP HANG' < <(stats 106 ''; stats 106 '')
+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 '')
+
+echo "1..$nchecks"
+test "$nfailed" -eq 0
--
2.43.0