Skip to contentSkip to conversation

tracing: make ftrace tests to be extended

PATCH Superseded Chunyu Hu 3 participants 32 messages Apr 18, 2016 – May 11, 2016

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Chunyu Hu

author
#0 lore raw

v2 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.

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

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

- Enhance the ftrace-stress test coverage.

- Do some cleanup and bug fix work.

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

Changes from V1:
1. Use ltp lib api.
2. Fix bashism issues.
3. ftrace_regression_test: make the two sub tests as two independent tests.
4. ftrace_stress: Wait for pid after execing a killing of sub test.
5. ftrace_stress: Fix tracing_cpumask test for case nr_cpu > 32.
6. ftrace_stress: Fix set_ftrace_filter test for module filter.
7. ftrace_stress: Fix small issue for trace_options test.

Chunyu Hu (6):
ftrace_stress: skip unsupported tests
ftrace_stress: keep the name of testscipt in sync with tracing file testcases/lib: Add tst_random decmical integer generator
ftrace_stress: update the trace_options test
ftrace_stress: add two new tests
ftrace_stress: cleanup and use ltp API

Li Wang (3):
tracing: reorganize ftrace-stress tests to general tests tracing/ftrace: add new case for ftrace userstacktrace tracing/ftrace: add a new case for signal_generate

author
#1 lore raw

PATCH v2 1/9 tracing: reorganize ftrace-stress tests to general tests

From: Li Wang <[email protected]>

Changs:
- renamed: ftrace_stress_test/ --> ftrace_test/
- extracted: ftrace_stress_test.sh --> ftrace_lib.sh
- modified: ftrace_stress_test.sh

---
 .../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 +
 testcases/kernel/tracing/ftrace_test/ftrace_lib.sh | 156 +++++++++++++
 .../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      | 123 +++++++++++
 37 files changed, 960 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_lib.sh
 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_lib.sh new file +156 -0

156 lines not on this page · raw message

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 +123 -0

123 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author
#2 lore raw

PATCH v2 2/9 tracing/ftrace: add new case for ftrace userstacktrace

From: Li Wang <[email protected]>

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)

---
 runtest/tracing                                    |  1 +
 .../tracing/ftrace_test/ftrace_regression01.sh     | 86 ++++++++++++++++++++++
 2 files changed, 87 insertions(+)
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh
runtest/tracing +1 -0
index ef3a048..fb82515 100644
@@ -1,2 +1,3 @@
 #DESCRIPTION:Tracing testing
+ftrace_regression01	ftrace_regression01.sh
 ftrace-stress-test	ftrace_stress_test.sh 90
testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh new file +86 -0

86 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author
#3 lore raw

PATCH v2 3/9 tracing/ftrace: add a new case for signal_generate

From: Li Wang <[email protected]>

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

---
 runtest/tracing                                    |  1 +
 .../tracing/ftrace_test/ftrace_regression02.sh     | 67 ++++++++++++++++++++++
 2 files changed, 68 insertions(+)
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh
runtest/tracing +1 -0
index fb82515..9f8d5c8 100644
@@ -1,3 +1,4 @@
 #DESCRIPTION:Tracing testing
 ftrace_regression01	ftrace_regression01.sh
+ftrace_regression02	ftrace_regression02.sh
 ftrace-stress-test	ftrace_stress_test.sh 90
testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh new file +67 -0

67 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author
#4 lore raw

PATCH v2 4/9 ftrace_stress: skip unsupported tests

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.

V2:
fix the bashism code style.
use ltp lib.

---
 testcases/kernel/tracing/ftrace_test/ftrace_lib.sh |  10 +-
 .../ftrace_test/ftrace_stress/ftrace_set_event.sh  |   5 +-
 .../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      | 132 ++++++++++-----------
 7 files changed, 78 insertions(+), 115 deletions(-)
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh +8 -2
index ea082dc..b7aef34 100755
@@ -40,9 +40,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
@@ -85,7 +88,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 +4 -1
index d7efdd4..e8fd5ea 100755
@@ -36,9 +36,12 @@ for ((; ;))
 
 	for event in `cat $TRACING_PATH/available_events`;
 	do
+		# ftrace event sys is special, skip it
+		if echo "$event" | grep "ftrace:*"; then
+			continue
+		fi
 		echo $event >> "$TRACING_PATH"/set_event
 	done
 
 	sleep 1
 }
-
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 +66 -66

164 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author
#5 lore raw

PATCH v2 5/9 ftrace_stress: keep the name of testscipt in sync with tracing file

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
#6 lore raw

PATCH v2 6/9 testcases/lib: Add tst_random decmical integer generator

It parse the input range and get one decimical integer in the range. Tests can use it to determin a random action.

+ documentation in the test-writing-guidelines

---
 doc/test-writing-guidelines.txt |  12 +++++
 testcases/lib/.gitignore        |   1 +
 testcases/lib/Makefile          |   4 +-
 testcases/lib/tst_random.c      | 104 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 119 insertions(+), 2 deletions(-)
 create mode 100644 testcases/lib/tst_random.c
doc/test-writing-guidelines.txt +12 -0
index d0b1408..a6b4c2d 100644
@@ -1203,6 +1203,18 @@ that can sleep for defined amount of seconds, milliseconds or microseconds.
 tst_sleep 100ms
 -------------------------------------------------------------------------------
 
+tst_random
++++++++++
+
+There may be test such as ftrace_test using random integer to determin the test action.
+here includes 'tst_random' to support it, avoid the `date+%N` action.
+
+[source,sh]
+-------------------------------------------------------------------------------
+# get random integer between 0 and 1000 (include 0 and 1000)
+tst_random 0 1000
+-------------------------------------------------------------------------------
+
 ROD and ROD_SILENT
 ++++++++++++++++++
 
testcases/lib/.gitignore +1 -0
index 8886b34..15a04df 100644
@@ -1 +1,2 @@
 tst_sleep
+tst_random
testcases/lib/Makefile +2 -2
index 0bfb149..be3a720 100644
@@ -24,8 +24,8 @@ top_srcdir		?= ../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-INSTALL_TARGETS		:= *.sh tst_sleep
+INSTALL_TARGETS		:= *.sh tst_sleep tst_random
 
-MAKE_TARGETS		:= tst_sleep
+MAKE_TARGETS		:= tst_sleep tst_random
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/lib/tst_random.c new file +104 -0

104 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author
#7 lore raw

PATCH v2 7/9 ftrace_stress: update the trace_options test

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.

V2:
Use tst_random.
Fix bashism code style.
Use ltp lib.
Check the existence before setting.

---
 .../ftrace_stress/ftrace_trace_options.sh          | 62 ++++++++++++++--------
 1 file changed, 41 insertions(+), 21 deletions(-)
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh +41 -21
index 47d2a62..3b6bc79 100755
@@ -13,30 +13,50 @@
 #                                                                             #
 ###############################################################################
 
-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)
+. test.sh
 
-NR_TRACE_OPTIONS=19
-
-for ((; ; ))
-{
-	for ((j = 0; j < $LOOP; j++))
-	{
-		num=`date +%N`
-		num=`printf 1%s $num`
+LOOP=200
 
-		for ((i = 0; i < $NR_TRACE_OPTIONS; i++))
-		{
-			n=$(( ( $num >> $i ) % 2 ))
+random_gen=tst_random
+
+while true; do
+	j=0;
+	while [ $j -lt $LOOP ]; do
+		trace_options="$(ls $TRACING_PATH/options/)"
+		# enable the nop_test_refuse can cause an
+		# 'write error: Invalid argument'. So don't test it.
+		trace_options="$(echo $trace_options | sed 's/test_nop_refuse//')"
+		nr_trace_options=$(echo "${trace_options}" | wc -w)
+
+		option_index=$($random_gen 1 $nr_trace_options)
+		option=$(echo "$trace_options" | awk "{print \$$option_index}")
+		i=0
+		while [ $i -lt $nr_trace_options ]; do
+			n=$($random_gen 0 1)
+			opt_f="$TRACING_PATH"/options/$option
+			ret_val=0
 			if [ $n -eq 0 ]; then
-				echo 0 > "$TRACING_PATH"/options/${trace_options[$i]}
+				operation="setup"
 			else
-				echo 1 > "$TRACING_PATH"/options/${trace_options[$i]}
+				operation="clear"
+			fi
+			# On old kernel, some trace option dirs
+			# won't be made if the option has nothing
+			# to do with the current tracer. But on newer
+			# kernel(4.4-rc1), all option dirs will be made.
+			# So here check it to avoid 'Permision denied'
+			if [ -f $opt_f ]; then
+				echo $n > $opt_f
+				ret_val=$?
 			fi
-		}
-	}
-
-	sleep 1
-}
 
+			if [ $ret_val -ne 0 ]; then
+				tst_resm TFAIL "$0: $operation trace option $option failed"
+			fi
+			i=$((i + 1))
+		done
+		j=$((j + 1))
+	done
+	# sleep is not needed if ftrace can surrive.
+	# tst_sleep 1s
+done
Signature · 1 line
1.8.3.1
author
#8 lore raw

PATCH v2 8/9 ftrace_stress: add two new tests

V2:
Use tst_random to get random integer.
Fix bashism code.
Simplify the get of cpu mask, make it work with nr_cpu > 32. Update the set_ftrace_filter, use awk instead sed.small fix moddule filter. Use ltp lib.

V1:
add ftrace_tracing_cpumask.sh.
add ftrace_set_ftrace_filter.sh.

---
 testcases/kernel/tracing/ftrace_test/ftrace_lib.sh |  22 ++++
 .../ftrace_stress/ftrace_set_ftrace_filter.sh      | 121 +++++++++++++++++++++
 .../ftrace_stress/ftrace_tracing_cpumask.sh        |  93 ++++++++++++++++
 .../tracing/ftrace_test/ftrace_stress_test.sh      |   3 +-
 4 files changed, 238 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 +22 -0
index b7aef34..8632e24 100755
@@ -41,6 +41,11 @@ 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_cpumask ]; then
+		old_tracing_cpumask=`cat tracing_cpumask`
+	fi
 
 	if [ -e tracing_enabled ]; then
 		old_tracing_enabled=`cat tracing_enabled`
@@ -69,6 +74,10 @@ restore_old_setting()
 	echo 0 > events/enable
 	echo 0 > tracing_max_latency 2> /dev/null
 
+	if [ -e tracing_cpumask ]; then
+		echo $old_tracing_cpumask > tracing_cpumask
+	fi
+
 	if [ -e trace_clock ]; then
 		echo local > trace_clock
 	fi
@@ -100,6 +109,19 @@ restore_old_setting()
 
 	echo > trace
 
+	if [ -f set_ftrace_filter ]; then
+		cat set_ftrace_filter | \
+		while read flt; do
+			if [ -n "$flt" ]; then
+				# the line start with # started is comment.
+				if echo $flt | grep -e "^#"; then
+					continue;
+				fi
+				echo '!'"$flt" > set_ftrace_filter
+			fi
+		done
+	fi
+
 	cd - > /dev/null
 }
 
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh new file +121 -0

121 lines not on this page · raw message

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

93 lines not on this page · raw message

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +2 -1
index 80c914c..eb2c5f6 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
author
#9 lore raw

PATCH v2 9/9 ftrace_stress: cleanup and use ltp API

1. fix the bashism code style.
2. Use ltp API

---
 .../ftrace_stress/ftrace_buffer_size_kb.sh         | 20 ++++++++---------
 .../ftrace_stress/ftrace_current_tracer.sh         | 14 ++++++------
 .../ftrace_stress/ftrace_ftrace_enabled.sh         | 13 ++++++-----
 .../ftrace_function_profile_enabled.sh             | 24 ++++++---------------
 .../ftrace_test/ftrace_stress/ftrace_set_event.sh  | 25 +++++++++++-----------
 .../ftrace_stress/ftrace_set_ftrace_pid.sh         | 21 +++++++++---------
 .../ftrace_stress/ftrace_stack_max_size.sh         | 13 ++++++-----
 .../ftrace_stress/ftrace_stack_trace.sh            | 19 ++++++++--------
 .../ftrace_test/ftrace_stress/ftrace_trace.sh      | 14 ++++++------
 .../ftrace_stress/ftrace_trace_clock.sh            | 25 ++++++++++++----------
 .../ftrace_test/ftrace_stress/ftrace_trace_pipe.sh | 19 ++++++++--------
 .../ftrace_test/ftrace_stress/ftrace_trace_stat.sh | 19 ++++++++--------
 .../ftrace_stress/ftrace_tracing_enabled.sh        | 13 ++++++-----
 .../ftrace_stress/ftrace_tracing_max_latency.sh    | 13 +++++------
 .../ftrace_test/ftrace_stress/ftrace_tracing_on.sh | 13 ++++++-----
 15 files changed, 124 insertions(+), 141 deletions(-)
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh +10 -10
index bd7dcc4..a0ebc32 100755
@@ -26,20 +26,20 @@ if [ $step -eq 0 ]; then
 	LOOP=50
 fi
 
-for ((; ;))
-{
+while true; do
 	new_size=1
-	for ((i = 0; i < $LOOP; i++))
-	{
+	i=0;
+	while [ $i -lt $LOOP ]; do
 		echo $new_size > "$TRACING_PATH"/buffer_size_kb
 		new_size=$(( $new_size + $step ))
-	}
+		i=$((i + 1))
+	done
 
-	for ((i = 0; i < $LOOP; i++))
-	{
+	i=0;
+	while [ $i -lt $LOOP ]; do
 		new_size=$(( $new_size - $step ))
 		echo $new_size > "$TRACING_PATH"/buffer_size_kb
-	}
-
+		i=$((i + 1))
+	done
 	sleep 1
-}
+done
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_current_tracer.sh +6 -8
index 88d576f..104b577 100755
@@ -15,10 +15,9 @@
 
 LOOP=200
 
-for ((; ;))
-{
-	for ((i = 0; i < $LOOP; i++))
-	{
+while true; do
+	i=0
+	while [ $i -lt $LOOP ]; do
 		for tracer in `cat "$TRACING_PATH"/available_tracers`
 		do
 			if [ "$tracer" = mmiotrace ]; then
@@ -27,8 +26,7 @@ for ((; ;))
 
 			echo $tracer > "$TRACING_PATH"/current_tracer 2> /dev/null
 		done
-	}
-
+		i=$((i + 1))
+	done
 	sleep 1
-}
-
+done
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_ftrace_enabled.sh +6 -7
index 20bb234..c6f8b48 100755
@@ -16,15 +16,14 @@
 MAX_LOOP=1500
 count=0
 
-for ((; ;))
-{
+while true; do
 	count=$(( $count + 1 ))
-
-	for ((i = 0; i < $MAX_LOOP; i++))
-	{
+	i=0
+	while [ $i -lt $MAX_LOOP ]; do
 		echo 0 > /proc/sys/kernel/ftrace_enabled
 		echo 1 > /proc/sys/kernel/ftrace_enabled
-	}
+		i=$((i + 1))
+	done
 
 	enable=$(( $count % 3 ))
 
@@ -35,5 +34,5 @@ for ((; ;))
 	fi
 
 	sleep 1
-}
+done
 
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_function_profile_enabled.sh +6 -18
index 9c6162a..7687420 100755
@@ -16,26 +16,15 @@
 MAX_LOOP=1500
 count=0
 
-if [ ! -e "$TRACING_PATH"/function_profile_enabled ]; then
-	should_skip=1
-else
-	should_skip=0
-fi
-
-for ((; ;))
-{
-	if [ $should_skip -eq 1 ]; then
-		sleep 2
-		continue
-	fi
 
+while true; do
 	count=$(( $count + 1 ))
-
-	for ((i = 0; i < $MAX_LOOP; i++))
-	{
+	i=0
+	while [ $i -lt $MAX_LOOP ]; do
 		echo 0 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
 		echo 1 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
-	}
+		i=$((i + 1))
+	done
 
 	enable=$(( $count % 3 ))
 
@@ -46,5 +35,4 @@ for ((; ;))
 	fi
 
 	sleep 1
-}
-
+done
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh +12 -13
index e8fd5ea..b2a1cae 100755
@@ -13,29 +13,28 @@
 #                                                                             #
 ###############################################################################
 
-for ((; ;))
-{
-	for ((i = 0; i < 100; i++))
-	{
+while true; do
+	i=0;
+	while [ $i -lt 100 ]; do
 		echo 1 > "$TRACING_PATH"/events/enable
 		echo 0 > "$TRACING_PATH"/events/enable
-	}
+		i=$((i + 1))
+	done
 
-	for dir in `ls $TRACING_PATH/events/`
-	do
+	for dir in `ls $TRACING_PATH/events/`; do
 		if [ ! -d $dir -o "$dir" = ftrace ]; then
 			continue;
 		fi
 
-		for ((i = 0; i < 20; i++))
-		{
+		i=0;
+		while [ $i -lt 20 ]; do
 			echo 1 > "$TRACING_PATH"/events/$dir/enable
 			echo 0 > "$TRACING_PATH"/events/$dir/enable
-		}
+			i=$((i + 1))
+		done
 	done
 
-	for event in `cat $TRACING_PATH/available_events`;
-	do
+	for event in `cat $TRACING_PATH/available_events`; do
 		# ftrace event sys is special, skip it
 		if echo "$event" | grep "ftrace:*"; then
 			continue
@@ -44,4 +43,4 @@ for ((; ;))
 	done
 
 	sleep 1
-}
+done
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh +10 -11
index 3eaf017..28aafd5 100755
@@ -15,16 +15,15 @@
 
 LOOP=300
 
-
-for ((; ; ))
-{
-	for ((j = 0; j < $LOOP; j++))
-	{
-		for ((k = 1; k <= NR_PIDS; k++))
-		{
+while true; do
+	j=0;
+	while [ $j -lt $LOOP ]; do
+		k=1
+		while [ $k -le $NR_PIDS ]; do
 			str="\$pid$k"
 			eval echo $str >> "$TRACING_PATH"/set_ftrace_pid
-		}
+			k=$((k + 1))
+		done
 
 		if ! echo > "$TRACING_PATH"/set_ftrace_pid >/dev/null 2>&1; then
 			if ! echo -1 > "$TRACING_PATH"/set_ftrace_pid >/dev/null 2>&1; then
@@ -32,7 +31,7 @@ for ((; ; ))
 				exit 1
 			fi
 		fi
-	}
-
+		j=$((j + 1))
+	done
 	sleep 1
-}
+done
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh +6 -7
index 34d506b..4e84f2f 100755
@@ -15,14 +15,13 @@
 
 MAX_STACK_SIZE=8192
 
-for ((; ;))
-{
-	for ((i = 0; i < $MAX_STACK_SIZE; i += 70))
-	{
+while true; do
+	i=0;
+	while [ $i -lt $MAX_STACK_SIZE ]; do
 		echo $i > "$TRACING_PATH"/stack_max_size
 		cat "$TRACING_PATH"/stack_max_size > /dev/null
-	}
-
+		i=$((i + 1))
+	done
 	sleep 1
-}
+done
 
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh +10 -9
index 1850c26..4c2f99c 100755
@@ -15,20 +15,21 @@
 
 LOOP=400
 
-for ((; ;))
-{
-	for ((i = 0; i < $LOOP; i++))
-	{
+while true; do
+	i=0;
+	while [ $i -lt $LOOP ]; do
 		cat "$TRACING_PATH"/stack_trace > /dev/null
-	}
+		i=$((i + 1))
+	done
 
 	sleep 1
 
-	for ((i = 0; i < $LOOP; i++))
-	{
+	i=0;
+	while [ $i -lt $LOOP ]; do
 		echo 0 > /proc/sys/kernel/stack_tracer_enabled
 		echo 1 > /proc/sys/kernel/stack_tracer_enabled
-	}
+		i=$((i + 1))
+	done
 
 	sleep 1
-}
+done
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh +6 -8
index e36712b..7c45f50 100755
@@ -15,13 +15,11 @@
 
 LOOP=200
 
-for ((; ;))
-{
-	for ((i = 0; i < $LOOP; i++))
-	{
+i=0;
+while true; do
+	while [ $i -lt $LOOP ]; do
 		cat "$TRACING_PATH"/trace > /dev/null
-	}
-
+		i=$((i + 1))
+	done
 	sleep 1
-}
-
+done
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh +14 -11
index de6bbea..70135c1 100755
@@ -13,6 +13,9 @@
 #                                                                             #
 ###############################################################################
 
+. test.sh
+
+TRACING_PATH=/sys/kernel/debug/tracing/
 LOOP=400
 
 # In kernel which is older than 2.6.32, we set global clock
@@ -24,23 +27,23 @@ else
         old_kernel=0
 fi
 
-for ((; ;))
-{
-	if [ $old_kernel -eq 1 ];
-	then
-		for ((i = 0; i < $LOOP; i++))
-		{
+while true; do
+	i=0;
+	if [ $old_kernel -eq 1 ]; then
+		while [ $i -lt $LOOP ]; do
 			echo 1 > "$TRACING_PATH"/options/global-clock
 			echo 0 > "$TRACING_PATH"/options/global-clock
-		}
+			i=$((i + 1))
+		done
 	else
-		for ((i = 0; i < $LOOP; i++))
-		{
+		while [ $i -lt $LOOP ]; do
 			echo local > "$TRACING_PATH"/trace_clock
 			echo global > "$TRACING_PATH"/trace_clock
-		}
+			i=$((i + 1))
+		done
+
 	fi
 
 	sleep 1
-}
+done
 
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh +9 -10
index 47d42bc..a24008a 100755
@@ -13,10 +13,11 @@
 #                                                                             #
 ###############################################################################
 
+. test.sh
+
 ftrace_sleep()
 {
-	# usleep is not a standard command?
-	usleep 200000 2> /dev/null
+	tst_sleep 200000us
 	if [ $? -ne 0 ]; then
 		sleep 1
 	fi
@@ -33,10 +34,9 @@ trap kill_this_pid SIGUSR1
 
 LOOP=20
 
-for ((; ;))
-{
-	for ((i = 0; i < $LOOP; i++))
-	{
+while true; do
+	i=0;
+	while [ $i -lt $LOOP ]; do
 		cat "$TRACING_PATH"/trace_pipe > /dev/null &
 
 		this_pid=$!
@@ -45,8 +45,7 @@ for ((; ;))
 		wait $this_pid
 		this_pid=0
 		ftrace_sleep
-	}
-
+		i=$((i + 1))
+	done
 	sleep 2
-}
-
+done
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh +10 -9
index d7e6fd3..2691991 100755
@@ -16,6 +16,8 @@
 LOOP=200
 
 should_skip=0
+rand_gen=tst_random
+nr_cpus=`tst_ncpus`
 
 if [ ! -e "$TRACING_PATH"/function_profile_enabled ]; then
         should_skip=1
@@ -28,18 +30,17 @@ if [ $? -eq 0 ]; then
 	should_skip=1
 fi
 
-for ((; ;))
-{
+while true; do
 	if [ $should_skip -eq 1 ]; then
 		sleep 2
 		continue
 	fi
-
-	for ((i = 0; i < $LOOP; i++))
-	{
-		cat "$TRACING_PATH"/trace_stat/function0 > /dev/null 2>&1
-	}
+	cpu=$($rand_gen 0 $((nr_cpus - 1)))
+	i=0;
+	while [ $i -lt $LOOP ]; do
+		cat "$TRACING_PATH"/trace_stat/function${cpu} > /dev/null 2>&1
+		i=$((i + 1))
+	done
 
 	sleep 1
-}
-
+done
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_enabled.sh +6 -7
index 69f2ae6..559cab0 100755
@@ -16,15 +16,14 @@
 MAX_LOOP=1500
 count=0
 
-for ((; ;))
-{
+while true; do
 	count=$(( $count + 1 ))
-
-	for ((i = 0; i < $MAX_LOOP; i++))
-	{
+	i=0;
+	while [ $i -lt $MAX_LOOP ]; do
 		echo 0 > "$TRACING_PATH"/tracing_enabled
 		echo 1 > "$TRACING_PATH"/tracing_enabled
-	}
+		i=$((i + 1))
+	done
 
 	enable=$(( $count % 3 ))
 
@@ -35,5 +34,5 @@ for ((; ;))
 	fi
 
 	sleep 1
-}
+done
 
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh +7 -6
index fbaceb8..6090a91 100755
@@ -15,12 +15,13 @@
 
 MAX_LATENCY=100000
 
-for ((; ;))
-{
-	for ((i = 0; i < $MAX_LATENCY; i += 400))
-	{
+while true; do
+	i=0;
+	while [ $i -lt $MAX_LATENCY ]; do
 		echo $i > "$TRACING_PATH"/tracing_max_latency
-	}
+		i=$((i + 400))
+	done
 
 	sleep 1
-}
+
+done
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_on.sh +6 -7
index 672c223..54e2795 100755
@@ -16,15 +16,14 @@
 MAX_LOOP=1500
 count=0
 
-for ((; ;))
-{
+while true; do
 	count=$(( $count + 1 ))
-
-	for ((i = 0; i < $MAX_LOOP; i++))
-	{
+	i=0;
+	while [ $i -lt $MAX_LOOP ]; do
 		echo 0 > "$TRACING_PATH"/tracing_on
 		echo 1 > "$TRACING_PATH"/tracing_on
-	}
+		i=$((i + 1))
+	done
 
 	enable=$(( $count % 3 ))
 
@@ -35,5 +34,5 @@ for ((; ;))
 	fi
 
 	sleep 1
-}
+done
 
Signature · 1 line
1.8.3.1
#10 lore raw

PATCH v2 9/9 ftrace_stress: cleanup and use ltp API

Hi!

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh if [ $step -eq 0 ]; then · line 31

Quoted 13 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh +2 -4
@@ -26,20 +26,20 @@ if [ $step -eq 0 ]; then
 	LOOP=50
 fi
 
-for ((; ;))
-{
+while true; do
 	new_size=1
-	for ((i = 0; i < $LOOP; i++))
-	{
+	i=0;

The semicolon after i=0 is useless (and in all i=0; lines in this patch).

...

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh line 16

Quoted 9 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh +1 -0
index de6bbea..70135c1 100755
@@ -13,6 +13,9 @@
 #                                                                             #
 ###############################################################################
 
+. test.sh

No need to source test.sh for the tst_kvercmp which is a separate binary.

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh line 18

Quoted 1 line
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh +1 -0
+TRACING_PATH=/sys/kernel/debug/tracing/

Shouldn't this be propagated from the main script? What's the point of redefining it here?

Quoted 43 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh +11 -11
 LOOP=400
 
 # In kernel which is older than 2.6.32, we set global clock
@@ -24,23 +27,23 @@ else
         old_kernel=0
 fi
 
-for ((; ;))
-{
-	if [ $old_kernel -eq 1 ];
-	then
-		for ((i = 0; i < $LOOP; i++))
-		{
+while true; do
+	i=0;
+	if [ $old_kernel -eq 1 ]; then
+		while [ $i -lt $LOOP ]; do
 			echo 1 > "$TRACING_PATH"/options/global-clock
 			echo 0 > "$TRACING_PATH"/options/global-clock
-		}
+			i=$((i + 1))
+		done
 	else
-		for ((i = 0; i < $LOOP; i++))
-		{
+		while [ $i -lt $LOOP ]; do
 			echo local > "$TRACING_PATH"/trace_clock
 			echo global > "$TRACING_PATH"/trace_clock
-		}
+			i=$((i + 1))
+		done
+
 	fi
 
 	sleep 1
-}
+done
 
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh +0 -0
index 47d42bc..a24008a 100755

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh line 16

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh +1 -0
@@ -13,10 +13,11 @@
 #                                                                             #
 ###############################################################################
 
+. test.sh

You don't have to add test.sh for tst_sleep.

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh line 23

Quoted 8 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh +1 -2
 ftrace_sleep()
 {
-	# usleep is not a standard command?
-	usleep 200000 2> /dev/null
+	tst_sleep 200000us
 	if [ $? -ne 0 ]; then
 		sleep 1
 	fi

You should remove the fallback to sleep 1 if the usleep wasn't found. Ideally the whole function ftrace_sleep should be removed and you should just call tst_sleep from the main loop.

Quoted 16 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh +3 -4
@@ -33,10 +34,9 @@ trap kill_this_pid SIGUSR1
 
 LOOP=20
 
-for ((; ;))
-{
-	for ((i = 0; i < $LOOP; i++))
-	{
+while true; do
+	i=0;
+	while [ $i -lt $LOOP ]; do
 		cat "$TRACING_PATH"/trace_pipe > /dev/null &
 
 		this_pid=$!
@@ -45,8 +45,7 @@ for ((; ;))
 		wait $this_pid

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh for ((; ;)) · line 51

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh +3 -4
 		this_pid=0
 		ftrace_sleep
-	}
-
+		i=$((i + 1))
+	done
 	sleep 2
-}
-
+done

And you should also fix the kill called by the full path in this script. It should really be just kill not /bin/kill.

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh line 19

Quoted 9 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh +1 -0
index d7e6fd3..2691991 100755
@@ -16,6 +16,8 @@
 LOOP=200
 
 should_skip=0
+rand_gen=tst_random

What's the point of assigning tst_random into a variable instead of using it directly?

Quoted 31 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh +9 -9
+nr_cpus=`tst_ncpus`
 
 if [ ! -e "$TRACING_PATH"/function_profile_enabled ]; then
         should_skip=1
@@ -28,18 +30,17 @@ if [ $? -eq 0 ]; then
 	should_skip=1
 fi
 
-for ((; ;))
-{
+while true; do
 	if [ $should_skip -eq 1 ]; then
 		sleep 2
 		continue
 	fi
-
-	for ((i = 0; i < $LOOP; i++))
-	{
-		cat "$TRACING_PATH"/trace_stat/function0 > /dev/null 2>&1
-	}
+	cpu=$($rand_gen 0 $((nr_cpus - 1)))
+	i=0;
+	while [ $i -lt $LOOP ]; do
+		cat "$TRACING_PATH"/trace_stat/function${cpu} > /dev/null 2>&1
+		i=$((i + 1))
+	done
 
 	sleep 1
-}
-
+done

...

Quoted 14 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh +2 -4
index fbaceb8..6090a91 100755
@@ -15,12 +15,13 @@
 
 MAX_LATENCY=100000
 
-for ((; ;))
-{
-	for ((i = 0; i < $MAX_LATENCY; i += 400))
-	{
+while true; do
+	i=0;

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh line 27

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh +5 -2
+	while [ $i -lt $MAX_LATENCY ]; do
 		echo $i > "$TRACING_PATH"/tracing_max_latency
-	}
+		i=$((i + 400))
+	done
 
 	sleep 1
-}
+
+Vdone

^
Typo?

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

PATCH v2 9/9 ftrace_stress: cleanup and use ltp API

Hi Cyril,

Thank you for reading this. But this patch is depending on previous patches, not a dependent one, it can't be applied cleanly without several patches. we can first work on the tst_random, which is totally independent. And will fixes the issues you mentioned in this series.

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

Quoted 15 lines

From: "Cyril Hrubis" <[email protected]>
To: "Chunyu Hu" <[email protected]>
Cc: [email protected], [email protected]
Sent: Wednesday, May 4, 2016 10:56:30 PM
Subject: Re: [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API

Hi!

Quoted 8 lines

---
a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh
+++
b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh

(quoted diff) +0 -0
@@ -26,20 +26,20 @@ if [ $step -eq 0 ]; then
 	LOOP=50
 fi
 
Quoted 10 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh if [ $step -eq 0 ]; then · line 31

Quoted 7 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh +2 -4
-for ((; ;))
-{
+while true; do
 	new_size=1
-	for ((i = 0; i < $LOOP; i++))
-	{
+	i=0;

The semicolon after i=0 is useless (and in all i=0; lines in this patch).

Thanks, new knowledge to me. will do remove.

Quoted 15 lines

...

Quoted 13 lines

diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh index de6bbea..70135c1 100755
---
a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh
+++
b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh +0 -0
@@ -13,6 +13,9 @@
 #
 #
 ###############################################################################
 
Quoted 4 lines

Review line 17

Quoted 1 line
(quoted diff) +1 -0
+. test.sh

No need to source test.sh for the tst_kvercmp which is a separate binary.

OK. We just remove it in next version, we indeed didn't call it here.

Quoted 4 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh line 18

Quoted 1 line
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh +1 -0
+TRACING_PATH=/sys/kernel/debug/tracing/

Shouldn't this be propagated from the main script? What's the point of redefining it here?

Thanks, I think you are right. this is defined in ftrace_lib.sh and not needed to be redefined here. will remove in next version.

Quoted 51 lines
Quoted 51 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh +11 -11
 LOOP=400
 
 # In kernel which is older than 2.6.32, we set global clock
@@ -24,23 +27,23 @@ else
         old_kernel=0
 fi
 
-for ((; ;))
-{
-	if [ $old_kernel -eq 1 ];
-	then
-		for ((i = 0; i < $LOOP; i++))
-		{
+while true; do
+	i=0;
+	if [ $old_kernel -eq 1 ]; then
+		while [ $i -lt $LOOP ]; do
 			echo 1 > "$TRACING_PATH"/options/global-clock
 			echo 0 > "$TRACING_PATH"/options/global-clock
-		}
+			i=$((i + 1))
+		done
 	else
-		for ((i = 0; i < $LOOP; i++))
-		{
+		while [ $i -lt $LOOP ]; do
 			echo local > "$TRACING_PATH"/trace_clock
 			echo global > "$TRACING_PATH"/trace_clock
-		}
+			i=$((i + 1))
+		done
+
 	fi
 
 	sleep 1
-}
+done
 

diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh index 47d42bc..a24008a 100755
---
a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh
+++
b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh +0 -0
@@ -13,10 +13,11 @@
 #
 #
 ###############################################################################
 
Quoted 3 lines

Review line 17

Quoted 1 line
(quoted diff) +1 -0
+. test.sh

You don't have to add test.sh for tst_sleep.

OK. will remove this.

Quoted 4 lines
Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh +0 -2
 ftrace_sleep()
 {
-	# usleep is not a standard command?
-	usleep 200000 2> /dev/null
Quoted 8 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh line 23

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh +1 -0
+	tst_sleep 200000us
 	if [ $? -ne 0 ]; then
 		sleep 1
 	fi

You should remove the fallback to sleep 1 if the usleep wasn't found. Ideally the whole function ftrace_sleep should be removed and you should just call tst_sleep from the main loop.

I think using tst_sleep directly is good way. thanks.

Quoted 13 lines
Quoted 13 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh +3 -4
@@ -33,10 +34,9 @@ trap kill_this_pid SIGUSR1
 
 LOOP=20
 
-for ((; ;))
-{
-	for ((i = 0; i < $LOOP; i++))
-	{
+while true; do
+	i=0;
+	while [ $i -lt $LOOP ]; do
 		cat "$TRACING_PATH"/trace_pipe > /dev/null &
 
Quoted 16 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh for ((; ;)) · line 51

Quoted 13 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh +3 -4
 		this_pid=$!
@@ -45,8 +45,7 @@ for ((; ;))
 		wait $this_pid
 		this_pid=0
 		ftrace_sleep
-	}
-
+		i=$((i + 1))
+	done
 	sleep 2
-}
-
+done

And you should also fix the kill called by the full path in this script. It should really be just kill not /bin/kill.

OK. Will fix this.

Quoted 11 lines
Quoted 11 lines

diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh index d7e6fd3..2691991 100755
---
a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh
+++
b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh

(quoted diff) +0 -0
@@ -16,6 +16,8 @@
 LOOP=200
 
Quoted 5 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh line 19

Quoted 2 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh +1 -0
 should_skip=0
+rand_gen=tst_random

What's the point of assigning tst_random into a variable instead of using it directly?

at the moment as this is still not in the test lib,so it is just marking a pending state. If that generator can be included, we can remove this and use it directly.

Quoted 58 lines
Quoted 31 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh +9 -9
+nr_cpus=`tst_ncpus`
 
 if [ ! -e "$TRACING_PATH"/function_profile_enabled ]; then
         should_skip=1
@@ -28,18 +30,17 @@ if [ $? -eq 0 ]; then
 	should_skip=1
 fi
 
-for ((; ;))
-{
+while true; do
 	if [ $should_skip -eq 1 ]; then
 		sleep 2
 		continue
 	fi
-
-	for ((i = 0; i < $LOOP; i++))
-	{
-		cat "$TRACING_PATH"/trace_stat/function0 > /dev/null 2>&1
-	}
+	cpu=$($rand_gen 0 $((nr_cpus - 1)))
+	i=0;
+	while [ $i -lt $LOOP ]; do
+		cat "$TRACING_PATH"/trace_stat/function${cpu} > /dev/null 2>&1
+		i=$((i + 1))
+	done
 
 	sleep 1
-}
-
+done

...

Quoted 24 lines

diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh index fbaceb8..6090a91 100755
---
a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh
+++
b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh +5 -5
@@ -15,12 +15,13 @@
 
 MAX_LATENCY=100000
 
-for ((; ;))
-{
-	for ((i = 0; i < $MAX_LATENCY; i += 400))
-	{
+while true; do
+	i=0;
+	while [ $i -lt $MAX_LATENCY ]; do
 		echo $i > "$TRACING_PATH"/tracing_max_latency
-	}
+		i=$((i + 400))
+	done
 
Quoted 6 lines

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

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh +2 -1
 	sleep 1
-}
+
+Vdone

^
Typo?

Here it is weird, I checked my repo and my email in ltp list, there is no char 'V', I will have a deeper check.

Quoted 4 lines

--
Cyril Hrubis
[email protected]

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

PATCH v2 9/9 ftrace_stress: cleanup and use ltp API

Hi!

Quoted 31 lines
Quoted 24 lines
Quoted 24 lines

diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh index fbaceb8..6090a91 100755
---
a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh
+++
b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh +5 -5
@@ -15,12 +15,13 @@
 
 MAX_LATENCY=100000
 
-for ((; ;))
-{
-	for ((i = 0; i < $MAX_LATENCY; i += 400))
-	{
+while true; do
+	i=0;
+	while [ $i -lt $MAX_LATENCY ]; do
 		echo $i > "$TRACING_PATH"/tracing_max_latency
-	}
+		i=$((i + 400))
+	done
 
Quoted 6 lines

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

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh +2 -1
 	sleep 1
-}
+
+Vdone

^
Typo?

Quoted 2 lines

Here it is weird, I checked my repo and my email in ltp list, there is no char 'V', I will have a deeper check.

Looks like this was a typo on my side. I've must have pressed the key by accident when I was editing a reply to the email. Sorry for the confusion.

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

PATCH v2 9/9 ftrace_stress: cleanup and use ltp API

In reply to Chunyu Hu

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

Quoted 41 lines

From: "Chunyu Hu" <[email protected]>
To: "Cyril Hrubis" <[email protected]>
Cc: [email protected], [email protected]
Sent: Wednesday, May 4, 2016 11:42:48 PM
Subject: Re: [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API

Hi Cyril,

Quoted 13 lines
Quoted 13 lines

diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh index 47d42bc..a24008a 100755
---
a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh
+++
b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh +0 -0
@@ -13,10 +13,11 @@
 #
 #
 ###############################################################################
 
Quoted 3 lines

Review line 17

Quoted 1 line
(quoted diff) +1 -0
+. test.sh

You don't have to add test.sh for tst_sleep.

OK. will remove this.

Quoted 4 lines
Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh +0 -2
 ftrace_sleep()
 {
-	# usleep is not a standard command?
-	usleep 200000 2> /dev/null
Quoted 8 lines

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh line 23

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh +1 -0
+	tst_sleep 200000us
 	if [ $? -ne 0 ]; then
 		sleep 1
 	fi

You should remove the fallback to sleep 1 if the usleep wasn't found. Ideally the whole function ftrace_sleep should be removed and you should just call tst_sleep from the main loop.

Quoted 32 lines

I think using tst_sleep directly is good way. thanks.

Quoted 29 lines
Quoted 16 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh +3 -4
@@ -33,10 +34,9 @@ trap kill_this_pid SIGUSR1
 
 LOOP=20
 
-for ((; ;))
-{
-	for ((i = 0; i < $LOOP; i++))
-	{
+while true; do
+	i=0;
+	while [ $i -lt $LOOP ]; do
 		cat "$TRACING_PATH"/trace_pipe > /dev/null &
 
 		this_pid=$!
@@ -45,8 +45,7 @@ for ((; ;))
 		wait $this_pid

testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh for ((; ;)) · line 51

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh +3 -4
 		this_pid=0
 		ftrace_sleep
-	}
-
+		i=$((i + 1))
+	done
 	sleep 2
-}
-
+done

And you should also fix the kill called by the full path in this script. It should really be just kill not /bin/kill.

Hi Cyril,

After i changing it to kill directly and retest it, i hit err message:

ftrace_trace_pipe.sh: line 18: kill: SIGKILL: invalid signal specification

then i found that kill is also one of the bash built-in cmd. So we'd better still use /bin/kill in this case.

# type kill
kill is a shell builtin

bash-4.2.46-19.el7.x86_64

#14 lore raw

PATCH v2 9/9 ftrace_stress: cleanup and use ltp API

Hi!

Quoted 3 lines

After i changing it to kill directly and retest it, i hit err message:

ftrace_trace_pipe.sh: line 18: kill: SIGKILL: invalid signal specification

That is because POSIX only accepts symbolic names without the SIG prefix while kill from procps works with both.

The correct way to send SIGKILL is 'kill -KILL $pid'.

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

PATCH v2 9/9 ftrace_stress: cleanup and use ltp API

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

Quoted 7 lines

From: "Cyril Hrubis" <[email protected]>
To: "Chunyu Hu" <[email protected]>
Cc: [email protected], [email protected]
Sent: Tuesday, May 10, 2016 10:13:00 PM
Subject: Re: [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API

Hi!

Quoted 8 lines
Quoted 3 lines

After i changing it to kill directly and retest it, i hit err message:

ftrace_trace_pipe.sh: line 18: kill: SIGKILL: invalid signal specification

That is because POSIX only accepts symbolic names without the SIG prefix while kill from procps works with both.

The correct way to send SIGKILL is 'kill -KILL $pid'.

Thanks. Really makes sense. Will fix it with V3-2. please ignore the previous V3. that's not complete considering this.

Quoted 4 lines

--
Cyril Hrubis
[email protected]

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

PATCH v2 7/9 ftrace_stress: update the trace_options test

In reply to Chunyu Hu

Hi!

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

Quoted 9 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh +9 -0
+			if [ $ret_val -ne 0 ]; then
+				tst_resm TFAIL "$0: $operation trace option $option failed"
+			fi
+			i=$((i + 1))
+		done
+		j=$((j + 1))
+	done
+	# sleep is not needed if ftrace can surrive.
+	# tst_sleep 1s

Just remove these lines if they are not needed.

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

PATCH v2 6/9 testcases/lib: Add tst_random decmical integer generator

In reply to Chunyu Hu

Hi!

Quoted 71 lines

include $(top_srcdir)/include/mk/generic_leaf_target.mk

testcases/lib/tst_random.c new file +64 -0
new file mode 100644
index 0000000..91a5247
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2016 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.
+ *
+ * This program is distributed in the hope that it would 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 the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Chunyu Hu <[email protected]>
+ *
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+static void print_help(void)
+{
+	printf("Usage: tst_random <value1> [value2]\n");
+	printf("       Generated random will be between value1 and value2.\n");
+	printf("       If only value1 is specified, value2 will treated as 0.\n");
+}
+
+static int get_seed(void)
+{
+	struct timeval tv;
+	gettimeofday(&tv, NULL);
+	return tv.tv_usec;
+}
+
+static long rand_range(long min, long max)
+{
+	return rand() % (max - min + 1) + min;
+}
+
+int main(int argc, char *argv[])
+{
+	int opt;
+	long min = 0, max = 0, tmp = 0;
+	long rval = 0;
+	char *end;
+
+	while ((opt = getopt(argc, argv, ":h")) != -1) {
+		switch (opt) {
+		case 'h':
+			print_help();
+			return 0;
+		default:
+			print_help();
+			return 1;
+		}
+	}
+

testcases/lib/tst_random.c line 74

Quoted 10 lines
testcases/lib/tst_random.c new file +10 -0
+	if (argc < 2 || argc > 3) {
+		print_help();
+		return 1;
+	}
+
+	if (optind >= argc) {
+		fprintf(stderr, "ERROR: Expected one or two range_val arguments\n\n");
+		print_help();
+		return 1;
+	}

We exit if getopt() finds any options in argv[] so optind == 1 here and since we check for argc < 2 before this this if is never true.

testcases/lib/tst_random.c line 76

Quoted 1 line
testcases/lib/tst_random.c new file +1 -0
+	max = strtol(argv[optind], &end, 10);

Here as well optind == 1 by definition.

testcases/lib/tst_random.c line 82

Quoted 6 lines
testcases/lib/tst_random.c new file +6 -0
+	if (argv[optind] == end) {
+		fprintf(stderr, "ERROR: Invalid range value1 '%s'\n\n",
+			argv[optind]);
+		print_help();
+		return 1;
+	}

Well if we bother with strtol() we may check that argv[1] != '\0' and end == '\0' which will ensure that whole parameter was a valid string.

testcases/lib/tst_random.c line 85

Quoted 2 lines
testcases/lib/tst_random.c new file +2 -0
+	if (argc == 3) {
+		min = strtol(argv[optind+1], &end, 10);

Here as well use just 2 instead of optind + 1.

testcases/lib/tst_random.c line 96

Quoted 11 lines
testcases/lib/tst_random.c new file +11 -0
+		if (argv[optind+1] == end) {
+			fprintf(stderr, "ERROR: Invalid range value2 '%s'\n\n",
+				argv[optind+1]);
+			print_help();
+			return 1;
+		}
+		if (min > max) {
+			tmp = min;
+			min = max;
+			max = tmp;
+		}

Well we may also do:

	rval = (min > max) ? rand_range(max, min) : rand_range(min, max);

In the code below instead, but that is merely cosmetic.

testcases/lib/tst_random.c line 103

Quoted 7 lines
testcases/lib/tst_random.c new file +7 -0
+	}
+
+	srand(get_seed());
+	rval = rand_range(min, max);
+	printf("%ld\n", rval);
+
+	return rval;

We should just return 0 here since the return value is limited to one byte. Exporting interface that works only in certain cases is a recipe for a disaster.

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

PATCH v2 6/9 testcases/lib: Add tst_random decmical integer generator

Hi,

Thank you for the quick review, will submit a new version soon,

Other tests indeed referenced this helper. Also added some comment

below.

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

Quoted 84 lines

From: "Cyril Hrubis" <[email protected]>
To: "Chunyu Hu" <[email protected]>
Cc: [email protected], [email protected]
Sent: Wednesday, May 4, 2016 9:34:53 PM
Subject: Re: [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator

Hi!

Quoted 77 lines

include $(top_srcdir)/include/mk/generic_leaf_target.mk

testcases/lib/tst_random.c new file +32 -0
new file mode 100644
index 0000000..91a5247
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2016 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.
+ *
+ * This program is distributed in the hope that it would 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 the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Chunyu Hu <[email protected]>
+ *
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+static void print_help(void)
+{
+	printf("Usage: tst_random <value1> [value2]\n");
+	printf("       Generated random will be between value1 and value2.\n");
+	printf("       If only value1 is specified, value2 will treated as

0.\n");

testcases/lib/tst_random.c new file +37 -0
+}
+
+static int get_seed(void)
+{
+	struct timeval tv;
+	gettimeofday(&tv, NULL);
+	return tv.tv_usec;
+}
+
+static long rand_range(long min, long max)
+{
+	return rand() % (max - min + 1) + min;
+}
+
+int main(int argc, char *argv[])
+{
+	int opt;
+	long min = 0, max = 0, tmp = 0;
+	long rval = 0;
+	char *end;
+
+	while ((opt = getopt(argc, argv, ":h")) != -1) {
+		switch (opt) {
+		case 'h':
+			print_help();
+			return 0;
+		default:
+			print_help();
+			return 1;
+		}
+	}
+
+	if (argc < 2 || argc > 3) {
+		print_help();
+		return 1;
+	}
+
Quoted 8 lines

testcases/lib/tst_random.c line 74

Quoted 5 lines
testcases/lib/tst_random.c new file +5 -0
+	if (optind >= argc) {
+		fprintf(stderr, "ERROR: Expected one or two range_val arguments\n\n");
+		print_help();
+		return 1;
+	}

We exit if getopt() finds any options in argv[] so optind == 1 here and since we check for argc < 2 before this this if is never true.

Good analysis, so this should be removed in next step.

Quoted 4 lines

testcases/lib/tst_random.c line 76

Quoted 2 lines
testcases/lib/tst_random.c new file +1 -0
+	max = strtol(argv[optind], &end, 10);

Here as well optind == 1 by definition.

Ok, will use 1 directly next step.

Quoted 10 lines

testcases/lib/tst_random.c line 82

Quoted 7 lines
testcases/lib/tst_random.c new file +6 -0
+	if (argv[optind] == end) {
+		fprintf(stderr, "ERROR: Invalid range value1 '%s'\n\n",
+			argv[optind]);
+		print_help();
+		return 1;
+	}

Well if we bother with strtol() we may check that argv[1] != '\0' and end == '\0' which will ensure that whole parameter was a valid string.

Looks like we just need to compare with ( *end != '\0' ), as argv[1] or argv[2] can't be '\0' (NULL) as it has been filtered by (argc <2 || argc > 3).

And i just verified this with this debug line:

   printf("end = %p, *end = %c\n", end, *end);
Quoted 4 lines

testcases/lib/tst_random.c line 85

Quoted 2 lines
testcases/lib/tst_random.c new file +2 -0
+	if (argc == 3) {
+		min = strtol(argv[optind+1], &end, 10);

Here as well use just 2 instead of optind + 1.

OK. Agree.

Quoted 15 lines

testcases/lib/tst_random.c line 96

Quoted 12 lines
testcases/lib/tst_random.c new file +11 -0
+		if (argv[optind+1] == end) {
+			fprintf(stderr, "ERROR: Invalid range value2 '%s'\n\n",
+				argv[optind+1]);
+			print_help();
+			return 1;
+		}
+		if (min > max) {
+			tmp = min;
+			min = max;
+			max = tmp;
+		}

Well we may also do:

Quoted 1 line
	rval = (min > max) ? rand_range(max, min) : rand_range(min, max);

Thanks for this good advise, i really like this style.

Quoted 1 line

In the code below instead, but that is merely cosmetic.

Thanks.

Quoted 12 lines

testcases/lib/tst_random.c line 103

Quoted 8 lines
testcases/lib/tst_random.c new file +7 -0
+	}
+
+	srand(get_seed());
+	rval = rand_range(min, max);
+	printf("%ld\n", rval);
+
+	return rval;

We should just return 0 here since the return value is limited to one byte. Exporting interface that works only in certain cases is a recipe for a disaster.

Thanks for catching this, can't agree more. Will fix this line in next step.

Quoted 4 lines

--
Cyril Hrubis
[email protected]

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

PATCH v2 6/9 testcases/lib: Add tst_random decmical integer generator

Hi!

Quoted 6 lines

Looks like we just need to compare with ( *end != '\0' ), as argv[1] or argv[2] can't be '\0' (NULL) as it has been filtered by (argc <2 || argc > 3).

And i just verified this with this debug line:

   printf("end = %p, *end = %c\n", end, *end);

What will happen when you call:

tst_random "" ""

Or more realistic case when FOO is not defined and you do:

tst_random "$FOO"

Note that empty string in C is an array with first element set to 0.

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

PATCH v2 6/9 testcases/lib: Add tst_random decmical integer generator

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

Quoted 17 lines

From: "Cyril Hrubis" <[email protected]>
To: "Chunyu Hu" <[email protected]>
Cc: [email protected], [email protected]
Sent: Wednesday, May 4, 2016 11:55:31 PM
Subject: Re: [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator

Hi!

Quoted 7 lines

Looks like we just need to compare with ( *end != '\0' ), as argv[1] or argv[2] can't be '\0' (NULL) as it has been filtered by (argc <2 || argc > 3).

And i just verified this with this debug line:

   printf("end = %p, *end = %c\n", end, *end);

What will happen when you call:

Quoted 7 lines

tst_random "" ""

Or more realistic case when FOO is not defined and you do:

tst_random "$FOO"

Note that empty string in C is an array with first element set to 0.

I was so hurried to send out the patch :/. You are right. I missed your mentioned here. I added some debug line, proving you are right.

        printf("argv[1] = [%d]\n", argv[1][0]);
        printf("argv[3] = [%d]\n", argv[3]);
        printf("end = %p, *end = [%d]\n", end, *end);

./a.out "" ""

argv[1] = [0]
argv[3] = [0]
end = 0x7ffc3d49861f, *end = [0]

I will reorganize this check later, my brain is so slow now. Thank you.

Quoted 4 lines

--
Cyril Hrubis
[email protected]

Signature · 2 lines
Regards,
Chunyu Hu
author
#21 lore raw

PATCH v2 6/9 testcases/lib: Add tst_random decmical integer generator

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

Quoted 8 lines

From: "Chunyu Hu" <[email protected]>
To: "Cyril Hrubis" <[email protected]>
Cc: [email protected], [email protected]
Sent: Thursday, May 5, 2016 12:28:30 AM
Subject: Re: [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator

Quoted 13 lines

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

Quoted 12 lines

From: "Cyril Hrubis" <[email protected]>
To: "Chunyu Hu" <[email protected]>
Cc: [email protected], [email protected]
Sent: Wednesday, May 4, 2016 11:55:31 PM
Subject: Re: [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator

Hi!

Quoted 4 lines

Looks like we just need to compare with ( *end != '\0' ), as argv[1] or argv[2] can't be '\0' (NULL) as it has been filtered by (argc <2 || argc

Quoted 1 line

3).

I proved to be wrong, which pointed bye you below. BTW, i also changed the argc check way to

if (argc != 2 && argc != 3)

I think this clearer than
if (argc < 2 || argc > 3 )

Quoted 22 lines
Quoted 6 lines
Quoted 3 lines

And i just verified this with this debug line:

   printf("end = %p, *end = %c\n", end, *end);

What will happen when you call:

Quoted 7 lines

tst_random "" ""

Or more realistic case when FOO is not defined and you do:

tst_random "$FOO"

Note that empty string in C is an array with first element set to 0.

I was so hurried to send out the patch :/. You are right. I missed your mentioned here. I added some debug line, proving you are right.

        printf("argv[1] = [%d]\n", argv[1][0]);
        printf("argv[3] = [%d]\n", argv[3]);
        printf("end = %p, *end = [%d]\n", end, *end);
Quoted 7 lines

./a.out "" ""

argv[1] = [0]
argv[3] = [0]
end = 0x7ffc3d49861f, *end = [0]

I will reorganize this check later, my brain is so slow now. Thank you.

after some rest, i considered it as your suggestion and man page. I think below condition is enough, if you don't have objection for this, i will use this in next step. Thanks.

if (!(argv[1][0] != '\0' && *end == '\0'))

Quoted 13 lines
Quoted 5 lines

--
Cyril Hrubis
[email protected]

--
Regards,
Chunyu Hu

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

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

PATCH v2 4/9 ftrace_stress: skip unsupported tests

In reply to Chunyu Hu

Hi!

Quoted 102 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +23 -56
index d9f7f8b..80c914c 100755
@@ -21,87 +21,92 @@
 ##                                                                       ##
 ###########################################################################
 
-
 export TCID="ftrace-stress-test"
 export TST_TOTAL=1
 export TST_COUNT=1
 
 . ftrace_lib.sh
 
-test_success=true
+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_pids()
+get_skip_targets()
 {
-	export pid1 pid2 pid3 pid4 pid5 pid6 pid7 pid8 pid9 pid10 pid11 pid12 \
-		pid13 pid14 pid15 pid16
-
-	export NR_PIDS=16
+	NR_PIDS=0
+	for target in ${test_targets}; do
+		if [ ! -e $TRACING_PATH/$target ] &&
+			[ ! -e /proc/sys/kernel/$target ]; then
+			eval skip_$target=1
+			tst_resm TINFO "$target is not supported. Skip it."
+		else
+			eval skip_$target=0
+			NR_PIDS=$((NR_PIDS + 1))
+		fi
+	done
+	# Export it before sub case is lanuched.
+	export NR_PIDS
 }
 
-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
-	kill -KILL $pid14 || test_success=false

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

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +8 -2
-	kill -KILL $pid15 || test_success=false
-	kill -KILL $pid16 || test_success=false
+	tst_resm TINFO "killing ${pid0}"
+	kill -USR1 ${pid0}
+	wait ${pid0}
+
+	local p=1;
+	while [ $p -lt $NR_PIDS ]; do
+                local kill_pid=pid${p}
+                kill -KILL ${!kill_pid}
                                ^
				Bashism.

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

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +4 -0
+		tst_resm TINFO "killing ${!kill_pid}"
+                wait ${!kill_pid}
+                p=$((p + 1))
+        done

This part seems to have misformatted whitespaces, please fix that.

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

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

The wait is done here, OK. But you should have dropped the sleep 2.

Quoted 22 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +19 -0
 	clean_up
 }
 
+test_stress()
+{
+	local index=0;
+
+	tst_resm TINFO "Test targets: ${test_targets}"
+
+	get_skip_targets
+	for target in ${test_targets}; do
+		if should_skip_target $target; then
+			continue
+		fi
+		sh ftrace_${target}.sh &
+		eval pid${index}=$!
+		tst_resm TINFO "Start pid${index}=$! $SPATH/ftrace_${target}.sh"
+		index=$((index + 1))
+	done
+	export_pids
+}
+

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

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +9 -0
+export_pids()
+{
+	local p=0
+	while [ $p -lt $NR_PIDS ]; do
+		export pid${p}
+		p=$((p + 1))
+	done
+}
 
+cd ftrace_stress/

Why the cd? It does not seem to be needed.

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

Quoted 12 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +2 -2
 # ----------------------------
-echo "Ftrace Stress Test Begin"
+tst_resm TINFO "Ftrace Stress Test Begin"
 
 save_old_setting
 
@@ -113,11 +118,6 @@ test_wait
 
 test_kill
 
-echo "Ftrace Stress Test End"
+tst_resm TINFO "Finished running the test. Run dmesg to double-check for bugs"

Well most of the things I've pointed out seems to be fixed but I still fail to see the restore_old_setting here. Or do I miss someting?

Quoted 7 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +1 -6
-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
+tst_exit
Signature · 2 lines
Cyril Hrubis
[email protected]
author
#23 lore raw

PATCH v2 4/9 ftrace_stress: skip unsupported tests

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

Quoted 84 lines

From: "Cyril Hrubis" <[email protected]>
To: "Chunyu Hu" <[email protected]>
Cc: [email protected], [email protected]
Sent: Thursday, May 5, 2016 12:50:50 AM
Subject: Re: [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests

Hi!

Quoted 77 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +20 -36
index d9f7f8b..80c914c 100755
@@ -21,87 +21,92 @@
 ##
 ##
 ###########################################################################
 
-
 export TCID="ftrace-stress-test"
 export TST_TOTAL=1
 export TST_COUNT=1
 
 . ftrace_lib.sh
 
-test_success=true
+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_pids()
+get_skip_targets()
 {
-	export pid1 pid2 pid3 pid4 pid5 pid6 pid7 pid8 pid9 pid10 pid11 pid12 \
-		pid13 pid14 pid15 pid16
-
-	export NR_PIDS=16
+	NR_PIDS=0
+	for target in ${test_targets}; do
+		if [ ! -e $TRACING_PATH/$target ] &&
+			[ ! -e /proc/sys/kernel/$target ]; then
+			eval skip_$target=1
+			tst_resm TINFO "$target is not supported. Skip it."
+		else
+			eval skip_$target=0
+			NR_PIDS=$((NR_PIDS + 1))
+		fi
+	done
+	# Export it before sub case is lanuched.
+	export NR_PIDS
 }
 
-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=$!
Quoted 8 lines

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

Quoted 8 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +2 -6
-	$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}

I found here i was using bashism too as your pointed below.

Quoted 23 lines
Quoted 23 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +3 -16
+	[ "$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
-	kill -KILL $pid14 || test_success=false
-	kill -KILL $pid15 || test_success=false
-	kill -KILL $pid16 || test_success=false
+	tst_resm TINFO "killing ${pid0}"
+	kill -USR1 ${pid0}
Quoted 8 lines

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

Quoted 6 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +6 -0
+	wait ${pid0}
+
+	local p=1;
+	while [ $p -lt $NR_PIDS ]; do
+                local kill_pid=pid${p}
+                kill -KILL ${!kill_pid}
                                ^
				Bashism.

I am trying to change to use this way

    local pid_var=pid${p}
                eval local kill_pid=\$${pid_var}
                tst_resm TINFO "killing ${kill_pid}"
                eval kill -KILL $kill_pid
                wait ${kill_pid}

maybe i'm still using bashism? thanks. if it's ok then i will use this way.

Ideally i should find a dash to try. but i have not found the package in rhel.

Quoted 7 lines

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

Quoted 5 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +4 -0
+		tst_resm TINFO "killing ${!kill_pid}"
+                wait ${!kill_pid}
+                p=$((p + 1))
+        done

This part seems to have misformatted whitespaces, please fix that.

OK. Noticed, fixed in my local repo now.

Quoted 4 lines

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

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

The wait is done here, OK. But you should have dropped the sleep 2.

OK. removed in my local now. Won't see it in next step.

Quoted 1 line

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

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

Here i will call restore_ path. but i think we'd better move it out of test_kill to main path, it's not appropriate in that func.

Quoted 30 lines
Quoted 30 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +27 -0
 }
 
+test_stress()
+{
+	local index=0;
+
+	tst_resm TINFO "Test targets: ${test_targets}"
+
+	get_skip_targets
+	for target in ${test_targets}; do
+		if should_skip_target $target; then
+			continue
+		fi
+		sh ftrace_${target}.sh &
+		eval pid${index}=$!
+		tst_resm TINFO "Start pid${index}=$! $SPATH/ftrace_${target}.sh"
+		index=$((index + 1))
+	done
+	export_pids
+}
+
+export_pids()
+{
+	local p=0
+	while [ $p -lt $NR_PIDS ]; do
+		export pid${p}
+		p=$((p + 1))
+	done
+}
 
Quoted 3 lines

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

Quoted 1 line
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +1 -0
+cd ftrace_stress/

Why the cd? It does not seem to be needed.

as currently we are in ftrace_test/, but sub stresses cases are in ftrace_test/ftrace_stress/

in test_stress(), i start the sub script using

  sh ftrace_${target}.sh &

This make the path shorter. If you don't have objection, I will move the cd ftrace_stress/ into test_stress(). What do you think of this?

Quoted 9 lines
Quoted 9 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +1 -1
 # ----------------------------
-echo "Ftrace Stress Test Begin"
+tst_resm TINFO "Ftrace Stress Test Begin"
 
 save_old_setting
 
@@ -113,11 +118,6 @@ test_wait
 
Quoted 8 lines
Quoted 5 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +1 -1
 test_kill
 
-echo "Ftrace Stress Test End"
+tst_resm TINFO "Finished running the test. Run dmesg to double-check for

bugs"

Well most of the things I've pointed out seems to be fixed but I still fail to see the restore_old_setting here. Or do I miss someting?

in ftrace_lib.sh , you can see a clean_up which calls the restore path. Looks like leave it in clean_up can make things simpler. you mentioned ltp can setup cleanup callback, if one clean_up can do all. then that's good to put it there with other clean steps together. your opinion?

Quoted 15 lines

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

Quoted 8 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +0 -2
-if $test_success; then
-	tst_resm TPASS "finished running the test. Run dmesg to double-check for

bugs"

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +1 -4
-else
-	tst_resm TFAIL "please check log message."
-	exit 1
-fi
+tst_exit

--
Cyril Hrubis
[email protected]

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

PATCH v2 4/9 ftrace_stress: skip unsupported tests

Hi!

Quoted 15 lines
Quoted 6 lines

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

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +4 -0
+	local p=1;
+	while [ $p -lt $NR_PIDS ]; do
+                local kill_pid=pid${p}
+                kill -KILL ${!kill_pid}
                                ^
				Bashism.

I am trying to change to use this way

    local pid_var=pid${p}
                eval local kill_pid=\$${pid_var}
                tst_resm TINFO "killing ${kill_pid}"
                eval kill -KILL $kill_pid
                wait ${kill_pid}
Quoted 5 lines

maybe i'm still using bashism? thanks. if it's ok then i will use this way.

Ideally i should find a dash to try. but i have not found the package in rhel.

You can always compile it from source:

http://gondor.apana.org.au/~herbert/dash/files/

And there also seems to be debian devel perl script that can check for bashism, maybe we can start using it to check shell scripts:

https://anonscm.debian.org/cgit/collab-maint/devscripts.git/tree/scripts/checkbashisms.pl

Quoted 16 lines
Quoted 9 lines
Quoted 9 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +8 -0
+export_pids()
+{
+	local p=0
+	while [ $p -lt $NR_PIDS ]; do
+		export pid${p}
+		p=$((p + 1))
+	done
+}
Quoted 3 lines
Quoted 1 line

+cd ftrace_stress/

Why the cd? It does not seem to be needed.

as currently we are in ftrace_test/, but sub stresses cases are in ftrace_test/ftrace_stress/

Quoted 7 lines

in test_stress(), i start the sub script using

  sh ftrace_${target}.sh &

This make the path shorter. If you don't have objection, I will move the cd ftrace_stress/ into test_stress(). What do you think of this?

The stress tests are installed into $DESTDIR/testcases/bin/ aren't they?

If that is the case these scripts are in $PATH and could be executed without fiddling with full path.

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

PATCH v2 4/9 ftrace_stress: skip unsupported tests

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

Quoted 25 lines

From: "Cyril Hrubis" <[email protected]>
To: "Chunyu Hu" <[email protected]>
Cc: [email protected], [email protected]
Sent: Tuesday, May 10, 2016 10:25:04 PM
Subject: Re: [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests

Hi!

Quoted 18 lines
Quoted 6 lines

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

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +4 -0
+	local p=1;
+	while [ $p -lt $NR_PIDS ]; do
+                local kill_pid=pid${p}
+                kill -KILL ${!kill_pid}
                                ^
				Bashism.

I am trying to change to use this way

    local pid_var=pid${p}
                eval local kill_pid=\$${pid_var}
                tst_resm TINFO "killing ${kill_pid}"
                eval kill -KILL $kill_pid
                wait ${kill_pid}

maybe i'm still using bashism? thanks. if it's ok then i will use this way.

Quoted 6 lines
Quoted 2 lines

Ideally i should find a dash to try. but i have not found the package in rhel.

You can always compile it from source:

http://gondor.apana.org.au/~herbert/dash/files/

Thanks. I compiled and tried, although test didn't hit issue, but this is all because it's using sh xxxxx.sh to execute sub tests, if i executed the cmd on bash directly, it would tell me the error.

Quoted 5 lines

And there also seems to be debian devel perl script that can check for bashism, maybe we can start using it to check shell scripts:

https://anonscm.debian.org/cgit/collab-maint/devscripts.git/tree/scripts/checkbashisms.pl

Thanks for the useful info, I tried the tool, it did find the bashism issue of ${!var}. and it also found another issue in ftrace_tracing_cpu_mask.sh of $(( a | (1 << $b) )), i have changed to use $((a | $(( 1 << $b)) )) instead.

Quoted 20 lines
Quoted 20 lines
Quoted 9 lines
Quoted 9 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +8 -0
+export_pids()
+{
+	local p=0
+	while [ $p -lt $NR_PIDS ]; do
+		export pid${p}
+		p=$((p + 1))
+	done
+}
Quoted 3 lines
Quoted 1 line

+cd ftrace_stress/

Why the cd? It does not seem to be needed.

as currently we are in ftrace_test/, but sub stresses cases are in ftrace_test/ftrace_stress/

in test_stress(), i start the sub script using

  sh ftrace_${target}.sh &
Quoted 8 lines
Quoted 3 lines

This make the path shorter. If you don't have objection, I will move the cd ftrace_stress/ into test_stress(). What do you think of this?

The stress tests are installed into $DESTDIR/testcases/bin/ aren't they?

If that is the case these scripts are in $PATH and could be executed without fiddling with full path.

[root@dhcp-chuhu bin]# ls ftrace_* -d
ftrace_lib.sh ftrace_regression01.sh ftrace_regression02.sh ftrace_stress ftrace_stress_test.sh [root@dhcp-chuhu bin]# pwd
/opt/ltp/testcases/bin

tests are under subdir ftrace_stress of bin. so we need a cd. but also can just remove it and use ftrace_stress/${target}.sh instead, ok, i will use this way. Please ignore the previous V3, that's not complete considering this.

Quoted 4 lines

--
Cyril Hrubis
[email protected]

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

PATCH v2 2/9 tracing/ftrace: add new case for ftrace userstacktrace

In reply to Chunyu Hu

Hi!

testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh line 52

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh new file +4 -0
+ftrace_userstacktrace_test()
+{
+	if [ ! -e "$TSTACK_TRACE_PATH" ]; then
+		tst_brkm TCONF ignored "Stack Tracer is not cofigured in This kernel"

The 'ignored' should really be removed here, it's a leftover when the tst_brkm called the broken-by-design binary.

Quoted 27 lines
testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh new file +27 -0
+	fi
+
+	for i in $(seq $LOOP); do
+		echo 1 >  $TSTACK_TRACE_PATH
+		echo userstacktrace > $TRACING_PATH/trace_options
+		grep -q "^userstacktrace"  $TRACING_PATH/trace_options
+		if [ $? -ne 0 ]; then
+			tst_brkm TBROK "Failed to set userstacktrace"
+		fi
+
+		if [ -f "$EXC_PAGE_FAULT_ENABLE" ]; then
+			exc_page_fault_enable=`cat $EXC_PAGE_FAULT_ENABLE`
+			echo 1 > $EXC_PAGE_FAULT_ENABLE
+		else
+			mm_page_fault_enable=`cat MM_PAGE_FAULT_ENABLE`
+			echo 1 > $MM_PAGE_FAULT_ENABLE
+		fi
+	done
+
+	if [ -f "$EXC_PAGE_FAULT_ENABLE" ]; then
+		echo "$exc_page_fault_enable" > $EXC_PAGE_FAULT_ENABLE
+	else
+		echo "$mm_page_fault_enable" > $MM_PAGE_FAULT_ENABLE
+	fi
+
+	tst_resm TPASS "Finished running the test"
+}
Signature · 2 lines
Cyril Hrubis
[email protected]
#27 lore raw

PATCH v2 2/9 tracing/ftrace: add new case for ftrace userstacktrace

Quoted 8 lines · Cyril Hrubis

Hi!

testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh line 52

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh new file +4 -0
+ftrace_userstacktrace_test()
+{
+	if [ ! -e "$TSTACK_TRACE_PATH" ]; then
+		tst_brkm TCONF ignored "Stack Tracer is not cofigured in This kernel"

The 'ignored' should really be removed here, it's a leftover when the tst_brkm called the broken-by-design binary.

ok. thanks for reivewing.

Quoted 32 lines
Quoted 28 lines
testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh new file +27 -0
+	fi
+
+	for i in $(seq $LOOP); do
+		echo 1 >  $TSTACK_TRACE_PATH
+		echo userstacktrace > $TRACING_PATH/trace_options
+		grep -q "^userstacktrace"  $TRACING_PATH/trace_options
+		if [ $? -ne 0 ]; then
+			tst_brkm TBROK "Failed to set userstacktrace"
+		fi
+
+		if [ -f "$EXC_PAGE_FAULT_ENABLE" ]; then
+			exc_page_fault_enable=`cat $EXC_PAGE_FAULT_ENABLE`
+			echo 1 > $EXC_PAGE_FAULT_ENABLE
+		else
+			mm_page_fault_enable=`cat MM_PAGE_FAULT_ENABLE`
+			echo 1 > $MM_PAGE_FAULT_ENABLE
+		fi
+	done
+
+	if [ -f "$EXC_PAGE_FAULT_ENABLE" ]; then
+		echo "$exc_page_fault_enable" > $EXC_PAGE_FAULT_ENABLE
+	else
+		echo "$mm_page_fault_enable" > $MM_PAGE_FAULT_ENABLE
+	fi
+
+	tst_resm TPASS "Finished running the test"
+}
Signature · 2 lines
Cyril Hrubis
[email protected]
#28 lore raw

PATCH v2 1/9 tracing: reorganize ftrace-stress tests to general tests

In reply to Chunyu Hu

Hi!

testcases/kernel/tracing/ftrace_test/ftrace_lib.sh line 1

Quoted 7 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +1 -0
new file mode 100755
index 0000000..ea082dc
@@ -0,0 +1,156 @@
+#! /bin/sh

^
The space should be removed

Quoted 16 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +16 -0
+###########################################################################
+##                                                                       ##
+## 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/>.  ##

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

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +10 -0
+##                                                                       ##
+## Author: Li Zefan <[email protected]>                                ##
+##                                                                       ##
+###########################################################################
+
+cd $LTPROOT/testcases/bin
+
+export TPATH="$PWD"
+export DEBUGFS_PATH="$PWD/debugfs"
+export TRACING_PATH="$PWD/debugfs/tracing"

The test must not create files and mount things outside of the test temporary directory. Expecially not in $LTPROOT. You should call tst_tmpdir to create temporary directory instead, then create directory there.

Also the ftrace filesystem seems to be mounted on /sys/kernel/debug/tracing/ on recent distributions, why don't we just set TRACING_PATH accodingly if it's already mounted and fallback to mounting it only when debugfs couldn't be found in /proc/mounts?

Quoted 96 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +96 -0
+export FPATH="$TPATH/ftrace_function"
+export RPATH="$TPATH/ftrace_regression"
+export SPATH="$TPATH/ftrace_stress"
+
+. test.sh
+
+test_interval=$1
+
+save_old_setting()
+{
+	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
+
+	cd - > /dev/null
+}
+
+
+restore_old_setting()
+{
+	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
+}
+
+clean_up()
+{
+	restore_old_setting
+
+	umount $DEBUGFS_PATH
+	rmdir $DEBUGFS_PATH
+}
+
+clean_up_exit()
+{
+	clean_up
+	exit 1
+}
+
+test_begin()
+{
+	start_time=`date +%s`
+}
+
+test_wait()
+{
+	for ((; ;))
+	{
+		sleep 2

testcases/kernel/tracing/ftrace_test/ftrace_lib.sh line 133

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +10 -0
+
+		cur_time=`date +%s`
+		elapsed=$(( $cur_time - $start_time ))
+
+		# run the test for $test_interval secs
+		if [ $elapsed -ge $test_interval ]; then
+			break
+		fi
+	}
+}

Why don't we just do sleep $test_interval instead?

testcases/kernel/tracing/ftrace_test/ftrace_lib.sh line 145

Quoted 11 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +11 -0
+trap clean_up_exit INT
+
+tst_require_root
+
+# 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

Don't do this. Really the whole point of LTP is to validate kernel, if we skip known bugs by default we would give users false impression that the kernel was thoroughly tested.

Also since you include the test.sh here the tst_brkm format is different and it exits the test, so the exit 0 is never reached.

testcases/kernel/tracing/ftrace_test/ftrace_lib.sh line 156

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +10 -0
+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

Here as well, the tst_brkm from test.sh exit the test. Ideally you should setup TST_CLEANUP to point to a cleanup function once you do the test initalization which would be then executed before the test exits automatically.

...

Quoted 94 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +88 -0
new file mode 100755
index 0000000..d9f7f8b
@@ -0,0 +1,123 @@
+#! /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 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
+
+. ftrace_lib.sh
+
+test_success=true
+
+export_pids()
+{
+	export pid1 pid2 pid3 pid4 pid5 pid6 pid7 pid8 pid9 pid10 pid11 pid12 \
+		pid13 pid14 pid15 pid16
+
+	export NR_PIDS=16
+}
+
+test_stress()
+{
+	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=$!
+}
+
+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

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

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +10 -0
+	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
+	kill -KILL $pid14 || test_success=false
+	kill -KILL $pid15 || test_success=false
+	kill -KILL $pid16 || test_success=false
+
+	sleep 2

I remember telling you to call wait on each pid instead of the sleep 2 here.

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

Quoted 6 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +6 -0
+	clean_up
+}
+
+
+# ----------------------------
+echo "Ftrace Stress Test Begin"

That should be tst_resm TINFO "..." but that is very minor.

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

Quoted 9 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +9 -0
+save_old_setting
+
+test_begin
+
+test_stress
+
+test_wait
+
+test_kill

Hmm, shouldn't you restore old settings here?

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

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

Here as well.

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

Quoted 6 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +6 -0
+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

You should call tst_exit at the end of the test instead of doing exit 1 after the tst_resm. This is another leftover caused by the broken-by-desing tst_resm and tst_brkm binaries.

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

PATCH v2 1/9 tracing: reorganize ftrace-stress tests to general tests

Quoted 10 lines · Cyril Hrubis

Hi!

testcases/kernel/tracing/ftrace_test/ftrace_lib.sh line 1

Quoted 7 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +1 -0
new file mode 100755
index 0000000..ea082dc
@@ -0,0 +1,156 @@
+#! /bin/sh

^
The space should be removed

This commit rename all of the ftrace file, it is just a preparing for the upcoming patches, we will fix the below issues with some kind of new patches.

And sorry for no clear note in the summary before.

Quoted 332 lines
Quoted 17 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +16 -0
+###########################################################################
+##                                                                       ##
+## 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/>.  ##

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

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +10 -0
+##                                                                       ##
+## Author: Li Zefan <[email protected]>                                ##
+##                                                                       ##
+###########################################################################
+
+cd $LTPROOT/testcases/bin
+
+export TPATH="$PWD"
+export DEBUGFS_PATH="$PWD/debugfs"
+export TRACING_PATH="$PWD/debugfs/tracing"

The test must not create files and mount things outside of the test temporary directory. Expecially not in $LTPROOT. You should call tst_tmpdir to create temporary directory instead, then create directory there.

Also the ftrace filesystem seems to be mounted on /sys/kernel/debug/tracing/ on recent distributions, why don't we just set TRACING_PATH accodingly if it's already mounted and fallback to mounting it only when debugfs couldn't be found in /proc/mounts?

Quoted 96 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +96 -0
+export FPATH="$TPATH/ftrace_function"
+export RPATH="$TPATH/ftrace_regression"
+export SPATH="$TPATH/ftrace_stress"
+
+. test.sh
+
+test_interval=$1
+
+save_old_setting()
+{
+	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
+
+	cd - > /dev/null
+}
+
+
+restore_old_setting()
+{
+	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
+}
+
+clean_up()
+{
+	restore_old_setting
+
+	umount $DEBUGFS_PATH
+	rmdir $DEBUGFS_PATH
+}
+
+clean_up_exit()
+{
+	clean_up
+	exit 1
+}
+
+test_begin()
+{
+	start_time=`date +%s`
+}
+
+test_wait()
+{
+	for ((; ;))
+	{
+		sleep 2

testcases/kernel/tracing/ftrace_test/ftrace_lib.sh line 133

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +10 -0
+
+		cur_time=`date +%s`
+		elapsed=$(( $cur_time - $start_time ))
+
+		# run the test for $test_interval secs
+		if [ $elapsed -ge $test_interval ]; then
+			break
+		fi
+	}
+}

Why don't we just do sleep $test_interval instead?

testcases/kernel/tracing/ftrace_test/ftrace_lib.sh line 145

Quoted 11 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +11 -0
+trap clean_up_exit INT
+
+tst_require_root
+
+# 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

Don't do this. Really the whole point of LTP is to validate kernel, if we skip known bugs by default we would give users false impression that the kernel was thoroughly tested.

Also since you include the test.sh here the tst_brkm format is different and it exits the test, so the exit 0 is never reached.

testcases/kernel/tracing/ftrace_test/ftrace_lib.sh line 156

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +10 -0
+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

Here as well, the tst_brkm from test.sh exit the test. Ideally you should setup TST_CLEANUP to point to a cleanup function once you do the test initalization which would be then executed before the test exits automatically.

...

Quoted 94 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +88 -0
new file mode 100755
index 0000000..d9f7f8b
@@ -0,0 +1,123 @@
+#! /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 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
+
+. ftrace_lib.sh
+
+test_success=true
+
+export_pids()
+{
+	export pid1 pid2 pid3 pid4 pid5 pid6 pid7 pid8 pid9 pid10 pid11 pid12 \
+		pid13 pid14 pid15 pid16
+
+	export NR_PIDS=16
+}
+
+test_stress()
+{
+	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=$!
+}
+
+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

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

Quoted 10 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +10 -0
+	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
+	kill -KILL $pid14 || test_success=false
+	kill -KILL $pid15 || test_success=false
+	kill -KILL $pid16 || test_success=false
+
+	sleep 2

I remember telling you to call wait on each pid instead of the sleep 2 here.

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

Quoted 6 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +6 -0
+	clean_up
+}
+
+
+# ----------------------------
+echo "Ftrace Stress Test Begin"

That should be tst_resm TINFO "..." but that is very minor.

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

Quoted 9 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +9 -0
+save_old_setting
+
+test_begin
+
+test_stress
+
+test_wait
+
+test_kill

Hmm, shouldn't you restore old settings here?

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

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

Here as well.

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

Quoted 6 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +6 -0
+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

You should call tst_exit at the end of the test instead of doing exit 1 after the tst_resm. This is another leftover caused by the broken-by-desing tst_resm and tst_brkm binaries.

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

PATCH v2 1/9 tracing: reorganize ftrace-stress tests to general tests

In reply to Cyril Hrubis

Thanks. Some issue has been done in patch 2/9, will fix other issues you mentioned in next step.

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

Quoted 7 lines

From: "Cyril Hrubis" <[email protected]>
To: "Chunyu Hu" <[email protected]>
Cc: [email protected], [email protected]
Sent: Thursday, May 5, 2016 12:26:56 AM
Subject: Re: [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests

Hi!

Quoted 10 lines

testcases/kernel/tracing/ftrace_test/ftrace_lib.sh line 1

Quoted 8 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +1 -0
new file mode 100755
index 0000000..ea082dc
@@ -0,0 +1,156 @@
+#! /bin/sh

^
The space should be removed

will fix this in patch 2/9 "skip unsupported tests and early cleanup".

Quoted 41 lines
Quoted 41 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +2 -0
+###########################################################################
+##

##
+## 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]>
##
+##
##

testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +4 -0
+###########################################################################
+
+cd $LTPROOT/testcases/bin
+
Quoted 8 lines

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

Quoted 3 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +3 -0
+export TPATH="$PWD"
+export DEBUGFS_PATH="$PWD/debugfs"
+export TRACING_PATH="$PWD/debugfs/tracing"

The test must not create files and mount things outside of the test temporary directory. Expecially not in $LTPROOT. You should call tst_tmpdir to create temporary directory instead, then create directory there.

Thanks for the suggestion, will take this way in next version, also add it into patch 2/9.

Quoted 4 lines

Also the ftrace filesystem seems to be mounted on /sys/kernel/debug/tracing/ on recent distributions, why don't we just set TRACING_PATH accodingly if it's already mounted and fallback to mounting it only when debugfs couldn't be found in /proc/mounts?

Thanks. Will take this way in next version, we check whether the mounting is needed, through /proc/mounts , and then only mount/umount
if it's not mounted by default.

Quoted 100 lines
Quoted 100 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +100 -0
+export FPATH="$TPATH/ftrace_function"
+export RPATH="$TPATH/ftrace_regression"
+export SPATH="$TPATH/ftrace_stress"
+
+. test.sh
+
+test_interval=$1
+
+save_old_setting()
+{
+	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
+
+	cd - > /dev/null
+}
+
+
+restore_old_setting()
+{
+	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
+}
+
+clean_up()
+{
+	restore_old_setting
+
+	umount $DEBUGFS_PATH
+	rmdir $DEBUGFS_PATH
+}
+
+clean_up_exit()
+{
+	clean_up
+	exit 1
+}
+
+test_begin()
+{
+	start_time=`date +%s`
+}
+
+test_wait()
+{
+	for ((; ;))
+	{
+		sleep 2
+
+		cur_time=`date +%s`
+		elapsed=$(( $cur_time - $start_time ))
+
Quoted 8 lines

testcases/kernel/tracing/ftrace_test/ftrace_lib.sh line 133

Quoted 6 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +6 -0
+		# run the test for $test_interval secs
+		if [ $elapsed -ge $test_interval ]; then
+			break
+		fi
+	}
+}

Why don't we just do sleep $test_interval instead?

Good idea, will leave only a tst_sleep in the func in next step.

Quoted 8 lines
Quoted 8 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +8 -0
+trap clean_up_exit INT
+
+tst_require_root
+
+# 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
Quoted 8 lines

testcases/kernel/tracing/ftrace_test/ftrace_lib.sh

Quoted 4 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +1 -0
+	tst_brkm TCONF ignored "The test should be run in kernels >= 2.6.34. Skip

the test..."

testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +2 -0
+	exit 0
+fi

Don't do this. Really the whole point of LTP is to validate kernel, if we skip known bugs by default we would give users false impression that the kernel was thoroughly tested.

OK, will remove the ignore, and remove this skip step, I agree that this skip is not needed. If user found panic, should fix the issue asap. and skip steps should be done in local repo if needed.

Quoted 2 lines

Also since you include the test.sh here the tst_brkm format is different and it exits the test, so the exit 0 is never reached.

OK. Will remove this.

Quoted 7 lines
Quoted 7 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +7 -0
+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
Quoted 8 lines

testcases/kernel/tracing/ftrace_test/ftrace_lib.sh line 145

Quoted 3 lines
testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file +3 -0
+	rmdir $DEBUGFS_PATH
+	exit 0
+fi

Here as well, the tst_brkm from test.sh exit the test. Ideally you should setup TST_CLEANUP to point to a cleanup function once you do the test initalization which would be then executed before the test exits automatically.

OK. I think we can add a function for test initiating. including check/mount debugfs, exporting the env like TRACING_PATH, and setting up the cleanup callback TST_CLEANUP=cleanup

Quoted 121 lines

...

Quoted 118 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +4 -0
new file mode 100755
index 0000000..d9f7f8b
@@ -0,0 +1,123 @@
+#! /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 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]>
##
+##
##

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +72 -0
+###########################################################################
+
+
+export TCID="ftrace-stress-test"
+export TST_TOTAL=1
+export TST_COUNT=1
+
+. ftrace_lib.sh
+
+test_success=true
+
+export_pids()
+{
+	export pid1 pid2 pid3 pid4 pid5 pid6 pid7 pid8 pid9 pid10 pid11 pid12 \
+		pid13 pid14 pid15 pid16
+
+	export NR_PIDS=16
+}
+
+test_stress()
+{
+	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=$!
+}
+
+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
Quoted 8 lines

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

Quoted 5 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +5 -0
+	kill -KILL $pid14 || test_success=false
+	kill -KILL $pid15 || test_success=false
+	kill -KILL $pid16 || test_success=false
+
+	sleep 2

I remember telling you to call wait on each pid instead of the sleep 2 here.

The sleep 2 wil be removed in next step into patch 2/9.

Quoted 8 lines

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

Quoted 6 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +6 -0
+	clean_up
+}
+
+
+# ----------------------------
+echo "Ftrace Stress Test Begin"

That should be tst_resm TINFO "..." but that is very minor.

This has been fixed in patch 2/9

Quoted 12 lines

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

Quoted 9 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +9 -0
+save_old_setting
+
+test_begin
+
+test_stress
+
+test_wait
+
+test_kill

Hmm, shouldn't you restore old settings here?

Quoted 3 lines
Quoted 1 line

+echo "Ftrace Stress Test End"

Here as well.

Fixed in patch 2/9.

Quoted 11 lines

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

Quoted 7 lines
testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +2 -0
+if $test_success; then
+	tst_resm TPASS "finished running the test. Run dmesg to double-check for

bugs"

testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh new file +4 -0
+else
+	tst_resm TFAIL "please check log message."
+	exit 1
+fi

You should call tst_exit at the end of the test instead of doing exit 1 after the tst_resm. This is another leftover caused by the broken-by-desing tst_resm and tst_brkm binaries.

This has been done in 2/9. thank you for the detailed info.

Quoted 4 lines

--
Cyril Hrubis
[email protected]

Signature · 2 lines
Regards,
Chunyu Hu
author
#31 lore raw

PATCH v2 1/9 tracing: reorganize ftrace-stress tests to general tests

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

Quoted 9 lines

From: "Chunyu Hu" <[email protected]>
To: "Cyril Hrubis" <[email protected]>
Cc: [email protected]
Sent: Thursday, May 5, 2016 6:11:04 PM
Subject: Re: [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests

Thanks. Some issue has been done in patch 2/9, will fix other issues you mentioned in next step.

Sorry, for a typo. 2/9 should be 4/9, all the 2/9 is meaning 4/9 here.