* [LTP] [PATCH V3-2 0/9] tracing: make ftrace tests to be extended
@ 2016-05-11 11:36 Chunyu Hu
2016-05-11 11:36 ` [LTP] [PATCH V3-2 1/9] tracing: reorganize ftrace-stress tests to general tests Chunyu Hu
2016-06-06 15:45 ` [LTP] [PATCH V3-2 0/9] tracing: make ftrace tests to be extended Cyril Hrubis
0 siblings, 2 replies; 14+ messages in thread
From: Chunyu Hu @ 2016-05-11 11:36 UTC (permalink / raw)
To: ltp
For the purpose of extending these ftrace cases, We rewrite some of them
to partition testcase into new structure.
- Reorganize the stress tests to ftrace general test, then that woule
be easy to introduce new function/regression testcases in the next
step.
- Adding two regression testcases as an example, We will roll
out some more later.
- Enhance the ftrace-stress test coverage.
- Do some cleanup and bug fix work.
At last, test PASS all the new testcases on kernel-4.5.0.
Changes in V2 -> V3:
1. Fix bashism issue in ftrace_stress_test.sh and tracing_cpu_mask.sh
2. ftrace_stress: remove the useless sleep in ftrace_stress_test.sh after wait.
3. ftrace_stress: remove useless ".test.sh" in some sub cases.
4. add ftrace_test_init to initiate test env and setup TST_CLEANUP=clean_up.
5. use tst_exit in ftrace_regression01 and ftrace_regression02, and remove the
'ignore' in tst_* usage.
6. simplify test_wait in ftrace_lib.sh.
7. cleanup the ';' in i=0 and j=0.
8. tst_random cleanup according to Cyril's advise.
Changes from V1 -> V2:
1. Use ltp lib api.
2. Fix bashism issues.
3. ftrace_regression_test: make the two sub tests as two independent tests.
4. ftrace_stress: Wait for pid after execing a killing of sub test.
5. ftrace_stress: Fix tracing_cpumask test for case nr_cpu > 32.
6. ftrace_stress: Fix set_ftrace_filter test for module filter.
7. ftrace_stress: Fix small issue for trace_options test.
Chunyu Hu (6):
ftrace_stress: skip unsupported tests and early cleanup
ftrace_stress: keep the name of testscipt in sync with tracing file
testcases/lib: Add tst_random decmical integer generator
ftrace_stress: update the trace_options test
ftrace_stress: add two new tests for ftrace_filter and
tracing_cpu_mask
ftrace_stress: cleanup and use ltp API
Li Wang (3):
tracing: reorganize ftrace-stress tests to general tests
tracing/ftrace: add new case for ftrace userstacktrace
tracing/ftrace: add a new case for signal_generate
^ permalink raw reply [flat|nested] 14+ messages in thread* [LTP] [PATCH V3-2 1/9] tracing: reorganize ftrace-stress tests to general tests 2016-05-11 11:36 [LTP] [PATCH V3-2 0/9] tracing: make ftrace tests to be extended Chunyu Hu @ 2016-05-11 11:36 ` Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 2/9] tracing/ftrace: add new case for ftrace userstacktrace Chunyu Hu 2016-06-06 15:45 ` [LTP] [PATCH V3-2 0/9] tracing: make ftrace tests to be extended Cyril Hrubis 1 sibling, 1 reply; 14+ messages in thread From: Chunyu Hu @ 2016-05-11 11:36 UTC (permalink / raw) To: ltp From: Li Wang <liwang@redhat.com> This commit is just preparing for the upcoming patch set. So do rename work, not changing anything of the content. Changs: - renamed: ftrace_stress_test/ --> ftrace_test/ - extracted: ftrace_stress_test.sh --> ftrace_lib.sh - modified: ftrace_stress_test.sh 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 + testcases/kernel/tracing/ftrace_test/ftrace_lib.sh | 156 +++++++++++++ .../ftrace_stress/ftrace_buffer_size.sh | 45 ++++ .../ftrace_stress/ftrace_current_tracer.sh | 34 +++ .../ftrace_stress/ftrace_ftrace_enabled.sh | 39 ++++ .../ftrace_stress/ftrace_profile_enabled.sh | 50 +++++ .../ftrace_test/ftrace_stress/ftrace_set_event.sh | 44 ++++ .../ftrace_stress/ftrace_set_ftrace_pid.sh | 49 +++++ .../ftrace_stress/ftrace_stack_max_size.sh | 39 ++++ .../ftrace_stress/ftrace_stack_trace.sh | 46 ++++ .../ftrace_test/ftrace_stress/ftrace_trace.sh | 27 +++ .../ftrace_stress/ftrace_trace_clock.sh | 46 ++++ .../ftrace_stress/ftrace_trace_options.sh | 42 ++++ .../ftrace_test/ftrace_stress/ftrace_trace_pipe.sh | 52 +++++ .../ftrace_test/ftrace_stress/ftrace_trace_stat.sh | 45 ++++ .../ftrace_stress/ftrace_tracing_enabled.sh | 39 ++++ .../ftrace_stress/ftrace_tracing_max_latency.sh | 38 ++++ .../ftrace_test/ftrace_stress/ftrace_tracing_on.sh | 39 ++++ .../tracing/ftrace_test/ftrace_stress_test.sh | 123 +++++++++++ 37 files changed, 960 insertions(+), 924 deletions(-) delete mode 100644 testcases/kernel/tracing/ftrace_stress_test/Makefile delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_buffer_size.sh delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_current_tracer.sh delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_ftrace_enabled.sh delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_profile_enabled.sh delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_set_event.sh delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_set_ftrace_pid.sh delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_stack_max_size.sh delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_stack_trace.sh delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace.sh delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_clock.sh delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_options.sh delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_pipe.sh delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_trace_stat.sh delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_enabled.sh delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_max_latency.sh delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress/ftrace_tracing_on.sh delete mode 100755 testcases/kernel/tracing/ftrace_stress_test/ftrace_stress_test.sh create mode 100644 testcases/kernel/tracing/ftrace_test/Makefile create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_lib.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_current_tracer.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_ftrace_enabled.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_profile_enabled.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_enabled.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_on.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh 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_lib.sh b/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh new file mode 100755 index 0000000..ea082dc --- /dev/null +++ b/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh @@ -0,0 +1,156 @@ +#! /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 + +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_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..d9f7f8b --- /dev/null +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh @@ -0,0 +1,123 @@ +#! /bin/sh + +########################################################################### +## ## +## Copyright (c) 2010 FUJITSU LIMITED ## +## ## +## This program is free software: you can redistribute it and/or modify ## +## it under the terms of the GNU General Public License as published by ## +## the Free Software Foundation, either version 3 of the License, or ## +## (at your option) any later version. ## +## ## +## This program is distributed in the hope that it will be useful, ## +## but WITHOUT ANY WARRANTY; without even the implied warranty of ## +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## +## GNU General Public License for more details. ## +## ## +## You should have received a copy of the GNU General Public License ## +## along with this program. If not, see <http://www.gnu.org/licenses/>. ## +## ## +## Author: Li Zefan <lizf@cn.fujitsu.com> ## +## ## +########################################################################### + + +export TCID="ftrace-stress-test" +export TST_TOTAL=1 +export TST_COUNT=1 + +. ftrace_lib.sh + +test_success=true + +export_pids() +{ + export pid1 pid2 pid3 pid4 pid5 pid6 pid7 pid8 pid9 pid10 pid11 pid12 \ + pid13 pid14 pid15 pid16 + + export NR_PIDS=16 +} + +test_stress() +{ + export_pids + + $SPATH/ftrace_trace_clock.sh & + pid1=$! + $SPATH/ftrace_current_tracer.sh & + pid2=$! + $SPATH/ftrace_trace_options.sh & + pid3=$! + $SPATH/ftrace_tracing_max_latency.sh & + pid4=$! + $SPATH/ftrace_stack_trace.sh & + pid5=$! + $SPATH/ftrace_stack_max_size.sh & + pid6=$! + $SPATH/ftrace_tracing_on.sh & + pid7=$! + $SPATH/ftrace_tracing_enabled.sh & + pid8=$! + $SPATH/ftrace_set_event.sh & + pid9=$! + $SPATH/ftrace_buffer_size.sh & + pid10=$! + $SPATH/ftrace_trace.sh & + pid11=$! + $SPATH/ftrace_trace_pipe.sh & + pid12=$! + $SPATH/ftrace_ftrace_enabled.sh & + pid13=$! + $SPATH/ftrace_set_ftrace_pid.sh & + pid14=$! + $SPATH/ftrace_profile_enabled.sh & + pid15=$! + $SPATH/ftrace_trace_stat.sh & + pid16=$! +} + +test_kill() +{ + kill -KILL $pid1 || test_success=false + kill -KILL $pid2 || test_success=false + kill -KILL $pid3 || test_success=false + kill -KILL $pid4 || test_success=false + kill -KILL $pid5 || test_success=false + kill -KILL $pid6 || test_success=false + kill -KILL $pid7 || test_success=false + kill -KILL $pid8 || test_success=false + kill -KILL $pid9 || test_success=false + kill -KILL $pid10 || test_success=false + kill -KILL $pid11 || test_success=false + kill -USR1 $pid12 || test_success=false + kill -KILL $pid13 || test_success=false + kill -KILL $pid14 || test_success=false + kill -KILL $pid15 || test_success=false + kill -KILL $pid16 || test_success=false + + sleep 2 + clean_up +} + + +# ---------------------------- +echo "Ftrace Stress Test Begin" + +save_old_setting + +test_begin + +test_stress + +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 -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [PATCH V3-2 2/9] tracing/ftrace: add new case for ftrace userstacktrace 2016-05-11 11:36 ` [LTP] [PATCH V3-2 1/9] tracing: reorganize ftrace-stress tests to general tests Chunyu Hu @ 2016-05-11 11:36 ` Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 3/9] tracing/ftrace: add a new case for signal_generate Chunyu Hu 0 siblings, 1 reply; 14+ messages in thread From: Chunyu Hu @ 2016-05-11 11:36 UTC (permalink / raw) To: ltp From: Li Wang <liwang@redhat.com> 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> --- runtest/tracing | 1 + .../tracing/ftrace_test/ftrace_regression01.sh | 86 ++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh diff --git a/runtest/tracing b/runtest/tracing index ef3a048..fb82515 100644 --- a/runtest/tracing +++ b/runtest/tracing @@ -1,2 +1,3 @@ #DESCRIPTION:Tracing testing +ftrace_regression01 ftrace_regression01.sh ftrace-stress-test ftrace_stress_test.sh 90 diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh b/testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh new file mode 100755 index 0000000..b25111a --- /dev/null +++ b/testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh @@ -0,0 +1,86 @@ +#! /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> ## +## ## +########################################################################### +## ## +## Summary: panic while using userstacktrace ## +## ## +## 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: ../system/cpu/cpu15/cache/index2/shared_cpu_map ## +## ## +## The bug was fixed by: ## +## 1dbd195 (tracing: Fix preempt count leak) ## +## ## +########################################################################### + +export TCID="ftrace_regression01" +export TST_TOTAL=1 + +. ftrace_lib.sh + +LOOP=10 + +TSTACK_TRACE_PATH="/proc/sys/kernel/stack_tracer_enabled" +EXC_PAGE_FAULT_ENABLE="$TRACING_PATH/events/exceptions/page_fault_kernel/enable" +MM_PAGE_FAULT_ENABLE="$TRACING_PATH/events/kmem/mm_kernel_pagefault/enable" + +ftrace_userstacktrace_test() +{ + if [ ! -e "$TSTACK_TRACE_PATH" ]; then + tst_brkm TCONF "Stack Tracer is not cofigured in This kernel" + fi + + for i in $(seq $LOOP); do + echo 1 > $TSTACK_TRACE_PATH + echo userstacktrace > $TRACING_PATH/trace_options + grep -q "^userstacktrace" $TRACING_PATH/trace_options + if [ $? -ne 0 ]; then + tst_brkm TBROK "Failed to set userstacktrace" + fi + + if [ -f "$EXC_PAGE_FAULT_ENABLE" ]; then + exc_page_fault_enable=`cat $EXC_PAGE_FAULT_ENABLE` + echo 1 > $EXC_PAGE_FAULT_ENABLE + else + mm_page_fault_enable=`cat MM_PAGE_FAULT_ENABLE` + echo 1 > $MM_PAGE_FAULT_ENABLE + fi + done + + if [ -f "$EXC_PAGE_FAULT_ENABLE" ]; then + echo "$exc_page_fault_enable" > $EXC_PAGE_FAULT_ENABLE + else + echo "$mm_page_fault_enable" > $MM_PAGE_FAULT_ENABLE + fi + + tst_resm TPASS "Finished running the test" +} + +#--------Test Start-------------- +save_old_setting + +ftrace_userstacktrace_test + +clean_up -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [PATCH V3-2 3/9] tracing/ftrace: add a new case for signal_generate 2016-05-11 11:36 ` [LTP] [PATCH V3-2 2/9] tracing/ftrace: add new case for ftrace userstacktrace Chunyu Hu @ 2016-05-11 11:36 ` Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 4/9] ftrace_stress: skip unsupported tests and early cleanup Chunyu Hu 0 siblings, 1 reply; 14+ messages in thread From: Chunyu Hu @ 2016-05-11 11:36 UTC (permalink / raw) To: ltp From: Li Wang <liwang@redhat.com> 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> --- runtest/tracing | 1 + .../tracing/ftrace_test/ftrace_regression02.sh | 67 ++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh diff --git a/runtest/tracing b/runtest/tracing index fb82515..9f8d5c8 100644 --- a/runtest/tracing +++ b/runtest/tracing @@ -1,3 +1,4 @@ #DESCRIPTION:Tracing testing ftrace_regression01 ftrace_regression01.sh +ftrace_regression02 ftrace_regression02.sh ftrace-stress-test ftrace_stress_test.sh 90 diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh b/testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh new file mode 100755 index 0000000..6704749 --- /dev/null +++ b/testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh @@ -0,0 +1,67 @@ +#! /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> ## +## ## +########################################################################### +## ## +## Summary: 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() ## +## ## +########################################################################### + +export TCID="ftrace_regression02" +export TST_TOTAL=1 + +. ftrace_lib.sh + +ftrace_signal_test() +{ + # Set envent + echo 'signal:signal_generate' > $TRACING_PATH/set_event + echo 1 > $TRACING_PATH/tracing_on + echo > $TRACING_PATH/trace + + # just to generate trace + for i in $(seq 100); do + ls -l /proc > /dev/null 2>&1 + done + + grep -q 'grp=[0-9] res=[0-9]' $TRACING_PATH/trace + if [ $? -eq 0 ]; then + tst_resm TPASS "finished running the test." + else + tst_resm TFAIL "running the test failed, please check log message." + fi +} + +#-----Test Start-------- +tst_kvercmp 3 2 0 +if [ $? -eq 0 ]; then + tst_brkm TCONF "The test should be run in kernels >= 3.2.0 Skip the test..." +fi + +save_old_setting + +ftrace_signal_test + +clean_up -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [PATCH V3-2 4/9] ftrace_stress: skip unsupported tests and early cleanup 2016-05-11 11:36 ` [LTP] [PATCH V3-2 3/9] tracing/ftrace: add a new case for signal_generate Chunyu Hu @ 2016-05-11 11:36 ` Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 5/9] ftrace_stress: keep the name of testscipt in sync with tracing file Chunyu Hu 0 siblings, 1 reply; 14+ messages in thread From: Chunyu Hu @ 2016-05-11 11:36 UTC (permalink / raw) To: ltp Checking if it's supported before lanuching a test script. This action is through verifying the matched file in ftrace tracing direcrotry. At the same time, transform the hard coded pids to the test_targets string and make it easier to be controlled. With this modification, the outdated tracing_enabled issue can be skiped on newer kernels. V2: fix the bashism code style. use ltp lib. V3: 1 fix white space issue in test_kill. 2 fix another ${!var} bashism. 3 remove the unneened sleep 2. 4 move clean_up() out from test_kill. 5 Also an early cleanup ftrace_lib.sh after the reorg, add a ftrace_test_init in ftrace_lib.sh, and move the save_old_setting in it, which will be called at test bebin. Signed-off-by: Chunyu Hu <chuhu@redhat.com> --- testcases/kernel/tracing/ftrace_test/ftrace_lib.sh | 108 ++++++++-------- .../tracing/ftrace_test/ftrace_regression01.sh | 5 +- .../tracing/ftrace_test/ftrace_regression02.sh | 5 +- .../ftrace_test/ftrace_stress/ftrace_set_event.sh | 5 +- .../ftrace_stress/ftrace_set_ftrace_pid.sh | 11 -- .../ftrace_stress/ftrace_stack_max_size.sh | 11 -- .../ftrace_stress/ftrace_stack_trace.sh | 12 -- .../ftrace_stress/ftrace_tracing_max_latency.sh | 12 -- .../tracing/ftrace_test/ftrace_stress_test.sh | 136 ++++++++++----------- 9 files changed, 134 insertions(+), 171 deletions(-) diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh b/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh index ea082dc..c131827 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh ########################################################################### ## ## @@ -21,16 +21,38 @@ ## ## ########################################################################### -cd $LTPROOT/testcases/bin +. test.sh -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" +ftrace_test_init() +{ + export TPATH="$PWD" + export SPATH="$TPATH/ftrace_stress" + + if grep -q debugfs /proc/mounts; then + export DEBUGFS_PATH=/sys/kernel/debug/ + export TRACING_PATH="$DEBUGFS_PATH/tracing" + debugfs_def_mounted=1 + else + tst_tmpdir + export DEBUGFS_PATH="$PWD/debugfs" + export TRACING_PATH="$PWD/debugfs/tracing" + mkdir $DEBUGFS_PATH + mount -t debugfs xxx $DEBUGFS_PATH + fi -. test.sh + TST_CLEANUP=clean_up + + trap clean_up_exit INT + + tst_require_root + + # Check to see tracing feature is supported or not + if [ ! -d $TRACING_PATH ]; then + tst_brkm TCONF "Tracing is not supported. Skip the test..." + fi + + save_old_setting +} test_interval=$1 @@ -40,9 +62,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 @@ -55,11 +80,17 @@ save_old_setting() old_profile_enabled=`cat function_profile_enabled` fi + setting_saved=1 + cd - > /dev/null } restore_old_setting() { + if [ ! "$setting_saved" = 1 ]; then + return + fi + cd $TRACING_PATH echo nop > current_tracer @@ -85,7 +116,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 @@ -97,20 +131,28 @@ restore_old_setting() cd - > /dev/null } +clean_up_mount() +{ + if [ ! "$debugfs_def_mounted" = "1" ]; then + umount $DEBUGFS_PATH + rmdir $DEBUGFS_PATH + fi +} + clean_up() { restore_old_setting - - umount $DEBUGFS_PATH - rmdir $DEBUGFS_PATH + clean_up_mount } clean_up_exit() { - clean_up + restore_old_setting + clean_up_mount exit 1 } + test_begin() { start_time=`date +%s` @@ -118,39 +160,9 @@ test_begin() 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 - } + # run the test for $test_interval secs + tst_sleep ${test_interval}s } -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 +ftrace_test_init -# 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_regression01.sh b/testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh index b25111a..a14b9d5 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh @@ -79,8 +79,7 @@ ftrace_userstacktrace_test() } #--------Test Start-------------- -save_old_setting - ftrace_userstacktrace_test -clean_up +tst_exit + diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh b/testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh index 6704749..1bf9d11 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh @@ -60,8 +60,7 @@ if [ $? -eq 0 ]; then tst_brkm TCONF "The test should be run in kernels >= 3.2.0 Skip the test..." fi -save_old_setting - ftrace_signal_test -clean_up +tst_exit + 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..e8fd5ea 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,9 +36,12 @@ for ((; ;)) for event in `cat $TRACING_PATH/available_events`; do + # ftrace event sys is special, skip it + if echo "$event" | grep "ftrace:*"; then + continue + fi echo $event >> "$TRACING_PATH"/set_event done sleep 1 } - 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 d9f7f8b..514f566 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh @@ -21,89 +21,89 @@ ## ## ########################################################################### - export TCID="ftrace-stress-test" export TST_TOTAL=1 export TST_COUNT=1 . ftrace_lib.sh -test_success=true +test_targets=" \ +trace_pipe current_tracer ftrace_enabled function_profile_enabled \ +set_event set_ftrace_pid stack_max_size stack_trace trace trace_clock \ +trace_options trace_stat tracing_enabled tracing_max_latency \ +tracing_on function_profile_enabled buffer_size_kb" -export_pids() +get_skip_targets() { - export pid1 pid2 pid3 pid4 pid5 pid6 pid7 pid8 pid9 pid10 pid11 pid12 \ - pid13 pid14 pid15 pid16 + NR_PIDS=0 + for target in ${test_targets}; do + if [ ! -e $TRACING_PATH/$target ] && + [ ! -e /proc/sys/kernel/$target ]; then + eval skip_$target=1 + tst_resm TINFO "$target is not supported. Skip it." + else + eval skip_$target=0 + NR_PIDS=$((NR_PIDS + 1)) + fi + done + # Export it before sub case is lanuched. + export NR_PIDS +} - export NR_PIDS=16 +should_skip_target() +{ + local skip_var=skip_$1 + eval local skip_val=\$${skip_var} + [ "$skip_val" = 1 ] +} + +test_kill() +{ + tst_resm TINFO "killing ${pid0}" + kill -USR1 ${pid0} + wait ${pid0} + + local p=1; + while [ $p -lt $NR_PIDS ]; do + local pid_var=pid${p} + eval local kill_pid=\$${pid_var} + tst_resm TINFO "killing ${kill_pid}" + kill -KILL $kill_pid + wait ${kill_pid} + p=$((p + 1)) + done } test_stress() { + local index=0; + + tst_resm TINFO "Test targets: ${test_targets}" + + get_skip_targets + for target in ${test_targets}; do + if should_skip_target $target; then + continue + fi + ./ftrace_stress/ftrace_${target}.sh & + eval pid${index}=$! + tst_resm TINFO "Start pid${index}=$! $SPATH/ftrace_${target}.sh" + index=$((index + 1)) + done export_pids - - $SPATH/ftrace_trace_clock.sh & - pid1=$! - $SPATH/ftrace_current_tracer.sh & - pid2=$! - $SPATH/ftrace_trace_options.sh & - pid3=$! - $SPATH/ftrace_tracing_max_latency.sh & - pid4=$! - $SPATH/ftrace_stack_trace.sh & - pid5=$! - $SPATH/ftrace_stack_max_size.sh & - pid6=$! - $SPATH/ftrace_tracing_on.sh & - pid7=$! - $SPATH/ftrace_tracing_enabled.sh & - pid8=$! - $SPATH/ftrace_set_event.sh & - pid9=$! - $SPATH/ftrace_buffer_size.sh & - pid10=$! - $SPATH/ftrace_trace.sh & - pid11=$! - $SPATH/ftrace_trace_pipe.sh & - pid12=$! - $SPATH/ftrace_ftrace_enabled.sh & - pid13=$! - $SPATH/ftrace_set_ftrace_pid.sh & - pid14=$! - $SPATH/ftrace_profile_enabled.sh & - pid15=$! - $SPATH/ftrace_trace_stat.sh & - pid16=$! } -test_kill() +export_pids() { - 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 - clean_up + local p=0 + while [ $p -lt $NR_PIDS ]; do + export pid${p} + p=$((p + 1)) + done } - # ---------------------------- -echo "Ftrace Stress Test Begin" - -save_old_setting +tst_resm TINFO "Ftrace Stress Test Begin" test_begin @@ -113,11 +113,7 @@ test_wait test_kill -echo "Ftrace Stress Test End" +tst_resm TINFO "Finished running the test. Run dmesg to double-check for bugs" + +tst_exit -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] 14+ messages in thread
* [LTP] [PATCH V3-2 5/9] ftrace_stress: keep the name of testscipt in sync with tracing file 2016-05-11 11:36 ` [LTP] [PATCH V3-2 4/9] ftrace_stress: skip unsupported tests and early cleanup Chunyu Hu @ 2016-05-11 11:36 ` Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 6/9] testcases/lib: Add tst_random decmical integer generator Chunyu Hu 0 siblings, 1 reply; 14+ messages in thread From: Chunyu Hu @ 2016-05-11 11:36 UTC (permalink / raw) To: ltp 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] 14+ messages in thread
* [LTP] [PATCH V3-2 6/9] testcases/lib: Add tst_random decmical integer generator 2016-05-11 11:36 ` [LTP] [PATCH V3-2 5/9] ftrace_stress: keep the name of testscipt in sync with tracing file Chunyu Hu @ 2016-05-11 11:36 ` Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 7/9] ftrace_stress: update the trace_options test Chunyu Hu 2016-06-06 15:46 ` [LTP] [PATCH V3-2 6/9] testcases/lib: Add tst_random decmical integer generator Cyril Hrubis 0 siblings, 2 replies; 14+ messages in thread From: Chunyu Hu @ 2016-05-11 11:36 UTC (permalink / raw) To: ltp It parse the input range and get one decimical integer in the range. Tests can use it to determin a random action. + documentation in the test-writing-guidelines Signed-off-by: Chunyu Hu <chuhu@redhat.com> --- doc/test-writing-guidelines.txt | 12 ++++++ testcases/lib/.gitignore | 1 + testcases/lib/Makefile | 4 +- testcases/lib/tst_random.c | 93 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 testcases/lib/tst_random.c diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt index d0b1408..a6b4c2d 100644 --- a/doc/test-writing-guidelines.txt +++ b/doc/test-writing-guidelines.txt @@ -1203,6 +1203,18 @@ that can sleep for defined amount of seconds, milliseconds or microseconds. tst_sleep 100ms ------------------------------------------------------------------------------- +tst_random ++++++++++ + +There may be test such as ftrace_test using random integer to determin the test action. +here includes 'tst_random' to support it, avoid the `date+%N` action. + +[source,sh] +------------------------------------------------------------------------------- +# get random integer between 0 and 1000 (include 0 and 1000) +tst_random 0 1000 +------------------------------------------------------------------------------- + ROD and ROD_SILENT ++++++++++++++++++ diff --git a/testcases/lib/.gitignore b/testcases/lib/.gitignore index 8886b34..15a04df 100644 --- a/testcases/lib/.gitignore +++ b/testcases/lib/.gitignore @@ -1 +1,2 @@ tst_sleep +tst_random diff --git a/testcases/lib/Makefile b/testcases/lib/Makefile index 0bfb149..be3a720 100644 --- a/testcases/lib/Makefile +++ b/testcases/lib/Makefile @@ -24,8 +24,8 @@ top_srcdir ?= ../.. include $(top_srcdir)/include/mk/env_pre.mk -INSTALL_TARGETS := *.sh tst_sleep +INSTALL_TARGETS := *.sh tst_sleep tst_random -MAKE_TARGETS := tst_sleep +MAKE_TARGETS := tst_sleep tst_random include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/lib/tst_random.c b/testcases/lib/tst_random.c new file mode 100644 index 0000000..5a72b1e --- /dev/null +++ b/testcases/lib/tst_random.c @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2016 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it would be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: Chunyu Hu <chuhu@redhat.com> + * + */ + +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <sys/time.h> + +static void print_help(void) +{ + printf("Usage: tst_random <value1> [value2]\n"); + printf(" Generated random will be between value1 and value2.\n"); + printf(" If only value1 is specified, value2 will treated as 0.\n"); +} + +static int get_seed(void) +{ + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_usec; +} + +static long rand_range(long min, long max) +{ + return rand() % (max - min + 1) + min; +} + +int main(int argc, char *argv[]) +{ + int opt; + long min = 0, max = 0, tmp = 0; + long rval = 0; + char *end; + + while ((opt = getopt(argc, argv, ":h")) != -1) { + switch (opt) { + case 'h': + print_help(); + return 0; + default: + print_help(); + return 1; + } + } + + if (argc != 2 && argc != 3) { + print_help(); + return 1; + } + + max = strtol(argv[1], &end, 10); + if (!(argv[1][0] != '\0' && *end == '\0')) { + fprintf(stderr, "ERROR: Invalid range value1 '%s'\n\n", + argv[optind]); + print_help(); + return 1; + } + + if (argc == 3) { + min = strtol(argv[2], &end, 10); + if (!(argv[2][0] != '\0' && *end == '\0')) { + fprintf(stderr, "ERROR: Invalid range value2 '%s'\n\n", + argv[optind+1]); + print_help(); + return 1; + } + } + + srand(get_seed()); + rval = (min > max) ? rand_range(max, min) : rand_range(min, max); + printf("%ld\n", rval); + + return 0; +} -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [PATCH V3-2 7/9] ftrace_stress: update the trace_options test 2016-05-11 11:36 ` [LTP] [PATCH V3-2 6/9] testcases/lib: Add tst_random decmical integer generator Chunyu Hu @ 2016-05-11 11:36 ` Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 8/9] ftrace_stress: add two new tests for ftrace_filter and tracing_cpu_mask Chunyu Hu 2016-06-06 15:46 ` [LTP] [PATCH V3-2 6/9] testcases/lib: Add tst_random decmical integer generator Cyril Hrubis 1 sibling, 1 reply; 14+ messages in thread From: Chunyu Hu @ 2016-05-11 11:36 UTC (permalink / raw) To: ltp The ftrace_trace_options.sh is using hard coced trace options, including the outdated 'branch', so let's get the trace_options dynamicly from the trace_options file. V2: Use tst_random. Fix bashism code style. Use ltp lib. Check the existence before setting. V3: Remove the unneeded code comment. use tst_random directly. Signed-off-by: Chunyu Hu <chuhu@redhat.com> --- .../ftrace_stress/ftrace_trace_options.sh | 58 ++++++++++++++-------- 1 file changed, 37 insertions(+), 21 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..253568c 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 @@ -13,30 +13,46 @@ # # ############################################################################### -LOOP=200 - -trace_options=(print-parent sym-offset sym-addr verbose raw hex bin block trace_printk ftrace_preempt branch annotate userstacktrace sym-userobj printk-msg-only context-info latency-format sleep-time graph-time) +. test.sh -NR_TRACE_OPTIONS=19 - -for ((; ; )) -{ - for ((j = 0; j < $LOOP; j++)) - { - num=`date +%N` - num=`printf 1%s $num` +LOOP=200 - for ((i = 0; i < $NR_TRACE_OPTIONS; i++)) - { - n=$(( ( $num >> $i ) % 2 )) +while true; do + j=0; + while [ $j -lt $LOOP ]; do + trace_options="$(ls $TRACING_PATH/options/)" + # enable the nop_test_refuse can cause an + # 'write error: Invalid argument'. So don't test it. + trace_options="$(echo $trace_options | sed 's/test_nop_refuse//')" + nr_trace_options=$(echo "${trace_options}" | wc -w) + + option_index=$(tst_random 1 $nr_trace_options) + option=$(echo "$trace_options" | awk "{print \$$option_index}") + i=0 + while [ $i -lt $nr_trace_options ]; do + n=$(tst_random 0 1) + opt_f="$TRACING_PATH"/options/$option + ret_val=0 if [ $n -eq 0 ]; then - echo 0 > "$TRACING_PATH"/options/${trace_options[$i]} + operation="setup" else - echo 1 > "$TRACING_PATH"/options/${trace_options[$i]} + operation="clear" + fi + # On old kernel, some trace option dirs + # won't be made if the option has nothing + # to do with the current tracer. But on newer + # kernel(4.4-rc1), all option dirs will be made. + # So here check it to avoid 'Permision denied' + if [ -f $opt_f ]; then + echo $n > $opt_f + ret_val=$? fi - } - } - - sleep 1 -} + if [ $ret_val -ne 0 ]; then + tst_resm TFAIL "$0: $operation trace option $option failed" + fi + i=$((i + 1)) + done + j=$((j + 1)) + done +done -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [PATCH V3-2 8/9] ftrace_stress: add two new tests for ftrace_filter and tracing_cpu_mask 2016-05-11 11:36 ` [LTP] [PATCH V3-2 7/9] ftrace_stress: update the trace_options test Chunyu Hu @ 2016-05-11 11:36 ` Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 9/9] ftrace_stress: cleanup and use ltp API Chunyu Hu 0 siblings, 1 reply; 14+ messages in thread From: Chunyu Hu @ 2016-05-11 11:36 UTC (permalink / raw) To: ltp V3: Fix code comment. Remove the ';' in 'i=0's Use tst_random directly simplify the reset of set_ftrace_filter Get the cpumask value using $(( a | $(( 1 << b)))) instead of $(( a | ( 1 << b))), as this is a bashism issue found by checkbashisms.pl V2: Use tst_random to get random integer. Fix bashism code. Simplify the get of cpu mask, make it work with nr_cpu > 32. Update the set_ftrace_filter, use awk instead sed.small fix moddule filter. Use ltp lib. V1: add ftrace_tracing_cpumask.sh. add ftrace_set_ftrace_filter.sh. Signed-off-by: Chunyu Hu <chuhu@redhat.com> --- testcases/kernel/tracing/ftrace_test/ftrace_lib.sh | 13 +++ .../ftrace_stress/ftrace_set_ftrace_filter.sh | 119 +++++++++++++++++++++ .../ftrace_stress/ftrace_tracing_cpumask.sh | 91 ++++++++++++++++ .../tracing/ftrace_test/ftrace_stress_test.sh | 3 +- 4 files changed, 225 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 c131827..c4a28ad 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh @@ -63,6 +63,11 @@ save_old_setting() old_trace_options=( `cat trace_options` ) old_tracing_on=`cat tracing_on` old_buffer_size=`cat buffer_size_kb` + old_tracing_cpumask=`cat tracing_cpumask` + + if [ -e tracing_cpumask ]; then + old_tracing_cpumask=`cat tracing_cpumask` + fi if [ -e tracing_enabled ]; then old_tracing_enabled=`cat tracing_enabled` @@ -97,6 +102,10 @@ restore_old_setting() echo 0 > events/enable echo 0 > tracing_max_latency 2> /dev/null + if [ -e tracing_cpumask ]; then + echo $old_tracing_cpumask > tracing_cpumask + fi + if [ -e trace_clock ]; then echo local > trace_clock fi @@ -128,6 +137,10 @@ restore_old_setting() echo > trace + if [ -f set_ftrace_filter ]; then + echo > set_ftrace_filter + fi + cd - > /dev/null } 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..af6ec9f --- /dev/null +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh @@ -0,0 +1,119 @@ +#! /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> ## +## ## +########################################################################### + +. test.sh + +triggers="traceon traceoff enable_event disable_event snapshot \ + dump cpudump stacktrace module function" +nr_triggers=$(echo ${triggers} | wc -w) + +module_pick() +{ + nr_module=$(lsmod | wc -l) + pick_one=$(tst_random 1 $nr_module) + picked_module=$(lsmod | awk "{if (NR == $pick_one) {print \$1}}") +} + +filter_file=$TRACING_PATH/available_filter_functions +nr_functions=$(awk 'END{print NR}' $filter_file) + +function_pick() +{ + if [ -f $filter_file ]; then + local pick_one=$(tst_random 1 $nr_functions) + picked_function=$(awk "{if (NR == $pick_one) {print \$1}}" $filter_file) + echo $picked_function + else + echo "\*sched\*" + fi +} + +event_pick() +{ + local events_file=$TRACING_PATH/available_events + if [ -f $events_file ]; then + nr_events=$(awk 'END{print NR}' $events_file) + local pick_one=$(tst_random 1 $nr_events) + picked_event=$(awk "{if (NR == $pick_one) {print \$0}}" $events_file) + echo "$picked_event" + else + echo "sched:sched_switch" + fi +} + +filter_formatter() +{ + function_str=$(function_pick) + count=$(tst_random 0 2) + + case $1 in + traceon|traceoff|snapshot|dump|cpudump|stacktrace) + trigger=$1 + ;; + enable_event|disable_event) + event_sys_name=$(event_pick) + trigger=$1:$event_sys_name + ;; + module) + module_pick + echo ":mod:$picked_module" + return + ;; + function) + echo "$function_str" + return + ;; + *) + trigger=$1 + ;; + esac + + if [ $count -gt 0 ]; then + trigger=$trigger:$count + fi + echo $function_str:$trigger +} + +signal_handler() +{ + tst_exit +} + +trap signal_handler SIGTERM + +while true; do + # Here try to check if a race caused issue can be hit. + cat $TRACING_PATH/set_ftrace_filter > /dev/null + + trigger_index=$(tst_random 1 $nr_triggers) + trigger_name=$(echo $triggers | awk "{print \$$trigger_index}") + filter_format=$(filter_formatter $trigger_name) + + echo "$filter_format" > $TRACING_PATH/set_ftrace_filter + [ $? -ne 0 ] && tst_resm TFAIL "$0: setup filter <$filter_format> failed" + + sleep 2 + + echo "!$filter_format" > $TRACING_PATH/set_ftrace_filter + [ $? -ne 0 ] && tst_resm TFAIL "$0: remove filter <$filter_format> failed" +done + 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..aeb0d92 --- /dev/null +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh @@ -0,0 +1,91 @@ +#! /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> ## +## ## +########################################################################### + +. test.sh +nr_cpus=`tst_ncpus` + +# the 32 bit integer count 32 cpus. One integer is not +# enough to store the cpu mask for nr_cpu > 32. +if [ $nr_cpus -gt 32 ]; then + group_cnt=$((nr_cpus / 32)) + range=31 + rem=$((nr_cpus % 32)) + if [ $rem -ne 0 ]; then + range_last=$((rem -1)) + fi +else + group_cnt=1 + range=$((nr_cpus - 1)) +fi + +get_test_cpumask() +{ + mask="" + + local i=0 + while [ $i -lt $group_cnt ]; do + # select count of cpu in one group, include the duplicate. + local set_cnt=$(tst_random 1 $((range + 1))) + + local c=0 + local temp_mask=0 + while [ $c -lt $set_cnt ]; do + local group_cpuid=$(tst_random 1 $range) + temp_mask=$((temp_mask | $((1 << $group_cpuid)))) + c=$((c + 1)) + done + + if [ $i = 0 ]; then + mask=`echo $temp_mask | awk '{printf "%x",$0}'` + else + mask=$mask","`echo $temp_mask | awk '{printf "%x",$0}'` + fi + + i=$((i + 1)) + done + + if [ $group_cnt -gt 1 ]; then + set_cnt=$(tst_random 1 $((range_last +1))) + c=0; + temp_mask=0 + while [ $c -lt $set_cnt ]; do + local group_cpuid=$(tst_random 1 $range_last) + temp_mask=$((temp_mask | $((1 << $group_cpuid)))) + c=$((c + 1)) + done + mask=`echo $temp_mask | awk '{printf "%x",$0}'` + fi + + echo "$mask" +} + +signal_handler() +{ + tst_exit +} + +trap signal_handler SIGTERM SIGKILL + +while true; do + get_test_cpumask > $TRACING_PATH/tracing_cpumask +done diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh index 514f566..abb7cd1 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] 14+ messages in thread
* [LTP] [PATCH V3-2 9/9] ftrace_stress: cleanup and use ltp API 2016-05-11 11:36 ` [LTP] [PATCH V3-2 8/9] ftrace_stress: add two new tests for ftrace_filter and tracing_cpu_mask Chunyu Hu @ 2016-05-11 11:36 ` Chunyu Hu 0 siblings, 0 replies; 14+ messages in thread From: Chunyu Hu @ 2016-05-11 11:36 UTC (permalink / raw) To: ltp V2: 1. fix the bashism code style. 2. Use ltp API. V3: 1. Remove all the tail ';' in 'i=0;' and 'j=0;' 2. ftrace_buffer_size_kb.sh remove the '. test.sh' in tests that don't use it. 3. ftrace_trace_clock.sh remove the TRACING_PATH var. 4. ftrace_trace_pipe.sh remove '. test.sh'. remove the ftrace_sleep, use tst_sleep instead. 5. ftrace_trace_stat.sh use tst_random directly. 6. use kill instead of /bin/kill Signed-off-by: Chunyu Hu <chuhu@redhat.com> --- .../ftrace_stress/ftrace_buffer_size_kb.sh | 20 ++++++------- .../ftrace_stress/ftrace_current_tracer.sh | 14 ++++----- .../ftrace_stress/ftrace_ftrace_enabled.sh | 13 ++++---- .../ftrace_function_profile_enabled.sh | 24 ++++----------- .../ftrace_test/ftrace_stress/ftrace_set_event.sh | 25 ++++++++-------- .../ftrace_stress/ftrace_set_ftrace_pid.sh | 21 +++++++------ .../ftrace_stress/ftrace_stack_max_size.sh | 13 ++++---- .../ftrace_stress/ftrace_stack_trace.sh | 19 ++++++------ .../ftrace_test/ftrace_stress/ftrace_trace.sh | 14 ++++----- .../ftrace_stress/ftrace_trace_clock.sh | 22 +++++++------- .../ftrace_stress/ftrace_trace_options.sh | 2 +- .../ftrace_test/ftrace_stress/ftrace_trace_pipe.sh | 35 +++++++++------------- .../ftrace_test/ftrace_stress/ftrace_trace_stat.sh | 18 +++++------ .../ftrace_stress/ftrace_tracing_enabled.sh | 13 ++++---- .../ftrace_stress/ftrace_tracing_max_latency.sh | 13 ++++---- .../ftrace_test/ftrace_stress/ftrace_tracing_on.sh | 13 ++++---- 16 files changed, 126 insertions(+), 153 deletions(-) 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 index bd7dcc4..6652914 100755 --- 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 @@ -26,20 +26,20 @@ if [ $step -eq 0 ]; then LOOP=50 fi -for ((; ;)) -{ +while true; do new_size=1 - for ((i = 0; i < $LOOP; i++)) - { + i=0 + while [ $i -lt $LOOP ]; do echo $new_size > "$TRACING_PATH"/buffer_size_kb new_size=$(( $new_size + $step )) - } + i=$((i + 1)) + done - for ((i = 0; i < $LOOP; i++)) - { + i=0 + while [ $i -lt $LOOP ]; do new_size=$(( $new_size - $step )) echo $new_size > "$TRACING_PATH"/buffer_size_kb - } - + i=$((i + 1)) + done sleep 1 -} +done 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 index 88d576f..104b577 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_current_tracer.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_current_tracer.sh @@ -15,10 +15,9 @@ LOOP=200 -for ((; ;)) -{ - for ((i = 0; i < $LOOP; i++)) - { +while true; do + i=0 + while [ $i -lt $LOOP ]; do for tracer in `cat "$TRACING_PATH"/available_tracers` do if [ "$tracer" = mmiotrace ]; then @@ -27,8 +26,7 @@ for ((; ;)) echo $tracer > "$TRACING_PATH"/current_tracer 2> /dev/null done - } - + i=$((i + 1)) + done sleep 1 -} - +done 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 index 20bb234..c6f8b48 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_ftrace_enabled.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_ftrace_enabled.sh @@ -16,15 +16,14 @@ MAX_LOOP=1500 count=0 -for ((; ;)) -{ +while true; do count=$(( $count + 1 )) - - for ((i = 0; i < $MAX_LOOP; i++)) - { + i=0 + while [ $i -lt $MAX_LOOP ]; do echo 0 > /proc/sys/kernel/ftrace_enabled echo 1 > /proc/sys/kernel/ftrace_enabled - } + i=$((i + 1)) + done enable=$(( $count % 3 )) @@ -35,5 +34,5 @@ for ((; ;)) fi sleep 1 -} +done 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 index 9c6162a..7687420 100755 --- 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 @@ -16,26 +16,15 @@ MAX_LOOP=1500 count=0 -if [ ! -e "$TRACING_PATH"/function_profile_enabled ]; then - should_skip=1 -else - should_skip=0 -fi - -for ((; ;)) -{ - if [ $should_skip -eq 1 ]; then - sleep 2 - continue - fi +while true; do count=$(( $count + 1 )) - - for ((i = 0; i < $MAX_LOOP; i++)) - { + i=0 + while [ $i -lt $MAX_LOOP ]; do echo 0 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null echo 1 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null - } + i=$((i + 1)) + done enable=$(( $count % 3 )) @@ -46,5 +35,4 @@ for ((; ;)) fi sleep 1 -} - +done 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 e8fd5ea..9a79b42 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 @@ -13,29 +13,28 @@ # # ############################################################################### -for ((; ;)) -{ - for ((i = 0; i < 100; i++)) - { +while true; do + i=0 + while [ $i -lt 100 ]; do echo 1 > "$TRACING_PATH"/events/enable echo 0 > "$TRACING_PATH"/events/enable - } + i=$((i + 1)) + done - for dir in `ls $TRACING_PATH/events/` - do + for dir in `ls $TRACING_PATH/events/`; do if [ ! -d $dir -o "$dir" = ftrace ]; then continue; fi - for ((i = 0; i < 20; i++)) - { + i=0 + while [ $i -lt 20 ]; do echo 1 > "$TRACING_PATH"/events/$dir/enable echo 0 > "$TRACING_PATH"/events/$dir/enable - } + i=$((i + 1)) + done done - for event in `cat $TRACING_PATH/available_events`; - do + for event in `cat $TRACING_PATH/available_events`; do # ftrace event sys is special, skip it if echo "$event" | grep "ftrace:*"; then continue @@ -44,4 +43,4 @@ for ((; ;)) done sleep 1 -} +done 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 3eaf017..fd42de4 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,16 +15,15 @@ LOOP=300 - -for ((; ; )) -{ - for ((j = 0; j < $LOOP; j++)) - { - for ((k = 1; k <= NR_PIDS; k++)) - { +while true; do + j=0 + while [ $j -lt $LOOP ]; do + k=1 + while [ $k -le $NR_PIDS ]; do str="\$pid$k" eval echo $str >> "$TRACING_PATH"/set_ftrace_pid - } + k=$((k + 1)) + done if ! echo > "$TRACING_PATH"/set_ftrace_pid >/dev/null 2>&1; then if ! echo -1 > "$TRACING_PATH"/set_ftrace_pid >/dev/null 2>&1; then @@ -32,7 +31,7 @@ for ((; ; )) exit 1 fi fi - } - + j=$((j + 1)) + done sleep 1 -} +done 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 34d506b..0842929 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,14 +15,13 @@ MAX_STACK_SIZE=8192 -for ((; ;)) -{ - for ((i = 0; i < $MAX_STACK_SIZE; i += 70)) - { +while true; do + i=0 + while [ $i -lt $MAX_STACK_SIZE ]; do echo $i > "$TRACING_PATH"/stack_max_size cat "$TRACING_PATH"/stack_max_size > /dev/null - } - + i=$((i + 1)) + done sleep 1 -} +done 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 1850c26..4c16a0a 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,20 +15,21 @@ LOOP=400 -for ((; ;)) -{ - for ((i = 0; i < $LOOP; i++)) - { +while true; do + i=0 + while [ $i -lt $LOOP ]; do cat "$TRACING_PATH"/stack_trace > /dev/null - } + i=$((i + 1)) + done sleep 1 - for ((i = 0; i < $LOOP; i++)) - { + i=0 + while [ $i -lt $LOOP ]; do echo 0 > /proc/sys/kernel/stack_tracer_enabled echo 1 > /proc/sys/kernel/stack_tracer_enabled - } + i=$((i + 1)) + done sleep 1 -} +done diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh index e36712b..7c45f50 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh @@ -15,13 +15,11 @@ LOOP=200 -for ((; ;)) -{ - for ((i = 0; i < $LOOP; i++)) - { +i=0; +while true; do + while [ $i -lt $LOOP ]; do cat "$TRACING_PATH"/trace > /dev/null - } - + i=$((i + 1)) + done sleep 1 -} - +done diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh index de6bbea..ca51117 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh @@ -24,23 +24,23 @@ else old_kernel=0 fi -for ((; ;)) -{ - if [ $old_kernel -eq 1 ]; - then - for ((i = 0; i < $LOOP; i++)) - { +while true; do + i=0 + if [ $old_kernel -eq 1 ]; then + while [ $i -lt $LOOP ]; do echo 1 > "$TRACING_PATH"/options/global-clock echo 0 > "$TRACING_PATH"/options/global-clock - } + i=$((i + 1)) + done else - for ((i = 0; i < $LOOP; i++)) - { + while [ $i -lt $LOOP ]; do echo local > "$TRACING_PATH"/trace_clock echo global > "$TRACING_PATH"/trace_clock - } + i=$((i + 1)) + done + fi sleep 1 -} +done diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh index 253568c..95da3f6 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 @@ -18,7 +18,7 @@ LOOP=200 while true; do - j=0; + j=0 while [ $j -lt $LOOP ]; do trace_options="$(ls $TRACING_PATH/options/)" # enable the nop_test_refuse can cause an diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh index 47d42bc..7d49745 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh @@ -13,18 +13,9 @@ # # ############################################################################### -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 + kill -KILL $this_pid wait $this_pid exit 0 } @@ -33,20 +24,22 @@ trap kill_this_pid SIGUSR1 LOOP=20 -for ((; ;)) -{ - for ((i = 0; i < $LOOP; i++)) - { +while true; do + i=0 + while [ $i -lt $LOOP ]; do cat "$TRACING_PATH"/trace_pipe > /dev/null & - this_pid=$! - ftrace_sleep - /bin/kill -SIGINT $this_pid + + tst_sleep 200000us + + kill -INT $this_pid wait $this_pid + this_pid=0 - ftrace_sleep - } - sleep 2 -} + tst_sleep 200000us + i=$((i + 1)) + done + sleep 2 +done diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh index d7e6fd3..f854e83 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh @@ -16,6 +16,7 @@ LOOP=200 should_skip=0 +nr_cpus=`tst_ncpus` if [ ! -e "$TRACING_PATH"/function_profile_enabled ]; then should_skip=1 @@ -28,18 +29,17 @@ if [ $? -eq 0 ]; then should_skip=1 fi -for ((; ;)) -{ +while true; do if [ $should_skip -eq 1 ]; then sleep 2 continue fi - - for ((i = 0; i < $LOOP; i++)) - { - cat "$TRACING_PATH"/trace_stat/function0 > /dev/null 2>&1 - } + cpu=$(tst_random 0 $((nr_cpus - 1))) + i=0; + while [ $i -lt $LOOP ]; do + cat "$TRACING_PATH"/trace_stat/function${cpu} > /dev/null 2>&1 + i=$((i + 1)) + done sleep 1 -} - +done 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 index 69f2ae6..9e0f5a7 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_enabled.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_enabled.sh @@ -16,15 +16,14 @@ MAX_LOOP=1500 count=0 -for ((; ;)) -{ +while true; do count=$(( $count + 1 )) - - for ((i = 0; i < $MAX_LOOP; i++)) - { + i=0 + while [ $i -lt $MAX_LOOP ]; do echo 0 > "$TRACING_PATH"/tracing_enabled echo 1 > "$TRACING_PATH"/tracing_enabled - } + i=$((i + 1)) + done enable=$(( $count % 3 )) @@ -35,5 +34,5 @@ for ((; ;)) fi sleep 1 -} +done diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh index fbaceb8..4ad8891 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,12 +15,13 @@ MAX_LATENCY=100000 -for ((; ;)) -{ - for ((i = 0; i < $MAX_LATENCY; i += 400)) - { +while true; do + i=0 + while [ $i -lt $MAX_LATENCY ]; do echo $i > "$TRACING_PATH"/tracing_max_latency - } + i=$((i + 400)) + done sleep 1 -} + +done 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 index 672c223..5ae9d76 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_on.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_on.sh @@ -16,15 +16,14 @@ MAX_LOOP=1500 count=0 -for ((; ;)) -{ +while true; do count=$(( $count + 1 )) - - for ((i = 0; i < $MAX_LOOP; i++)) - { + i=0 + while [ $i -lt $MAX_LOOP ]; do echo 0 > "$TRACING_PATH"/tracing_on echo 1 > "$TRACING_PATH"/tracing_on - } + i=$((i + 1)) + done enable=$(( $count % 3 )) @@ -35,5 +34,5 @@ for ((; ;)) fi sleep 1 -} +done -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [PATCH V3-2 6/9] testcases/lib: Add tst_random decmical integer generator 2016-05-11 11:36 ` [LTP] [PATCH V3-2 6/9] testcases/lib: Add tst_random decmical integer generator Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 7/9] ftrace_stress: update the trace_options test Chunyu Hu @ 2016-06-06 15:46 ` Cyril Hrubis 1 sibling, 0 replies; 14+ messages in thread From: Cyril Hrubis @ 2016-06-06 15:46 UTC (permalink / raw) To: ltp Hi! > +static long rand_range(long min, long max) > +{ > + return rand() % (max - min + 1) + min; > +} I've changed this to use random() and srandom() instead of rand() and srand(), since rand() and srand() are obsolete and moreover rand() returns only int while the rest of the test uses long. -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 14+ messages in thread
* [LTP] [PATCH V3-2 0/9] tracing: make ftrace tests to be extended 2016-05-11 11:36 [LTP] [PATCH V3-2 0/9] tracing: make ftrace tests to be extended Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 1/9] tracing: reorganize ftrace-stress tests to general tests Chunyu Hu @ 2016-06-06 15:45 ` Cyril Hrubis 2016-06-07 3:38 ` Chunyu Hu 1 sibling, 1 reply; 14+ messages in thread From: Cyril Hrubis @ 2016-06-06 15:45 UTC (permalink / raw) To: ltp Hi! I've reorganized the patchset so that fixes are before new testcases and pushed, thanks. -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 14+ messages in thread
* [LTP] [PATCH V3-2 0/9] tracing: make ftrace tests to be extended 2016-06-06 15:45 ` [LTP] [PATCH V3-2 0/9] tracing: make ftrace tests to be extended Cyril Hrubis @ 2016-06-07 3:38 ` Chunyu Hu 2016-06-07 10:25 ` Cyril Hrubis 0 siblings, 1 reply; 14+ messages in thread From: Chunyu Hu @ 2016-06-07 3:38 UTC (permalink / raw) To: ltp ----- Original Message ----- > From: "Cyril Hrubis" <chrubis@suse.cz> > To: "Chunyu Hu" <chuhu@redhat.com> > Cc: ltp@lists.linux.it, liwang@redhat.com > Sent: Monday, June 6, 2016 11:45:13 PM > Subject: Re: [PATCH V3-2 0/9] tracing: make ftrace tests to be extended > > Hi! > I've reorganized the patchset so that fixes are before new testcases and > pushed, thanks. Thanks for the patience on reviewing the patch and the excellent ideas! I really like your two proposed tool to verify bashism code, paste it here again and hope it can help others too. 1) Check bashism issue through dash, compile it from source: http://gondor.apana.org.au/~herbert/dash/files/ 2) debian devel perl script that can check for bashism, https://anonscm.debian.org/cgit/collab-maint/devscripts.git/tree/scripts/checkbashisms.pl ^ permalink raw reply [flat|nested] 14+ messages in thread
* [LTP] [PATCH V3-2 0/9] tracing: make ftrace tests to be extended 2016-06-07 3:38 ` Chunyu Hu @ 2016-06-07 10:25 ` Cyril Hrubis 0 siblings, 0 replies; 14+ messages in thread From: Cyril Hrubis @ 2016-06-07 10:25 UTC (permalink / raw) To: ltp Hi! > Thanks for the patience on reviewing the patch and the excellent ideas! > > I really like your two proposed tool to verify bashism code, paste it here > again and hope it can help others too. > > 1) Check bashism issue through dash, compile it from source: > http://gondor.apana.org.au/~herbert/dash/files/ > > 2) debian devel perl script that can check for bashism, > https://anonscm.debian.org/cgit/collab-maint/devscripts.git/tree/scripts/checkbashisms.pl I've added note about these into test-writing-guidelines: https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#132-shell-coding-style -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2016-06-07 10:25 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-05-11 11:36 [LTP] [PATCH V3-2 0/9] tracing: make ftrace tests to be extended Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 1/9] tracing: reorganize ftrace-stress tests to general tests Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 2/9] tracing/ftrace: add new case for ftrace userstacktrace Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 3/9] tracing/ftrace: add a new case for signal_generate Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 4/9] ftrace_stress: skip unsupported tests and early cleanup Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 5/9] ftrace_stress: keep the name of testscipt in sync with tracing file Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 6/9] testcases/lib: Add tst_random decmical integer generator Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 7/9] ftrace_stress: update the trace_options test Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 8/9] ftrace_stress: add two new tests for ftrace_filter and tracing_cpu_mask Chunyu Hu 2016-05-11 11:36 ` [LTP] [PATCH V3-2 9/9] ftrace_stress: cleanup and use ltp API Chunyu Hu 2016-06-06 15:46 ` [LTP] [PATCH V3-2 6/9] testcases/lib: Add tst_random decmical integer generator Cyril Hrubis 2016-06-06 15:45 ` [LTP] [PATCH V3-2 0/9] tracing: make ftrace tests to be extended Cyril Hrubis 2016-06-07 3:38 ` Chunyu Hu 2016-06-07 10:25 ` Cyril Hrubis
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox