Thread (3 messages) read the whole thread 3 messages, 2 authors, 2025-12-27
STALE215d

[PATCH] selftests/tracing: Fix test_multiple_writes stall

From: Fushuai Wang <hidden>
Date: 2025-12-26 09:12:58
Also in: linux-kselftest, lkml
Subsystem: kernel selftest framework, the rest, tracing · Maintainers: Shuah Khan, Shuah Khan, Linus Torvalds, Steven Rostedt, Masami Hiramatsu

When /sys/kernel/tracing/buffer_size_kb is less than 12KB,
the test_multiple_writes test will stall and wait for more
input due to insufficient buffer space.

This patch check current buffer_size_kb value before the test.
If it is less than 12KB, it temporarily increase the buffer to
12KB, and restore the original value after the tests are completed.

Fixes: 37f46601383a ("selftests/tracing: Add basic test for trace_marker_raw file")
Signed-off-by: Fushuai Wang <redacted>
---
 .../ftrace/test.d/00basic/trace_marker_raw.tc    | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc b/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc
index 7daf7292209e..216f87d89c3f 100644
--- a/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc
+++ b/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc
@@ -58,7 +58,7 @@ test_multiple_writes() {
 	echo stop > trace_marker
 
 	# Check to make sure the number of entries is the id (rounded up by 4)
-	awk '/.*: # [0-9a-f]* / {
+	awk -v ORIG="${ORIG}" '/.*: # [0-9a-f]* / {
 			print;
 			cnt = -1;
 			for (i = 0; i < NF; i++) {
@@ -70,6 +70,7 @@ test_multiple_writes() {
 					# The number of items is always rounded up by 4
 					cnt2 = int((cnt + 3) / 4) * 4;
 					if (cnt2 != num) {
+						system("echo \""ORIG"\" > buffer_size_kb");
 						exit 1;
 					}
 					break;
@@ -89,6 +90,7 @@ test_buffer() {
 	# The id must be four bytes, test that 3 bytes fails a write
 	if echo -n abc > ./trace_marker_raw ; then
 		echo "Too small of write expected to fail but did not"
+		echo $ORIG > buffer_size_kb
 		exit_fail
 	fi
 
@@ -99,9 +101,21 @@ test_buffer() {
 
 	if write_buffer 0xdeadbeef $size ; then
 		echo "Too big of write expected to fail but did not"
+		echo $ORIG > buffer_size_kb
 		exit_fail
 	fi
 }
 
+ORIG=`cat buffer_size_kb`
+
+# test_multiple_writes test needs at least 12KB buffer
+NEW_SIZE=12
+
+if [ ${ORIG} -lt ${NEW_SIZE} ]; then
+	echo ${NEW_SIZE} > buffer_size_kb
+fi
+
 test_buffer
 test_multiple_writes
+
+echo $ORIG > buffer_size_kb
-- 
2.36.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help