Linux Trace Kernel
 help / color / mirror / Atom feed
From: Gabriele Monaco <gmonaco@redhat.com>
To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	Gabriele Monaco <gmonaco@redhat.com>,
	Shuah Khan <shuah@kernel.org>,
	linux-kselftest@vger.kernel.org
Cc: Wen Yang <wen.yang@linux.dev>, Nam Cao <namcao@linutronix.de>,
	Thomas Weissschuh <thomas.weissschuh@linutronix.de>,
	Tomas Glozar <tglozar@redhat.com>, John Kacur <jkacur@redhat.com>
Subject: [PATCH v4 16/17] selftests/verification: Rearrange the wwnr_printk test
Date: Fri, 17 Jul 2026 17:46:37 +0200	[thread overview]
Message-ID: <20260717154638.220789-17-gmonaco@redhat.com> (raw)
In-Reply-To: <20260717154638.220789-1-gmonaco@redhat.com>

The wwnr_printk test expects no reactions in some situations, after
fixing the bash assertion, the test is failing because expecting no
reaction after a previous step had reactions is flaky without making
sure all buffers are flushed.

Wait for reactions to be over when expected by polling dmesg for an
interval without any rv message.
Also simplify the load function to stop loads as soon as a reaction
occurs, this limits the number of lines to flush and makes tests overall
faster and more stable.

Reviewed-by: Wen Yang <wen.yang@linux.dev>
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
---

Notes:
    V4:
    * Wait for dmesg to flush all messages after reactions

 .../verification/test.d/rv_wwnr_printk.tc     | 23 ++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc b/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc
index 96de95edb530..37d96e1ae93b 100644
--- a/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc
+++ b/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc
@@ -4,23 +4,40 @@
 # requires: available_reactors wwnr:monitor printk:reactor stress-ng:program
 
 load() { # returns true if there was a reaction
-	local lines_before num
+	local lines_before num load_pid ret
 	num=$((($(nproc) + 1) / 2))
 	lines_before=$(dmesg | wc -l)
-	stress-ng --cpu-sched "$num" --timer "$num" -t 5 -q
-	dmesg | tail -n $((lines_before + 1)) | grep -q "rv: monitor wwnr does not allow event"
+	stress-ng --cpu-sched "$num" --timer "$num" -t 5 -q &
+	load_pid=$!
+	timeout 5 dmesg -w | tail -n +$((lines_before + 1)) | grep -m 1 -q "rv: monitor wwnr does not allow event"
+	ret=$?
+	kill "$load_pid" || true
+	wait "$load_pid" || true
+	return $ret
+}
+
+# loads may flood the ringbuffer, wait for all pending printks
+wait_dmesg_flush() {
+	local last_before last_after=$(dmesg | grep "rv:" | tail -n 1 || true)
+	while [ "$last_before" != "$last_after" ]; do
+		last_before=$last_after
+		sleep .3
+		last_after=$(dmesg | grep "rv:" | tail -n 1 || true)
+	done
 }
 
 echo 1 > monitors/wwnr/enable
 echo printk > monitors/wwnr/reactors
 
 load
+wait_dmesg_flush
 
 echo 0 > monitoring_on
 ! load || false
 echo 1 > monitoring_on
 
 load
+wait_dmesg_flush
 
 echo 0 > reacting_on
 ! load || false
-- 
2.55.0


  parent reply	other threads:[~2026-07-17 15:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17 15:46 [PATCH v4 00/17] rv: Add selftests to tools and KUnit tests Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 01/17] rv: Use generic rv_this for the rv_monitor variable in LTL Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 02/17] tools/rv: Fix exit status when monitor execution fails Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 03/17] verification/rvgen: Improve rv_dir discovery in RVGenerator Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 04/17] verification/rvgen: Use pathlib instead of os.path Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 05/17] verification/rvgen: Improve consistency in template files Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 06/17] tools/rv: Add selftests Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 07/17] verification/rvgen: Add golden and spec folders for tests Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 08/17] verification/rvgen: Add selftests Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 09/17] verification/rvgen: Add the rvgen kunit subcommand Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 10/17] verification/rvgen: Add selftests for rvgen kunit Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 11/17] rv: Export task monitor slot and react symbols Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 12/17] rv: Add KUnit tests for some DA/HA monitors Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 13/17] rv: Add KUnit stub for current Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 14/17] rv: Add KUnit tests for some LTL monitors Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 15/17] selftests/verification: Fix wrong errexit assumption Gabriele Monaco
2026-07-17 15:46 ` Gabriele Monaco [this message]
2026-07-17 15:46 ` [PATCH v4 17/17] selftests/verification: Add selftests for deadline and stall monitors Gabriele Monaco

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260717154638.220789-17-gmonaco@redhat.com \
    --to=gmonaco@redhat.com \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=namcao@linutronix.de \
    --cc=rostedt@goodmis.org \
    --cc=shuah@kernel.org \
    --cc=tglozar@redhat.com \
    --cc=thomas.weissschuh@linutronix.de \
    --cc=wen.yang@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox