[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1682414197-13173-3-git-send-email-alan.maguire@oracle.com>
Date: Tue, 25 Apr 2023 10:16:36 +0100
From: Alan Maguire <alan.maguire@...cle.com>
To: rostedt@...dmis.org, mhiramat@...nel.org
Cc: corbet@....net, shuah@...nel.org, linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
linux-kselftest@...r.kernel.org,
Alan Maguire <alan.maguire@...cle.com>
Subject: [PATCH tracing 2/3] selftests/ftrace: add test coverage for filter predicates
add tests verifying filter predicates work for 1/2/4/8/16 byte values
and strings; use predicates at event and subsystem level.
Signed-off-by: Alan Maguire <alan.maguire@...cle.com>
---
.../selftests/ftrace/test.d/event/filter.tc | 62 +++++++++++++++++++
1 file changed, 62 insertions(+)
create mode 100644 tools/testing/selftests/ftrace/test.d/event/filter.tc
diff --git a/tools/testing/selftests/ftrace/test.d/event/filter.tc b/tools/testing/selftests/ftrace/test.d/event/filter.tc
new file mode 100644
index 000000000000..df5c93d5aa4d
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/event/filter.tc
@@ -0,0 +1,62 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# description: event tracing - enable filter predicates
+# requires: set_event events/sched
+# flags:
+
+do_reset() {
+ echo 0 > ${event}/enable
+ echo 0 > ${event}/filter
+ clear_trace
+}
+
+fail() { #msg
+ echo $1
+ exit_fail
+}
+
+# verify filter predicates at trace event/subsys level for
+# - string (prev_comm)
+# - 1-byte value (common_flags)
+# - 2-byte value (common_type)
+# - 4-byte value (next_pid)
+# - 8-byte value (prev_state)
+
+for event in events/sched/sched_switch events/sched
+do
+ for filter in "prev_comm == 'ping'" \
+ "common_flags != 0" \
+ "common_type >= 0" \
+ "next_pid > 0" \
+ "prev_state != 0"
+ do
+ echo "$filter" > ${event}/filter
+ echo 1 > ${event}/enable
+ yield
+ count=`grep sched_switch trace|wc -l`
+ if [ $count -lt 1 ]; then
+ fail "at least one $event should be recorded for '$filter'"
+ fi
+ do_reset
+ done
+done
+
+# verify '==', '!=' filter predicates for 16-byte array at event/subsys
+# level
+
+LOCALHOST="-6 ::1"
+for event in events/fib6/fib6_table_lookup events/fib6 ; do
+ for filter in "dst == 0x00000000000000000000000000000001" \
+ "src != 0x00000000000000000000000000000001"
+ do
+ echo "$filter" > ${event}/filter
+ echo 1 > ${event}/enable
+ yield
+ count=`grep fib6_table_lookup trace|wc -l`
+ if [ $count -lt 1 ]; then
+ fail "at least one $event should be recorded for '$filter'"
+ fi
+ do_reset
+ done
+done
+exit 0
--
2.31.1
Powered by blists - more mailing lists