]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/tracing: Fix test_multiple_writes stall
authorFushuai Wang <wangfushuai@baidu.com>
Fri, 9 Jan 2026 03:36:20 +0000 (11:36 +0800)
committerShuah Khan <skhan@linuxfoundation.org>
Fri, 9 Jan 2026 22:49:32 +0000 (15:49 -0700)
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.

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.

Link: https://lore.kernel.org/r/20260109033620.25727-1-fushuai.wang@linux.dev
Fixes: 37f46601383a ("selftests/tracing: Add basic test for trace_marker_raw file")
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc

index 7daf7292209e5281c8c9caec45b506e037819c1e..a2c42e13f614b4cbb4252df8923a770f48acd598 100644 (file)
@@ -89,6 +89,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 +100,24 @@ 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
+if ! test_multiple_writes; then
+       echo ${ORIG} > buffer_size_kb
+       exit_fail
+fi
+
+echo ${ORIG} > buffer_size_kb