All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH RFC 0/9] tracing: make ftrace tests to be extended
@ 2016-03-04  8:24 Li Wang
  2016-03-04  8:24 ` [LTP] [PATCH RFC 1/9] ftrace_stress: remove the useless file ftrace_get_page_size.c Li Wang
  0 siblings, 1 reply; 27+ messages in thread
From: Li Wang @ 2016-03-04  8:24 UTC (permalink / raw)
  To: ltp

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

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

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

 3, Enhance the ftrace-stress test coverage.

 4, Do some cleanup and bug fix work.

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

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

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

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 1/9] ftrace_stress: remove the useless file ftrace_get_page_size.c
  2016-03-04  8:24 [LTP] [PATCH RFC 0/9] tracing: make ftrace tests to be extended Li Wang
@ 2016-03-04  8:24 ` Li Wang
  2016-03-04  8:24   ` [LTP] [PATCH RFC 2/9] tracing[1]: reorganize ftrace-stress tests to general tests Li Wang
  2016-03-17 16:29   ` [LTP] [PATCH RFC 1/9] ftrace_stress: remove the useless file ftrace_get_page_size.c Cyril Hrubis
  0 siblings, 2 replies; 27+ messages in thread
From: Li Wang @ 2016-03-04  8:24 UTC (permalink / raw)
  To: ltp

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

Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/tracing/ftrace_stress_test/.gitignore            | 1 -
 .../kernel/tracing/ftrace_stress_test/ftrace_get_page_size.c      | 8 --------
 2 files changed, 9 deletions(-)
 delete mode 100644 testcases/kernel/tracing/ftrace_stress_test/.gitignore
 delete mode 100644 testcases/kernel/tracing/ftrace_stress_test/ftrace_get_page_size.c

diff --git a/testcases/kernel/tracing/ftrace_stress_test/.gitignore b/testcases/kernel/tracing/ftrace_stress_test/.gitignore
deleted file mode 100644
index 099ec4e..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/ftrace_get_page_size
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_get_page_size.c b/testcases/kernel/tracing/ftrace_stress_test/ftrace_get_page_size.c
deleted file mode 100644
index 9f5dec7..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_get_page_size.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <unistd.h>
-#include <stdio.h>
-
-int main(void)
-{
-	printf("%d\n", getpagesize());
-	return 0;
-}
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 2/9] tracing[1]: reorganize ftrace-stress tests to general tests
  2016-03-04  8:24 ` [LTP] [PATCH RFC 1/9] ftrace_stress: remove the useless file ftrace_get_page_size.c Li Wang
@ 2016-03-04  8:24   ` Li Wang
  2016-03-04  8:24     ` [LTP] [PATCH RFC 3/9] tracing[2]: reorganize ftrace stress " Li Wang
  2016-03-17 16:29   ` [LTP] [PATCH RFC 1/9] ftrace_stress: remove the useless file ftrace_get_page_size.c Cyril Hrubis
  1 sibling, 1 reply; 27+ messages in thread
From: Li Wang @ 2016-03-04  8:24 UTC (permalink / raw)
  To: ltp

In this commit, just rename the ftrace_stress_test to ftrace_test.

Signed-off-by: Li Wang <liwang@redhat.com>
---
 .../kernel/tracing/ftrace_stress_test/Makefile     |   7 -
 .../ftrace_stress/ftrace_buffer_size.sh            |  45 ----
 .../ftrace_stress/ftrace_current_tracer.sh         |  34 ---
 .../ftrace_stress/ftrace_ftrace_enabled.sh         |  39 ----
 .../ftrace_stress/ftrace_profile_enabled.sh        |  50 -----
 .../ftrace_stress/ftrace_set_event.sh              |  44 ----
 .../ftrace_stress/ftrace_set_ftrace_pid.sh         |  49 -----
 .../ftrace_stress/ftrace_stack_max_size.sh         |  39 ----
 .../ftrace_stress/ftrace_stack_trace.sh            |  46 ----
 .../ftrace_stress/ftrace_trace.sh                  |  27 ---
 .../ftrace_stress/ftrace_trace_clock.sh            |  46 ----
 .../ftrace_stress/ftrace_trace_options.sh          |  42 ----
 .../ftrace_stress/ftrace_trace_pipe.sh             |  52 -----
 .../ftrace_stress/ftrace_trace_stat.sh             |  45 ----
 .../ftrace_stress/ftrace_tracing_enabled.sh        |  39 ----
 .../ftrace_stress/ftrace_tracing_max_latency.sh    |  38 ----
 .../ftrace_stress/ftrace_tracing_on.sh             |  39 ----
 .../ftrace_stress_test/ftrace_stress_test.sh       | 243 ---------------------
 testcases/kernel/tracing/ftrace_test/Makefile      |   7 +
 .../ftrace_stress/ftrace_buffer_size.sh            |  45 ++++
 .../ftrace_stress/ftrace_current_tracer.sh         |  34 +++
 .../ftrace_stress/ftrace_ftrace_enabled.sh         |  39 ++++
 .../ftrace_stress/ftrace_profile_enabled.sh        |  50 +++++
 .../ftrace_test/ftrace_stress/ftrace_set_event.sh  |  44 ++++
 .../ftrace_stress/ftrace_set_ftrace_pid.sh         |  49 +++++
 .../ftrace_stress/ftrace_stack_max_size.sh         |  39 ++++
 .../ftrace_stress/ftrace_stack_trace.sh            |  46 ++++
 .../ftrace_test/ftrace_stress/ftrace_trace.sh      |  27 +++
 .../ftrace_stress/ftrace_trace_clock.sh            |  46 ++++
 .../ftrace_stress/ftrace_trace_options.sh          |  42 ++++
 .../ftrace_test/ftrace_stress/ftrace_trace_pipe.sh |  52 +++++
 .../ftrace_test/ftrace_stress/ftrace_trace_stat.sh |  45 ++++
 .../ftrace_stress/ftrace_tracing_enabled.sh        |  39 ++++
 .../ftrace_stress/ftrace_tracing_max_latency.sh    |  38 ++++
 .../ftrace_test/ftrace_stress/ftrace_tracing_on.sh |  39 ++++
 .../tracing/ftrace_test/ftrace_stress_test.sh      | 243 +++++++++++++++++++++
 36 files changed, 924 insertions(+), 924 deletions(-)
 delete mode 100644 testcases/kernel/tracing/ftrace_stress_test/Makefile
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_buffer_size.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_current_tracer.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_ftrace_enabled.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_profile_enabled.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_set_event.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_set_ftrace_pid.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_stack_max_size.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_stack_trace.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_clock.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_options.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_pipe.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_stat.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_enabled.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_max_latency.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_on.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress_test.sh
 create mode 100644 testcases/kernel/tracing/ftrace_test/Makefile
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_current_tracer.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_ftrace_enabled.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_profile_enabled.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_enabled.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_on.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh

diff --git a/testcases/kernel/tracing/ftrace_stress_test/Makefile b/testcases/kernel/tracing/ftrace_stress_test/Makefile
deleted file mode 100644
index e4a913a..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/Makefile
+++ /dev/null
@@ -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
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_buffer_size.sh b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_buffer_size.sh
deleted file mode 100755
index bd7dcc4..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_buffer_size.sh
+++ /dev/null
@@ -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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-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
-}
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_current_tracer.sh b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_current_tracer.sh
deleted file mode 100755
index 88d576f..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_current_tracer.sh
+++ /dev/null
@@ -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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-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
-}
-
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_ftrace_enabled.sh b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_ftrace_enabled.sh
deleted file mode 100755
index 20bb234..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_ftrace_enabled.sh
+++ /dev/null
@@ -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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-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
-}
-
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_profile_enabled.sh b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_profile_enabled.sh
deleted file mode 100755
index 9c6162a..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_profile_enabled.sh
+++ /dev/null
@@ -1,50 +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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-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
-
-	count=$(( $count + 1 ))
-
-	for ((i = 0; i < $MAX_LOOP; i++))
-	{
-		echo 0 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
-		echo 1 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
-	}
-
-	enable=$(( $count % 3 ))
-
-	if [ $enable -eq 0 ]; then
-		echo 1 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
-	else
-		echo 0 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
-	fi
-
-	sleep 1
-}
-
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_set_event.sh b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_set_event.sh
deleted file mode 100755
index d7efdd4..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_set_event.sh
+++ /dev/null
@@ -1,44 +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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-for ((; ;))
-{
-	for ((i = 0; i < 100; i++))
-	{
-		echo 1 > "$TRACING_PATH"/events/enable
-		echo 0 > "$TRACING_PATH"/events/enable
-	}
-
-	for dir in `ls $TRACING_PATH/events/`
-	do
-		if [ ! -d $dir -o "$dir" = ftrace ]; then
-			continue;
-		fi
-
-		for ((i = 0; i < 20; i++))
-		{
-			echo 1 > "$TRACING_PATH"/events/$dir/enable
-			echo 0 > "$TRACING_PATH"/events/$dir/enable
-		}
-	done
-
-	for event in `cat $TRACING_PATH/available_events`;
-	do
-		echo $event >> "$TRACING_PATH"/set_event
-	done
-
-	sleep 1
-}
-
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_set_ftrace_pid.sh b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_set_ftrace_pid.sh
deleted file mode 100755
index 7bc76d9..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_set_ftrace_pid.sh
+++ /dev/null
@@ -1,49 +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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-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++))
-		{
-			str="\$pid$k"
-			eval echo $str >> "$TRACING_PATH"/set_ftrace_pid
-		}
-
-		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
-				tst_resm TBROK "Cannot disable set_ftrace_pid!"
-				exit 1
-			fi
-		fi
-	}
-
-	sleep 1
-}
-
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_stack_max_size.sh b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_stack_max_size.sh
deleted file mode 100755
index 682d05e..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_stack_max_size.sh
+++ /dev/null
@@ -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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-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
-}
-
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_stack_trace.sh b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_stack_trace.sh
deleted file mode 100755
index a406c51..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_stack_trace.sh
+++ /dev/null
@@ -1,46 +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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-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
-	}
-
-	sleep 1
-
-	for ((i = 0; i < $LOOP; i++))
-	{
-		echo 0 > /proc/sys/kernel/stack_tracer_enabled
-		echo 1 > /proc/sys/kernel/stack_tracer_enabled
-	}
-
-	sleep 1
-}
-
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace.sh b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace.sh
deleted file mode 100755
index e36712b..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace.sh
+++ /dev/null
@@ -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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-LOOP=200
-
-for ((; ;))
-{
-	for ((i = 0; i < $LOOP; i++))
-	{
-		cat "$TRACING_PATH"/trace > /dev/null
-	}
-
-	sleep 1
-}
-
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_clock.sh b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_clock.sh
deleted file mode 100755
index de6bbea..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_clock.sh
+++ /dev/null
@@ -1,46 +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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-LOOP=400
-
-# In kernel which is older than 2.6.32, we set global clock
-# via trace_options.
-tst_kvercmp 2 6 32
-if [ $? -eq 0 ]; then
-        old_kernel=1
-else
-        old_kernel=0
-fi
-
-for ((; ;))
-{
-	if [ $old_kernel -eq 1 ];
-	then
-		for ((i = 0; i < $LOOP; i++))
-		{
-			echo 1 > "$TRACING_PATH"/options/global-clock
-			echo 0 > "$TRACING_PATH"/options/global-clock
-		}
-	else
-		for ((i = 0; i < $LOOP; i++))
-		{
-			echo local > "$TRACING_PATH"/trace_clock
-			echo global > "$TRACING_PATH"/trace_clock
-		}
-	fi
-
-	sleep 1
-}
-
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_options.sh b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_options.sh
deleted file mode 100755
index 47d2a62..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_options.sh
+++ /dev/null
@@ -1,42 +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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-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)
-
-NR_TRACE_OPTIONS=19
-
-for ((; ; ))
-{
-	for ((j = 0; j < $LOOP; j++))
-	{
-		num=`date +%N`
-		num=`printf 1%s $num`
-
-		for ((i = 0; i < $NR_TRACE_OPTIONS; i++))
-		{
-			n=$(( ( $num >> $i ) % 2 ))
-			if [ $n -eq 0 ]; then
-				echo 0 > "$TRACING_PATH"/options/${trace_options[$i]}
-			else
-				echo 1 > "$TRACING_PATH"/options/${trace_options[$i]}
-			fi
-		}
-	}
-
-	sleep 1
-}
-
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_pipe.sh b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_pipe.sh
deleted file mode 100755
index 47d42bc..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_pipe.sh
+++ /dev/null
@@ -1,52 +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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-ftrace_sleep()
-{
-	# usleep is not a standard command?
-	usleep 200000 2> /dev/null
-	if [ $? -ne 0 ]; then
-		sleep 1
-	fi
-}
-
-kill_this_pid()
-{
-	/bin/kill -SIGKILL $this_pid
-	wait $this_pid
-	exit 0
-}
-
-trap kill_this_pid SIGUSR1
-
-LOOP=20
-
-for ((; ;))
-{
-	for ((i = 0; i < $LOOP; i++))
-	{
-		cat "$TRACING_PATH"/trace_pipe > /dev/null &
-
-		this_pid=$!
-		ftrace_sleep
-		/bin/kill -SIGINT $this_pid
-		wait $this_pid
-		this_pid=0
-		ftrace_sleep
-	}
-
-	sleep 2
-}
-
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_stat.sh b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_stat.sh
deleted file mode 100755
index d7e6fd3..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_stat.sh
+++ /dev/null
@@ -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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-LOOP=200
-
-should_skip=0
-
-if [ ! -e "$TRACING_PATH"/function_profile_enabled ]; then
-        should_skip=1
-fi
-
-# For kernels older than 2.6.36, this testcase can result in
-# divide-by-zero kernel bug
-tst_kvercmp 2 6 36
-if [ $? -eq 0 ]; then
-	should_skip=1
-fi
-
-for ((; ;))
-{
-	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
-	}
-
-	sleep 1
-}
-
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_enabled.sh b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_enabled.sh
deleted file mode 100755
index 69f2ae6..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_enabled.sh
+++ /dev/null
@@ -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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-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
-}
-
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_max_latency.sh b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_max_latency.sh
deleted file mode 100755
index f19d734..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_max_latency.sh
+++ /dev/null
@@ -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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-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
-}
-
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_on.sh b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_on.sh
deleted file mode 100755
index 672c223..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_on.sh
+++ /dev/null
@@ -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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-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
-}
-
diff --git a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress_test.sh b/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress_test.sh
deleted file mode 100755
index 6a111e9..0000000
--- a/testcases/kernel/tracing/ftrace_stress_test/ftrace_stress_test.sh
+++ /dev/null
@@ -1,243 +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.                                        ##
-##                                                                            ##
-## This program is distributed in the hope that it will be useful, but        ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
-## for more details.                                                          ##
-##                                                                            ##
-## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
-##                                                                            ##
-## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
-##                                                                            ##
-################################################################################
-
-cd $LTPROOT/testcases/bin
-
-export TCID="ftrace-stress-test"
-export TST_TOTAL=1
-export TST_COUNT=1
-
-export TPATH="$PWD"
-export DEBUGFS_PATH="$PWD/debugfs"
-export TRACING_PATH="$PWD/debugfs/tracing"
-export SPATH="$TPATH/ftrace_stress"
-
-test_interval=$1
-test_success=true
-
-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()
-{
-	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
-
-	sleep 2
-	restore_old_setting
-
-	umount $DEBUGFS_PATH
-	rmdir $DEBUGFS_PATH
-}
-
-clean_up_exit()
-{
-	clean_up
-	exit 1
-}
-
-export_pids()
-{
-	export pid1 pid2 pid3 pid4 pid5 pid6 pid7 pid8 pid9 pid10 pid11 pid12 \
-		pid13 pid14 pid15 pid16
-
-	export NR_PIDS=16
-}
-
-test_begin()
-{
-	start_time=`date +%s`
-}
-
-test_wait()
-{
-	for ((; ;))
-	{
-		sleep 2
-
-		cur_time=`date +%s`
-		elapsed=$(( $cur_time - $start_time ))
-
-		# run the stress test for $test_interval secs
-		if [ $elapsed -ge $test_interval ]; then
-			break
-		fi
-	}
-}
-
-trap clean_up_exit INT
-
-# Should be run by root user
-if [ `id -ru` != 0 ]; then
-	tst_brkm TCONF ignored "The test should be run by root user. Skip the test..."
-	exit 0
-fi
-
-# Don't run the test on kernels older than 2.6.34, otherwise
-# it can crash the system if the kernel is not latest-stable
-tst_kvercmp 2 6 34
-if [ $? -eq 0 ]; then
-	tst_brkm TCONF ignored "The test should be run in kernels >= 2.6.34. Skip the test..."
-	exit 0
-fi
-
-mkdir $DEBUGFS_PATH
-mount -t debugfs xxx $DEBUGFS_PATH
-
-# Check to see tracing feature is supported or not
-if [ ! -d $TRACING_PATH ]; then
-	tst_brkm TCONF ignored "Tracing is not supported. Skip the test..."
-	umount $DEBUGFS_PATH
-	rmdir $DEBUGFS_PATH
-	exit 0
-fi
-
-echo "Ftrace Stress Test Begin"
-
-save_old_setting
-
-test_begin
-
-$SPATH/ftrace_trace_clock.sh &
-pid1=$!
-$SPATH/ftrace_current_tracer.sh &
-pid2=$!
-$SPATH/ftrace_trace_options.sh &
-pid3=$!
-$SPATH/ftrace_tracing_max_latency.sh &
-pid4=$!
-$SPATH/ftrace_stack_trace.sh &
-pid5=$!
-$SPATH/ftrace_stack_max_size.sh &
-pid6=$!
-$SPATH/ftrace_tracing_on.sh &
-pid7=$!
-$SPATH/ftrace_tracing_enabled.sh &
-pid8=$!
-$SPATH/ftrace_set_event.sh &
-pid9=$!
-$SPATH/ftrace_buffer_size.sh &
-pid10=$!
-$SPATH/ftrace_trace.sh &
-pid11=$!
-$SPATH/ftrace_trace_pipe.sh &
-pid12=$!
-$SPATH/ftrace_ftrace_enabled.sh &
-pid13=$!
-$SPATH/ftrace_set_ftrace_pid.sh &
-pid14=$!
-$SPATH/ftrace_profile_enabled.sh &
-pid15=$!
-$SPATH/ftrace_trace_stat.sh &
-pid16=$!
-
-export_pids
-
-test_wait
-
-clean_up
-
-echo "Ftrace Stress Test End"
-
-if $test_success; then
-	tst_resm TPASS "finished running the test. Run dmesg to double-check for bugs"
-else
-	tst_resm TFAIL "please check log message."
-	exit 1
-fi
-
diff --git a/testcases/kernel/tracing/ftrace_test/Makefile b/testcases/kernel/tracing/ftrace_test/Makefile
new file mode 100644
index 0000000..e4a913a
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/Makefile
@@ -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
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size.sh
new file mode 100755
index 0000000..bd7dcc4
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size.sh
@@ -0,0 +1,45 @@
+#! /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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+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
+}
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_current_tracer.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_current_tracer.sh
new file mode 100755
index 0000000..88d576f
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_current_tracer.sh
@@ -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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+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
+}
+
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_ftrace_enabled.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_ftrace_enabled.sh
new file mode 100755
index 0000000..20bb234
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_ftrace_enabled.sh
@@ -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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+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
+}
+
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_profile_enabled.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_profile_enabled.sh
new file mode 100755
index 0000000..9c6162a
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_profile_enabled.sh
@@ -0,0 +1,50 @@
+#! /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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+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
+
+	count=$(( $count + 1 ))
+
+	for ((i = 0; i < $MAX_LOOP; i++))
+	{
+		echo 0 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
+		echo 1 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
+	}
+
+	enable=$(( $count % 3 ))
+
+	if [ $enable -eq 0 ]; then
+		echo 1 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
+	else
+		echo 0 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
+	fi
+
+	sleep 1
+}
+
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
new file mode 100755
index 0000000..d7efdd4
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
@@ -0,0 +1,44 @@
+#! /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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+for ((; ;))
+{
+	for ((i = 0; i < 100; i++))
+	{
+		echo 1 > "$TRACING_PATH"/events/enable
+		echo 0 > "$TRACING_PATH"/events/enable
+	}
+
+	for dir in `ls $TRACING_PATH/events/`
+	do
+		if [ ! -d $dir -o "$dir" = ftrace ]; then
+			continue;
+		fi
+
+		for ((i = 0; i < 20; i++))
+		{
+			echo 1 > "$TRACING_PATH"/events/$dir/enable
+			echo 0 > "$TRACING_PATH"/events/$dir/enable
+		}
+	done
+
+	for event in `cat $TRACING_PATH/available_events`;
+	do
+		echo $event >> "$TRACING_PATH"/set_event
+	done
+
+	sleep 1
+}
+
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh
new file mode 100755
index 0000000..7bc76d9
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh
@@ -0,0 +1,49 @@
+#! /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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+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++))
+		{
+			str="\$pid$k"
+			eval echo $str >> "$TRACING_PATH"/set_ftrace_pid
+		}
+
+		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
+				tst_resm TBROK "Cannot disable set_ftrace_pid!"
+				exit 1
+			fi
+		fi
+	}
+
+	sleep 1
+}
+
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh
new file mode 100755
index 0000000..682d05e
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh
@@ -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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+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
+}
+
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh
new file mode 100755
index 0000000..a406c51
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh
@@ -0,0 +1,46 @@
+#! /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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+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
+	}
+
+	sleep 1
+
+	for ((i = 0; i < $LOOP; i++))
+	{
+		echo 0 > /proc/sys/kernel/stack_tracer_enabled
+		echo 1 > /proc/sys/kernel/stack_tracer_enabled
+	}
+
+	sleep 1
+}
+
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh
new file mode 100755
index 0000000..e36712b
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh
@@ -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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+LOOP=200
+
+for ((; ;))
+{
+	for ((i = 0; i < $LOOP; i++))
+	{
+		cat "$TRACING_PATH"/trace > /dev/null
+	}
+
+	sleep 1
+}
+
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
new file mode 100755
index 0000000..de6bbea
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh
@@ -0,0 +1,46 @@
+#! /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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+LOOP=400
+
+# In kernel which is older than 2.6.32, we set global clock
+# via trace_options.
+tst_kvercmp 2 6 32
+if [ $? -eq 0 ]; then
+        old_kernel=1
+else
+        old_kernel=0
+fi
+
+for ((; ;))
+{
+	if [ $old_kernel -eq 1 ];
+	then
+		for ((i = 0; i < $LOOP; i++))
+		{
+			echo 1 > "$TRACING_PATH"/options/global-clock
+			echo 0 > "$TRACING_PATH"/options/global-clock
+		}
+	else
+		for ((i = 0; i < $LOOP; i++))
+		{
+			echo local > "$TRACING_PATH"/trace_clock
+			echo global > "$TRACING_PATH"/trace_clock
+		}
+	fi
+
+	sleep 1
+}
+
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh
new file mode 100755
index 0000000..47d2a62
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh
@@ -0,0 +1,42 @@
+#! /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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+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)
+
+NR_TRACE_OPTIONS=19
+
+for ((; ; ))
+{
+	for ((j = 0; j < $LOOP; j++))
+	{
+		num=`date +%N`
+		num=`printf 1%s $num`
+
+		for ((i = 0; i < $NR_TRACE_OPTIONS; i++))
+		{
+			n=$(( ( $num >> $i ) % 2 ))
+			if [ $n -eq 0 ]; then
+				echo 0 > "$TRACING_PATH"/options/${trace_options[$i]}
+			else
+				echo 1 > "$TRACING_PATH"/options/${trace_options[$i]}
+			fi
+		}
+	}
+
+	sleep 1
+}
+
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
new file mode 100755
index 0000000..47d42bc
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh
@@ -0,0 +1,52 @@
+#! /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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+ftrace_sleep()
+{
+	# usleep is not a standard command?
+	usleep 200000 2> /dev/null
+	if [ $? -ne 0 ]; then
+		sleep 1
+	fi
+}
+
+kill_this_pid()
+{
+	/bin/kill -SIGKILL $this_pid
+	wait $this_pid
+	exit 0
+}
+
+trap kill_this_pid SIGUSR1
+
+LOOP=20
+
+for ((; ;))
+{
+	for ((i = 0; i < $LOOP; i++))
+	{
+		cat "$TRACING_PATH"/trace_pipe > /dev/null &
+
+		this_pid=$!
+		ftrace_sleep
+		/bin/kill -SIGINT $this_pid
+		wait $this_pid
+		this_pid=0
+		ftrace_sleep
+	}
+
+	sleep 2
+}
+
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
new file mode 100755
index 0000000..d7e6fd3
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh
@@ -0,0 +1,45 @@
+#! /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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+LOOP=200
+
+should_skip=0
+
+if [ ! -e "$TRACING_PATH"/function_profile_enabled ]; then
+        should_skip=1
+fi
+
+# For kernels older than 2.6.36, this testcase can result in
+# divide-by-zero kernel bug
+tst_kvercmp 2 6 36
+if [ $? -eq 0 ]; then
+	should_skip=1
+fi
+
+for ((; ;))
+{
+	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
+	}
+
+	sleep 1
+}
+
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_enabled.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_enabled.sh
new file mode 100755
index 0000000..69f2ae6
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_enabled.sh
@@ -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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+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
+}
+
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
new file mode 100755
index 0000000..f19d734
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh
@@ -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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+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
+}
+
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_on.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_on.sh
new file mode 100755
index 0000000..672c223
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_on.sh
@@ -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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+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
+}
+
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
new file mode 100755
index 0000000..dc8cf3e
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
@@ -0,0 +1,243 @@
+#! /bin/sh
+
+################################################################################
+##                                                                            ##
+## Copyright (c) 2010 FUJITSU LIMITED                                         ##
+##                                                                            ##
+## This program is free software;  you can redistribute it and#or modify      ##
+## it under the terms of the GNU General Public License as published by       ##
+## the Free Software Foundation; either version 2 of the License, or          ##
+## (at your option) any later version.                                        ##
+##                                                                            ##
+## This program is distributed in the hope that it will be useful, but        ##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
+## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
+## for more details.                                                          ##
+##                                                                            ##
+## You should have received a copy of the GNU General Public License          ##
+## along with this program;  if not, write to the Free Software               ##
+## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
+##                                                                            ##
+## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
+##                                                                            ##
+################################################################################
+
+cd $LTPROOT/testcases/bin
+
+export TCID="ftrace-test"
+export TST_TOTAL=1
+export TST_COUNT=1
+
+export TPATH="$PWD"
+export DEBUGFS_PATH="$PWD/debugfs"
+export TRACING_PATH="$PWD/debugfs/tracing"
+export SPATH="$TPATH/ftrace_stress"
+
+test_interval=$1
+test_success=true
+
+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()
+{
+	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
+
+	sleep 2
+	restore_old_setting
+
+	umount $DEBUGFS_PATH
+	rmdir $DEBUGFS_PATH
+}
+
+clean_up_exit()
+{
+	clean_up
+	exit 1
+}
+
+export_pids()
+{
+	export pid1 pid2 pid3 pid4 pid5 pid6 pid7 pid8 pid9 pid10 pid11 pid12 \
+		pid13 pid14 pid15 pid16
+
+	export NR_PIDS=16
+}
+
+test_begin()
+{
+	start_time=`date +%s`
+}
+
+test_wait()
+{
+	for ((; ;))
+	{
+		sleep 2
+
+		cur_time=`date +%s`
+		elapsed=$(( $cur_time - $start_time ))
+
+		# run the test for $test_interval secs
+		if [ $elapsed -ge $test_interval ]; then
+			break
+		fi
+	}
+}
+
+trap clean_up_exit INT
+
+# Should be run by root user
+if [ `id -ru` != 0 ]; then
+	tst_brkm TCONF ignored "The test should be run by root user. Skip the test..."
+	exit 0
+fi
+
+# Don't run the test on kernels older than 2.6.34, otherwise
+# it can crash the system if the kernel is not latest-stable
+tst_kvercmp 2 6 34
+if [ $? -eq 0 ]; then
+	tst_brkm TCONF ignored "The test should be run in kernels >= 2.6.34. Skip the test..."
+	exit 0
+fi
+
+mkdir $DEBUGFS_PATH
+mount -t debugfs xxx $DEBUGFS_PATH
+
+# Check to see tracing feature is supported or not
+if [ ! -d $TRACING_PATH ]; then
+	tst_brkm TCONF ignored "Tracing is not supported. Skip the test..."
+	umount $DEBUGFS_PATH
+	rmdir $DEBUGFS_PATH
+	exit 0
+fi
+
+echo "Ftrace Stress Test Begin"
+
+save_old_setting
+
+test_begin
+
+$SPATH/ftrace_trace_clock.sh &
+pid1=$!
+$SPATH/ftrace_current_tracer.sh &
+pid2=$!
+$SPATH/ftrace_trace_options.sh &
+pid3=$!
+$SPATH/ftrace_tracing_max_latency.sh &
+pid4=$!
+$SPATH/ftrace_stack_trace.sh &
+pid5=$!
+$SPATH/ftrace_stack_max_size.sh &
+pid6=$!
+$SPATH/ftrace_tracing_on.sh &
+pid7=$!
+$SPATH/ftrace_tracing_enabled.sh &
+pid8=$!
+$SPATH/ftrace_set_event.sh &
+pid9=$!
+$SPATH/ftrace_buffer_size.sh &
+pid10=$!
+$SPATH/ftrace_trace.sh &
+pid11=$!
+$SPATH/ftrace_trace_pipe.sh &
+pid12=$!
+$SPATH/ftrace_ftrace_enabled.sh &
+pid13=$!
+$SPATH/ftrace_set_ftrace_pid.sh &
+pid14=$!
+$SPATH/ftrace_profile_enabled.sh &
+pid15=$!
+$SPATH/ftrace_trace_stat.sh &
+pid16=$!
+
+export_pids
+
+test_wait
+
+clean_up
+
+echo "Ftrace Stress Test End"
+
+if $test_success; then
+	tst_resm TPASS "finished running the test. Run dmesg to double-check for bugs"
+else
+	tst_resm TFAIL "please check log message."
+	exit 1
+fi
+
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 3/9] tracing[2]: reorganize ftrace stress tests to general tests
  2016-03-04  8:24   ` [LTP] [PATCH RFC 2/9] tracing[1]: reorganize ftrace-stress tests to general tests Li Wang
@ 2016-03-04  8:24     ` Li Wang
  2016-03-04  8:24       ` [LTP] [PATCH RFC 4/9] ftrace_regression: add new case to ftrace_regression/ dir Li Wang
  2016-03-17 16:39       ` [LTP] [PATCH RFC 3/9] tracing[2]: reorganize ftrace stress tests to general tests Cyril Hrubis
  0 siblings, 2 replies; 27+ messages in thread
From: Li Wang @ 2016-03-04  8:24 UTC (permalink / raw)
  To: ltp

In this commit, code changing as below:
----
new file:   ftrace_regression_test.sh
modified:   ftrace_stress_test.sh
renamed:    ftrace_stress_test.sh -> ftrace_lib.sh

Signed-off-by: Li Wang <liwang@redhat.com>
---
 runtest/tracing                                    |   1 +
 testcases/kernel/tracing/ftrace_test/Makefile      |   2 +-
 testcases/kernel/tracing/ftrace_test/ftrace_lib.sh | 157 +++++++++++++
 .../tracing/ftrace_test/ftrace_regression_test.sh  |  59 +++++
 .../tracing/ftrace_test/ftrace_stress_test.sh      | 256 ++++++---------------
 5 files changed, 285 insertions(+), 190 deletions(-)
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_lib.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_regression_test.sh

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


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 4/9] ftrace_regression: add new case to ftrace_regression/ dir
  2016-03-04  8:24     ` [LTP] [PATCH RFC 3/9] tracing[2]: reorganize ftrace stress " Li Wang
@ 2016-03-04  8:24       ` Li Wang
  2016-03-04  8:24         ` [LTP] [PATCH RFC 5/9] ftrace_regression: add a new testcase Li Wang
  2016-03-17 16:49         ` [LTP] [PATCH RFC 4/9] ftrace_regression: add new case to ftrace_regression/ dir Cyril Hrubis
  2016-03-17 16:39       ` [LTP] [PATCH RFC 3/9] tracing[2]: reorganize ftrace stress tests to general tests Cyril Hrubis
  1 sibling, 2 replies; 27+ messages in thread
From: Li Wang @ 2016-03-04  8:24 UTC (permalink / raw)
  To: ltp

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)

Signed-off-by: Li Wang <liwang@redhat.com>
---
 .../ftrace_panic_with_userstacktrace.sh            | 52 ++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_panic_with_userstacktrace.sh

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


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 5/9] ftrace_regression: add a new testcase
  2016-03-04  8:24       ` [LTP] [PATCH RFC 4/9] ftrace_regression: add new case to ftrace_regression/ dir Li Wang
@ 2016-03-04  8:24         ` Li Wang
  2016-03-04  8:24           ` [LTP] [PATCH RFC 6/9] ftrace_stress: skip unsupported tests Li Wang
  2016-03-17 16:50           ` [LTP] [PATCH RFC 5/9] ftrace_regression: add a new testcase Cyril Hrubis
  2016-03-17 16:49         ` [LTP] [PATCH RFC 4/9] ftrace_regression: add new case to ftrace_regression/ dir Cyril Hrubis
  1 sibling, 2 replies; 27+ messages in thread
From: Li Wang @ 2016-03-04  8:24 UTC (permalink / raw)
  To: ltp

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

Signed-off-by: Li Wang <liwang@redhat.com>
---
 .../ftrace_enhanced_signal_tracepoint.sh           | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_regression/ftrace_enhanced_signal_tracepoint.sh

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


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 6/9] ftrace_stress: skip unsupported tests
  2016-03-04  8:24         ` [LTP] [PATCH RFC 5/9] ftrace_regression: add a new testcase Li Wang
@ 2016-03-04  8:24           ` Li Wang
  2016-03-04  8:24             ` [LTP] [PATCH RFC 7/9] ftrace_stress: keep the name of testscipt in sync with tracing file Li Wang
  2016-03-17 17:07             ` [LTP] [PATCH RFC 6/9] ftrace_stress: skip unsupported tests Cyril Hrubis
  2016-03-17 16:50           ` [LTP] [PATCH RFC 5/9] ftrace_regression: add a new testcase Cyril Hrubis
  1 sibling, 2 replies; 27+ messages in thread
From: Li Wang @ 2016-03-04  8:24 UTC (permalink / raw)
  To: ltp

From: Chunyu Hu <chuhu@redhat.com>

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.

Signed-off-by: Chunyu Hu <chuhu@redhat.com>
---
 testcases/kernel/tracing/ftrace_test/ftrace_lib.sh |  10 +-
 .../ftrace_test/ftrace_stress/ftrace_set_event.sh  |   2 +
 .../ftrace_stress/ftrace_set_ftrace_pid.sh         |  11 --
 .../ftrace_stress/ftrace_stack_max_size.sh         |  11 --
 .../ftrace_stress/ftrace_stack_trace.sh            |  12 ---
 .../ftrace_stress/ftrace_tracing_max_latency.sh    |  12 ---
 .../tracing/ftrace_test/ftrace_stress_test.sh      | 113 ++++++++++-----------
 7 files changed, 64 insertions(+), 107 deletions(-)

diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh b/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh
index 7c72afb..81af617 100755
--- a/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh
@@ -41,9 +41,12 @@ save_old_setting()
 
 	old_trace_options=( `cat trace_options` )
 	old_tracing_on=`cat tracing_on`
-	old_tracing_enabled=`cat tracing_enabled`
 	old_buffer_size=`cat buffer_size_kb`
 
+	if [ -e tracing_enabled ]; then
+		old_tracing_enabled=`cat tracing_enabled`
+	fi
+
 	if [ -e stack_max_size ]; then
 		old_stack_tracer_enabled=`cat /proc/sys/kernel/stack_tracer_enabled`
 	fi
@@ -86,7 +89,10 @@ restore_old_setting()
 
 	echo $old_buffer_size > buffer_size_kb
 	echo $old_tracing_on > tracing_on
-	echo $old_tracing_enabled > tracing_enabled
+
+	if [ -e tracing_enabled ];then
+		echo $old_tracing_enabled > tracing_enabled
+	fi
 
 	for option in $old_trace_options
 	do
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
index d7efdd4..d1a6bd3 100755
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
@@ -36,6 +36,8 @@ for ((; ;))
 
 	for event in `cat $TRACING_PATH/available_events`;
 	do
+		# ftrace event sys is special, skip it
+		[[ $event =~ ftrace:* ]] && continue
 		echo $event >> "$TRACING_PATH"/set_event
 	done
 
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh
index 7bc76d9..3eaf017 100755
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh
@@ -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
 }
-
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh
index 682d05e..34d506b 100755
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh
@@ -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
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh
index a406c51..1850c26 100755
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh
@@ -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
 }
-
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 f19d734..fbaceb8 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
@@ -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
 }
-
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
index beced43..d1be49a 100755
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
@@ -21,82 +21,77 @@
 ##                                                                       ##
 ###########################################################################
 
-
 export TCID="ftrace-stress-test"
 export TST_TOTAL=1
 export TST_COUNT=1
 
 . ftrace_lib.sh
 
-export_pids()
-{
-	export pid1 pid2 pid3 pid4 pid5 pid6 pid7 pid8 pid9 pid10 pid11 pid12 \
-		pid13 pid14 pid15 pid16
+test_targets=" \
+trace_pipe current_tracer ftrace_enabled function_profile_enabled \
+set_event set_ftrace_pid stack_max_size stack_trace trace trace_clock \
+trace_options trace_stat tracing_enabled tracing_max_latency \
+tracing_on function_profile_enabled buffer_size_kb"
 
-	export NR_PIDS=16
+get_skip_targets()
+{
+	for target in ${test_targets}; do
+		if [ ! -e $TRACING_PATH/$target ] &&
+			[ ! -e /proc/sys/kernel/$target ]; then
+			eval skip_$target=1
+			echo "$target is not supported. Skip it."
+		else
+			eval skip_$target=0
+		fi
+	done
 }
 
-test_stress()
+should_skip_target()
 {
-	export_pids
-
-	$SPATH/ftrace_trace_clock.sh &
-	pid1=$!
-	$SPATH/ftrace_current_tracer.sh &
-	pid2=$!
-	$SPATH/ftrace_trace_options.sh &
-	pid3=$!
-	$SPATH/ftrace_tracing_max_latency.sh &
-	pid4=$!
-	$SPATH/ftrace_stack_trace.sh &
-	pid5=$!
-	$SPATH/ftrace_stack_max_size.sh &
-	pid6=$!
-	$SPATH/ftrace_tracing_on.sh &
-	pid7=$!
-	$SPATH/ftrace_tracing_enabled.sh &
-	pid8=$!
-	$SPATH/ftrace_set_event.sh &
-	pid9=$!
-	$SPATH/ftrace_buffer_size.sh &
-	pid10=$!
-	$SPATH/ftrace_trace.sh &
-	pid11=$!
-	$SPATH/ftrace_trace_pipe.sh &
-	pid12=$!
-	$SPATH/ftrace_ftrace_enabled.sh &
-	pid13=$!
-	$SPATH/ftrace_set_ftrace_pid.sh &
-	pid14=$!
-	$SPATH/ftrace_profile_enabled.sh &
-	pid15=$!
-	$SPATH/ftrace_trace_stat.sh &
-	pid16=$!
+	local var=skip_$1
+	local val=${!var}
+	[ "$val" = 1 ]
 }
 
 test_kill()
 {
-	kill -KILL $pid1 || test_success=false
-	kill -KILL $pid2 || test_success=false
-	kill -KILL $pid3 || test_success=false
-	kill -KILL $pid4 || test_success=false
-	kill -KILL $pid5 || test_success=false
-	kill -KILL $pid6 || test_success=false
-	kill -KILL $pid7 || test_success=false
-	kill -KILL $pid8 || test_success=false
-	kill -KILL $pid9 || test_success=false
-	kill -KILL $pid10 || test_success=false
-	kill -KILL $pid11 || test_success=false
-	kill -USR1 $pid12 || test_success=false
-	kill -KILL $pid13 || test_success=false
-	kill -KILL $pid14 || test_success=false
-	kill -KILL $pid15 || test_success=false
-	kill -KILL $pid16 || test_success=false
+	kill -USR1 ${pid0} || test_success=false
+
+	for ((p=1; p<NR_PIDS; p++))
+	{
+		local kill_pid=pid${p}
+		kill -KILL ${!kill_pid} || test_success=false
+	}
 
 	sleep 2
 	clean_up
 }
 
+test_stress()
+{
+	NR_PIDS=0
+	echo "Test targets: ${test_targets}"
+	get_skip_targets
+	for target in ${test_targets}; do
+		if should_skip_target $target; then
+			continue
+		fi
+		$SPATH/ftrace_${target}.sh &
+		eval pid${NR_PIDS}=$!
+		echo "Start pid${NR_PIDS}=$! $SPATH/ftrace_${target}.sh"
+		((NR_PIDS++))
+	done
+	export_pids
+}
+
+export_pids()
+{
+	for ((i=0; i<NR_PIDS; i++))
+	{
+		export pid${i}
+	}
+	export NR_PIDS
+}
 
 # ----------------------------
 echo "Ftrace Stress Test Begin"
@@ -111,11 +106,11 @@ test_wait
 
 test_kill
 
-echo "Ftrace Stress Test End"
-
 if $test_success; then
 	tst_resm TPASS "finished running the test. Run dmesg to double-check for bugs"
 else
 	tst_resm TFAIL "please check log message."
 	exit 1
 fi
+
+echo "Ftrace Stress Test End"
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 7/9] ftrace_stress: keep the name of testscipt in sync with tracing file
  2016-03-04  8:24           ` [LTP] [PATCH RFC 6/9] ftrace_stress: skip unsupported tests Li Wang
@ 2016-03-04  8:24             ` Li Wang
  2016-03-04  8:24               ` [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test Li Wang
  2016-03-17 17:07             ` [LTP] [PATCH RFC 6/9] ftrace_stress: skip unsupported tests Cyril Hrubis
  1 sibling, 1 reply; 27+ messages in thread
From: Li Wang @ 2016-03-04  8:24 UTC (permalink / raw)
  To: ltp

From: Chunyu Hu <chuhu@redhat.com>

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.

Signed-off-by: Chunyu Hu <chuhu@redhat.com>
---
 .../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

diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size.sh
deleted file mode 100755
index bd7dcc4..0000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size.sh
+++ /dev/null
@@ -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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-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
-}
diff --git 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
new file mode 100755
index 0000000..bd7dcc4
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh
@@ -0,0 +1,45 @@
+#! /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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+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
+}
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_function_profile_enabled.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_function_profile_enabled.sh
new file mode 100755
index 0000000..9c6162a
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_function_profile_enabled.sh
@@ -0,0 +1,50 @@
+#! /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 <lizf@cn.fujitsu.com>                                      #
+#                                                                             #
+###############################################################################
+
+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
+
+	count=$(( $count + 1 ))
+
+	for ((i = 0; i < $MAX_LOOP; i++))
+	{
+		echo 0 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
+		echo 1 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
+	}
+
+	enable=$(( $count % 3 ))
+
+	if [ $enable -eq 0 ]; then
+		echo 1 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
+	else
+		echo 0 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
+	fi
+
+	sleep 1
+}
+
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_profile_enabled.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_profile_enabled.sh
deleted file mode 100755
index 9c6162a..0000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_profile_enabled.sh
+++ /dev/null
@@ -1,50 +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 <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-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
-
-	count=$(( $count + 1 ))
-
-	for ((i = 0; i < $MAX_LOOP; i++))
-	{
-		echo 0 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
-		echo 1 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
-	}
-
-	enable=$(( $count % 3 ))
-
-	if [ $enable -eq 0 ]; then
-		echo 1 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
-	else
-		echo 0 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
-	fi
-
-	sleep 1
-}
-
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test
  2016-03-04  8:24             ` [LTP] [PATCH RFC 7/9] ftrace_stress: keep the name of testscipt in sync with tracing file Li Wang
@ 2016-03-04  8:24               ` Li Wang
  2016-03-04  8:24                 ` [LTP] [PATCH RFC 9/9] ftrace_stress: add two new tests Li Wang
  2016-03-17 17:19                 ` [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test Cyril Hrubis
  0 siblings, 2 replies; 27+ messages in thread
From: Li Wang @ 2016-03-04  8:24 UTC (permalink / raw)
  To: ltp

From: Chunyu Hu <chuhu@redhat.com>

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.

Signed-off-by: Chunyu Hu <chuhu@redhat.com>
---
 .../ftrace_test/ftrace_stress/ftrace_trace_options.sh       | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

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


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 9/9] ftrace_stress: add two new tests
  2016-03-04  8:24               ` [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test Li Wang
@ 2016-03-04  8:24                 ` Li Wang
  2016-03-17 18:08                   ` Cyril Hrubis
  2016-03-17 17:19                 ` [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test Cyril Hrubis
  1 sibling, 1 reply; 27+ messages in thread
From: Li Wang @ 2016-03-04  8:24 UTC (permalink / raw)
  To: ltp

From: Chunyu Hu <chuhu@redhat.com>

Signed-off-by: Chunyu Hu <chuhu@redhat.com>
---
 testcases/kernel/tracing/ftrace_test/ftrace_lib.sh |   2 +
 .../ftrace_stress/ftrace_set_ftrace_filter.sh      | 103 +++++++++++++++++++++
 .../ftrace_stress/ftrace_tracing_cpumask.sh        |  51 ++++++++++
 .../tracing/ftrace_test/ftrace_stress_test.sh      |   3 +-
 4 files changed, 158 insertions(+), 1 deletion(-)
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh
 create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh

diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh b/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh
index 81af617..5fceb80 100755
--- a/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh
@@ -42,6 +42,7 @@ save_old_setting()
 	old_trace_options=( `cat trace_options` )
 	old_tracing_on=`cat tracing_on`
 	old_buffer_size=`cat buffer_size_kb`
+	old_tracing_cpumask=`cat tracing_cpumask`
 
 	if [ -e tracing_enabled ]; then
 		old_tracing_enabled=`cat tracing_enabled`
@@ -69,6 +70,7 @@ restore_old_setting()
 	echo nop > current_tracer
 	echo 0 > events/enable
 	echo 0 > tracing_max_latency 2> /dev/null
+	echo $old_tracing_cpumask > tracing_cpumask
 
 	if [ -e trace_clock ]; then
 		echo local > trace_clock
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh
new file mode 100755
index 0000000..2f9a143
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh
@@ -0,0 +1,103 @@
+#! /bin/sh
+###########################################################################
+##                                                                       ##
+## Copyright (c) 2015, Red Hat Inc.                                      ##
+##                                                                       ##
+## This program is free software: you can redistribute it and/or modify  ##
+## it under the terms of the GNU General Public License as published by  ##
+## the Free Software Foundation, either version 3 of the License, or     ##
+## (at your option) any later version.                                   ##
+##                                                                       ##
+## This program is distributed in the hope that it will be useful,       ##
+## but WITHOUT ANY WARRANTY; without even the implied warranty of        ##
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          ##
+## GNU General Public License for more details.                          ##
+##                                                                       ##
+## You should have received a copy of the GNU General Public License     ##
+## along with this program. If not, see <http://www.gnu.org/licenses/>.  ##
+##                                                                       ##
+## Author: Chunyu Hu <chuhu@redhat.com>                                  ##
+##                                                                       ##
+###########################################################################
+
+triggers=( traceon traceoff enable_event disable_event snapshot\
+	 dump cpudump stacktrace module function )
+n_triggers=${#triggers}
+
+module_pick()
+{
+	nr_module=$(lsmod | wc -l)
+	pick_one=$(( (RANDOM % nr_module) +1 ))
+	picked_module=$(lsmod | sed -n ''$pick_one'p')
+}
+
+nr_functions=$(cat $TRACING_PATH/available_filter_functions|wc -l)
+
+function_pick()
+{
+	if [ -f $TRACING_PATH/available_filter_functions ]; then
+		local pick_one=$(( (RANDOM % nr_functions) + 1 ))
+		picked_function=$(cat $TRACING_PATH/available_filter_functions |\
+				 sed -n ''$pick_one'p'|awk '{print $1}')
+		echo $picked_function
+	else
+		echo "\*sched\*"
+	fi
+}
+
+event_pick()
+{
+	if [ -f $TRACING_PATH/available_events ]; then
+		nr_events=$(cat $TRACING_PATH/available_events | wc -l)
+		local pick_one=$(( (RANDOM % nr_events) + 1 ))
+		picked_event=$(cat $TRACING_PATH/available_events | sed -n ''$pick_one'p')
+		echo "$picked_event"
+	else
+		echo "sched:sched_switch"
+	fi
+}
+
+filter_formatter()
+{
+	local count=$(( (RANDOM % 5) + 1 ))
+	function_name=$(function_pick)
+	case $1 in
+	traceon|traceoff|snapshot|dump|cpudump|stacktrace|module|function)
+		format=$1
+		;;
+	enable_event|disable_event)
+		event_sys_name=$(event_pick)
+		format=$1:$event_sys_name
+		;;
+	module)
+		module_pick
+		echo "$picked_module:\*"
+		return
+		;;
+	function)
+		echo "$picked_function"
+		return
+		;;
+	*)
+		format=$1
+		;;
+	esac
+	((count)) && format=$format:$count
+	echo $function_name:$format
+}
+
+for ((; ;))
+{
+	cat $TRACING_PATH/set_ftrace_filter > /dev/null
+	trigger_index=$((RANDOM % n_triggers))
+	trigger_name=${triggers[$trigger_index]}
+	filter_format=$(filter_formatter $trigger_name)
+
+	echo "$filter_format" > $TRACING_PATH/set_ftrace_filter
+	[ $? -ne 0 ] && echo "setup filter <$filter_format> failed"
+
+	sleep 1
+
+	echo "!$filter_format" > $TRACING_PATH/set_ftrace_filter
+	[ $? -ne 0 ] && echo "remove filter <$filter_format> failed"
+}
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh
new file mode 100755
index 0000000..28bbc27
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+
+###########################################################################
+##                                                                       ##
+## Copyright (c) 2015, Red Hat Inc.                                      ##
+##                                                                       ##
+## This program is free software: you can redistribute it and/or modify  ##
+## it under the terms of the GNU General Public License as published by  ##
+## the Free Software Foundation, either version 3 of the License, or     ##
+## (at your option) any later version.                                   ##
+##                                                                       ##
+## This program is distributed in the hope that it will be useful,       ##
+## but WITHOUT ANY WARRANTY; without even the implied warranty of        ##
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          ##
+## GNU General Public License for more details.                          ##
+##                                                                       ##
+## You should have received a copy of the GNU General Public License     ##
+## along with this program. If not, see <http://www.gnu.org/licenses/>.  ##
+##                                                                       ##
+## Author: Chunyu Hu <chuhu@redhat.com>                                  ##
+##                                                                       ##
+###########################################################################
+
+nr_cpus=`tst_ncpus`
+
+get_random_value()
+{
+	local max=$1
+	local min=${2:-0}
+	local random=${RANDOM:-$(date +%N)}
+	echo $(( random % max  ))
+}
+
+get_test_cpumask()
+{
+	local random=${RANDOM:-$(date +%N)}
+	local set_cnt=$(get_random_value $nr_cpus);
+	mask=0
+	for ((c=0; c<set_cnt; c++));do
+		local cpuid=$(get_random_value $nr_cpus)
+		mask=$(( mask| (1<<$cpuid) ))
+	done
+	mask=`echo $mask | awk '{printf "%x",$0}'`
+}
+
+for ((; ;))
+{
+	get_test_cpumask
+	echo $mask > $TRACING_PATH/tracing_cpumask
+	sleep 5
+}
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
index d1be49a..49cae86 100755
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
@@ -31,7 +31,8 @@ test_targets=" \
 trace_pipe current_tracer ftrace_enabled function_profile_enabled \
 set_event set_ftrace_pid stack_max_size stack_trace trace trace_clock \
 trace_options trace_stat tracing_enabled tracing_max_latency \
-tracing_on function_profile_enabled buffer_size_kb"
+tracing_on function_profile_enabled buffer_size_kb tracing_cpumask \
+set_ftrace_filter"
 
 get_skip_targets()
 {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 1/9] ftrace_stress: remove the useless file ftrace_get_page_size.c
  2016-03-04  8:24 ` [LTP] [PATCH RFC 1/9] ftrace_stress: remove the useless file ftrace_get_page_size.c Li Wang
  2016-03-04  8:24   ` [LTP] [PATCH RFC 2/9] tracing[1]: reorganize ftrace-stress tests to general tests Li Wang
@ 2016-03-17 16:29   ` Cyril Hrubis
  1 sibling, 0 replies; 27+ messages in thread
From: Cyril Hrubis @ 2016-03-17 16:29 UTC (permalink / raw)
  To: ltp

Hi!
Pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 3/9] tracing[2]: reorganize ftrace stress tests to general tests
  2016-03-04  8:24     ` [LTP] [PATCH RFC 3/9] tracing[2]: reorganize ftrace stress " Li Wang
  2016-03-04  8:24       ` [LTP] [PATCH RFC 4/9] ftrace_regression: add new case to ftrace_regression/ dir Li Wang
@ 2016-03-17 16:39       ` Cyril Hrubis
  2016-03-18 10:42         ` Li Wang
  1 sibling, 1 reply; 27+ messages in thread
From: Cyril Hrubis @ 2016-03-17 16:39 UTC (permalink / raw)
  To: ltp

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

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

Also newly added test should use test.sh library.

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

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 4/9] ftrace_regression: add new case to ftrace_regression/ dir
  2016-03-04  8:24       ` [LTP] [PATCH RFC 4/9] ftrace_regression: add new case to ftrace_regression/ dir Li Wang
  2016-03-04  8:24         ` [LTP] [PATCH RFC 5/9] ftrace_regression: add a new testcase Li Wang
@ 2016-03-17 16:49         ` Cyril Hrubis
  1 sibling, 0 replies; 27+ messages in thread
From: Cyril Hrubis @ 2016-03-17 16:49 UTC (permalink / raw)
  To: ltp

Hi!
> +LOOP=10
> +
> +TSTACK_TRACE_PATH=/proc/sys/kernel/stack_tracer_enabled
> +
> +cd $TRACING_PATH

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

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

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

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

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

> +if [ $? -ne 0 ];then
> +	echo "Stack Tracer is not cofigured in This kernel. Skip the test"

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

> +else
> +	for ((i = 0; i < $LOOP; i++))
> +	{

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

> +		echo 1 >  $TSTACK_TRACE_PATH
> +		echo userstacktrace > trace_options
> +		grep -q "^userstacktrace"  trace_options
> +
> +		if [ -f "events/exceptions/page_fault_kernel/enable" ]; then
> +			PAGE_FAULT_KERNEL_ENABLE=`cat events/exceptions/page_fault_kernel/enable`
> +			echo 1 > events/exceptions/page_fault_kernel/enable
> +		else
> +			MM_KERNEL_PAGEFAULT_ENABLE=`cat events/kmem/mm_kernel_pagefault/enable`
> +			echo 1 > events/kmem/mm_kernel_pagefault/enable
> +		fi
> +	}
> +
> +	if [ -f "events/exceptions/page_fault_kernel/enable" ]; then
> +		echo "$PAGE_FAULT_KERNEL_ENABLE" > events/exceptions/page_fault_kernel/enable
> +	else
> +		echo "$MM_KERNEL_PAGEFAULT_ENABLE" > events/kmem/mm_kernel_pagefault/enable
> +	fi
> +	# echo "No panic, Still alive."

No unused code in test please.

> +fi
> +
> +cd - > /dev/null
> -- 
> 1.8.3.1
> 
> 
> -- 
> Mailing list info: http://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 5/9] ftrace_regression: add a new testcase
  2016-03-04  8:24         ` [LTP] [PATCH RFC 5/9] ftrace_regression: add a new testcase Li Wang
  2016-03-04  8:24           ` [LTP] [PATCH RFC 6/9] ftrace_stress: skip unsupported tests Li Wang
@ 2016-03-17 16:50           ` Cyril Hrubis
  2016-03-18  7:57             ` Li Wang
  1 sibling, 1 reply; 27+ messages in thread
From: Cyril Hrubis @ 2016-03-17 16:50 UTC (permalink / raw)
  To: ltp

Hi!
> +###############################################################################
> +#                                                                             #
> +# Copyright (c) 2015, Red Hat Inc.                                            #
> +#                                                                             #
> +# This program is free software; you can redistribute it and/or modify it     #
> +# under the terms of the GNU General Public License as published by the Free  #
> +# Software Foundation; either version 2 of the License, or (at your option)   #
> +# any later version.                                                          #
> +#                                                                             #
> +# PURPOSE: check signal:signal_generate gives 2 more fields: grp res          #
> +#                                                                             #
> +# This testcase is verifing signal events change:                             #
> +#        6c303d3 tracing: let trace_signal_generate() report more info...     #
> +#        163566f tracing: send_sigqueue() needs trace_signal_generate() too   #
> +#                                                                             #
> +###############################################################################
> +
> +
> +# Set envent
> +echo 'signal:signal_generate' > $TRACING_PATH/set_event
> +
> +echo 1 > $TRACING_PATH/tracing_on
> +
> +echo > $TRACING_PATH/trace
> +
> +sleep 10

Why sleep 10 here?

> +grep -q 'grp=[0-9] res=[0-9]' $TRACING_PATH/trace
> +if [ $? -eq 0 ]; then
> +	exit 0
> +else
> +	exit 1
> +fi

Use test.sh and tst_resm instead.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 6/9] ftrace_stress: skip unsupported tests
  2016-03-04  8:24           ` [LTP] [PATCH RFC 6/9] ftrace_stress: skip unsupported tests Li Wang
  2016-03-04  8:24             ` [LTP] [PATCH RFC 7/9] ftrace_stress: keep the name of testscipt in sync with tracing file Li Wang
@ 2016-03-17 17:07             ` Cyril Hrubis
  2016-03-18 13:08               ` Chunyu Hu
  1 sibling, 1 reply; 27+ messages in thread
From: Cyril Hrubis @ 2016-03-17 17:07 UTC (permalink / raw)
  To: ltp

Hi!
>  	if [ -e stack_max_size ]; then
>  		old_stack_tracer_enabled=`cat /proc/sys/kernel/stack_tracer_enabled`
>  	fi
> @@ -86,7 +89,10 @@ restore_old_setting()
>  
>  	echo $old_buffer_size > buffer_size_kb
>  	echo $old_tracing_on > tracing_on
> -	echo $old_tracing_enabled > tracing_enabled
> +
> +	if [ -e tracing_enabled ];then
                                  ^
				  missing space here
> +		echo $old_tracing_enabled > tracing_enabled
> +	fi
>  
>  	for option in $old_trace_options
>  	do
> diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
> index d7efdd4..d1a6bd3 100755
> --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
> +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
> @@ -36,6 +36,8 @@ for ((; ;))
>  
>  	for event in `cat $TRACING_PATH/available_events`;
>  	do
> +		# ftrace event sys is special, skip it
> +		[[ $event =~ ftrace:* ]] && continue

This is bashism.

>  		echo $event >> "$TRACING_PATH"/set_event
>  	done
>  
> diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh
> index 7bc76d9..3eaf017 100755
> --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh
> +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh
> @@ -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
>  }
> -
> diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh
> index 682d05e..34d506b 100755
> --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh
> +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh
> @@ -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
> diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh
> index a406c51..1850c26 100755
> --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh
> +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh
> @@ -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
>  }
> -
> 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 f19d734..fbaceb8 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
> @@ -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
>  }
> -
> diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
> index beced43..d1be49a 100755
> --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
> +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
> @@ -21,82 +21,77 @@
>  ##                                                                       ##
>  ###########################################################################
>  
> -
>  export TCID="ftrace-stress-test"
>  export TST_TOTAL=1
>  export TST_COUNT=1
>  
>  . ftrace_lib.sh
>  
> -export_pids()
> -{
> -	export pid1 pid2 pid3 pid4 pid5 pid6 pid7 pid8 pid9 pid10 pid11 pid12 \
> -		pid13 pid14 pid15 pid16
> +test_targets=" \
> +trace_pipe current_tracer ftrace_enabled function_profile_enabled \
> +set_event set_ftrace_pid stack_max_size stack_trace trace trace_clock \
> +trace_options trace_stat tracing_enabled tracing_max_latency \
> +tracing_on function_profile_enabled buffer_size_kb"
>  
> -	export NR_PIDS=16
> +get_skip_targets()
> +{
> +	for target in ${test_targets}; do
> +		if [ ! -e $TRACING_PATH/$target ] &&
> +			[ ! -e /proc/sys/kernel/$target ]; then
> +			eval skip_$target=1
> +			echo "$target is not supported. Skip it."
> +		else
> +			eval skip_$target=0
> +		fi
> +	done
>  }
>  
> -test_stress()
> +should_skip_target()
>  {
> -	export_pids
> -
> -	$SPATH/ftrace_trace_clock.sh &
> -	pid1=$!
> -	$SPATH/ftrace_current_tracer.sh &
> -	pid2=$!
> -	$SPATH/ftrace_trace_options.sh &
> -	pid3=$!
> -	$SPATH/ftrace_tracing_max_latency.sh &
> -	pid4=$!
> -	$SPATH/ftrace_stack_trace.sh &
> -	pid5=$!
> -	$SPATH/ftrace_stack_max_size.sh &
> -	pid6=$!
> -	$SPATH/ftrace_tracing_on.sh &
> -	pid7=$!
> -	$SPATH/ftrace_tracing_enabled.sh &
> -	pid8=$!
> -	$SPATH/ftrace_set_event.sh &
> -	pid9=$!
> -	$SPATH/ftrace_buffer_size.sh &
> -	pid10=$!
> -	$SPATH/ftrace_trace.sh &
> -	pid11=$!
> -	$SPATH/ftrace_trace_pipe.sh &
> -	pid12=$!
> -	$SPATH/ftrace_ftrace_enabled.sh &
> -	pid13=$!
> -	$SPATH/ftrace_set_ftrace_pid.sh &
> -	pid14=$!
> -	$SPATH/ftrace_profile_enabled.sh &
> -	pid15=$!
> -	$SPATH/ftrace_trace_stat.sh &
> -	pid16=$!
> +	local var=skip_$1
> +	local val=${!var}
> +	[ "$val" = 1 ]
>  }
>  
>  test_kill()
>  {
> -	kill -KILL $pid1 || test_success=false
> -	kill -KILL $pid2 || test_success=false
> -	kill -KILL $pid3 || test_success=false
> -	kill -KILL $pid4 || test_success=false
> -	kill -KILL $pid5 || test_success=false
> -	kill -KILL $pid6 || test_success=false
> -	kill -KILL $pid7 || test_success=false
> -	kill -KILL $pid8 || test_success=false
> -	kill -KILL $pid9 || test_success=false
> -	kill -KILL $pid10 || test_success=false
> -	kill -KILL $pid11 || test_success=false
> -	kill -USR1 $pid12 || test_success=false
> -	kill -KILL $pid13 || test_success=false
> -	kill -KILL $pid14 || test_success=false
> -	kill -KILL $pid15 || test_success=false
> -	kill -KILL $pid16 || test_success=false
> +	kill -USR1 ${pid0} || test_success=false
> +
> +	for ((p=1; p<NR_PIDS; p++))
> +	{
> +		local kill_pid=pid${p}
> +		kill -KILL ${!kill_pid} || test_success=false
> +	}

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

>  	sleep 2

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

>  	clean_up
>  }
>  
> +test_stress()
> +{
> +	NR_PIDS=0
> +	echo "Test targets: ${test_targets}"
> +	get_skip_targets
> +	for target in ${test_targets}; do
> +		if should_skip_target $target; then
> +			continue
> +		fi
> +		$SPATH/ftrace_${target}.sh &

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

> +		eval pid${NR_PIDS}=$!
> +		echo "Start pid${NR_PIDS}=$! $SPATH/ftrace_${target}.sh"
> +		((NR_PIDS++))

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

> +	done
> +	export_pids
> +}
> +
> +export_pids()
> +{
> +	for ((i=0; i<NR_PIDS; i++))
> +	{
> +		export pid${i}
> +	}

Bashism again.

> +	export NR_PIDS
> +}
>  
>  # ----------------------------
>  echo "Ftrace Stress Test Begin"
> @@ -111,11 +106,11 @@ test_wait
>  
>  test_kill
>  
> -echo "Ftrace Stress Test End"
> -
>  if $test_success; then
>  	tst_resm TPASS "finished running the test. Run dmesg to double-check for bugs"
>  else
>  	tst_resm TFAIL "please check log message."
>  	exit 1
>  fi

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

> +echo "Ftrace Stress Test End"

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

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test
  2016-03-04  8:24               ` [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test Li Wang
  2016-03-04  8:24                 ` [LTP] [PATCH RFC 9/9] ftrace_stress: add two new tests Li Wang
@ 2016-03-17 17:19                 ` Cyril Hrubis
  2016-03-17 17:28                   ` Cyril Hrubis
  2016-03-18 13:21                   ` Chunyu Hu
  1 sibling, 2 replies; 27+ messages in thread
From: Cyril Hrubis @ 2016-03-17 17:19 UTC (permalink / raw)
  To: ltp

Hi!
> +# enable the nop_test_refuse can cause an
> +# 'write error: Invalid argument'. So don't
> +# test it.
> +option_files=${option_files/test_nop_refuse/}
> +trace_options=( $option_files )
> +
> +NR_TRACE_OPTIONS=${#trace_options[*]}

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

The portable way is plain old wc:

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

>  for ((; ; ))
>  {

Please fix these bash style loops as well.

> @@ -25,7 +31,6 @@ for ((; ; ))
>  	{
>  		num=`date +%N`
>  		num=`printf 1%s $num`
> -
>  		for ((i = 0; i < $NR_TRACE_OPTIONS; i++))
>  		{

And here.

>  			n=$(( ( $num >> $i ) % 2 ))
> @@ -34,9 +39,9 @@ for ((; ; ))
>  			else
>  				echo 1 > "$TRACING_PATH"/options/${trace_options[$i]}
>  			fi
> +			[ $? -ne 0 ] && echo "setup trace option ${trace_options[$i]} failed"

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

>  		}
>  	}
>  
>  	sleep 1
>  }
> -
> -- 
> 1.8.3.1
> 
> 
> -- 
> Mailing list info: http://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test
  2016-03-17 17:19                 ` [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test Cyril Hrubis
@ 2016-03-17 17:28                   ` Cyril Hrubis
  2016-03-18 13:24                     ` Chunyu Hu
  2016-03-18 13:21                   ` Chunyu Hu
  1 sibling, 1 reply; 27+ messages in thread
From: Cyril Hrubis @ 2016-03-17 17:28 UTC (permalink / raw)
  To: ltp

Hi!
> > +# enable the nop_test_refuse can cause an
> > +# 'write error: Invalid argument'. So don't
> > +# test it.
> > +option_files=${option_files/test_nop_refuse/}
> > +trace_options=( $option_files )
> > +
> > +NR_TRACE_OPTIONS=${#trace_options[*]}
> 
> This does not work even in bash because the trace_options is never
> casted to array so it just returns 0.

My bad, it is converted by the ().

But the point is the same, use portable code.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 9/9] ftrace_stress: add two new tests
  2016-03-04  8:24                 ` [LTP] [PATCH RFC 9/9] ftrace_stress: add two new tests Li Wang
@ 2016-03-17 18:08                   ` Cyril Hrubis
  2016-03-18 14:08                     ` Chunyu Hu
  0 siblings, 1 reply; 27+ messages in thread
From: Cyril Hrubis @ 2016-03-17 18:08 UTC (permalink / raw)
  To: ltp

Hi!
> +###########################################################################
> +##                                                                       ##
> +## Copyright (c) 2015, Red Hat Inc.                                      ##
> +##                                                                       ##
> +## This program is free software: you can redistribute it and/or modify  ##
> +## it under the terms of the GNU General Public License as published by  ##
> +## the Free Software Foundation, either version 3 of the License, or     ##
> +## (at your option) any later version.                                   ##
> +##                                                                       ##
> +## This program is distributed in the hope that it will be useful,       ##
> +## but WITHOUT ANY WARRANTY; without even the implied warranty of        ##
> +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          ##
> +## GNU General Public License for more details.                          ##
> +##                                                                       ##
> +## You should have received a copy of the GNU General Public License     ##
> +## along with this program. If not, see <http://www.gnu.org/licenses/>.  ##
> +##                                                                       ##
> +## Author: Chunyu Hu <chuhu@redhat.com>                                  ##
> +##                                                                       ##
> +###########################################################################
> +
> +triggers=( traceon traceoff enable_event disable_event snapshot\
> +	 dump cpudump stacktrace module function )
> +n_triggers=${#triggers}

Bashism again.

> +module_pick()
> +{
> +	nr_module=$(lsmod | wc -l)
> +	pick_one=$(( (RANDOM % nr_module) +1 ))
> +	picked_module=$(lsmod | sed -n ''$pick_one'p')

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

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

> +}
> +
> +nr_functions=$(cat $TRACING_PATH/available_filter_functions|wc -l)

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

> +function_pick()
> +{
	local AVAILABLE_FUNCTIONS="$TRACING_PATH/available_filter_functions"
> +	if [ -f $TRACING_PATH/available_filter_functions ]; then
> +		local pick_one=$(( (RANDOM % nr_functions) + 1 ))
> +		picked_function=$(cat $TRACING_PATH/available_filter_functions |\
> +				 sed -n ''$pick_one'p'|awk '{print $1}')
> +		echo $picked_function

You can just do:

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

instead of cat, sed and echo.

> +	else
> +		echo "\*sched\*"
> +	fi
> +}
> +
> +event_pick()
> +{
> +	if [ -f $TRACING_PATH/available_events ]; then
> +		nr_events=$(cat $TRACING_PATH/available_events | wc -l)
> +		local pick_one=$(( (RANDOM % nr_events) + 1 ))
> +		picked_event=$(cat $TRACING_PATH/available_events | sed -n ''$pick_one'p')
> +
> +		echo "$picked_event"

Here as well no need to use echo and cat:

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

> +	else
> +		echo "sched:sched_switch"
> +	fi
> +}
> +
> +filter_formatter()
> +{
> +	local count=$(( (RANDOM % 5) + 1 ))
> +	function_name=$(function_pick)
> +	case $1 in
> +	traceon|traceoff|snapshot|dump|cpudump|stacktrace|module|function)
> +		format=$1
> +		;;
> +	enable_event|disable_event)
> +		event_sys_name=$(event_pick)
> +		format=$1:$event_sys_name
> +		;;
> +	module)
> +		module_pick
> +		echo "$picked_module:\*"
> +		return
> +		;;
> +	function)
> +		echo "$picked_function"
> +		return
> +		;;
> +	*)
> +		format=$1
> +		;;
> +	esac
> +	((count)) && format=$format:$count

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

> +	echo $function_name:$format
> +}
> +
> +for ((; ;))
> +{

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

> +	cat $TRACING_PATH/set_ftrace_filter > /dev/null

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

> +	trigger_index=$((RANDOM % n_triggers))
> +	trigger_name=${triggers[$trigger_index]}
> +	filter_format=$(filter_formatter $trigger_name)
> +
> +	echo "$filter_format" > $TRACING_PATH/set_ftrace_filter
> +	[ $? -ne 0 ] && echo "setup filter <$filter_format> failed"

Shouldn't we report a failure here?

> +	sleep 1
> +
> +	echo "!$filter_format" > $TRACING_PATH/set_ftrace_filter
> +	[ $? -ne 0 ] && echo "remove filter <$filter_format> failed"

Here as well.

> +}
> diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh
> new file mode 100755
> index 0000000..28bbc27
> --- /dev/null
> +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh
> @@ -0,0 +1,51 @@
> +#! /bin/sh
> +
> +###########################################################################
> +##                                                                       ##
> +## Copyright (c) 2015, Red Hat Inc.                                      ##
> +##                                                                       ##
> +## This program is free software: you can redistribute it and/or modify  ##
> +## it under the terms of the GNU General Public License as published by  ##
> +## the Free Software Foundation, either version 3 of the License, or     ##
> +## (at your option) any later version.                                   ##
> +##                                                                       ##
> +## This program is distributed in the hope that it will be useful,       ##
> +## but WITHOUT ANY WARRANTY; without even the implied warranty of        ##
> +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          ##
> +## GNU General Public License for more details.                          ##
> +##                                                                       ##
> +## You should have received a copy of the GNU General Public License     ##
> +## along with this program. If not, see <http://www.gnu.org/licenses/>.  ##
> +##                                                                       ##
> +## Author: Chunyu Hu <chuhu@redhat.com>                                  ##
> +##                                                                       ##
> +###########################################################################
> +
> +nr_cpus=`tst_ncpus`
> +
> +get_random_value()
> +{
> +	local max=$1
> +	local min=${2:-0}
> +	local random=${RANDOM:-$(date +%N)}
> +	echo $(( random % max  ))
> +}

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

it should really be:

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

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

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

> +get_test_cpumask()
> +{
> +	local random=${RANDOM:-$(date +%N)}

Unused variable.

> +	local set_cnt=$(get_random_value $nr_cpus);
> +	mask=0
> +	for ((c=0; c<set_cnt; c++));do

Bashism.

> +		local cpuid=$(get_random_value $nr_cpus)
> +		mask=$(( mask| (1<<$cpuid) ))
> +	done
> +	mask=`echo $mask | awk '{printf "%x",$0}'`

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

get_test_cpumask > $TRACING_PATH/tracing_cpumask

in the main loop?

> +}
> +
> +for ((; ;))
> +{

Bashism.

> +	get_test_cpumask
> +	echo $mask > $TRACING_PATH/tracing_cpumask
> +	sleep 5

Why sleep 5?

> +}
> diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
> index d1be49a..49cae86 100755
> --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
> +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
> @@ -31,7 +31,8 @@ test_targets=" \
>  trace_pipe current_tracer ftrace_enabled function_profile_enabled \
>  set_event set_ftrace_pid stack_max_size stack_trace trace trace_clock \
>  trace_options trace_stat tracing_enabled tracing_max_latency \
> -tracing_on function_profile_enabled buffer_size_kb"
> +tracing_on function_profile_enabled buffer_size_kb tracing_cpumask \
> +set_ftrace_filter"
>  
>  get_skip_targets()
>  {
> -- 
> 1.8.3.1
> 
> 
> -- 
> Mailing list info: http://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 5/9] ftrace_regression: add a new testcase
  2016-03-17 16:50           ` [LTP] [PATCH RFC 5/9] ftrace_regression: add a new testcase Cyril Hrubis
@ 2016-03-18  7:57             ` Li Wang
  0 siblings, 0 replies; 27+ messages in thread
From: Li Wang @ 2016-03-18  7:57 UTC (permalink / raw)
  To: ltp

Hi,

Thanks for reviewing. Comments in follows:

On Fri, Mar 18, 2016 at 12:50 AM, Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> >
> +###############################################################################
> > +#
>        #
> > +# Copyright (c) 2015, Red Hat Inc.
>       #
> > +#
>        #
> > +# This program is free software; you can redistribute it and/or modify
> it     #
> > +# under the terms of the GNU General Public License as published by the
> Free  #
> > +# Software Foundation; either version 2 of the License, or (at your
> option)   #
> > +# any later version.
>       #
> > +#
>        #
> > +# PURPOSE: check signal:signal_generate gives 2 more fields: grp res
>       #
> > +#
>        #
> > +# This testcase is verifing signal events change:
>        #
> > +#        6c303d3 tracing: let trace_signal_generate() report more
> info...     #
> > +#        163566f tracing: send_sigqueue() needs trace_signal_generate()
> too   #
> > +#
>        #
> >
> +###############################################################################
> > +
> > +
> > +# Set envent
> > +echo 'signal:signal_generate' > $TRACING_PATH/set_event
> > +
> > +echo 1 > $TRACING_PATH/tracing_on
> > +
> > +echo > $TRACING_PATH/trace
> > +
> > +sleep 10
>
> Why sleep 10 here?
>

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


> > +grep -q 'grp=[0-9] res=[0-9]' $TRACING_PATH/trace
> > +if [ $? -eq 0 ]; then
> > +     exit 0
> > +else
> > +     exit 1
> > +fi
>
> Use test.sh and tst_resm instead.
>

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

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



-- 
Regards,
Li Wang
Email: liwang@redhat.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20160318/2cd9dac2/attachment.html>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 3/9] tracing[2]: reorganize ftrace stress tests to general tests
  2016-03-17 16:39       ` [LTP] [PATCH RFC 3/9] tracing[2]: reorganize ftrace stress tests to general tests Cyril Hrubis
@ 2016-03-18 10:42         ` Li Wang
  2016-03-21 12:21           ` Cyril Hrubis
  0 siblings, 1 reply; 27+ messages in thread
From: Li Wang @ 2016-03-18 10:42 UTC (permalink / raw)
  To: ltp

Hi Cyril,

On Fri, Mar 18, 2016 at 12:39 AM, Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> ...
>
> Adding a script that runs all testcases is frowned upon in LTP. What you
> should do instead is to make it possible to run individual testcases and
> add the tests one test per line to a runtest file.
>
>
Seems like these regression cases are petty and simple. I fear that would
be too dispersed to read. How about taking use of the cgroup tests
code-style to organise them?

which will be like:
---------------------
$ cat ftrace_regression_test.sh
#! /bin/sh
...

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

. ftrace_lib.sh

test_success=false

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

    test_success=false
}

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

test_2()
{
   ...
   test_check;
}

test_3()
{
   ...
   test_check;
}

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

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

save_old_setting

test_regression

clean_up

echo "Ftrace Regression Test End"



> Also newly added test should use test.sh library.
>

sure, this no problem!

-- 
Regards,
Li Wang
Email: liwang@redhat.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20160318/1bbe9eee/attachment-0001.html>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 6/9] ftrace_stress: skip unsupported tests
  2016-03-17 17:07             ` [LTP] [PATCH RFC 6/9] ftrace_stress: skip unsupported tests Cyril Hrubis
@ 2016-03-18 13:08               ` Chunyu Hu
  0 siblings, 0 replies; 27+ messages in thread
From: Chunyu Hu @ 2016-03-18 13:08 UTC (permalink / raw)
  To: ltp

Hi Cyril,

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

I also your replied the issues below. Thanks!

----- Original Message -----
> From: "Cyril Hrubis" <chrubis@suse.cz>
> To: "Li Wang" <liwang@redhat.com>
> Cc: ltp@lists.linux.it
> Sent: Friday, March 18, 2016 1:07:01 AM
> Subject: Re: [LTP] [PATCH RFC 6/9] ftrace_stress: skip unsupported tests
> 
> Hi!
> >  	if [ -e stack_max_size ]; then
> >  		old_stack_tracer_enabled=`cat /proc/sys/kernel/stack_tracer_enabled`
> >  	fi
> > @@ -86,7 +89,10 @@ restore_old_setting()
> >  
> >  	echo $old_buffer_size > buffer_size_kb
> >  	echo $old_tracing_on > tracing_on
> > -	echo $old_tracing_enabled > tracing_enabled
> > +
> > +	if [ -e tracing_enabled ];then
>                                   ^
> 				  missing space here

Will modify it in V2. Thanks.


> > a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
> > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
> > index d7efdd4..d1a6bd3 100755
> > ---
> > a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
> > +++
> > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
> > @@ -36,6 +36,8 @@ for ((; ;))
> >  
> >  	for event in `cat $TRACING_PATH/available_events`;
> >  	do
> > +		# ftrace event sys is special, skip it
> > +		[[ $event =~ ftrace:* ]] && continue
> This is bashism.


I just had a experience with bash. thanks for catching this issue. Will update it 
with something like:
 
if echo $event | grep "ftrace:*"; then
        continue;
fi


> > diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
> > b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
> > index beced43..d1be49a 100755
> > --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
> > +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
> > @@ -21,82 +21,77 @@

> > -	kill -USR1 $pid12 || test_success=false
> > -	kill -KILL $pid13 || test_success=false
> > -	kill -KILL $pid14 || test_success=false
> > -	kill -KILL $pid15 || test_success=false
> > -	kill -KILL $pid16 || test_success=false
> > +	kill -USR1 ${pid0} || test_success=false
> > +
> > +	for ((p=1; p<NR_PIDS; p++))
> > +	{
> > +		local kill_pid=pid${p}
> > +		kill -KILL ${!kill_pid} || test_success=false
> > +	}
> 
> Again this is bashism loop over $(seq NR_PIDS).

Thanks for catching this.

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

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

        done

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

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



> >  	clean_up
> >  }
> >  
> > +test_stress()
> > +{
> > +	NR_PIDS=0
> > +	echo "Test targets: ${test_targets}"
> > +	get_skip_targets
> > +	for target in ${test_targets}; do
> > +		if should_skip_target $target; then
> > +			continue
> > +		fi
> > +		$SPATH/ftrace_${target}.sh &
> 
> The path to test binaries must be in $PATH before testcases are executed
> so you should just do ftrace_${target}.sh & instead.

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


> > +		eval pid${NR_PIDS}=$!
> > +		echo "Start pid${NR_PIDS}=$! $SPATH/ftrace_${target}.sh"
> > +		((NR_PIDS++))
> 
> Bashism. Portable way is a=$((a+1))

Thanks for reviewing this. Will update this in V2.


> > +	done
> > +	export_pids
> > +}
> > +
> > +export_pids()
> > +{
> > +	for ((i=0; i<NR_PIDS; i++))
> > +	{
> > +		export pid${i}
> > +	}
> 
> Bashism again.


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


> > +	export NR_PIDS
> > +}
> >  
> >  # ----------------------------
> >  echo "Ftrace Stress Test Begin"
> > @@ -111,11 +106,11 @@ test_wait
> >  
> >  test_kill
> >  
> > -echo "Ftrace Stress Test End"
> > -
> >  if $test_success; then
> >  	tst_resm TPASS "finished running the test. Run dmesg to double-check for
> >  	bugs"
> >  else
> >  	tst_resm TFAIL "please check log message."
> >  	exit 1
> >  fi
> 
> Again the test should be really converted to test.sh library. That way
> we would exit with correct exit status at tst_exit instead of calling
> exit manually depending on some flag.

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

> > +echo "Ftrace Stress Test End"
> 
> And ideally bashism should be fixed in the substests called from this
> tests. So that the test can run with dash or bussy box as well.

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

> --
> Cyril Hrubis
> chrubis@suse.cz
> 
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
> 

-- 
Regards,
Chunyu Hu


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test
  2016-03-17 17:19                 ` [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test Cyril Hrubis
  2016-03-17 17:28                   ` Cyril Hrubis
@ 2016-03-18 13:21                   ` Chunyu Hu
  1 sibling, 0 replies; 27+ messages in thread
From: Chunyu Hu @ 2016-03-18 13:21 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> From: "Cyril Hrubis" <chrubis@suse.cz>
> To: "Li Wang" <liwang@redhat.com>
> Cc: ltp@lists.linux.it
> Sent: Friday, March 18, 2016 1:19:00 AM
> Subject: Re: [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test
> 
> Hi!
> > +# enable the nop_test_refuse can cause an
> > +# 'write error: Invalid argument'. So don't
> > +# test it.
> > +option_files=${option_files/test_nop_refuse/}
> > +trace_options=( $option_files )
> > +
> > +NR_TRACE_OPTIONS=${#trace_options[*]}
> 
> This does not work even in bash because the trace_options is never
> casted to array so it just returns 0.
> 
> The portable way is plain old wc:
> 
> NR=$(echo $trace_options |wc -w)

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

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


> >  for ((; ; ))
> >  {
> 
> Please fix these bash style loops as well.

Will do it in V2. Thanks.

> > @@ -25,7 +31,6 @@ for ((; ; ))
> >  	{
> >  		num=`date +%N`
> >  		num=`printf 1%s $num`
> > -
> >  		for ((i = 0; i < $NR_TRACE_OPTIONS; i++))
> >  		{
> 
> And here.

Will modify this in V2. Thanks for reviewing this.

> >  			n=$(( ( $num >> $i ) % 2 ))
> > @@ -34,9 +39,9 @@ for ((; ; ))
> >  			else
> >  				echo 1 > "$TRACING_PATH"/options/${trace_options[$i]}
> >  			fi
> > +			[ $? -ne 0 ] && echo "setup trace option ${trace_options[$i]} failed"
> 
> Shouldn't this check be just after the echo rather than here?

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

> >  		}
> >  	}
> >  
> >  	sleep 1
> >  }
> > -
> > --
> > 1.8.3.1
> > 
> > 
> > --
> > Mailing list info: http://lists.linux.it/listinfo/ltp
> 
> --
> Cyril Hrubis
> chrubis@suse.cz
> 
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
> 

-- 
Regards,
Chunyu Hu


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test
  2016-03-17 17:28                   ` Cyril Hrubis
@ 2016-03-18 13:24                     ` Chunyu Hu
  0 siblings, 0 replies; 27+ messages in thread
From: Chunyu Hu @ 2016-03-18 13:24 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> From: "Cyril Hrubis" <chrubis@suse.cz>
> To: "Li Wang" <liwang@redhat.com>
> Cc: ltp@lists.linux.it
> Sent: Friday, March 18, 2016 1:28:51 AM
> Subject: Re: [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test
> 
> Hi!
> > > +# enable the nop_test_refuse can cause an
> > > +# 'write error: Invalid argument'. So don't
> > > +# test it.
> > > +option_files=${option_files/test_nop_refuse/}
> > > +trace_options=( $option_files )
> > > +
> > > +NR_TRACE_OPTIONS=${#trace_options[*]}
> > 
> > This does not work even in bash because the trace_options is never
> > casted to array so it just returns 0.
> 
> My bad, it is converted by the ().
> 
> But the point is the same, use portable code.

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

> --
> Cyril Hrubis
> chrubis@suse.cz
> 
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
> 

-- 
Regards,
Chunyu Hu


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 9/9] ftrace_stress: add two new tests
  2016-03-17 18:08                   ` Cyril Hrubis
@ 2016-03-18 14:08                     ` Chunyu Hu
  2016-03-21 12:09                       ` Cyril Hrubis
  0 siblings, 1 reply; 27+ messages in thread
From: Chunyu Hu @ 2016-03-18 14:08 UTC (permalink / raw)
  To: ltp


Hi Cyril,

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

----- Original Message -----
> From: "Cyril Hrubis" <chrubis@suse.cz>
> To: "Li Wang" <liwang@redhat.com>
> Cc: ltp@lists.linux.it
> Sent: Friday, March 18, 2016 2:08:33 AM
> Subject: Re: [LTP] [PATCH RFC 9/9] ftrace_stress: add two new tests
> 
> Hi!
> > +###########################################################################
> > +##
> > ##
> > +## Copyright (c) 2015, Red Hat Inc.
> > ##
> > +##
> > ##
> > +## This program is free software: you can redistribute it and/or modify
> > ##
> > +## it under the terms of the GNU General Public License as published by
> > ##
> > +## the Free Software Foundation, either version 3 of the License, or
> > ##
> > +## (at your option) any later version.
> > ##
> > +##
> > ##
> > +## This program is distributed in the hope that it will be useful,
> > ##
> > +## but WITHOUT ANY WARRANTY; without even the implied warranty of
> > ##
> > +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > ##
> > +## GNU General Public License for more details.
> > ##
> > +##
> > ##
> > +## You should have received a copy of the GNU General Public License
> > ##
> > +## along with this program. If not, see <http://www.gnu.org/licenses/>.
> > ##
> > +##
> > ##
> > +## Author: Chunyu Hu <chuhu@redhat.com>
> > ##
> > +##
> > ##
> > +###########################################################################
> > +
> > +triggers=( traceon traceoff enable_event disable_event snapshot\
> > +	 dump cpudump stacktrace module function )
> > +n_triggers=${#triggers}
> 
> Bashism again.

Hi Cyril,

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

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

Thanks!

> > +module_pick()
> > +{
> > +	nr_module=$(lsmod | wc -l)
> > +	pick_one=$(( (RANDOM % nr_module) +1 ))
> > +	picked_module=$(lsmod | sed -n ''$pick_one'p')
> 
> Unfortunately there is no portable way to get random numbers in shell.

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

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

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


> > +}
> > +
> > +nr_functions=$(cat $TRACING_PATH/available_filter_functions|wc -l)
> 
> You can do just 'wc -l $TRACING_PATH/available_filter_functions'

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

> > +function_pick()
> > +{
> 	local AVAILABLE_FUNCTIONS="$TRACING_PATH/available_filter_functions"
> > +	if [ -f $TRACING_PATH/available_filter_functions ]; then
> > +		local pick_one=$(( (RANDOM % nr_functions) + 1 ))
> > +		picked_function=$(cat $TRACING_PATH/available_filter_functions |\
> > +				 sed -n ''$pick_one'p'|awk '{print $1}')
> > +		echo $picked_function
> 
> You can just do:
> 
> 		awk "{if (NR==$pick_one) {print \$1}}" $AVAILABLE_FUNCTIONS
> 
> instead of cat, sed and echo.

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

> > +	else
> > +		echo "\*sched\*"
> > +	fi
> > +}
> > +
> > +event_pick()
> > +{
> > +	if [ -f $TRACING_PATH/available_events ]; then
> > +		nr_events=$(cat $TRACING_PATH/available_events | wc -l)
> > +		local pick_one=$(( (RANDOM % nr_events) + 1 ))
> > +		picked_event=$(cat $TRACING_PATH/available_events | sed -n
> > ''$pick_one'p')
> > +
> > +		echo "$picked_event"
> 
> Here as well no need to use echo and cat:
> 
> sed -n ''$pick_one'p' $AVAILABLE_EVENTS

Will update it V2. Thanks!


> > +	else
> > +		echo "sched:sched_switch"
> > +	fi
> > +}
> > +
> > +filter_formatter()
> > +{
> > +	local count=$(( (RANDOM % 5) + 1 ))
> > +	function_name=$(function_pick)
> > +	case $1 in
> > +	traceon|traceoff|snapshot|dump|cpudump|stacktrace|module|function)
> > +		format=$1
> > +		;;
> > +	enable_event|disable_event)
> > +		event_sys_name=$(event_pick)
> > +		format=$1:$event_sys_name
> > +		;;
> > +	module)
> > +		module_pick
> > +		echo "$picked_module:\*"
> > +		return
> > +		;;
> > +	function)
> > +		echo "$picked_function"
> > +		return
> > +		;;
> > +	*)
> > +		format=$1
> > +		;;
> > +	esac
> > +	((count)) && format=$format:$count
> 
> Bahsism. Also the count is non-zero since it's RANDOM % 5 + 1.

Will modify it in V2. Something like:

if [ $count -gt 0 ]; then
     .....
fi

And will correct the random issue in V2. Thanks.


> > +	echo $function_name:$format
> > +}
> > +
> > +for ((; ;))
> > +{
> 
> Bash style loop. Use while true; do ... done

Will make it while []; do in V2.


> > +	cat $TRACING_PATH/set_ftrace_filter > /dev/null
> 
> Why do we cat the file to /dev/null?

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

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

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

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


> > +	trigger_index=$((RANDOM % n_triggers))
> > +	trigger_name=${triggers[$trigger_index]}
> > +	filter_format=$(filter_formatter $trigger_name)
> > +
> > +	echo "$filter_format" > $TRACING_PATH/set_ftrace_filter
> > +	[ $? -ne 0 ] && echo "setup filter <$filter_format> failed"
> 
> Shouldn't we report a failure here?

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

> > +	sleep 1
> > +
> > +	echo "!$filter_format" > $TRACING_PATH/set_ftrace_filter
> > +	[ $? -ne 0 ] && echo "remove filter <$filter_format> failed"
> 
> Here as well.

Will make it report ltp test failure on V2.

> > +}
> > diff --git
> > a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh
> > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh
> > new file mode 100755
> > index 0000000..28bbc27
> > --- /dev/null
> > +++
> > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh
> > @@ -0,0 +1,51 @@
> > +#! /bin/sh
> > +
> > +###########################################################################
> > +##
> > ##
> > +## Copyright (c) 2015, Red Hat Inc.
> > ##
> > +##
> > ##
> > +## This program is free software: you can redistribute it and/or modify
> > ##
> > +## it under the terms of the GNU General Public License as published by
> > ##
> > +## the Free Software Foundation, either version 3 of the License, or
> > ##
> > +## (at your option) any later version.
> > ##
> > +##
> > ##
> > +## This program is distributed in the hope that it will be useful,
> > ##
> > +## but WITHOUT ANY WARRANTY; without even the implied warranty of
> > ##
> > +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > ##
> > +## GNU General Public License for more details.
> > ##
> > +##
> > ##
> > +## You should have received a copy of the GNU General Public License
> > ##
> > +## along with this program. If not, see <http://www.gnu.org/licenses/>.
> > ##
> > +##
> > ##
> > +## Author: Chunyu Hu <chuhu@redhat.com>
> > ##
> > +##
> > ##
> > +###########################################################################
> > +
> > +nr_cpus=`tst_ncpus`
> > +
> > +get_random_value()
> > +{
> > +	local max=$1
> > +	local min=${2:-0}
> > +	local random=${RANDOM:-$(date +%N)}
> > +	echo $(( random % max  ))
> > +}
> 
> Well looks like you have implemented portable random function after all
> although the range does not work at all.

Hmm, it's not working, agree. So the only portable way is using the
glibc interfaces. You mean I need to write this with c lib, or you mean
you will do this? Thanks !
 
> it should really be:
> 
> echo $((min + (random % (max - min + 1))))

Good algorithm. I just didn't realize this way. 
 
> Which would cover range [min, max] including both min and max.
> 
> And the function should be in a library used by all the testcases.
> 
> > +get_test_cpumask()
> > +{
> > +	local random=${RANDOM:-$(date +%N)}
> 
> Unused variable.

Ah, will remove that in V2.


> > +	local set_cnt=$(get_random_value $nr_cpus);
> > +	mask=0
> > +	for ((c=0; c<set_cnt; c++));do
> 
> Bashism.

Will fix this in V2.

> > +		local cpuid=$(get_random_value $nr_cpus)
> > +		mask=$(( mask| (1<<$cpuid) ))
> > +	done
> > +	mask=`echo $mask | awk '{printf "%x",$0}'`
> 
> Why can't we echo the mask here and do:
> 
> get_test_cpumask > $TRACING_PATH/tracing_cpumask
> 
> in the main loop?

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



> > +}
> > +
> > +for ((; ;))
> > +{
> 
> Bashism.

Will fix in V2. Thanks.


> > +	get_test_cpumask
> > +	echo $mask > $TRACING_PATH/tracing_cpumask
> > +	sleep 5
> 
> Why sleep 5?

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

> > +}
> > diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
> > b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
> > index d1be49a..49cae86 100755
> > --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
> > +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
> > @@ -31,7 +31,8 @@ test_targets=" \
> >  trace_pipe current_tracer ftrace_enabled function_profile_enabled \
> >  set_event set_ftrace_pid stack_max_size stack_trace trace trace_clock \
> >  trace_options trace_stat tracing_enabled tracing_max_latency \
> > -tracing_on function_profile_enabled buffer_size_kb"
> > +tracing_on function_profile_enabled buffer_size_kb tracing_cpumask \
> > +set_ftrace_filter"
> >  
> >  get_skip_targets()
> >  {
> > --
> > 1.8.3.1
> > 
> > 
> > --
> > Mailing list info: http://lists.linux.it/listinfo/ltp
> 
> --
> Cyril Hrubis
> chrubis@suse.cz
> 
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
> 

-- 
Regards,
Chunyu Hu


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 9/9] ftrace_stress: add two new tests
  2016-03-18 14:08                     ` Chunyu Hu
@ 2016-03-21 12:09                       ` Cyril Hrubis
  0 siblings, 0 replies; 27+ messages in thread
From: Cyril Hrubis @ 2016-03-21 12:09 UTC (permalink / raw)
  To: ltp

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

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

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

Arrays are bash specific feature.

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

That would be the best solution.

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

...

> > > +	cat $TRACING_PATH/set_ftrace_filter > /dev/null
> > 
> > Why do we cat the file to /dev/null?
> 
> since the set_ftrace_filter can use reg match and support mod.
> such as if I:
> 
> echo :mod:kvm > /sys/kernel/debug/tracing/set_ftrace_filter 
> 
> cat /sys/kernel/debug/tracing/set_ftrace_filter  | head -n 10
> ack_flush [kvm]
> kvm_get_kvm [kvm]
> kvm_disable_largepages [kvm]
> kvm_vcpu_mmap [kvm]
> kvm_io_bus_sort_cmp [kvm]
> mark_page_dirty_in_slot [kvm]
> kvm_sched_out [kvm]
> kvm_vcpu_init [kvm]
> kvm_vcpu_uninit [kvm]
> 
> The log will be rather long, I just concern it will make the log
> too large. You suggest make it show ?

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

> > > +}
> > > diff --git
> > > a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh
> > > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh
> > > new file mode 100755
> > > index 0000000..28bbc27
> > > --- /dev/null
> > > +++
> > > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh
> > > @@ -0,0 +1,51 @@
> > > +#! /bin/sh
> > > +
> > > +###########################################################################
> > > +##
> > > ##
> > > +## Copyright (c) 2015, Red Hat Inc.
> > > ##
> > > +##
> > > ##
> > > +## This program is free software: you can redistribute it and/or modify
> > > ##
> > > +## it under the terms of the GNU General Public License as published by
> > > ##
> > > +## the Free Software Foundation, either version 3 of the License, or
> > > ##
> > > +## (at your option) any later version.
> > > ##
> > > +##
> > > ##
> > > +## This program is distributed in the hope that it will be useful,
> > > ##
> > > +## but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > ##
> > > +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > > ##
> > > +## GNU General Public License for more details.
> > > ##
> > > +##
> > > ##
> > > +## You should have received a copy of the GNU General Public License
> > > ##
> > > +## along with this program. If not, see <http://www.gnu.org/licenses/>.
> > > ##
> > > +##
> > > ##
> > > +## Author: Chunyu Hu <chuhu@redhat.com>
> > > ##
> > > +##
> > > ##
> > > +###########################################################################
> > > +
> > > +nr_cpus=`tst_ncpus`
> > > +
> > > +get_random_value()
> > > +{
> > > +	local max=$1
> > > +	local min=${2:-0}
> > > +	local random=${RANDOM:-$(date +%N)}
> > > +	echo $(( random % max  ))
> > > +}
> > 
> > Well looks like you have implemented portable random function after all
> > although the range does not work at all.
> 
> Hmm, it's not working, agree. So the only portable way is using the
> glibc interfaces. You mean I need to write this with c lib, or you mean
> you will do this? Thanks !

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

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 3/9] tracing[2]: reorganize ftrace stress tests to general tests
  2016-03-18 10:42         ` Li Wang
@ 2016-03-21 12:21           ` Cyril Hrubis
  2016-03-22  8:27             ` Li Wang
  0 siblings, 1 reply; 27+ messages in thread
From: Cyril Hrubis @ 2016-03-21 12:21 UTC (permalink / raw)
  To: ltp

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

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

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

> which will be like:
> ---------------------
> $ cat ftrace_regression_test.sh
> #! /bin/sh
> ...
> 
> export TCID="ftrace-regression-test"
> export TST_TOTAL=N ( N depends on how many test_$cur)
> export TST_COUNT=1
> 
> . ftrace_lib.sh
> 
> test_success=false
> 
> test_check()
> {
>     if $test_success; then
>         tst_resm TPASS "finished running the test."
>     else
>         tst_resm TFAIL "running the test failed, please check log message."
>     fi
> 
>     test_success=false

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

> }
> 
> #comments the test_1 info blablabla....
> test_1()
> {
>    ...
>    set test_success 'true' or 'false' base on the test result
>    ...
>    test_check;
> }
> 
> test_2()
> {
>    ...
>    test_check;
> }
> 
> test_3()
> {
>    ...
>    test_check;
> }
> 
> test_regression()
> {
>     for cur in $(seq $TST_TOTAL); do
>         test_$cur
>     done
> }
> 
> #----------------------------------
> echo "Ftrace Regression Test Begin"
> 
> save_old_setting
> 
> test_regression
> 
> clean_up
> 
> echo "Ftrace Regression Test End"

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

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [LTP] [PATCH RFC 3/9] tracing[2]: reorganize ftrace stress tests to general tests
  2016-03-21 12:21           ` Cyril Hrubis
@ 2016-03-22  8:27             ` Li Wang
  0 siblings, 0 replies; 27+ messages in thread
From: Li Wang @ 2016-03-22  8:27 UTC (permalink / raw)
  To: ltp

Hi Cyril,

On Mon, Mar 21, 2016 at 8:21 PM, Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> > Seems like these regression cases are petty and simple. I fear that would
> > be too dispersed to read. How about taking use of the cgroup tests
> > code-style to organise them?
>
> I do not think so. The problem with running to many testcases as one
> test is that we get wrong idea about the overall result. Even if one
> regression test fails the test will return failure and instead of 90%
> green we end up with 100% red in the results.
>

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


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

-- 
Regards,
Li Wang
Email: liwang@redhat.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20160322/d063e72e/attachment.html>

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2016-03-22  8:27 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-04  8:24 [LTP] [PATCH RFC 0/9] tracing: make ftrace tests to be extended Li Wang
2016-03-04  8:24 ` [LTP] [PATCH RFC 1/9] ftrace_stress: remove the useless file ftrace_get_page_size.c Li Wang
2016-03-04  8:24   ` [LTP] [PATCH RFC 2/9] tracing[1]: reorganize ftrace-stress tests to general tests Li Wang
2016-03-04  8:24     ` [LTP] [PATCH RFC 3/9] tracing[2]: reorganize ftrace stress " Li Wang
2016-03-04  8:24       ` [LTP] [PATCH RFC 4/9] ftrace_regression: add new case to ftrace_regression/ dir Li Wang
2016-03-04  8:24         ` [LTP] [PATCH RFC 5/9] ftrace_regression: add a new testcase Li Wang
2016-03-04  8:24           ` [LTP] [PATCH RFC 6/9] ftrace_stress: skip unsupported tests Li Wang
2016-03-04  8:24             ` [LTP] [PATCH RFC 7/9] ftrace_stress: keep the name of testscipt in sync with tracing file Li Wang
2016-03-04  8:24               ` [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test Li Wang
2016-03-04  8:24                 ` [LTP] [PATCH RFC 9/9] ftrace_stress: add two new tests Li Wang
2016-03-17 18:08                   ` Cyril Hrubis
2016-03-18 14:08                     ` Chunyu Hu
2016-03-21 12:09                       ` Cyril Hrubis
2016-03-17 17:19                 ` [LTP] [PATCH RFC 8/9] ftrace_stress: update the trace_options test Cyril Hrubis
2016-03-17 17:28                   ` Cyril Hrubis
2016-03-18 13:24                     ` Chunyu Hu
2016-03-18 13:21                   ` Chunyu Hu
2016-03-17 17:07             ` [LTP] [PATCH RFC 6/9] ftrace_stress: skip unsupported tests Cyril Hrubis
2016-03-18 13:08               ` Chunyu Hu
2016-03-17 16:50           ` [LTP] [PATCH RFC 5/9] ftrace_regression: add a new testcase Cyril Hrubis
2016-03-18  7:57             ` Li Wang
2016-03-17 16:49         ` [LTP] [PATCH RFC 4/9] ftrace_regression: add new case to ftrace_regression/ dir Cyril Hrubis
2016-03-17 16:39       ` [LTP] [PATCH RFC 3/9] tracing[2]: reorganize ftrace stress tests to general tests Cyril Hrubis
2016-03-18 10:42         ` Li Wang
2016-03-21 12:21           ` Cyril Hrubis
2016-03-22  8:27             ` Li Wang
2016-03-17 16:29   ` [LTP] [PATCH RFC 1/9] ftrace_stress: remove the useless file ftrace_get_page_size.c Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.