Skip to contentSkip to conversation

tracing: make ftrace tests to be extended

RFC PATCH New Li Wang 3 participants 27 messages Mar 4, 2016 – Mar 22, 2016

lore
Share & tools
lore

Li Wang

author
#0 lore raw

cover tracing: make ftrace tests to be extended

For the purpose of extending these ftrace cases, We rewrite some of them to partition testcase into new structure.

1, Reorganize the stress tests to ftrace general test, then that woule be
easy to introduce new function/regression testcases in the next step.

2, Adding two regression testcases as an example, We will roll out some more later.

3, Enhance the ftrace-stress test coverage.

4, Do some cleanup and bug fix work.

At last, test PASS all the new testcases on kernel-4.4.0.

Chunyu Hu (4):
ftrace_stress: skip unsupported tests
ftrace_stress: keep the name of testscipt in sync with tracing file
ftrace_stress: update the trace_options test
ftrace_stress: add two new tests

Li Wang (5):
ftrace_stress: remove the useless file ftrace_get_page_size.c tracing[1]: reorganize ftrace-stress tests to general tests tracing[2]: reorganize ftrace stress tests to general tests
ftrace_regression: add new case to ftrace_regression/ dir
ftrace_regression: add a new testcase

Signature · 1 line
1.8.3.1
author
#1 lore raw

RFC PATCH 1/9 ftrace_stress: remove the useless file ftrace_get_page_size.c

After checking the whole test suit, I didn't find anyplace calling this program. Also, we cloud get system page size by command 'getconf PAGESIZE'.

---
 testcases/kernel/tracing/ftrace_stress_test/.gitignore            | 1 -
 .../kernel/tracing/ftrace_stress_test/ftrace_get_page_size.c      | 8 --------
 2 files changed, 9 deletions(-)
 delete mode 100644 testcases/kernel/tracing/ftrace_stress_test/.gitignore
 delete mode 100644 testcases/kernel/tracing/ftrace_stress_test/ftrace_get_page_size.c
testcases/kernel/tracing/ftrace_stress_test/.gitignore deleted +0 -1
deleted file mode 100644
index 099ec4e..0000000
@@ -1 +0,0 @@
-/ftrace_get_page_size
testcases/kernel/tracing/ftrace_stress_test/ftrace_get_page_size.c deleted +0 -8
deleted file mode 100644
index 9f5dec7..0000000
@@ -1,8 +0,0 @@
-#include <unistd.h>
-#include <stdio.h>
-
-int main(void)
-{
-	printf("%d\n", getpagesize());
-	return 0;
-}
Signature · 1 line
1.8.3.1
author
#2 lore raw

RFC PATCH 2/9 tracing[1]: reorganize ftrace-stress tests to general tests

In this commit, just rename the ftrace_stress_test to ftrace_test.

---
 .../kernel/tracing/ftrace_stress_test/Makefile     |   7 -
 .../ftrace_stress/ftrace_buffer_size.sh            |  45 ----
 .../ftrace_stress/ftrace_current_tracer.sh         |  34 ---
 .../ftrace_stress/ftrace_ftrace_enabled.sh         |  39 ----
 .../ftrace_stress/ftrace_profile_enabled.sh        |  50 -----
 .../ftrace_stress/ftrace_set_event.sh              |  44 ----
 .../ftrace_stress/ftrace_set_ftrace_pid.sh         |  49 -----
 .../ftrace_stress/ftrace_stack_max_size.sh         |  39 ----
 .../ftrace_stress/ftrace_stack_trace.sh            |  46 ----
 .../ftrace_stress/ftrace_trace.sh                  |  27 ---
 .../ftrace_stress/ftrace_trace_clock.sh            |  46 ----
 .../ftrace_stress/ftrace_trace_options.sh          |  42 ----
 .../ftrace_stress/ftrace_trace_pipe.sh             |  52 -----
 .../ftrace_stress/ftrace_trace_stat.sh             |  45 ----
 .../ftrace_stress/ftrace_tracing_enabled.sh        |  39 ----
 .../ftrace_stress/ftrace_tracing_max_latency.sh    |  38 ----
 .../ftrace_stress/ftrace_tracing_on.sh             |  39 ----
 .../ftrace_stress_test/ftrace_stress_test.sh       | 243 ---------------------
 testcases/kernel/tracing/ftrace_test/Makefile      |   7 +
 .../ftrace_stress/ftrace_buffer_size.sh            |  45 ++++
 .../ftrace_stress/ftrace_current_tracer.sh         |  34 +++
 .../ftrace_stress/ftrace_ftrace_enabled.sh         |  39 ++++
 .../ftrace_stress/ftrace_profile_enabled.sh        |  50 +++++
 .../ftrace_test/ftrace_stress/ftrace_set_event.sh  |  44 ++++
 .../ftrace_stress/ftrace_set_ftrace_pid.sh         |  49 +++++
 .../ftrace_stress/ftrace_stack_max_size.sh         |  39 ++++
 .../ftrace_stress/ftrace_stack_trace.sh            |  46 ++++
 .../ftrace_test/ftrace_stress/ftrace_trace.sh      |  27 +++
 .../ftrace_stress/ftrace_trace_clock.sh            |  46 ++++
 .../ftrace_stress/ftrace_trace_options.sh          |  42 ++++
 .../ftrace_test/ftrace_stress/ftrace_trace_pipe.sh |  52 +++++
 .../ftrace_test/ftrace_stress/ftrace_trace_stat.sh |  45 ++++
 .../ftrace_stress/ftrace_tracing_enabled.sh        |  39 ++++
 .../ftrace_stress/ftrace_tracing_max_latency.sh    |  38 ++++
 .../ftrace_test/ftrace_stress/ftrace_tracing_on.sh |  39 ++++
 .../tracing/ftrace_test/ftrace_stress_test.sh      | 243 +++++++++++++++++++++
 36 files changed, 924 insertions(+), 924 deletions(-)
 delete mode 100644 testcases/kernel/tracing/ftrace_stress_test/Makefile
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_buffer_size.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_current_tracer.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_ftrace_enabled.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_profile_enabled.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_set_event.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_set_ftrace_pid.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_stack_max_size.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_stack_trace.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_clock.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_options.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_pipe.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_stat.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_enabled.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_max_latency.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_on.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress_test.sh
 create mode 100644 testcases/kernel/tracing/ftrace_test/Makefile
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_current_tracer.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_ftrace_enabled.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_profile_enabled.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_enabled.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_on.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
testcases/kernel/tracing/ftrace_stress_test/Makefile deleted +0 -7
deleted file mode 100644
index e4a913a..0000000
@@ -1,7 +0,0 @@
-top_srcdir              ?= ../../../..
-
-include $(top_srcdir)/include/mk/testcases.mk
-
-INSTALL_TARGETS         := *.sh ftrace_stress/*
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_buffer_size.sh deleted +0 -45

45 lines not on this page · raw message

testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_current_tracer.sh deleted +0 -34
deleted file mode 100755
index 88d576f..0000000
@@ -1,34 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <[email protected]>                                      #
-#                                                                             #
-###############################################################################
-
-LOOP=200
-
-for ((; ;))
-{
-	for ((i = 0; i < $LOOP; i++))
-	{
-		for tracer in `cat "$TRACING_PATH"/available_tracers`
-		do
-			if [ "$tracer" = mmiotrace ]; then
-				continue
-			fi
-
-			echo $tracer > "$TRACING_PATH"/current_tracer 2> /dev/null
-		done
-	}
-
-	sleep 1
-}
-
testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_ftrace_enabled.sh deleted +0 -39
deleted file mode 100755
index 20bb234..0000000
@@ -1,39 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <[email protected]>                                      #
-#                                                                             #
-###############################################################################
-
-MAX_LOOP=1500
-count=0
-
-for ((; ;))
-{
-	count=$(( $count + 1 ))
-
-	for ((i = 0; i < $MAX_LOOP; i++))
-	{
-		echo 0 > /proc/sys/kernel/ftrace_enabled
-		echo 1 > /proc/sys/kernel/ftrace_enabled
-	}
-
-	enable=$(( $count % 3 ))
-
-	if [ $enable -eq 0 ]; then
-		echo 1 > /proc/sys/kernel/ftrace_enabled
-	else
-		echo 0 > /proc/sys/kernel/ftrace_enabled
-	fi
-
-	sleep 1
-}
-
testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_profile_enabled.sh deleted +0 -50

50 lines not on this page · raw message

testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_set_event.sh deleted +0 -44

44 lines not on this page · raw message

testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_set_ftrace_pid.sh deleted +0 -49

49 lines not on this page · raw message

testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_stack_max_size.sh deleted +0 -39
deleted file mode 100755
index 682d05e..0000000
@@ -1,39 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <[email protected]>                                      #
-#                                                                             #
-###############################################################################
-
-MAX_STACK_SIZE=8192
-
-if [ ! -e /proc/sys/kernel/stack_tracer_enabled ]; then
-	should_skip=1
-else
-	should_skip=0
-fi
-
-for ((; ;))
-{
-	if [ $should_skip -eq 1 ]; then
-		sleep 2
-		continue
-	fi
-
-	for ((i = 0; i < $MAX_STACK_SIZE; i += 70))
-	{
-		echo $i > "$TRACING_PATH"/stack_max_size
-		cat "$TRACING_PATH"/stack_max_size > /dev/null
-	}
-
-	sleep 1
-}
-
testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_stack_trace.sh deleted +0 -46

46 lines not on this page · raw message

testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace.sh deleted +0 -27
deleted file mode 100755
index e36712b..0000000
@@ -1,27 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <[email protected]>                                      #
-#                                                                             #
-###############################################################################
-
-LOOP=200
-
-for ((; ;))
-{
-	for ((i = 0; i < $LOOP; i++))
-	{
-		cat "$TRACING_PATH"/trace > /dev/null
-	}
-
-	sleep 1
-}
-
testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_clock.sh deleted +0 -46

46 lines not on this page · raw message

testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_options.sh deleted +0 -42

42 lines not on this page · raw message

testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_pipe.sh deleted +0 -52

52 lines not on this page · raw message

testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_stat.sh deleted +0 -45

45 lines not on this page · raw message

testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_enabled.sh deleted +0 -39
deleted file mode 100755
index 69f2ae6..0000000
@@ -1,39 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <[email protected]>                                      #
-#                                                                             #
-###############################################################################
-
-MAX_LOOP=1500
-count=0
-
-for ((; ;))
-{
-	count=$(( $count + 1 ))
-
-	for ((i = 0; i < $MAX_LOOP; i++))
-	{
-		echo 0 > "$TRACING_PATH"/tracing_enabled
-		echo 1 > "$TRACING_PATH"/tracing_enabled
-	}
-
-	enable=$(( $count % 3 ))
-
-	if [ $enable -eq 0 ]; then
-		echo 0 > "$TRACING_PATH"/tracing_enabled
-	else
-		echo 1 > "$TRACING_PATH"/tracing_enabled
-	fi
-
-	sleep 1
-}
-
testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_max_latency.sh deleted +0 -38
deleted file mode 100755
index f19d734..0000000
@@ -1,38 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <[email protected]>                                      #
-#                                                                             #
-###############################################################################
-
-MAX_LATENCY=100000
-
-if [ ! -e "$TRACING_PATH"/tracing_max_latency ]; then
-        should_skip=1
-else
-        should_skip=0
-fi
-
-for ((; ;))
-{
-        if [ $should_skip -eq 1 ]; then
-                sleep 2
-                continue
-        fi
-
-	for ((i = 0; i < $MAX_LATENCY; i += 400))
-	{
-		echo $i > "$TRACING_PATH"/tracing_max_latency
-	}
-
-	sleep 1
-}
-
testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_on.sh deleted +0 -39
deleted file mode 100755
index 672c223..0000000
@@ -1,39 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <[email protected]>                                      #
-#                                                                             #
-###############################################################################
-
-MAX_LOOP=1500
-count=0
-
-for ((; ;))
-{
-	count=$(( $count + 1 ))
-
-	for ((i = 0; i < $MAX_LOOP; i++))
-	{
-		echo 0 > "$TRACING_PATH"/tracing_on
-		echo 1 > "$TRACING_PATH"/tracing_on
-	}
-
-	enable=$(( $count % 3 ))
-
-	if [ $enable -eq 0 ]; then
-		echo 0 > "$TRACING_PATH"/tracing_on
-	else
-		echo 1 > "$TRACING_PATH"/tracing_on
-	fi
-
-	sleep 1
-}
-
testcases/kernel/tracing/ftrace_stress_test/ftrace_stress_test.sh deleted +0 -243

243 lines not on this page · raw message

testcases/kernel/tracing/ftrace_test/Makefile new file +7 -0
new file mode 100644
index 0000000..e4a913a
@@ -0,0 +1,7 @@
+top_srcdir              ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+INSTALL_TARGETS         := *.sh ftrace_stress/*
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size.sh new file +45 -0

45 lines not on this page · raw message

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_current_tracer.sh new file +34 -0
new file mode 100755
index 0000000..88d576f
@@ -0,0 +1,34 @@
+#! /bin/sh
+
+###############################################################################
+#                                                                             #
+# Copyright (c) 2010 FUJITSU LIMITED                                          #
+#                                                                             #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; either version 2 of the License, or (at your option)   #
+# any later version.                                                          #
+#                                                                             #
+# Author: Li Zefan <[email protected]>                                      #
+#                                                                             #
+###############################################################################
+
+LOOP=200
+
+for ((; ;))
+{
+	for ((i = 0; i < $LOOP; i++))
+	{
+		for tracer in `cat "$TRACING_PATH"/available_tracers`
+		do
+			if [ "$tracer" = mmiotrace ]; then
+				continue
+			fi
+
+			echo $tracer > "$TRACING_PATH"/current_tracer 2> /dev/null
+		done
+	}
+
+	sleep 1
+}
+
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_ftrace_enabled.sh new file +39 -0
new file mode 100755
index 0000000..20bb234
@@ -0,0 +1,39 @@
+#! /bin/sh
+
+###############################################################################
+#                                                                             #
+# Copyright (c) 2010 FUJITSU LIMITED                                          #
+#                                                                             #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; either version 2 of the License, or (at your option)   #
+# any later version.                                                          #
+#                                                                             #
+# Author: Li Zefan <[email protected]>                                      #
+#                                                                             #
+###############################################################################
+
+MAX_LOOP=1500
+count=0
+
+for ((; ;))
+{
+	count=$(( $count + 1 ))
+
+	for ((i = 0; i < $MAX_LOOP; i++))
+	{
+		echo 0 > /proc/sys/kernel/ftrace_enabled
+		echo 1 > /proc/sys/kernel/ftrace_enabled
+	}
+
+	enable=$(( $count % 3 ))
+
+	if [ $enable -eq 0 ]; then
+		echo 1 > /proc/sys/kernel/ftrace_enabled
+	else
+		echo 0 > /proc/sys/kernel/ftrace_enabled
+	fi
+
+	sleep 1
+}
+
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_profile_enabled.sh new file +50 -0

50 lines not on this page · raw message

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh new file +44 -0

44 lines not on this page · raw message

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh new file +49 -0

49 lines not on this page · raw message

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh new file +39 -0
new file mode 100755
index 0000000..682d05e
@@ -0,0 +1,39 @@
+#! /bin/sh
+
+###############################################################################
+#                                                                             #
+# Copyright (c) 2010 FUJITSU LIMITED                                          #
+#                                                                             #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; either version 2 of the License, or (at your option)   #
+# any later version.                                                          #
+#                                                                             #
+# Author: Li Zefan <[email protected]>                                      #
+#                                                                             #
+###############################################################################
+
+MAX_STACK_SIZE=8192
+
+if [ ! -e /proc/sys/kernel/stack_tracer_enabled ]; then
+	should_skip=1
+else
+	should_skip=0
+fi
+
+for ((; ;))
+{
+	if [ $should_skip -eq 1 ]; then
+		sleep 2
+		continue
+	fi
+
+	for ((i = 0; i < $MAX_STACK_SIZE; i += 70))
+	{
+		echo $i > "$TRACING_PATH"/stack_max_size
+		cat "$TRACING_PATH"/stack_max_size > /dev/null
+	}
+
+	sleep 1
+}
+
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh new file +46 -0

46 lines not on this page · raw message

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh new file +27 -0
new file mode 100755
index 0000000..e36712b
@@ -0,0 +1,27 @@
+#! /bin/sh
+
+###############################################################################
+#                                                                             #
+# Copyright (c) 2010 FUJITSU LIMITED                                          #
+#                                                                             #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; either version 2 of the License, or (at your option)   #
+# any later version.                                                          #
+#                                                                             #
+# Author: Li Zefan <[email protected]>                                      #
+#                                                                             #
+###############################################################################
+
+LOOP=200
+
+for ((; ;))
+{
+	for ((i = 0; i < $LOOP; i++))
+	{
+		cat "$TRACING_PATH"/trace > /dev/null
+	}
+
+	sleep 1
+}
+
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh new file +46 -0

46 lines not on this page · raw message

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh new file +42 -0

42 lines not on this page · raw message

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh new file +52 -0

52 lines not on this page · raw message

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh new file +45 -0

45 lines not on this page · raw message

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_enabled.sh new file +39 -0
new file mode 100755
index 0000000..69f2ae6
@@ -0,0 +1,39 @@
+#! /bin/sh
+
+###############################################################################
+#                                                                             #
+# Copyright (c) 2010 FUJITSU LIMITED                                          #
+#                                                                             #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; either version 2 of the License, or (at your option)   #
+# any later version.                                                          #
+#                                                                             #
+# Author: Li Zefan <[email protected]>                                      #
+#                                                                             #
+###############################################################################
+
+MAX_LOOP=1500
+count=0
+
+for ((; ;))
+{
+	count=$(( $count + 1 ))
+
+	for ((i = 0; i < $MAX_LOOP; i++))
+	{
+		echo 0 > "$TRACING_PATH"/tracing_enabled
+		echo 1 > "$TRACING_PATH"/tracing_enabled
+	}
+
+	enable=$(( $count % 3 ))
+
+	if [ $enable -eq 0 ]; then
+		echo 0 > "$TRACING_PATH"/tracing_enabled
+	else
+		echo 1 > "$TRACING_PATH"/tracing_enabled
+	fi
+
+	sleep 1
+}
+
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh new file +38 -0
new file mode 100755
index 0000000..f19d734
@@ -0,0 +1,38 @@
+#! /bin/sh
+
+###############################################################################
+#                                                                             #
+# Copyright (c) 2010 FUJITSU LIMITED                                          #
+#                                                                             #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; either version 2 of the License, or (at your option)   #
+# any later version.                                                          #
+#                                                                             #
+# Author: Li Zefan <[email protected]>                                      #
+#                                                                             #
+###############################################################################
+
+MAX_LATENCY=100000
+
+if [ ! -e "$TRACING_PATH"/tracing_max_latency ]; then
+        should_skip=1
+else
+        should_skip=0
+fi
+
+for ((; ;))
+{
+        if [ $should_skip -eq 1 ]; then
+                sleep 2
+                continue
+        fi
+
+	for ((i = 0; i < $MAX_LATENCY; i += 400))
+	{
+		echo $i > "$TRACING_PATH"/tracing_max_latency
+	}
+
+	sleep 1
+}
+
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_on.sh new file +39 -0
new file mode 100755
index 0000000..672c223
@@ -0,0 +1,39 @@
+#! /bin/sh
+
+###############################################################################
+#                                                                             #
+# Copyright (c) 2010 FUJITSU LIMITED                                          #
+#                                                                             #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; either version 2 of the License, or (at your option)   #
+# any later version.                                                          #
+#                                                                             #
+# Author: Li Zefan <[email protected]>                                      #
+#                                                                             #
+###############################################################################
+
+MAX_LOOP=1500
+count=0
+
+for ((; ;))
+{
+	count=$(( $count + 1 ))
+
+	for ((i = 0; i < $MAX_LOOP; i++))
+	{
+		echo 0 > "$TRACING_PATH"/tracing_on
+		echo 1 > "$TRACING_PATH"/tracing_on
+	}
+
+	enable=$(( $count % 3 ))
+
+	if [ $enable -eq 0 ]; then
+		echo 0 > "$TRACING_PATH"/tracing_on
+	else
+		echo 1 > "$TRACING_PATH"/tracing_on
+	fi
+
+	sleep 1
+}
+
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +243 -0

243 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author
#3 lore raw

RFC PATCH 3/9 tracing[2]: reorganize ftrace stress tests to general tests

In this commit, code changing as below:
----

new file:   ftrace_regression_test.sh
modified:   ftrace_stress_test.sh
renamed:    ftrace_stress_test.sh -> ftrace_lib.sh
---
 runtest/tracing                                    |   1 +
 testcases/kernel/tracing/ftrace_test/Makefile      |   2 +-
 testcases/kernel/tracing/ftrace_test/ftrace_lib.sh | 157 +++++++++++++
 .../tracing/ftrace_test/ftrace_regression_test.sh  |  59 +++++
 .../tracing/ftrace_test/ftrace_stress_test.sh      | 256 ++++++---------------
 5 files changed, 285 insertions(+), 190 deletions(-)
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_lib.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_regression_test.sh
runtest/tracing +1 -0
index ef3a048..e14e87a 100644
@@ -1,2 +1,3 @@
 #DESCRIPTION:Tracing testing
+ftrace-regression-test	ftrace_regression_test.sh
 ftrace-stress-test	ftrace_stress_test.sh 90
testcases/kernel/tracing/ftrace_test/Makefile +1 -1
index e4a913a..35f1af5 100644
@@ -2,6 +2,6 @@ top_srcdir              ?= ../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-INSTALL_TARGETS         := *.sh ftrace_stress/*
+INSTALL_TARGETS         := *.sh ftrace_function/* ftrace_regression/* ftrace_stress/*
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +157 -0

157 lines not on this page · raw message

testcases/kernel/tracing/ftrace_test/ftrace_regression_test.sh new file +59 -0

59 lines not on this page · raw message

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +67 -189

294 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author
#4 lore raw

RFC PATCH 4/9 ftrace_regression: add new case to ftrace_regression/ dir

This case is the reproducer of ftrace userstacktrace bug.

BUG: unable to handle kernel paging request at 00000000417683c0
IP: [<ffffffff8105c834>] update_curr+0x124/0x1e0
PGD 41a796067 PUD 0
Thread overran stack, or stack corrupted
Oops: 0000 [#1] SMP

last sysfs file: /sys/devices/system/cpu/cpu15/cache/index2/shared_cpu_map

The bug was fixed by:
1dbd195 (tracing: Fix preempt count leak)

---
 .../ftrace_panic_with_userstacktrace.sh            | 52 ++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_panic_with_userstacktrace.sh
testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_panic_with_userstacktrace.sh new file +52 -0
new file mode 100755
index 0000000..10ed16a
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+###############################################################################
+#                                                                             #
+# Copyright (c) 2015, Red Hat Inc.                                            #
+#                                                                             #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; either version 2 of the License, or (at your option)   #
+# any later version.                                                          #
+#                                                                             #
+# Summary:                                                                    #
+#      panic while using userstacktrace                                       #
+#                                                                             #
+# This is a regression case for commit:                                       #
+#      1dbd195 tracing: Fix preempt count leak                                #
+###############################################################################
+
+LOOP=10
+
+TSTACK_TRACE_PATH=/proc/sys/kernel/stack_tracer_enabled
+
+cd $TRACING_PATH
+
+grep -q CONFIG_STACK_TRACER=y /boot/config-`uname -r`
+if [ $? -ne 0 ];then
+	echo "Stack Tracer is not cofigured in This kernel. Skip the test"
+else
+	for ((i = 0; i < $LOOP; i++))
+	{
+		echo 1 >  $TSTACK_TRACE_PATH
+		echo userstacktrace > trace_options
+		grep -q "^userstacktrace"  trace_options
+
+		if [ -f "events/exceptions/page_fault_kernel/enable" ]; then
+			PAGE_FAULT_KERNEL_ENABLE=`cat events/exceptions/page_fault_kernel/enable`
+			echo 1 > events/exceptions/page_fault_kernel/enable
+		else
+			MM_KERNEL_PAGEFAULT_ENABLE=`cat events/kmem/mm_kernel_pagefault/enable`
+			echo 1 > events/kmem/mm_kernel_pagefault/enable
+		fi
+	}
+
+	if [ -f "events/exceptions/page_fault_kernel/enable" ]; then
+		echo "$PAGE_FAULT_KERNEL_ENABLE" > events/exceptions/page_fault_kernel/enable
+	else
+		echo "$MM_KERNEL_PAGEFAULT_ENABLE" > events/kmem/mm_kernel_pagefault/enable
+	fi
+	# echo "No panic, Still alive."
+fi
+
+cd - > /dev/null
Signature · 1 line
1.8.3.1
author
#5 lore raw

RFC PATCH 5/9 ftrace_regression: add a new testcase

PURPOSE: check signal:signal_generate gives 2 more fields: grp res

This testcase is writing for signal events change:
6c303d3 tracing: let trace_signal_generate() report more info... 163566f tracing: send_sigqueue() needs trace_signal_generate() too

---
 .../ftrace_enhanced_signal_tracepoint.sh           | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_enhanced_signal_tracepoint.sh
testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_enhanced_signal_tracepoint.sh new file +35 -0
new file mode 100755
index 0000000..36fc2ba
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+###############################################################################
+#                                                                             #
+# Copyright (c) 2015, Red Hat Inc.                                            #
+#                                                                             #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; either version 2 of the License, or (at your option)   #
+# any later version.                                                          #
+#                                                                             #
+# PURPOSE: check signal:signal_generate gives 2 more fields: grp res          #
+#                                                                             #
+# This testcase is verifing signal events change:                             #
+#        6c303d3 tracing: let trace_signal_generate() report more info...     #
+#        163566f tracing: send_sigqueue() needs trace_signal_generate() too   #
+#                                                                             #
+###############################################################################
+
+
+# Set envent
+echo 'signal:signal_generate' > $TRACING_PATH/set_event
+
+echo 1 > $TRACING_PATH/tracing_on
+
+echo > $TRACING_PATH/trace
+
+sleep 10
+
+grep -q 'grp=[0-9] res=[0-9]' $TRACING_PATH/trace
+if [ $? -eq 0 ]; then
+	exit 0
+else
+	exit 1
+fi
Signature · 1 line
1.8.3.1
author
#6 lore raw

RFC PATCH 6/9 ftrace_stress: skip unsupported tests

From: Chunyu Hu <[email protected]>

Checking if it's supported before lanuching a test script. This action is through verifing the matched file in ftrace tracing direcrotry.

At the same time, transform the hard coded pids to the test_targets string and make it easier to be controlled.

With this modification, the outdated tracing_enabled issue can be skiped on newer kernels.

---
 testcases/kernel/tracing/ftrace_test/ftrace_lib.sh |  10 +-
 .../ftrace_test/ftrace_stress/ftrace_set_event.sh  |   2 +
 .../ftrace_stress/ftrace_set_ftrace_pid.sh         |  11 --
 .../ftrace_stress/ftrace_stack_max_size.sh         |  11 --
 .../ftrace_stress/ftrace_stack_trace.sh            |  12 ---
 .../ftrace_stress/ftrace_tracing_max_latency.sh    |  12 ---
 .../tracing/ftrace_test/ftrace_stress_test.sh      | 113 ++++++++++-----------
 7 files changed, 64 insertions(+), 107 deletions(-)
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh +8 -2
index 7c72afb..81af617 100755
@@ -41,9 +41,12 @@ save_old_setting()
 
 	old_trace_options=( `cat trace_options` )
 	old_tracing_on=`cat tracing_on`
-	old_tracing_enabled=`cat tracing_enabled`
 	old_buffer_size=`cat buffer_size_kb`
 
+	if [ -e tracing_enabled ]; then
+		old_tracing_enabled=`cat tracing_enabled`
+	fi
+
 	if [ -e stack_max_size ]; then
 		old_stack_tracer_enabled=`cat /proc/sys/kernel/stack_tracer_enabled`
 	fi
@@ -86,7 +89,10 @@ restore_old_setting()
 
 	echo $old_buffer_size > buffer_size_kb
 	echo $old_tracing_on > tracing_on
-	echo $old_tracing_enabled > tracing_enabled
+
+	if [ -e tracing_enabled ];then
+		echo $old_tracing_enabled > tracing_enabled
+	fi
 
 	for option in $old_trace_options
 	do
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh +2 -0
index d7efdd4..d1a6bd3 100755
@@ -36,6 +36,8 @@ for ((; ;))
 
 	for event in `cat $TRACING_PATH/available_events`;
 	do
+		# ftrace event sys is special, skip it
+		[[ $event =~ ftrace:* ]] && continue
 		echo $event >> "$TRACING_PATH"/set_event
 	done
 
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh +0 -11
index 7bc76d9..3eaf017 100755
@@ -15,19 +15,9 @@
 
 LOOP=300
 
-if [ ! -e "$TRACING_PATH"/set_ftrace_pid ]; then
-	should_skip=1
-else
-	should_skip=0
-fi
 
 for ((; ; ))
 {
-	if [ $should_skip -eq 1 ]; then
-		sleep 2
-		continue
-	fi
-
 	for ((j = 0; j < $LOOP; j++))
 	{
 		for ((k = 1; k <= NR_PIDS; k++))
@@ -46,4 +36,3 @@ for ((; ; ))
 
 	sleep 1
 }
-
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh +0 -11
index 682d05e..34d506b 100755
@@ -15,19 +15,8 @@
 
 MAX_STACK_SIZE=8192
 
-if [ ! -e /proc/sys/kernel/stack_tracer_enabled ]; then
-	should_skip=1
-else
-	should_skip=0
-fi
-
 for ((; ;))
 {
-	if [ $should_skip -eq 1 ]; then
-		sleep 2
-		continue
-	fi
-
 	for ((i = 0; i < $MAX_STACK_SIZE; i += 70))
 	{
 		echo $i > "$TRACING_PATH"/stack_max_size
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh +0 -12
index a406c51..1850c26 100755
@@ -15,19 +15,8 @@
 
 LOOP=400
 
-if [ ! -e /proc/sys/kernel/stack_tracer_enabled ]; then
-	should_skip=1
-else
-	should_skip=0
-fi
-
 for ((; ;))
 {
-	if [ $should_skip -eq 1 ]; then
-		sleep 2
-		continue
-	fi
-
 	for ((i = 0; i < $LOOP; i++))
 	{
 		cat "$TRACING_PATH"/stack_trace > /dev/null
@@ -43,4 +32,3 @@ for ((; ;))
 
 	sleep 1
 }
-
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh +0 -12
index f19d734..fbaceb8 100755
@@ -15,19 +15,8 @@
 
 MAX_LATENCY=100000
 
-if [ ! -e "$TRACING_PATH"/tracing_max_latency ]; then
-        should_skip=1
-else
-        should_skip=0
-fi
-
 for ((; ;))
 {
-        if [ $should_skip -eq 1 ]; then
-                sleep 2
-                continue
-        fi
-
 	for ((i = 0; i < $MAX_LATENCY; i += 400))
 	{
 		echo $i > "$TRACING_PATH"/tracing_max_latency
@@ -35,4 +24,3 @@ for ((; ;))
 
 	sleep 1
 }
-
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +54 -59

147 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author
#7 lore raw

RFC PATCH 7/9 ftrace_stress: keep the name of testscipt in sync with tracing file

From: Chunyu Hu <[email protected]>

The test scripts under ftrace_stress/ are all named after the tracing file with a 'ftrace_' prefix, except the ftrace_buffer_size.sh and ftrace_profile_enabled.sh. Here just rename them.

---
 .../ftrace_stress/ftrace_buffer_size.sh            | 45 -------------------
 .../ftrace_stress/ftrace_buffer_size_kb.sh         | 45 +++++++++++++++++++
 .../ftrace_function_profile_enabled.sh             | 50 ++++++++++++++++++++++
 .../ftrace_stress/ftrace_profile_enabled.sh        | 50 ----------------------
 4 files changed, 95 insertions(+), 95 deletions(-)
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_function_profile_enabled.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_profile_enabled.sh
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size.sh deleted +0 -45
deleted file mode 100755
index bd7dcc4..0000000
@@ -1,45 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <[email protected]>                                      #
-#                                                                             #
-###############################################################################
-
-LOOP=200
-
-# Use up to 10% of free memory
-free_mem=`cat /proc/meminfo | grep '^MemFree' | awk '{ print $2 }'`
-cpus=`tst_ncpus`
-
-step=$(( $free_mem / 10 / $LOOP / $cpus ))
-
-if [ $step -eq 0 ]; then
-	step=1
-	LOOP=50
-fi
-
-for ((; ;))
-{
-	new_size=1
-	for ((i = 0; i < $LOOP; i++))
-	{
-		echo $new_size > "$TRACING_PATH"/buffer_size_kb
-		new_size=$(( $new_size + $step ))
-	}
-
-	for ((i = 0; i < $LOOP; i++))
-	{
-		new_size=$(( $new_size - $step ))
-		echo $new_size > "$TRACING_PATH"/buffer_size_kb
-	}
-
-	sleep 1
-}
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh new file +45 -0

45 lines not on this page · raw message

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_function_profile_enabled.sh new file +50 -0

50 lines not on this page · raw message

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_profile_enabled.sh deleted +0 -50

50 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author
#8 lore raw

RFC PATCH 8/9 ftrace_stress: update the trace_options test

From: Chunyu Hu <[email protected]>

The ftrace_trace_options.sh is using hard coced trace options, including the outdated 'branch', so let's get the trace_options dynamicly from the trace_options file.

---
 .../ftrace_test/ftrace_stress/ftrace_trace_options.sh       | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh +9 -4
index 47d2a62..5efbcce 100755
@@ -15,9 +15,15 @@
 
 LOOP=200
 
-trace_options=(print-parent sym-offset sym-addr verbose raw hex bin block trace_printk ftrace_preempt branch annotate userstacktrace sym-userobj printk-msg-only context-info latency-format sleep-time graph-time)
+option_files=$(ls $TRACING_PATH/options/)
 
-NR_TRACE_OPTIONS=19
+# enable the nop_test_refuse can cause an
+# 'write error: Invalid argument'. So don't
+# test it.
+option_files=${option_files/test_nop_refuse/}
+trace_options=( $option_files )
+
+NR_TRACE_OPTIONS=${#trace_options[*]}
 
 for ((; ; ))
 {
@@ -25,7 +31,6 @@ for ((; ; ))
 	{
 		num=`date +%N`
 		num=`printf 1%s $num`
-
 		for ((i = 0; i < $NR_TRACE_OPTIONS; i++))
 		{
 			n=$(( ( $num >> $i ) % 2 ))
@@ -34,9 +39,9 @@ for ((; ; ))
 			else
 				echo 1 > "$TRACING_PATH"/options/${trace_options[$i]}
 			fi
+			[ $? -ne 0 ] && echo "setup trace option ${trace_options[$i]} failed"
 		}
 	}
 
 	sleep 1
 }
-
Signature · 1 line
1.8.3.1
author
#9 lore raw

RFC PATCH 9/9 ftrace_stress: add two new tests

From: Chunyu Hu <[email protected]>

---
 testcases/kernel/tracing/ftrace_test/ftrace_lib.sh |   2 +
 .../ftrace_stress/ftrace_set_ftrace_filter.sh      | 103 +++++++++++++++++++++
 .../ftrace_stress/ftrace_tracing_cpumask.sh        |  51 ++++++++++
 .../tracing/ftrace_test/ftrace_stress_test.sh      |   3 +-
 4 files changed, 158 insertions(+), 1 deletion(-)
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh +2 -0
index 81af617..5fceb80 100755
@@ -42,6 +42,7 @@ save_old_setting()
 	old_trace_options=( `cat trace_options` )
 	old_tracing_on=`cat tracing_on`
 	old_buffer_size=`cat buffer_size_kb`
+	old_tracing_cpumask=`cat tracing_cpumask`
 
 	if [ -e tracing_enabled ]; then
 		old_tracing_enabled=`cat tracing_enabled`
@@ -69,6 +70,7 @@ restore_old_setting()
 	echo nop > current_tracer
 	echo 0 > events/enable
 	echo 0 > tracing_max_latency 2> /dev/null
+	echo $old_tracing_cpumask > tracing_cpumask
 
 	if [ -e trace_clock ]; then
 		echo local > trace_clock
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +103 -0

103 lines not on this page · raw message

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +51 -0

51 lines not on this page · raw message

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +2 -1
index d1be49a..49cae86 100755
@@ -31,7 +31,8 @@ test_targets=" \
 trace_pipe current_tracer ftrace_enabled function_profile_enabled \
 set_event set_ftrace_pid stack_max_size stack_trace trace trace_clock \
 trace_options trace_stat tracing_enabled tracing_max_latency \
-tracing_on function_profile_enabled buffer_size_kb"
+tracing_on function_profile_enabled buffer_size_kb tracing_cpumask \
+set_ftrace_filter"
 
 get_skip_targets()
 {
Signature · 1 line
1.8.3.1
#22 lore raw

RFC PATCH 3/9 tracing[2]: reorganize ftrace stress tests to general tests

In reply to Li Wang

Hi!

Quoted 55 lines
testcases/kernel/tracing/ftrace_test/ftrace_regression_test.sh new file +49 -0
new file mode 100755
index 0000000..3646619
@@ -0,0 +1,59 @@
+#! /bin/sh
+
+###########################################################################
+##                                                                       ##
+## Copyright (c) 2015, Red Hat Inc.                                      ##
+##                                                                       ##
+## This program is free software: you can redistribute it and/or modify  ##
+## it under the terms of the GNU General Public License as published by  ##
+## the Free Software Foundation, either version 3 of the License, or     ##
+## (at your option) any later version.                                   ##
+##                                                                       ##
+## This program is distributed in the hope that it will be useful,       ##
+## but WITHOUT ANY WARRANTY; without even the implied warranty of        ##
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          ##
+## GNU General Public License for more details.                          ##
+##                                                                       ##
+## You should have received a copy of the GNU General Public License     ##
+## along with this program. If not, see <http://www.gnu.org/licenses/>.  ##
+##                                                                       ##
+## Author: Li Wang <[email protected]>                                   ##
+##                                                                       ##
+###########################################################################
+
+export TCID="ftrace-regression-test"
+export TST_TOTAL=1
+export TST_COUNT=1
+
+. ftrace_lib.sh
+
+test_check()
+{
+	if $test_success; then
+		tst_resm TPASS "finished running the test: $subcase."
+	else
+		tst_resm TFAIL "running the test: $subcase failed, please check log message."
+	fi
+
+	test_success=true
+}
+
+test_regression()
+{
+	local subcase
+	for subcase in $(find $RPATH -name 'ftrace*.sh'); do
+		$subcase || test_success=false
+		test_check
+	done
+}
+

testcases/kernel/tracing/ftrace_test/ftrace_regression_test.sh line 59

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_regression_test.sh new file +10 -0
+# ----------------------------
+echo "Ftrace Regression Test Begin"
+
+save_old_setting
+
+test_regression
+
+clean_up
+
+echo "Ftrace Regression Test End"

Adding a script that runs all testcases is frowned upon in LTP. What you should do instead is to make it possible to run individual testcases and add the tests one test per line to a runtest file.

Also newly added test should use test.sh library.

Quoted 307 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +67 -189
index dc8cf3e..beced43 100755
@@ -1,105 +1,80 @@
 #! /bin/sh
 
-################################################################################
-##                                                                            ##
-## Copyright (c) 2010 FUJITSU LIMITED                                         ##
-##                                                                            ##
-## This program is free software;  you can redistribute it and#or modify      ##
-## it under the terms of the GNU General Public License as published by       ##
-## the Free Software Foundation; either version 2 of the License, or          ##
-## (at your option) any later version.                                        ##
-##                                                                            ##
-## This program is distributed in the hope that it will be useful, but        ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
-## for more details.                                                          ##
-##                                                                            ##
-## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
-##                                                                            ##
-## Author: Li Zefan <[email protected]>                                     ##
-##                                                                            ##
-################################################################################
-
-cd $LTPROOT/testcases/bin
-
-export TCID="ftrace-test"
+###########################################################################
+##                                                                       ##
+## Copyright (c) 2010 FUJITSU LIMITED                                    ##
+##                                                                       ##
+## This program is free software: you can redistribute it and/or modify  ##
+## it under the terms of the GNU General Public License as published by  ##
+## the Free Software Foundation, either version 3 of the License, or     ##
+## (at your option) any later version.                                   ##
+##                                                                       ##
+## This program is distributed in the hope that it will be useful,       ##
+## but WITHOUT ANY WARRANTY; without even the implied warranty of        ##
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          ##
+## GNU General Public License for more details.                          ##
+##                                                                       ##
+## You should have received a copy of the GNU General Public License     ##
+## along with this program. If not, see <http://www.gnu.org/licenses/>.  ##
+##                                                                       ##
+## Author: Li Zefan <[email protected]>                                ##
+##                                                                       ##
+###########################################################################
+
+
+export TCID="ftrace-stress-test"
 export TST_TOTAL=1
 export TST_COUNT=1
 
-export TPATH="$PWD"
-export DEBUGFS_PATH="$PWD/debugfs"
-export TRACING_PATH="$PWD/debugfs/tracing"
-export SPATH="$TPATH/ftrace_stress"
+. ftrace_lib.sh
 
-test_interval=$1
-test_success=true
-
-save_old_setting()
+export_pids()
 {
-	cd $TRACING_PATH
-
-	old_trace_options=( `cat trace_options` )
-	old_tracing_on=`cat tracing_on`
-	old_tracing_enabled=`cat tracing_enabled`
-	old_buffer_size=`cat buffer_size_kb`
-
-	if [ -e stack_max_size ]; then
-		old_stack_tracer_enabled=`cat /proc/sys/kernel/stack_tracer_enabled`
-	fi
-
-	if [ -e "/proc/sys/kernel/ftrace_enabled" ]; then
-		old_ftrace_enabled=`cat /proc/sys/kernel/ftrace_enabled`
-	fi
-
-	if [ -e "function_profile_enabled" ]; then
-		old_profile_enabled=`cat function_profile_enabled`
-	fi
+	export pid1 pid2 pid3 pid4 pid5 pid6 pid7 pid8 pid9 pid10 pid11 pid12 \
+		pid13 pid14 pid15 pid16
 
-	cd - > /dev/null
+	export NR_PIDS=16
 }
 
-restore_old_setting()
+test_stress()
 {
-	cd $TRACING_PATH
-
-	echo nop > current_tracer
-	echo 0 > events/enable
-	echo 0 > tracing_max_latency 2> /dev/null
-
-	if [ -e trace_clock ]; then
-		echo local > trace_clock
-	fi
-
-	if [ -e "function_pofile_enabled" ]; then
-		echo $old_profile_enabled > function_profile_enabled
-	fi
-
-	if [ -e "/proc/sys/kernel/ftrace_enabled" ]; then
-		echo $old_ftrace_enabled > /proc/sys/kernel/ftrace_enabled
-	fi
-
-	if [ -e stack_max_size ]; then
-		echo $old_stack_tracer_enabled > /proc/sys/kernel/stack_tracer_enabled
-		echo 0 > stack_max_size
-	fi
-
-	echo $old_buffer_size > buffer_size_kb
-	echo $old_tracing_on > tracing_on
-	echo $old_tracing_enabled > tracing_enabled
-
-	for option in $old_trace_options
-	do
-		echo $option > trace_options 2> /dev/null
-	done
-
-	echo > trace
-
-	cd - > /dev/null
+	export_pids
+
+	$SPATH/ftrace_trace_clock.sh &
+	pid1=$!
+	$SPATH/ftrace_current_tracer.sh &
+	pid2=$!
+	$SPATH/ftrace_trace_options.sh &
+	pid3=$!
+	$SPATH/ftrace_tracing_max_latency.sh &
+	pid4=$!
+	$SPATH/ftrace_stack_trace.sh &
+	pid5=$!
+	$SPATH/ftrace_stack_max_size.sh &
+	pid6=$!
+	$SPATH/ftrace_tracing_on.sh &
+	pid7=$!
+	$SPATH/ftrace_tracing_enabled.sh &
+	pid8=$!
+	$SPATH/ftrace_set_event.sh &
+	pid9=$!
+	$SPATH/ftrace_buffer_size.sh &
+	pid10=$!
+	$SPATH/ftrace_trace.sh &
+	pid11=$!
+	$SPATH/ftrace_trace_pipe.sh &
+	pid12=$!
+	$SPATH/ftrace_ftrace_enabled.sh &
+	pid13=$!
+	$SPATH/ftrace_set_ftrace_pid.sh &
+	pid14=$!
+	$SPATH/ftrace_profile_enabled.sh &
+	pid15=$!
+	$SPATH/ftrace_trace_stat.sh &
+	pid16=$!
 }
 
-clean_up()
+test_kill()
 {
 	kill -KILL $pid1 || test_success=false
 	kill -KILL $pid2 || test_success=false
@@ -119,118 +94,22 @@ clean_up()
 	kill -KILL $pid16 || test_success=false
 
 	sleep 2
-	restore_old_setting
-
-	umount $DEBUGFS_PATH
-	rmdir $DEBUGFS_PATH
-}
-
-clean_up_exit()
-{
 	clean_up
-	exit 1
 }
 
-export_pids()
-{
-	export pid1 pid2 pid3 pid4 pid5 pid6 pid7 pid8 pid9 pid10 pid11 pid12 \
-		pid13 pid14 pid15 pid16
-
-	export NR_PIDS=16
-}
-
-test_begin()
-{
-	start_time=`date +%s`
-}
-
-test_wait()
-{
-	for ((; ;))
-	{
-		sleep 2
-
-		cur_time=`date +%s`
-		elapsed=$(( $cur_time - $start_time ))
-
-		# run the test for $test_interval secs
-		if [ $elapsed -ge $test_interval ]; then
-			break
-		fi
-	}
-}
-
-trap clean_up_exit INT
-
-# Should be run by root user
-if [ `id -ru` != 0 ]; then
-	tst_brkm TCONF ignored "The test should be run by root user. Skip the test..."
-	exit 0
-fi
-
-# Don't run the test on kernels older than 2.6.34, otherwise
-# it can crash the system if the kernel is not latest-stable
-tst_kvercmp 2 6 34
-if [ $? -eq 0 ]; then
-	tst_brkm TCONF ignored "The test should be run in kernels >= 2.6.34. Skip the test..."
-	exit 0
-fi
-
-mkdir $DEBUGFS_PATH
-mount -t debugfs xxx $DEBUGFS_PATH
-
-# Check to see tracing feature is supported or not
-if [ ! -d $TRACING_PATH ]; then
-	tst_brkm TCONF ignored "Tracing is not supported. Skip the test..."
-	umount $DEBUGFS_PATH
-	rmdir $DEBUGFS_PATH
-	exit 0
-fi
 
+# ----------------------------
 echo "Ftrace Stress Test Begin"
 
 save_old_setting
 
 test_begin
 
-$SPATH/ftrace_trace_clock.sh &
-pid1=$!
-$SPATH/ftrace_current_tracer.sh &
-pid2=$!
-$SPATH/ftrace_trace_options.sh &
-pid3=$!
-$SPATH/ftrace_tracing_max_latency.sh &
-pid4=$!
-$SPATH/ftrace_stack_trace.sh &
-pid5=$!
-$SPATH/ftrace_stack_max_size.sh &
-pid6=$!
-$SPATH/ftrace_tracing_on.sh &
-pid7=$!
-$SPATH/ftrace_tracing_enabled.sh &
-pid8=$!
-$SPATH/ftrace_set_event.sh &
-pid9=$!
-$SPATH/ftrace_buffer_size.sh &
-pid10=$!
-$SPATH/ftrace_trace.sh &
-pid11=$!
-$SPATH/ftrace_trace_pipe.sh &
-pid12=$!
-$SPATH/ftrace_ftrace_enabled.sh &
-pid13=$!
-$SPATH/ftrace_set_ftrace_pid.sh &
-pid14=$!
-$SPATH/ftrace_profile_enabled.sh &
-pid15=$!
-$SPATH/ftrace_trace_stat.sh &
-pid16=$!
-
-export_pids
+test_stress
 
 test_wait
 
-clean_up
+test_kill
 
 echo "Ftrace Stress Test End"
 
@@ -240,4 +119,3 @@ else
 	tst_resm TFAIL "please check log message."
 	exit 1
 fi
-
Signature · 5 lines
1.8.3.1


-- 
Mailing list info: http://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis
[email protected]
#21 lore raw

RFC PATCH 4/9 ftrace_regression: add new case to ftrace_regression/ dir

In reply to Li Wang

Hi!

testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_panic_with_userstacktrace.sh line 23

Quoted 5 lines
testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_panic_with_userstacktrace.sh new file +5 -0
+LOOP=10
+
+TSTACK_TRACE_PATH=/proc/sys/kernel/stack_tracer_enabled
+
+cd $TRACING_PATH

Why cant we setup a few variables to use in the code below instead of changing the test directory?

EXC_PAGE_FAULT_ENABLE="$TRACING_PATH/events/exceptions/page_fault_kernel/enable" MM_PAGE_FAULT_ENABLE="$TRACING_PATH/events/kmem/mm_kernel_pagefault/enable"

Quoted 1 line

+grep -q CONFIG_STACK_TRACER=y /boot/config-uname -r

This is not portable. Some distributions store the config in different places while others don't have it at all.

Can't we do [ -e "$TSTACK_TRACE_PATH" ] or similar instead?

testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_panic_with_userstacktrace.sh line 27

Quoted 2 lines
testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_panic_with_userstacktrace.sh new file +2 -0
+if [ $? -ne 0 ];then
+	echo "Stack Tracer is not cofigured in This kernel. Skip the test"

You must correctly report the TCONF here. If you have used the test.sh library you could have simply done tst_resm TCONF "..." and there would ne no need for the else branch as well.

testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_panic_with_userstacktrace.sh line 30

Quoted 3 lines
testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_panic_with_userstacktrace.sh new file +3 -0
+else
+	for ((i = 0; i < $LOOP; i++))
+	{

This is bashism. You should do 'for i in $(seq $LOOP); do' instead.

Quoted 9 lines
testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_panic_with_userstacktrace.sh new file +9 -0
+		echo 1 >  $TSTACK_TRACE_PATH
+		echo userstacktrace > trace_options
+		grep -q "^userstacktrace"  trace_options
+
+		if [ -f "events/exceptions/page_fault_kernel/enable" ]; then
+			PAGE_FAULT_KERNEL_ENABLE=`cat events/exceptions/page_fault_kernel/enable`
+			echo 1 > events/exceptions/page_fault_kernel/enable
+		else
+			MM_KERNEL_PAGEFAULT_ENABLE=`cat events/kmem/mm_kernel_pagefault/enable`

testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_panic_with_userstacktrace.sh line 49

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_panic_with_userstacktrace.sh new file +10 -0
+			echo 1 > events/kmem/mm_kernel_pagefault/enable
+		fi
+	}
+
+	if [ -f "events/exceptions/page_fault_kernel/enable" ]; then
+		echo "$PAGE_FAULT_KERNEL_ENABLE" > events/exceptions/page_fault_kernel/enable
+	else
+		echo "$MM_KERNEL_PAGEFAULT_ENABLE" > events/kmem/mm_kernel_pagefault/enable
+	fi
+	# echo "No panic, Still alive."

No unused code in test please.

Quoted 9 lines
testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_panic_with_userstacktrace.sh new file +3 -0
+fi
+
+cd - > /dev/null
Signature · 5 lines
1.8.3.1


-- 
Mailing list info: http://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis
[email protected]
#19 lore raw

RFC PATCH 5/9 ftrace_regression: add a new testcase

In reply to Li Wang

Hi!

Quoted 16 lines
testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_enhanced_signal_tracepoint.sh new file +16 -0
+###############################################################################
+#                                                                             #
+# Copyright (c) 2015, Red Hat Inc.                                            #
+#                                                                             #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; either version 2 of the License, or (at your option)   #
+# any later version.                                                          #
+#                                                                             #
+# PURPOSE: check signal:signal_generate gives 2 more fields: grp res          #
+#                                                                             #
+# This testcase is verifing signal events change:                             #
+#        6c303d3 tracing: let trace_signal_generate() report more info...     #
+#        163566f tracing: send_sigqueue() needs trace_signal_generate() too   #
+#                                                                             #
+###############################################################################

testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_enhanced_signal_tracepoint.sh line 28

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_enhanced_signal_tracepoint.sh new file +10 -0
+
+
+# Set envent
+echo 'signal:signal_generate' > $TRACING_PATH/set_event
+
+echo 1 > $TRACING_PATH/tracing_on
+
+echo > $TRACING_PATH/trace
+
+sleep 10

Why sleep 10 here?

testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_enhanced_signal_tracepoint.sh line 35

Quoted 6 lines
testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_enhanced_signal_tracepoint.sh new file +6 -0
+grep -q 'grp=[0-9] res=[0-9]' $TRACING_PATH/trace
+if [ $? -eq 0 ]; then
+	exit 0
+else
+	exit 1
+fi

Use test.sh and tst_resm instead.

Signature · 2 lines
Cyril Hrubis
[email protected]
#17 lore raw

RFC PATCH 6/9 ftrace_stress: skip unsupported tests

In reply to Li Wang

Hi!

testcases/kernel/tracing/ftrace_test/ftrace_lib.sh restore_old_setting() · line 93

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh +2 -1
 	if [ -e stack_max_size ]; then
 		old_stack_tracer_enabled=`cat /proc/sys/kernel/stack_tracer_enabled`
 	fi
@@ -86,7 +89,10 @@ restore_old_setting()
 
 	echo $old_buffer_size > buffer_size_kb
 	echo $old_tracing_on > tracing_on
-	echo $old_tracing_enabled > tracing_enabled
+
+	if [ -e tracing_enabled ];then

^
missing space here

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh +2 -0
+		echo $old_tracing_enabled > tracing_enabled
+	fi
 
 	for option in $old_trace_options
 	do
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh +0 -0
index d7efdd4..d1a6bd3 100755

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh for ((; ;)) · line 40

Quoted 5 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh +2 -0
@@ -36,6 +36,8 @@ for ((; ;))
 
 	for event in `cat $TRACING_PATH/available_events`;
 	do
+		# ftrace event sys is special, skip it
+		[[ $event =~ ftrace:* ]] && continue

This is bashism.

Quoted 210 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh +0 -0
 		echo $event >> "$TRACING_PATH"/set_event
 	done
 
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh +0 -11
index 7bc76d9..3eaf017 100755
@@ -15,19 +15,9 @@
 
 LOOP=300
 
-if [ ! -e "$TRACING_PATH"/set_ftrace_pid ]; then
-	should_skip=1
-else
-	should_skip=0
-fi
 
 for ((; ; ))
 {
-	if [ $should_skip -eq 1 ]; then
-		sleep 2
-		continue
-	fi
-
 	for ((j = 0; j < $LOOP; j++))
 	{
 		for ((k = 1; k <= NR_PIDS; k++))
@@ -46,4 +36,3 @@ for ((; ; ))
 
 	sleep 1
 }
-
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh +0 -11
index 682d05e..34d506b 100755
@@ -15,19 +15,8 @@
 
 MAX_STACK_SIZE=8192
 
-if [ ! -e /proc/sys/kernel/stack_tracer_enabled ]; then
-	should_skip=1
-else
-	should_skip=0
-fi
-
 for ((; ;))
 {
-	if [ $should_skip -eq 1 ]; then
-		sleep 2
-		continue
-	fi
-
 	for ((i = 0; i < $MAX_STACK_SIZE; i += 70))
 	{
 		echo $i > "$TRACING_PATH"/stack_max_size
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh +0 -12
index a406c51..1850c26 100755
@@ -15,19 +15,8 @@
 
 LOOP=400
 
-if [ ! -e /proc/sys/kernel/stack_tracer_enabled ]; then
-	should_skip=1
-else
-	should_skip=0
-fi
-
 for ((; ;))
 {
-	if [ $should_skip -eq 1 ]; then
-		sleep 2
-		continue
-	fi
-
 	for ((i = 0; i < $LOOP; i++))
 	{
 		cat "$TRACING_PATH"/stack_trace > /dev/null
@@ -43,4 +32,3 @@ for ((; ;))
 
 	sleep 1
 }
-
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh +0 -12
index f19d734..fbaceb8 100755
@@ -15,19 +15,8 @@
 
 MAX_LATENCY=100000
 
-if [ ! -e "$TRACING_PATH"/tracing_max_latency ]; then
-        should_skip=1
-else
-        should_skip=0
-fi
-
 for ((; ;))
 {
-        if [ $should_skip -eq 1 ]; then
-                sleep 2
-                continue
-        fi
-
 	for ((i = 0; i < $MAX_LATENCY; i += 400))
 	{
 		echo $i > "$TRACING_PATH"/tracing_max_latency
@@ -35,4 +24,3 @@ for ((; ;))
 
 	sleep 1
 }
-
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +20 -54
index beced43..d1be49a 100755
@@ -21,82 +21,77 @@
 ##                                                                       ##
 ###########################################################################
 
-
 export TCID="ftrace-stress-test"
 export TST_TOTAL=1
 export TST_COUNT=1
 
 . ftrace_lib.sh
 
-export_pids()
-{
-	export pid1 pid2 pid3 pid4 pid5 pid6 pid7 pid8 pid9 pid10 pid11 pid12 \
-		pid13 pid14 pid15 pid16
+test_targets=" \
+trace_pipe current_tracer ftrace_enabled function_profile_enabled \
+set_event set_ftrace_pid stack_max_size stack_trace trace trace_clock \
+trace_options trace_stat tracing_enabled tracing_max_latency \
+tracing_on function_profile_enabled buffer_size_kb"
 
-	export NR_PIDS=16
+get_skip_targets()
+{
+	for target in ${test_targets}; do
+		if [ ! -e $TRACING_PATH/$target ] &&
+			[ ! -e /proc/sys/kernel/$target ]; then
+			eval skip_$target=1
+			echo "$target is not supported. Skip it."
+		else
+			eval skip_$target=0
+		fi
+	done
 }
 
-test_stress()
+should_skip_target()
 {
-	export_pids
-
-	$SPATH/ftrace_trace_clock.sh &
-	pid1=$!
-	$SPATH/ftrace_current_tracer.sh &
-	pid2=$!
-	$SPATH/ftrace_trace_options.sh &
-	pid3=$!
-	$SPATH/ftrace_tracing_max_latency.sh &
-	pid4=$!
-	$SPATH/ftrace_stack_trace.sh &
-	pid5=$!
-	$SPATH/ftrace_stack_max_size.sh &
-	pid6=$!
-	$SPATH/ftrace_tracing_on.sh &
-	pid7=$!
-	$SPATH/ftrace_tracing_enabled.sh &
-	pid8=$!
-	$SPATH/ftrace_set_event.sh &
-	pid9=$!
-	$SPATH/ftrace_buffer_size.sh &
-	pid10=$!
-	$SPATH/ftrace_trace.sh &
-	pid11=$!
-	$SPATH/ftrace_trace_pipe.sh &
-	pid12=$!
-	$SPATH/ftrace_ftrace_enabled.sh &
-	pid13=$!
-	$SPATH/ftrace_set_ftrace_pid.sh &
-	pid14=$!
-	$SPATH/ftrace_profile_enabled.sh &
-	pid15=$!
-	$SPATH/ftrace_trace_stat.sh &
-	pid16=$!
+	local var=skip_$1
+	local val=${!var}
+	[ "$val" = 1 ]
 }
 
 test_kill()
 {
-	kill -KILL $pid1 || test_success=false
-	kill -KILL $pid2 || test_success=false
-	kill -KILL $pid3 || test_success=false
-	kill -KILL $pid4 || test_success=false
-	kill -KILL $pid5 || test_success=false
-	kill -KILL $pid6 || test_success=false
-	kill -KILL $pid7 || test_success=false
-	kill -KILL $pid8 || test_success=false
-	kill -KILL $pid9 || test_success=false
-	kill -KILL $pid10 || test_success=false
-	kill -KILL $pid11 || test_success=false
-	kill -USR1 $pid12 || test_success=false
-	kill -KILL $pid13 || test_success=false

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh line 64

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +7 -3
-	kill -KILL $pid14 || test_success=false
-	kill -KILL $pid15 || test_success=false
-	kill -KILL $pid16 || test_success=false
+	kill -USR1 ${pid0} || test_success=false
+
+	for ((p=1; p<NR_PIDS; p++))
+	{
+		local kill_pid=pid${p}
+		kill -KILL ${!kill_pid} || test_success=false
+	}

Again this is bashism loop over $(seq NR_PIDS).

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh line 65

Quoted 1 line
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +0 -0
 	sleep 2

We should wait on the pids here instead of the sleep, which would guarantee tha the processes have really finished.

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh line 79

Quoted 13 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +10 -0
 	clean_up
 }
 
+test_stress()
+{
+	NR_PIDS=0
+	echo "Test targets: ${test_targets}"
+	get_skip_targets
+	for target in ${test_targets}; do
+		if should_skip_target $target; then
+			continue
+		fi
+		$SPATH/ftrace_${target}.sh &

The path to test binaries must be in $PATH before testcases are executed so you should just do ftrace_${target}.sh & instead.

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh line 82

Quoted 3 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +3 -0
+		eval pid${NR_PIDS}=$!
+		echo "Start pid${NR_PIDS}=$! $SPATH/ftrace_${target}.sh"
+		((NR_PIDS++))

Bashism. Portable way is a=$((a+1))

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh line 92

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +10 -0
+	done
+	export_pids
+}
+
+export_pids()
+{
+	for ((i=0; i<NR_PIDS; i++))
+	{
+		export pid${i}
+	}

Bashism again.

Quoted 7 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +2 -0
+	export NR_PIDS
+}
 
 # ----------------------------
 echo "Ftrace Stress Test Begin"
@@ -111,11 +106,11 @@ test_wait
 

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh test_wait · line 114

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +0 -2
 test_kill
 
-echo "Ftrace Stress Test End"
-
 if $test_success; then
 	tst_resm TPASS "finished running the test. Run dmesg to double-check for bugs"
 else
 	tst_resm TFAIL "please check log message."
 	exit 1
 fi

Again the test should be really converted to test.sh library. That way we would exit with correct exit status at tst_exit instead of calling exit manually depending on some flag.

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh test_wait · line 116

Quoted 1 line
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +1 -0
+echo "Ftrace Stress Test End"

And ideally bashism should be fixed in the substests called from this tests. So that the test can run with dash or bussy box as well.

Signature · 2 lines
Cyril Hrubis
[email protected]
#13 lore raw

RFC PATCH 8/9 ftrace_stress: update the trace_options test

In reply to Li Wang

Hi!

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh line 26

Quoted 7 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh +7 -0
+# enable the nop_test_refuse can cause an
+# 'write error: Invalid argument'. So don't
+# test it.
+option_files=${option_files/test_nop_refuse/}
+trace_options=( $option_files )
+
+NR_TRACE_OPTIONS=${#trace_options[*]}

This does not work even in bash because the trace_options is never casted to array so it just returns 0.

The portable way is plain old wc:

NR=$(echo $trace_options |wc -w)

Quoted 2 lines

for ((; ; ))
{

Please fix these bash style loops as well.

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh for ((; ; )) · line 35

Quoted 7 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh +0 -1
@@ -25,7 +31,6 @@ for ((; ; ))
 	{
 		num=`date +%N`
 		num=`printf 1%s $num`
-
 		for ((i = 0; i < $NR_TRACE_OPTIONS; i++))
 		{

And here.

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh for ((; ; )) · line 42

Quoted 6 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh +1 -0
 			n=$(( ( $num >> $i ) % 2 ))
@@ -34,9 +39,9 @@ for ((; ; ))
 			else
 				echo 1 > "$TRACING_PATH"/options/${trace_options[$i]}
 			fi
+			[ $? -ne 0 ] && echo "setup trace option ${trace_options[$i]} failed"

Shouldn't this check be just after the echo rather than here?

Quoted 12 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh +0 -1
 		}
 	}
 
 	sleep 1
 }
-
Signature · 5 lines
1.8.3.1


-- 
Mailing list info: http://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis
[email protected]
#14 lore raw

RFC PATCH 8/9 ftrace_stress: update the trace_options test

Hi!

Quoted 10 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh line 26

Quoted 7 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh +7 -0
+# enable the nop_test_refuse can cause an
+# 'write error: Invalid argument'. So don't
+# test it.
+option_files=${option_files/test_nop_refuse/}
+trace_options=( $option_files )
+
+NR_TRACE_OPTIONS=${#trace_options[*]}

This does not work even in bash because the trace_options is never casted to array so it just returns 0.

My bad, it is converted by the ().

But the point is the same, use portable code.

Signature · 2 lines
Cyril Hrubis
[email protected]
#10 lore raw

RFC PATCH 9/9 ftrace_stress: add two new tests

In reply to Li Wang

Hi!

Quoted 14 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +14 -0
+###########################################################################
+##                                                                       ##
+## Copyright (c) 2015, Red Hat Inc.                                      ##
+##                                                                       ##
+## This program is free software: you can redistribute it and/or modify  ##
+## it under the terms of the GNU General Public License as published by  ##
+## the Free Software Foundation, either version 3 of the License, or     ##
+## (at your option) any later version.                                   ##
+##                                                                       ##
+## This program is distributed in the hope that it will be useful,       ##
+## but WITHOUT ANY WARRANTY; without even the implied warranty of        ##
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          ##
+## GNU General Public License for more details.                          ##
+##                                                                       ##

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 25

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +10 -0
+## You should have received a copy of the GNU General Public License     ##
+## along with this program. If not, see <http://www.gnu.org/licenses/>.  ##
+##                                                                       ##
+## Author: Chunyu Hu <[email protected]>                                  ##
+##                                                                       ##
+###########################################################################
+
+triggers=( traceon traceoff enable_event disable_event snapshot\
+	 dump cpudump stacktrace module function )
+n_triggers=${#triggers}

Bashism again.

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 31

Quoted 5 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +5 -0
+module_pick()
+{
+	nr_module=$(lsmod | wc -l)
+	pick_one=$(( (RANDOM % nr_module) +1 ))
+	picked_module=$(lsmod | sed -n ''$pick_one'p')

Unfortunately there is no portable way to get random numbers in shell.

So the best we can do is to write a small helper tst_random to take a range and produce random number in that range. I would have just added a simple C program to testcases/lib/ the same way we did for portable sleep shorted than 1s in tst_sleep.c.

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 34

Quoted 3 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +3 -0
+}
+
+nr_functions=$(cat $TRACING_PATH/available_filter_functions|wc -l)

You can do just 'wc -l $TRACING_PATH/available_filter_functions'

Review

Quoted 2 lines
(quoted diff) +2 -0
+function_pick()
+{

local AVAILABLE_FUNCTIONS="$TRACING_PATH/available_filter_functions"

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 42

Quoted 5 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +5 -0
+	if [ -f $TRACING_PATH/available_filter_functions ]; then
+		local pick_one=$(( (RANDOM % nr_functions) + 1 ))
+		picked_function=$(cat $TRACING_PATH/available_filter_functions |\
+				 sed -n ''$pick_one'p'|awk '{print $1}')
+		echo $picked_function

You can just do:

		awk "{if (NR==$pick_one) {print \$1}}" $AVAILABLE_FUNCTIONS

instead of cat, sed and echo.

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh

Quoted 13 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +13 -0
+	else
+		echo "\*sched\*"
+	fi
+}
+
+event_pick()
+{
+	if [ -f $TRACING_PATH/available_events ]; then
+		nr_events=$(cat $TRACING_PATH/available_events | wc -l)
+		local pick_one=$(( (RANDOM % nr_events) + 1 ))
+		picked_event=$(cat $TRACING_PATH/available_events | sed -n ''$pick_one'p')
+
+		echo "$picked_event"

Here as well no need to use echo and cat:

sed -n ''$pick_one'p' $AVAILABLE_EVENTS

Quoted 21 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +21 -0
+	else
+		echo "sched:sched_switch"
+	fi
+}
+
+filter_formatter()
+{
+	local count=$(( (RANDOM % 5) + 1 ))
+	function_name=$(function_pick)
+	case $1 in
+	traceon|traceoff|snapshot|dump|cpudump|stacktrace|module|function)
+		format=$1
+		;;
+	enable_event|disable_event)
+		event_sys_name=$(event_pick)
+		format=$1:$event_sys_name
+		;;
+	module)
+		module_pick
+		echo "$picked_module:\*"
+		return

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 85

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +10 -0
+		;;
+	function)
+		echo "$picked_function"
+		return
+		;;
+	*)
+		format=$1
+		;;
+	esac
+	((count)) && format=$format:$count

Bahsism. Also the count is non-zero since it's RANDOM % 5 + 1.

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 90

Quoted 5 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +5 -0
+	echo $function_name:$format
+}
+
+for ((; ;))
+{

Bash style loop. Use while true; do ... done

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 91

Quoted 1 line
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +1 -0
+	cat $TRACING_PATH/set_ftrace_filter > /dev/null

Why do we cat the file to /dev/null?

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 97

Quoted 6 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +6 -0
+	trigger_index=$((RANDOM % n_triggers))
+	trigger_name=${triggers[$trigger_index]}
+	filter_format=$(filter_formatter $trigger_name)
+
+	echo "$filter_format" > $TRACING_PATH/set_ftrace_filter
+	[ $? -ne 0 ] && echo "setup filter <$filter_format> failed"

Shouldn't we report a failure here?

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 102

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +4 -0
+	sleep 1
+
+	echo "!$filter_format" > $TRACING_PATH/set_ftrace_filter
+	[ $? -ne 0 ] && echo "remove filter <$filter_format> failed"

Here as well.

Quoted 29 lines
(quoted diff) +1 -0
+}
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +22 -0
new file mode 100755
index 0000000..28bbc27
@@ -0,0 +1,51 @@
+#! /bin/sh
+
+###########################################################################
+##                                                                       ##
+## Copyright (c) 2015, Red Hat Inc.                                      ##
+##                                                                       ##
+## This program is free software: you can redistribute it and/or modify  ##
+## it under the terms of the GNU General Public License as published by  ##
+## the Free Software Foundation, either version 3 of the License, or     ##
+## (at your option) any later version.                                   ##
+##                                                                       ##
+## This program is distributed in the hope that it will be useful,       ##
+## but WITHOUT ANY WARRANTY; without even the implied warranty of        ##
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          ##
+## GNU General Public License for more details.                          ##
+##                                                                       ##
+## You should have received a copy of the GNU General Public License     ##
+## along with this program. If not, see <http://www.gnu.org/licenses/>.  ##
+##                                                                       ##
+## Author: Chunyu Hu <[email protected]>                                  ##
+##                                                                       ##
+###########################################################################

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh line 32

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +10 -0
+
+nr_cpus=`tst_ncpus`
+
+get_random_value()
+{
+	local max=$1
+	local min=${2:-0}
+	local random=${RANDOM:-$(date +%N)}
+	echo $(( random % max  ))
+}

Well looks like you have implemented portable random function after all although the range does not work at all.

it should really be:

echo $((min + (random % (max - min + 1))))

Which would cover range [min, max] including both min and max.

And the function should be in a library used by all the testcases.

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh line 36

Quoted 3 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +3 -0
+get_test_cpumask()
+{
+	local random=${RANDOM:-$(date +%N)}

Unused variable.

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh line 39

Quoted 3 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +3 -0
+	local set_cnt=$(get_random_value $nr_cpus);
+	mask=0
+	for ((c=0; c<set_cnt; c++));do

Bashism.

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh line 43

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +4 -0
+		local cpuid=$(get_random_value $nr_cpus)
+		mask=$(( mask| (1<<$cpuid) ))
+	done
+	mask=`echo $mask | awk '{printf "%x",$0}'`

Why can't we echo the mask here and do:

get_test_cpumask > $TRACING_PATH/tracing_cpumask

in the main loop?

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh line 46

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +4 -0
+}
+
+for ((; ;))
+{

Bashism.

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh line 50

Quoted 3 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +3 -0
+	get_test_cpumask
+	echo $mask > $TRACING_PATH/tracing_cpumask
+	sleep 5

Why sleep 5?

Quoted 21 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +1 -0
+}
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +2 -1
index d1be49a..49cae86 100755
@@ -31,7 +31,8 @@ test_targets=" \
 trace_pipe current_tracer ftrace_enabled function_profile_enabled \
 set_event set_ftrace_pid stack_max_size stack_trace trace trace_clock \
 trace_options trace_stat tracing_enabled tracing_max_latency \
-tracing_on function_profile_enabled buffer_size_kb"
+tracing_on function_profile_enabled buffer_size_kb tracing_cpumask \
+set_ftrace_filter"
 
 get_skip_targets()
 {
Signature · 5 lines
1.8.3.1


-- 
Mailing list info: http://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis
[email protected]
author
#20 lore raw

RFC PATCH 5/9 ftrace_regression: add a new testcase

In reply to Cyril Hrubis

Hi,

Thanks for reviewing. Comments in follows:

Quoted 33 lines · Cyril Hrubis

Hi!

Quoted 1 line

+###############################################################################

Quoted 1 line

+#

       #
Quoted 1 line

+# Copyright (c) 2015, Red Hat Inc.

      #
Quoted 1 line

+#

       #
Quoted 1 line

+# This program is free software; you can redistribute it and/or modify

it #

Quoted 1 line

+# under the terms of the GNU General Public License as published by the

Free #

Quoted 1 line

+# Software Foundation; either version 2 of the License, or (at your

option) #

Quoted 1 line

+# any later version.

      #
Quoted 1 line

+#

       #
Quoted 1 line

+# PURPOSE: check signal:signal_generate gives 2 more fields: grp res

      #
Quoted 1 line

+#

       #
Quoted 1 line

+# This testcase is verifing signal events change:

       #
Quoted 1 line

+# 6c303d3 tracing: let trace_signal_generate() report more

info... #

Quoted 1 line

+# 163566f tracing: send_sigqueue() needs trace_signal_generate()

too #

Quoted 1 line

+#

       #
Quoted 1 line

+###############################################################################

Quoted 13 lines

testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_enhanced_signal_tracepoint.sh line 28

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_enhanced_signal_tracepoint.sh new file +10 -0
+
+
+# Set envent
+echo 'signal:signal_generate' > $TRACING_PATH/set_event
+
+echo 1 > $TRACING_PATH/tracing_on
+
+echo > $TRACING_PATH/trace
+
+sleep 10

Why sleep 10 here?

It's waiting for ftrace capture the system trace. There probably no any trace be recorded if we check it at once.

Quoted 9 lines

testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_enhanced_signal_tracepoint.sh line 35

Quoted 6 lines
testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_enhanced_signal_tracepoint.sh new file +6 -0
+grep -q 'grp=[0-9] res=[0-9]' $TRACING_PATH/trace
+if [ $? -eq 0 ]; then
+     exit 0
+else
+     exit 1
+fi

Use test.sh and tst_resm instead.

Sure, I'd like to make change of the patches(2/9 -- 5/9) as your suggested.

CC' chuhu@ here. Since the patches(6/9 -- 9/9) were signed off by him.

Signature · 6 lines
Regards,
Li Wang
Email: [email protected]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20160318/2cd9dac2/attachment.html>
author
#23 lore raw

RFC PATCH 3/9 tracing[2]: reorganize ftrace stress tests to general tests

In reply to Cyril Hrubis

Hi Cyril,

Quoted 8 lines · Cyril Hrubis

Hi!
...

Adding a script that runs all testcases is frowned upon in LTP. What you should do instead is to make it possible to run individual testcases and add the tests one test per line to a runtest file.

Seems like these regression cases are petty and simple. I fear that would be too dispersed to read. How about taking use of the cgroup tests code-style to organise them?

which will be like:
---------------------

$ cat ftrace_regression_test.sh
#! /bin/sh
...

export TCID="ftrace-regression-test"
export TST_TOTAL=N ( N depends on how many test_$cur) export TST_COUNT=1

. ftrace_lib.sh

test_success=false

test_check()
{
if $test_success; then
tst_resm TPASS "finished running the test."
else
tst_resm TFAIL "running the test failed, please check log message."
fi

test_success=false
}

#comments the test_1 info blablabla....
test_1()
{
...
set test_success 'true' or 'false' base on the test result
...
test_check;
}

test_2()
{
...
test_check;
}

test_3()
{
...
test_check;
}

test_regression()

{
    for cur in $(seq $TST_TOTAL); do
        test_$cur
    done
}

#----------------------------------
echo "Ftrace Regression Test Begin"

save_old_setting

test_regression

clean_up

echo "Ftrace Regression Test End"

Quoted 2 lines

Also newly added test should use test.sh library.

sure, this no problem!

Signature · 6 lines
Regards,
Li Wang
Email: [email protected]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20160318/1bbe9eee/attachment-0001.html>
#18 lore raw

RFC PATCH 6/9 ftrace_stress: skip unsupported tests

In reply to Cyril Hrubis

Hi Cyril,

I will fix the issues you mentioned about the stress test in V2. As when i talked about the ftrace test i knew Li Wang is doing something reorg the ftrace test. So i just append the stress related 4 fix to his. as we guess this will make it be simpler to be reviewed by you, and make it easier to be considered for organizing the case.

I also your replied the issues below. Thanks!

----- Original Message -----

Quoted 12 lines

From: "Cyril Hrubis" <[email protected]>
To: "Li Wang" <[email protected]>
Cc: [email protected]
Sent: Friday, March 18, 2016 1:07:01 AM
Subject: Re: [LTP] [PATCH RFC 6/9] ftrace_stress: skip unsupported tests

Hi!

Quoted 5 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh +0 -0
 	if [ -e stack_max_size ]; then
 		old_stack_tracer_enabled=`cat /proc/sys/kernel/stack_tracer_enabled`
 	fi
@@ -86,7 +89,10 @@ restore_old_setting()
 
Quoted 7 lines

testcases/kernel/tracing/ftrace_test/ftrace_lib.sh restore_old_setting() · line 93

Quoted 5 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh +2 -1
 	echo $old_buffer_size > buffer_size_kb
 	echo $old_tracing_on > tracing_on
-	echo $old_tracing_enabled > tracing_enabled
+
+	if [ -e tracing_enabled ];then

^
missing space here

Will modify it in V2. Thanks.

Quoted 9 lines
Quoted 9 lines

a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh index d7efdd4..d1a6bd3 100755
---
a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
+++
b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh

(quoted diff) +0 -0
@@ -36,6 +36,8 @@ for ((; ;))
 
Quoted 5 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh for ((; ;)) · line 40

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh +2 -0
 	for event in `cat $TRACING_PATH/available_events`;
 	do
+		# ftrace event sys is special, skip it
+		[[ $event =~ ftrace:* ]] && continue

This is bashism.

I just had a experience with bash. thanks for catching this issue. Will update it with something like:

if echo $event | grep "ftrace:*"; then

        continue;

fi

Quoted 7 lines
Quoted 6 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +0 -0
index beced43..d1be49a 100755
@@ -21,82 +21,77 @@
Quoted 14 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh line 64

Quoted 12 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +7 -5
-	kill -USR1 $pid12 || test_success=false
-	kill -KILL $pid13 || test_success=false
-	kill -KILL $pid14 || test_success=false
-	kill -KILL $pid15 || test_success=false
-	kill -KILL $pid16 || test_success=false
+	kill -USR1 ${pid0} || test_success=false
+
+	for ((p=1; p<NR_PIDS; p++))
+	{
+		local kill_pid=pid${p}
+		kill -KILL ${!kill_pid} || test_success=false
+	}

Again this is bashism loop over $(seq NR_PIDS).

Thanks for catching this.

Refer the style of test.sh. I will modify this to use a while loop

        p=1;
        while [ p -lt $NR_PIDS ]; do 
                local kill_pid=pid${p}
                kill -KILL ${!kill_pid} || test_success=false 
                tst_record_childstatus ${!p}    
                p=$((p + 1))

        done
Quoted 5 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh line 28

Quoted 2 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +0 -0
 	sleep 2

We should wait on the pids here instead of the sleep, which would guarantee tha the processes have really finished.

Hi,
Thx. I will try to update it using tst_record_childstatus as the above while loop did.

Quoted 16 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh line 79

Quoted 13 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +10 -0
 	clean_up
 }
 
+test_stress()
+{
+	NR_PIDS=0
+	echo "Test targets: ${test_targets}"
+	get_skip_targets
+	for target in ${test_targets}; do
+		if should_skip_target $target; then
+			continue
+		fi
+		$SPATH/ftrace_${target}.sh &

The path to test binaries must be in $PATH before testcases are executed so you should just do ftrace_${target}.sh & instead.

Thanks. I will modify it in V2.
in ftrace_lib.sh, it executes : cd $LTPROOT/testcases/bin, So i need to cd ftrace_stress dir first. then do as you mentioned, make the path shorter is better.

Quoted 5 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh line 82

Quoted 3 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +3 -0
+		eval pid${NR_PIDS}=$!
+		echo "Start pid${NR_PIDS}=$! $SPATH/ftrace_${target}.sh"
+		((NR_PIDS++))

Bashism. Portable way is a=$((a+1))

Thanks for reviewing this. Will update this in V2.

Quoted 4 lines
Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +4 -0
+	done
+	export_pids
+}
+
Quoted 8 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh line 92

Quoted 6 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +6 -0
+export_pids()
+{
+	for ((i=0; i<NR_PIDS; i++))
+	{
+		export pid${i}
+	}

Bashism again.

Thx. Will modify it to use while [] in V2.

Quoted 9 lines
Quoted 9 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +2 -0
+	export NR_PIDS
+}
 
 # ----------------------------
 echo "Ftrace Stress Test Begin"
@@ -111,11 +106,11 @@ test_wait
 
 test_kill
 
Quoted 13 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh test_wait · line 114

Quoted 9 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +0 -2
-echo "Ftrace Stress Test End"
-
 if $test_success; then
 	tst_resm TPASS "finished running the test. Run dmesg to double-check for
 	bugs"
 else
 	tst_resm TFAIL "please check log message."
 	exit 1
 fi

Again the test should be really converted to test.sh library. That way we would exit with correct exit status at tst_exit instead of calling exit manually depending on some flag.

Thanks. have read the test.sh lib. that's really great. Will modify this in V2.

Quoted 4 lines
Quoted 1 line

+echo "Ftrace Stress Test End"

And ideally bashism should be fixed in the substests called from this tests. So that the test can run with dash or bussy box as well.

Thanks. I will try in V2, in fact, I was referring the old subcases, not realizing the portable issue.

Quoted 7 lines

--
Cyril Hrubis
[email protected]

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 2 lines
Regards,
Chunyu Hu
#16 lore raw

RFC PATCH 8/9 ftrace_stress: update the trace_options test

In reply to Cyril Hrubis

----- Original Message -----

Quoted 18 lines

From: "Cyril Hrubis" <[email protected]>
To: "Li Wang" <[email protected]>
Cc: [email protected]
Sent: Friday, March 18, 2016 1:19:00 AM
Subject: Re: [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test

Hi!

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh line 26

Quoted 7 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh +7 -0
+# enable the nop_test_refuse can cause an
+# 'write error: Invalid argument'. So don't
+# test it.
+option_files=${option_files/test_nop_refuse/}
+trace_options=( $option_files )
+
+NR_TRACE_OPTIONS=${#trace_options[*]}

This does not work even in bash because the trace_options is never casted to array so it just returns 0.

Quoted 3 lines

The portable way is plain old wc:

NR=$(echo $trace_options |wc -w)

Will take this way in V2, thanks for the suggestion.

In fact i made it to an array. But i will make trace_options to a string in V2. As you mentioned, some other shells may not recognize the bash style array. Thanks !

Quoted 4 lines
Quoted 2 lines

for ((; ; ))
{

Please fix these bash style loops as well.

Will do it in V2. Thanks.

Quoted 9 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh for ((; ; )) · line 35

Quoted 7 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh +0 -1
@@ -25,7 +31,6 @@ for ((; ; ))
 	{
 		num=`date +%N`
 		num=`printf 1%s $num`
-
 		for ((i = 0; i < $NR_TRACE_OPTIONS; i++))
 		{

And here.

Will modify this in V2. Thanks for reviewing this.

Quoted 8 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh for ((; ; )) · line 42

Quoted 6 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh +1 -0
 			n=$(( ( $num >> $i ) % 2 ))
@@ -34,9 +39,9 @@ for ((; ; ))
 			else
 				echo 1 > "$TRACING_PATH"/options/${trace_options[$i]}
 			fi
+			[ $? -ne 0 ] && echo "setup trace option ${trace_options[$i]} failed"

Shouldn't this check be just after the echo rather than here?

Agree, the echo message is just for setting, but the clear branch can also hit this message. So we need to make the message can express both set and the clear option failure.

Quoted 20 lines
Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh +0 -2
 		}
 	}
 
 	sleep 1
 }
-
--

1.8.3.1

Quoted 2 lines

--
Mailing list info: http://lists.linux.it/listinfo/ltp

--
Cyril Hrubis
[email protected]

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 2 lines
Regards,
Chunyu Hu
#15 lore raw

RFC PATCH 8/9 ftrace_stress: update the trace_options test

In reply to Cyril Hrubis

----- Original Message -----

Quoted 18 lines

From: "Cyril Hrubis" <[email protected]>
To: "Li Wang" <[email protected]>
Cc: [email protected]
Sent: Friday, March 18, 2016 1:28:51 AM
Subject: Re: [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test

Hi!

Quoted 10 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh line 26

Quoted 7 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh +7 -0
+# enable the nop_test_refuse can cause an
+# 'write error: Invalid argument'. So don't
+# test it.
+option_files=${option_files/test_nop_refuse/}
+trace_options=( $option_files )
+
+NR_TRACE_OPTIONS=${#trace_options[*]}

This does not work even in bash because the trace_options is never casted to array so it just returns 0.

Quoted 3 lines

My bad, it is converted by the ().

But the point is the same, use portable code.

Thanks for suggestion! Will make it a string in V2.

Quoted 7 lines

--
Cyril Hrubis
[email protected]

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 2 lines
Regards,
Chunyu Hu
#11 lore raw

RFC PATCH 9/9 ftrace_stress: add two new tests

In reply to Cyril Hrubis

Hi Cyril,

Thanks for the review. Seems some Bash styles needs to be fixed in all subcase. I replied the issues you pointed out below. You mean I need to write a c bin to generate random? Or you will make it in lib?

----- Original Message -----

Quoted 43 lines

From: "Cyril Hrubis" <[email protected]>
To: "Li Wang" <[email protected]>
Cc: [email protected]
Sent: Friday, March 18, 2016 2:08:33 AM
Subject: Re: [LTP] [PATCH RFC 9/9] ftrace_stress: add two new tests

Hi!

Quoted 36 lines
(quoted diff) +2 -0
+###########################################################################
+##

##
+## Copyright (c) 2015, Red Hat Inc.
##
+##
##
+## This program is free software: you can redistribute it and/or modify ##
+## it under the terms of the GNU General Public License as published by ##
+## the Free Software Foundation, either version 3 of the License, or ##
+## (at your option) any later version.
##
+##
##
+## This program is distributed in the hope that it will be useful, ##
+## but WITHOUT ANY WARRANTY; without even the implied warranty of ##
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##
+## GNU General Public License for more details.
##
+##
##
+## You should have received a copy of the GNU General Public License ##
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
##
+##
##
+## Author: Chunyu Hu <[email protected]>
##
+##

Quoted 8 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 25

Quoted 6 lines

##

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +5 -0
+###########################################################################
+
+triggers=( traceon traceoff enable_event disable_event snapshot\
+	 dump cpudump stacktrace module function )
+n_triggers=${#triggers}

Bashism again.

Hi Cyril,

I have to ask a question about the portable.Can we use an array here? You mean we can't use array or just can't use the ${#array_name} to get the number of elements? If array can be used, I guess I can use something like

echo ${triggers[*]} | wc -w , If not accepted by some shells. Then I need to change it to string, and use the way you mentioned echo "$string" | wc -w

Thanks!

Quoted 7 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 31

Quoted 5 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +5 -0
+module_pick()
+{
+	nr_module=$(lsmod | wc -l)
+	pick_one=$(( (RANDOM % nr_module) +1 ))
+	picked_module=$(lsmod | sed -n ''$pick_one'p')

Unfortunately there is no portable way to get random numbers in shell.

Agree, I really worried that this RANDOME value may not work in some case, you confirmed my concern, but i didn't come up with a good solution.

Quoted 5 lines

So the best we can do is to write a small helper tst_random to take a range and produce random number in that range. I would have just added a simple C program to testcases/lib/ the same way we did for portable sleep shorted than 1s in tst_sleep.c.

Thanks ! If we have that interface, that will be great! Hope I can use it in V2.

Quoted 5 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 34

Quoted 3 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +3 -0
+}
+
+nr_functions=$(cat $TRACING_PATH/available_filter_functions|wc -l)

You can do just 'wc -l $TRACING_PATH/available_filter_functions'

Agree, really my bad habit of using a pipe. Thanks for the suggestion.

Quoted 11 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+function_pick()
+{

local AVAILABLE_FUNCTIONS="$TRACING_PATH/available_filter_functions"

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 42

Quoted 5 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +5 -0
+	if [ -f $TRACING_PATH/available_filter_functions ]; then
+		local pick_one=$(( (RANDOM % nr_functions) + 1 ))
+		picked_function=$(cat $TRACING_PATH/available_filter_functions |\
+				 sed -n ''$pick_one'p'|awk '{print $1}')
+		echo $picked_function

You can just do:

Quoted 3 lines
		awk "{if (NR==$pick_one) {print \$1}}" $AVAILABLE_FUNCTIONS

instead of cat, sed and echo.

Oh, that's amazing, I learned a new method. Thanks for the good suggestion. Will update it in V2.

Quoted 17 lines
Quoted 12 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +11 -0
+	else
+		echo "\*sched\*"
+	fi
+}
+
+event_pick()
+{
+	if [ -f $TRACING_PATH/available_events ]; then
+		nr_events=$(cat $TRACING_PATH/available_events | wc -l)
+		local pick_one=$(( (RANDOM % nr_events) + 1 ))
+		picked_event=$(cat $TRACING_PATH/available_events | sed -n

''$pick_one'p')

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+		echo "$picked_event"

Here as well no need to use echo and cat:

Quoted 1 line

sed -n ''$pick_one'p' $AVAILABLE_EVENTS

Will update it V2. Thanks!

Quoted 25 lines
Quoted 25 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +25 -0
+	else
+		echo "sched:sched_switch"
+	fi
+}
+
+filter_formatter()
+{
+	local count=$(( (RANDOM % 5) + 1 ))
+	function_name=$(function_pick)
+	case $1 in
+	traceon|traceoff|snapshot|dump|cpudump|stacktrace|module|function)
+		format=$1
+		;;
+	enable_event|disable_event)
+		event_sys_name=$(event_pick)
+		format=$1:$event_sys_name
+		;;
+	module)
+		module_pick
+		echo "$picked_module:\*"
+		return
+		;;
+	function)
+		echo "$picked_function"
+		return
Quoted 8 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 85

Quoted 6 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +6 -0
+		;;
+	*)
+		format=$1
+		;;
+	esac
+	((count)) && format=$format:$count

Bahsism. Also the count is non-zero since it's RANDOM % 5 + 1.

Will modify it in V2. Something like:

if [ $count -gt 0 ]; then

     .....

fi

And will correct the random issue in V2. Thanks.

Quoted 7 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 90

Quoted 5 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +5 -0
+	echo $function_name:$format
+}
+
+for ((; ;))
+{

Bash style loop. Use while true; do ... done

Will make it while []; do in V2.

Quoted 3 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 91

Quoted 1 line
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +1 -0
+	cat $TRACING_PATH/set_ftrace_filter > /dev/null

Why do we cat the file to /dev/null?

since the set_ftrace_filter can use reg match and support mod. such as if I:

echo :mod:kvm > /sys/kernel/debug/tracing/set_ftrace_filter

cat /sys/kernel/debug/tracing/set_ftrace_filter | head -n 10 ack_flush [kvm]
kvm_get_kvm [kvm]
kvm_disable_largepages [kvm]
kvm_vcpu_mmap [kvm]
kvm_io_bus_sort_cmp [kvm]
mark_page_dirty_in_slot [kvm]
kvm_sched_out [kvm]
kvm_vcpu_init [kvm]
kvm_vcpu_uninit [kvm]

The log will be rather long, I just concern it will make the log too large. You suggest make it show ?

Quoted 8 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 97

Quoted 6 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +6 -0
+	trigger_index=$((RANDOM % n_triggers))
+	trigger_name=${triggers[$trigger_index]}
+	filter_format=$(filter_formatter $trigger_name)
+
+	echo "$filter_format" > $TRACING_PATH/set_ftrace_filter
+	[ $? -ne 0 ] && echo "setup filter <$filter_format> failed"

Shouldn't we report a failure here?

Yes, agree. I should call some ltp interface to report a fail, Will do it in V2, thx.

Quoted 6 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 102

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +4 -0
+	sleep 1
+
+	echo "!$filter_format" > $TRACING_PATH/set_ftrace_filter
+	[ $? -ne 0 ] && echo "remove filter <$filter_format> failed"

Here as well.

Will make it report ltp test failure on V2.

Quoted 55 lines
Quoted 55 lines

+}
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file mode 100755
index 0000000..28bbc27
--- /dev/null
+++
b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +4 -0
@@ -0,0 +1,51 @@
+#! /bin/sh
+
+###########################################################################
+##

##
+## Copyright (c) 2015, Red Hat Inc.
##
+##
##
+## This program is free software: you can redistribute it and/or modify ##
+## it under the terms of the GNU General Public License as published by ##
+## the Free Software Foundation, either version 3 of the License, or ##
+## (at your option) any later version.
##
+##
##
+## This program is distributed in the hope that it will be useful, ##
+## but WITHOUT ANY WARRANTY; without even the implied warranty of ##
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##
+## GNU General Public License for more details.
##
+##
##
+## You should have received a copy of the GNU General Public License ##
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
##
+##
##
+## Author: Chunyu Hu <[email protected]>
##
+##
##

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +6 -0
+###########################################################################
+
+nr_cpus=`tst_ncpus`
+
+get_random_value()
+{
Quoted 8 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh line 32

Quoted 5 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +5 -0
+	local max=$1
+	local min=${2:-0}
+	local random=${RANDOM:-$(date +%N)}
+	echo $(( random % max  ))
+}

Well looks like you have implemented portable random function after all although the range does not work at all.

Hmm, it's not working, agree. So the only portable way is using the glibc interfaces. You mean I need to write this with c lib, or you mean you will do this? Thanks !

Quoted 3 lines

it should really be:

echo $((min + (random % (max - min + 1))))

Good algorithm. I just didn't realize this way.

Quoted 9 lines

Which would cover range [min, max] including both min and max.

And the function should be in a library used by all the testcases.

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh line 36

Quoted 3 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +3 -0
+get_test_cpumask()
+{
+	local random=${RANDOM:-$(date +%N)}

Unused variable.

Ah, will remove that in V2.

Quoted 5 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh line 39

Quoted 3 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +3 -0
+	local set_cnt=$(get_random_value $nr_cpus);
+	mask=0
+	for ((c=0; c<set_cnt; c++));do

Bashism.

Will fix this in V2.

Quoted 10 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh line 43

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +4 -0
+		local cpuid=$(get_random_value $nr_cpus)
+		mask=$(( mask| (1<<$cpuid) ))
+	done
+	mask=`echo $mask | awk '{printf "%x",$0}'`

Why can't we echo the mask here and do:

get_test_cpumask > $TRACING_PATH/tracing_cpumask

in the main loop?

Thanks for the suggestion, will use this way in V2.

Quoted 6 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 90

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +4 -0
+}
+
+for ((; ;))
+{

Bashism.

Will fix in V2. Thanks.

Quoted 5 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh line 50

Quoted 3 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +3 -0
+	get_test_cpumask
+	echo $mask > $TRACING_PATH/tracing_cpumask
+	sleep 5

Why sleep 5?

When I was testing the code, I found sometimes it can hit an softlockup issue.I doubt it was caused by this setup. But maybe not, it may be the func_stack_trace under the option dir causing the issue, if set_ftrace_filter is not setup, then alll kernel functions will be traced with every stack frame be scanned, I asked this issue to the ftrace maintainer Steve, I guess i can remove this in V2, to handle the func_stack_trace instead.

Quoted 30 lines
Quoted 20 lines
(quoted diff) +1 -0
+}
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +2 -2
index d1be49a..49cae86 100755
@@ -31,7 +31,8 @@ test_targets=" \
 trace_pipe current_tracer ftrace_enabled function_profile_enabled \
 set_event set_ftrace_pid stack_max_size stack_trace trace trace_clock \
 trace_options trace_stat tracing_enabled tracing_max_latency \
-tracing_on function_profile_enabled buffer_size_kb"
+tracing_on function_profile_enabled buffer_size_kb tracing_cpumask \
+set_ftrace_filter"
 
 get_skip_targets()
 {
--

1.8.3.1

Quoted 2 lines

--
Mailing list info: http://lists.linux.it/listinfo/ltp

--
Cyril Hrubis
[email protected]

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 2 lines
Regards,
Chunyu Hu
#12 lore raw

RFC PATCH 9/9 ftrace_stress: add two new tests

Hi!

Quoted 3 lines

Thanks for the review. Seems some Bash styles needs to be fixed in all subcase. I replied the issues you pointed out below. You mean I need to write a c bin to generate random? Or you will make it in lib?

I think easiest solution would be to add tst_random that takes min and max parameters to the test.sh and use date to implement it. Just do it in a separate patch, or if needed I can add it for you.

Quoted 3 lines

I have to ask a question about the portable.Can we use an array here? You mean we can't use array or just can't use the ${#array_name} to get the number of elements? If array can be used, I guess I can use something like

Arrays are bash specific feature.

Quoted 2 lines

echo ${triggers[*]} | wc -w , If not accepted by some shells. Then I need to change it to string, and use the way you mentioned echo "$string" | wc -w

That would be the best solution.

FYI you can install dash on most of the distributions and try to run the scripts with it. That will catch most of the portability issues.

...

Quoted 20 lines
Quoted 3 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh line 91

Quoted 1 line
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +1 -0
+	cat $TRACING_PATH/set_ftrace_filter > /dev/null

Why do we cat the file to /dev/null?

since the set_ftrace_filter can use reg match and support mod. such as if I:

echo :mod:kvm > /sys/kernel/debug/tracing/set_ftrace_filter

cat /sys/kernel/debug/tracing/set_ftrace_filter | head -n 10 ack_flush [kvm]
kvm_get_kvm [kvm]
kvm_disable_largepages [kvm]
kvm_vcpu_mmap [kvm]
kvm_io_bus_sort_cmp [kvm]
mark_page_dirty_in_slot [kvm]
kvm_sched_out [kvm]
kvm_vcpu_init [kvm]
kvm_vcpu_uninit [kvm]

Quoted 2 lines

The log will be rather long, I just concern it will make the log too large. You suggest make it show ?

I'm just asking since it looks to me like this statement has no effect at all. Or are we trying to test that kernel does not break if we read the file? In that case we should add a short comment with explanation.

Quoted 64 lines
Quoted 55 lines
Quoted 55 lines

+}
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file mode 100755
index 0000000..28bbc27
--- /dev/null
+++
b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +4 -0
@@ -0,0 +1,51 @@
+#! /bin/sh
+
+###########################################################################
+##

##
+## Copyright (c) 2015, Red Hat Inc.
##
+##
##
+## This program is free software: you can redistribute it and/or modify ##
+## it under the terms of the GNU General Public License as published by ##
+## the Free Software Foundation, either version 3 of the License, or ##
+## (at your option) any later version.
##
+##
##
+## This program is distributed in the hope that it will be useful, ##
+## but WITHOUT ANY WARRANTY; without even the implied warranty of ##
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##
+## GNU General Public License for more details.
##
+##
##
+## You should have received a copy of the GNU General Public License ##
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
##
+##
##
+## Author: Chunyu Hu <[email protected]>
##
+##
##

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +6 -0
+###########################################################################
+
+nr_cpus=`tst_ncpus`
+
+get_random_value()
+{
Quoted 8 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh line 32

Quoted 5 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh new file +5 -0
+	local max=$1
+	local min=${2:-0}
+	local random=${RANDOM:-$(date +%N)}
+	echo $(( random % max  ))
+}

Well looks like you have implemented portable random function after all although the range does not work at all.

Quoted 3 lines

Hmm, it's not working, agree. So the only portable way is using the glibc interfaces. You mean I need to write this with c lib, or you mean you will do this? Thanks !

Not really the date +%N would work fine in this case as we do not need too complicated random generator after all.

Signature · 2 lines
Cyril Hrubis
[email protected]
#24 lore raw

RFC PATCH 3/9 tracing[2]: reorganize ftrace stress tests to general tests

In reply to Li Wang

Hi!

Quoted 3 lines

Seems like these regression cases are petty and simple. I fear that would be too dispersed to read. How about taking use of the cgroup tests code-style to organise them?

I do not think so. The problem with running to many testcases as one test is that we get wrong idea about the overall result. Even if one regression test fails the test will return failure and instead of 90% green we end up with 100% red in the results.

And also the cgroup_regression_test.sh does not use the test.sh library do not take the test as example please.

Quoted 22 lines

which will be like:
---------------------

$ cat ftrace_regression_test.sh
#! /bin/sh
...

export TCID="ftrace-regression-test"
export TST_TOTAL=N ( N depends on how many test_$cur) export TST_COUNT=1

. ftrace_lib.sh

test_success=false

test_check()
{
if $test_success; then
tst_resm TPASS "finished running the test."
else
tst_resm TFAIL "running the test failed, please check log message."
fi

Quoted 1 line

test_success=false

Generic failure messages are not a good idea. The test should really report what exactly went wrong.

Quoted 33 lines

}

#comments the test_1 info blablabla....
test_1()

{
   ...
   set test_success 'true' or 'false' base on the test result
   ...
   test_check;
}

test_2()

{
   ...
   test_check;
}

test_3()

{
   ...
   test_check;
}

test_regression()

{
    for cur in $(seq $TST_TOTAL); do
        test_$cur
    done
}

#----------------------------------
echo "Ftrace Regression Test Begin"

Quoted 7 lines

save_old_setting

test_regression

clean_up

echo "Ftrace Regression Test End"

You should use tst_resm TINFO here. And also these messages are quite meaningless anyway.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#25 lore raw

RFC PATCH 3/9 tracing[2]: reorganize ftrace stress tests to general tests

Hi Cyril,

Quoted 10 lines · Cyril Hrubis

Hi!

Quoted 3 lines

Seems like these regression cases are petty and simple. I fear that would be too dispersed to read. How about taking use of the cgroup tests code-style to organise them?

I do not think so. The problem with running to many testcases as one test is that we get wrong idea about the overall result. Even if one regression test fails the test will return failure and instead of 90% green we end up with 100% red in the results.

ok, I have got the point, will separate the regression case in each.

Quoted 5 lines

And also the cgroup_regression_test.sh does not use the test.sh library do not take the test as example please.

thanks!

Signature · 6 lines
Regards,
Li Wang
Email: [email protected]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20160322/d063e72e/attachment.html>