linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Shuah Khan <shuah@kernel.org>, Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 14/25] selftests/ftrace: Test kprobe-event argument with various bitsize
Date: Fri, 27 Jul 2018 21:16:33 +0900	[thread overview]
Message-ID: <153269379362.3084.6493537345417100466.stgit@devbox> (raw)
In-Reply-To: <153269339575.3084.16279591141931053689.stgit@devbox>

Improve the kprobe-event with argument types testcase
to test it with various bitsize.
kprobe-event argument can be recorded in given types with
various bitsize (8, 16, 32, 64), thus the type testcase
should test the different bitsize too.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 .../ftrace/test.d/kprobe/kprobe_args_type.tc       |   48 +++++++++++++-------
 1 file changed, 32 insertions(+), 16 deletions(-)

diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc
index 37443dd23d15..1bcb67dcae26 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc
@@ -6,29 +6,45 @@
 
 grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue
 
-echo 'p:testprobe _do_fork $stack0:s32 $stack0:u32 $stack0:x32 $stack0:b8@4/32' > kprobe_events
-grep testprobe kprobe_events
-test -d events/kprobes/testprobe
-
-echo 1 > events/kprobes/testprobe/enable
-( echo "forked")
-echo 0 > events/kprobes/testprobe/enable
-ARGS=`tail -n 1 trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'`
+gen_event() { # Bitsize
+  echo "p:testprobe _do_fork \$stack0:s$1 \$stack0:u$1 \$stack0:x$1 \$stack0:b4@4/$1"
+}
 
-check_types() {
-  X1=`printf "%x" $1 | tail -c 8`
+check_types() { # s-type u-type x-type bf-type width
+  test $# -eq 5
+  CW=$5
+  CW=$((CW / 4))
+  X1=`printf "%x" $1 | tail -c ${CW}`
   X2=`printf "%x" $2`
   X3=`printf "%x" $3`
   test $X1 = $X2
   test $X2 = $X3
   test 0x$X3 = $3
 
-  B4=`printf "%02x" $4`
-  B3=`echo -n $X3 | tail -c 3 | head -c 2`
+  B4=`printf "%1x" $4`
+  B3=`printf "%03x" 0x$X3 | tail -c 2 | head -c 1`
   test $B3 = $B4
 }
-check_types $ARGS
 
-echo "-:testprobe" >> kprobe_events
-clear_trace
-test -d events/kprobes/testprobe && exit_fail || exit_pass
+for width in 64 32 16 8; do
+  : "Add new event with basic types"
+  gen_event $width > kprobe_events
+  grep testprobe kprobe_events
+  test -d events/kprobes/testprobe
+
+  : "Trace the event"
+  echo 1 > events/kprobes/testprobe/enable
+  ( echo "forked")
+  echo 0 > events/kprobes/testprobe/enable
+
+  : "Confirm the arguments is recorded in given types correctly"
+  ARGS=`grep "testprobe" trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'`
+  check_types $ARGS $width
+
+  : "Clear event for next loop"
+  echo "-:testprobe" >> kprobe_events
+  clear_trace
+
+done
+
+exit_pass


  parent reply	other threads:[~2018-07-27 12:16 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-27 12:09 [PATCH 00/25] selftests/ftrace: Improve ftracetest with coverage check Masami Hiramatsu
2018-07-27 12:10 ` [PATCH 01/25] tracing: Allow gcov profiling on only ftrace subsystem Masami Hiramatsu
2018-07-27 12:10 ` [PATCH 02/25] selftests/ftrace: Add --stop-fail hidden option for debug Masami Hiramatsu
2018-07-27 12:11 ` [PATCH 03/25] selftests/ftrace: Add --console hidden option Masami Hiramatsu
2018-07-27 12:11 ` [PATCH 04/25] selftests/ftrace: Add case number prefix to logfile Masami Hiramatsu
2018-07-27 12:12 ` [PATCH 05/25] selftests/ftrace: More initialize features in initialize_ftrace Masami Hiramatsu
2018-07-27 12:12 ` [PATCH 06/25] selftests/ftrace: Cleanup ftrace after running test Masami Hiramatsu
2018-07-27 12:13 ` [PATCH 07/25] selftests/ftrace: Remove unneeded per-test init/cleanup ftrace Masami Hiramatsu
2018-07-27 12:13 ` [PATCH 08/25] selftests/ftrace: Fix to test kprobe $comm arg only if available Masami Hiramatsu
2018-07-27 12:14 ` [PATCH 09/25] selftests/ftrace: Fix checkbashisms errors Masami Hiramatsu
2018-07-27 12:14 ` [PATCH 10/25] selftests/ftrace: Use loopback address instead of localhost Masami Hiramatsu
2018-07-27 12:15 ` [PATCH 11/25] selftests/ftrace: Improve kprobe on module testcase to load/unload module Masami Hiramatsu
2018-08-02  1:02   ` Masami Hiramatsu
2018-08-02  7:22     ` Masami Hiramatsu
2018-07-27 12:15 ` [PATCH 12/25] selftests/ftrace: Improve kprobe testcase to check log data Masami Hiramatsu
2018-07-27 12:16 ` [PATCH 13/25] selftests/ftrace: Improve kretprobe " Masami Hiramatsu
2018-07-27 12:16 ` Masami Hiramatsu [this message]
2018-07-27 12:17 ` [PATCH 15/25] selftests/ftrace: Check set_event_pid result Masami Hiramatsu
2018-07-27 12:17 ` [PATCH 16/25] selftests/ftrace: Add kprobe event with $comm argument testcase Masami Hiramatsu
2018-07-27 12:17 ` [PATCH 17/25] selftests/ftrace: Add kprobe profile testcase Masami Hiramatsu
2018-07-27 12:18 ` [PATCH 18/25] selftests/ftrace: Add a testcase for nop tracer Masami Hiramatsu
2018-07-27 12:18 ` [PATCH 19/25] selftests/ftrace: Add kprobe-event with symbol argument test Masami Hiramatsu
2018-07-27 12:19 ` [PATCH 20/25] selftests/ftrace: Add trace_printk sample module test Masami Hiramatsu
2018-07-27 12:19 ` [PATCH 21/25] selftests/ftrace: Add ringbuffer size changing testcase Masami Hiramatsu
2018-07-27 12:20 ` [PATCH 22/25] selftests/ftrace: Add function profiling stat testcase Masami Hiramatsu
2018-07-27 12:20 ` [PATCH 23/25] selftests/ftrace: Add max stack tracer testcase Masami Hiramatsu
2018-08-03  5:24   ` Masami Hiramatsu
2018-07-27 12:21 ` [PATCH 24/25] selftests/ftrace: Add function filter on module testcase Masami Hiramatsu
2018-07-27 12:21 ` [PATCH 25/25] selftests/ftrace: Add trace_pipe testcase Masami Hiramatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=153269379362.3084.6493537345417100466.stgit@devbox \
    --to=mhiramat@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).