[PATCH 14/14] ringbuffer/selftest: Add basic selftest to test chaning subbuf order

From: Steven Rostedt
Date: Sat Dec 09 2023 - 23:05:18 EST


From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>

Add a self test that will write into the trace buffer with differ trace
sub buffer order sizes.

Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
---
.../ftrace/test.d/00basic/ringbuffer_order.tc | 46 +++++++++++++++++++
1 file changed, 46 insertions(+)
create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_order.tc

diff --git a/tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_order.tc b/tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_order.tc
new file mode 100644
index 000000000000..c0d76dc724d3
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_order.tc
@@ -0,0 +1,46 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# description: Change the ringbuffer size
+# requires: buffer_subbuf_order
+# flags: instance
+
+get_buffer_data_size() {
+ sed -ne 's/^.*data.*size:\([0-9][0-9]*\).*/\1/p' events/header_page
+}
+
+a="1234567890"
+
+make_str() {
+ cnt=$1
+ s=""
+ while [ $cnt -gt 10 ]; do
+ s="${s}${a}"
+ cnt=$((cnt-10))
+ done
+ while [ $cnt -gt 0 ]; do
+ s="${s}X"
+ cnt=$((cnt-1))
+ done
+ echo -n $s
+}
+
+test_buffer() {
+
+ size=`get_buffer_data_size`
+
+ str=`make_str $size`
+
+ echo $str > trace_marker
+
+ grep -q $a trace
+}
+
+ORIG=`cat buffer_subbuf_order`
+
+for a in `seq 0 4`; do
+ echo 0 > buffer_subbuf_order
+ test_buffer
+done
+
+echo $ORIG > buffer_subbuf_order
+
--
2.42.0