linux/tools/testing/selftests/ftrace/test.d/remotes/reset.tc
Vincent Donnefort 0a1b03251d tracing: selftests: Add trace remote tests
Exercise the tracefs interface for trace remote with a set of tests to
check:

  * loading/unloading (unloading.tc)
  * reset (reset.tc)
  * size changes (buffer_size.tc)
  * consuming read (trace_pipe.tc)
  * non-consuming read (trace.tc)

Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: linux-kselftest@vger.kernel.org
Link: https://patch.msgid.link/20260309162516.2623589-16-vdonnefort@google.com
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
2026-03-09 12:33:55 -04:00

91 lines
1.8 KiB
Bash

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: Test trace remote reset
# requires: remotes/test
. $TEST_DIR/remotes/functions
check_reset()
{
write_event_path="write_event"
taskset=""
clear_trace
# Is the buffer empty?
output=$(dump_trace_pipe)
test $(wc -l $output | cut -d ' ' -f1) -eq 0
if $(echo $(pwd) | grep -q "per_cpu/cpu"); then
write_event_path="../../write_event"
cpu_id=$(echo $(pwd) | sed -e 's/.*per_cpu\/cpu//')
taskset="taskset -c $cpu_id"
fi
rm $output
# Can we properly write a new event?
$taskset echo 7890 > $write_event_path
output=$(dump_trace_pipe)
test $(wc -l $output | cut -d ' ' -f1) -eq 1
grep -q "id=7890" $output
rm $output
}
test_global_interface()
{
output=$(mktemp $TMPDIR/remote_test.XXXXXX)
# Confidence check
echo 123456 > write_event
output=$(dump_trace_pipe)
grep -q "id=123456" $output
rm $output
# Reset single event
echo 1 > write_event
check_reset
# Reset lost events
for i in $(seq 1 10000); do
echo 1 > write_event
done
check_reset
}
test_percpu_interface()
{
[ "$(get_cpu_ids | wc -l)" -ge 2 ] || return 0
for cpu in $(get_cpu_ids); do
taskset -c $cpu echo 1 > write_event
done
check_non_empty=0
for cpu in $(get_cpu_ids); do
cd per_cpu/cpu$cpu/
if [ $check_non_empty -eq 0 ]; then
check_reset
check_non_empty=1
else
# Check we have only reset 1 CPU
output=$(dump_trace_pipe)
test $(wc -l $output | cut -d ' ' -f1) -eq 1
rm $output
fi
cd -
done
}
test_reset()
{
test_global_interface
test_percpu_interface
}
if [ -z "$SOURCE_REMOTE_TEST" ]; then
set -e
setup_remote_test
test_reset
fi