* [LTP] [PATCH V2 0/9] tracing: make ftrace tests to be extended @ 2016-04-18 8:04 Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests Chunyu Hu 0 siblings, 1 reply; 32+ messages in thread From: Chunyu Hu @ 2016-04-18 8:04 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 from V1: 1. Use ltp lib api. 2. Fix bashism issues. 3. ftrace_regression_test: make the two sub tests as two independent tests. 4. ftrace_stress: Wait for pid after execing a killing of sub test. 5. ftrace_stress: Fix tracing_cpumask test for case nr_cpu > 32. 6. ftrace_stress: Fix set_ftrace_filter test for module filter. 7. ftrace_stress: Fix small issue for trace_options test. Chunyu Hu (6): ftrace_stress: skip unsupported tests ftrace_stress: keep the name of testscipt in sync with tracing file testcases/lib: Add tst_random decmical integer generator ftrace_stress: update the trace_options test ftrace_stress: add two new tests ftrace_stress: cleanup and use ltp API Li Wang (3): tracing: reorganize ftrace-stress tests to general tests tracing/ftrace: add new case for ftrace userstacktrace tracing/ftrace: add a new case for signal_generate ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests 2016-04-18 8:04 [LTP] [PATCH V2 0/9] tracing: make ftrace tests to be extended Chunyu Hu @ 2016-04-18 8:04 ` Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 2/9] tracing/ftrace: add new case for ftrace userstacktrace Chunyu Hu 2016-05-04 16:26 ` [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests Cyril Hrubis 0 siblings, 2 replies; 32+ messages in thread From: Chunyu Hu @ 2016-04-18 8:04 UTC (permalink / raw) To: ltp From: Li Wang <liwang@redhat.com> 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] 32+ messages in thread
* [LTP] [PATCH V2 2/9] tracing/ftrace: add new case for ftrace userstacktrace 2016-04-18 8:04 ` [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests Chunyu Hu @ 2016-04-18 8:04 ` Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 3/9] tracing/ftrace: add a new case for signal_generate Chunyu Hu 2016-05-04 16:00 ` [LTP] [PATCH V2 2/9] tracing/ftrace: add new case for ftrace userstacktrace Cyril Hrubis 2016-05-04 16:26 ` [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests Cyril Hrubis 1 sibling, 2 replies; 32+ messages in thread From: Chunyu Hu @ 2016-04-18 8:04 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..1453f5d --- /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 ignored "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] 32+ messages in thread
* [LTP] [PATCH V2 3/9] tracing/ftrace: add a new case for signal_generate 2016-04-18 8:04 ` [LTP] [PATCH V2 2/9] tracing/ftrace: add new case for ftrace userstacktrace Chunyu Hu @ 2016-04-18 8:04 ` Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests Chunyu Hu 2016-05-04 16:00 ` [LTP] [PATCH V2 2/9] tracing/ftrace: add new case for ftrace userstacktrace Cyril Hrubis 1 sibling, 1 reply; 32+ messages in thread From: Chunyu Hu @ 2016-04-18 8:04 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..c30bf29 --- /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 ignored "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] 32+ messages in thread
* [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests 2016-04-18 8:04 ` [LTP] [PATCH V2 3/9] tracing/ftrace: add a new case for signal_generate Chunyu Hu @ 2016-04-18 8:04 ` Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 5/9] ftrace_stress: keep the name of testscipt in sync with tracing file Chunyu Hu 2016-05-04 16:50 ` [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests Cyril Hrubis 0 siblings, 2 replies; 32+ messages in thread From: Chunyu Hu @ 2016-04-18 8:04 UTC (permalink / raw) To: ltp Checking if it's supported before lanuching a test script. This action is through verifing the matched file in ftrace tracing direcrotry. At the same time, transform the hard coded pids to the test_targets string and make it easier to be controlled. With this modification, the outdated tracing_enabled issue can be skiped on newer kernels. V2: fix the bashism code style. use ltp lib. Signed-off-by: Chunyu Hu <chuhu@redhat.com> --- testcases/kernel/tracing/ftrace_test/ftrace_lib.sh | 10 +- .../ftrace_test/ftrace_stress/ftrace_set_event.sh | 5 +- .../ftrace_stress/ftrace_set_ftrace_pid.sh | 11 -- .../ftrace_stress/ftrace_stack_max_size.sh | 11 -- .../ftrace_stress/ftrace_stack_trace.sh | 12 -- .../ftrace_stress/ftrace_tracing_max_latency.sh | 12 -- .../tracing/ftrace_test/ftrace_stress_test.sh | 132 ++++++++++----------- 7 files changed, 78 insertions(+), 115 deletions(-) diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh b/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh index ea082dc..b7aef34 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh @@ -40,9 +40,12 @@ save_old_setting() old_trace_options=( `cat trace_options` ) old_tracing_on=`cat tracing_on` - old_tracing_enabled=`cat tracing_enabled` old_buffer_size=`cat buffer_size_kb` + if [ -e tracing_enabled ]; then + old_tracing_enabled=`cat tracing_enabled` + fi + if [ -e stack_max_size ]; then old_stack_tracer_enabled=`cat /proc/sys/kernel/stack_tracer_enabled` fi @@ -85,7 +88,10 @@ restore_old_setting() echo $old_buffer_size > buffer_size_kb echo $old_tracing_on > tracing_on - echo $old_tracing_enabled > tracing_enabled + + if [ -e tracing_enabled ];then + echo $old_tracing_enabled > tracing_enabled + fi for option in $old_trace_options do 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..80c914c 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh @@ -21,87 +21,92 @@ ## ## ########################################################################### - export TCID="ftrace-stress-test" export TST_TOTAL=1 export TST_COUNT=1 . ftrace_lib.sh -test_success=true +test_targets=" \ +trace_pipe current_tracer ftrace_enabled function_profile_enabled \ +set_event set_ftrace_pid stack_max_size stack_trace trace trace_clock \ +trace_options trace_stat tracing_enabled tracing_max_latency \ +tracing_on function_profile_enabled buffer_size_kb" -export_pids() +get_skip_targets() { - export pid1 pid2 pid3 pid4 pid5 pid6 pid7 pid8 pid9 pid10 pid11 pid12 \ - pid13 pid14 pid15 pid16 - - export NR_PIDS=16 + NR_PIDS=0 + for target in ${test_targets}; do + if [ ! -e $TRACING_PATH/$target ] && + [ ! -e /proc/sys/kernel/$target ]; then + eval skip_$target=1 + tst_resm TINFO "$target is not supported. Skip it." + else + eval skip_$target=0 + NR_PIDS=$((NR_PIDS + 1)) + fi + done + # Export it before sub case is lanuched. + export NR_PIDS } -test_stress() +should_skip_target() { - export_pids - - $SPATH/ftrace_trace_clock.sh & - pid1=$! - $SPATH/ftrace_current_tracer.sh & - pid2=$! - $SPATH/ftrace_trace_options.sh & - pid3=$! - $SPATH/ftrace_tracing_max_latency.sh & - pid4=$! - $SPATH/ftrace_stack_trace.sh & - pid5=$! - $SPATH/ftrace_stack_max_size.sh & - pid6=$! - $SPATH/ftrace_tracing_on.sh & - pid7=$! - $SPATH/ftrace_tracing_enabled.sh & - pid8=$! - $SPATH/ftrace_set_event.sh & - pid9=$! - $SPATH/ftrace_buffer_size.sh & - pid10=$! - $SPATH/ftrace_trace.sh & - pid11=$! - $SPATH/ftrace_trace_pipe.sh & - pid12=$! - $SPATH/ftrace_ftrace_enabled.sh & - pid13=$! - $SPATH/ftrace_set_ftrace_pid.sh & - pid14=$! - $SPATH/ftrace_profile_enabled.sh & - pid15=$! - $SPATH/ftrace_trace_stat.sh & - pid16=$! + local var=skip_$1 + local val=${!var} + [ "$val" = 1 ] } test_kill() { - kill -KILL $pid1 || test_success=false - kill -KILL $pid2 || test_success=false - kill -KILL $pid3 || test_success=false - kill -KILL $pid4 || test_success=false - kill -KILL $pid5 || test_success=false - kill -KILL $pid6 || test_success=false - kill -KILL $pid7 || test_success=false - kill -KILL $pid8 || test_success=false - kill -KILL $pid9 || test_success=false - kill -KILL $pid10 || test_success=false - kill -KILL $pid11 || test_success=false - kill -USR1 $pid12 || test_success=false - kill -KILL $pid13 || test_success=false - kill -KILL $pid14 || test_success=false - kill -KILL $pid15 || test_success=false - kill -KILL $pid16 || test_success=false + tst_resm TINFO "killing ${pid0}" + kill -USR1 ${pid0} + wait ${pid0} + + local p=1; + while [ $p -lt $NR_PIDS ]; do + local kill_pid=pid${p} + kill -KILL ${!kill_pid} + tst_resm TINFO "killing ${!kill_pid}" + wait ${!kill_pid} + p=$((p + 1)) + done sleep 2 clean_up } +test_stress() +{ + local index=0; + + tst_resm TINFO "Test targets: ${test_targets}" + + get_skip_targets + for target in ${test_targets}; do + if should_skip_target $target; then + continue + fi + sh ftrace_${target}.sh & + eval pid${index}=$! + tst_resm TINFO "Start pid${index}=$! $SPATH/ftrace_${target}.sh" + index=$((index + 1)) + done + export_pids +} + +export_pids() +{ + local p=0 + while [ $p -lt $NR_PIDS ]; do + export pid${p} + p=$((p + 1)) + done +} +cd ftrace_stress/ # ---------------------------- -echo "Ftrace Stress Test Begin" +tst_resm TINFO "Ftrace Stress Test Begin" save_old_setting @@ -113,11 +118,6 @@ test_wait test_kill -echo "Ftrace Stress Test End" +tst_resm TINFO "Finished running the test. Run dmesg to double-check for bugs" -if $test_success; then - tst_resm TPASS "finished running the test. Run dmesg to double-check for bugs" -else - tst_resm TFAIL "please check log message." - exit 1 -fi +tst_exit -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 5/9] ftrace_stress: keep the name of testscipt in sync with tracing file 2016-04-18 8:04 ` [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests Chunyu Hu @ 2016-04-18 8:04 ` Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator Chunyu Hu 2016-05-04 16:50 ` [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests Cyril Hrubis 1 sibling, 1 reply; 32+ messages in thread From: Chunyu Hu @ 2016-04-18 8:04 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] 32+ messages in thread
* [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator 2016-04-18 8:04 ` [LTP] [PATCH V2 5/9] ftrace_stress: keep the name of testscipt in sync with tracing file Chunyu Hu @ 2016-04-18 8:04 ` Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 7/9] ftrace_stress: update the trace_options test Chunyu Hu 2016-05-04 13:34 ` [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator Cyril Hrubis 0 siblings, 2 replies; 32+ messages in thread From: Chunyu Hu @ 2016-04-18 8:04 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 | 104 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 119 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..91a5247 --- /dev/null +++ b/testcases/lib/tst_random.c @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2016 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it would be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: Chunyu Hu <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; + } + + if (optind >= argc) { + fprintf(stderr, "ERROR: Expected one or two range_val arguments\n\n"); + print_help(); + return 1; + } + + max = strtol(argv[optind], &end, 10); + if (argv[optind] == end) { + fprintf(stderr, "ERROR: Invalid range value1 '%s'\n\n", + argv[optind]); + print_help(); + return 1; + } + + if (argc == 3) { + min = strtol(argv[optind+1], &end, 10); + if (argv[optind+1] == end) { + fprintf(stderr, "ERROR: Invalid range value2 '%s'\n\n", + argv[optind+1]); + print_help(); + return 1; + } + if (min > max) { + tmp = min; + min = max; + max = tmp; + } + } + + srand(get_seed()); + rval = rand_range(min, max); + printf("%ld\n", rval); + + return rval; +} -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 7/9] ftrace_stress: update the trace_options test 2016-04-18 8:04 ` [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator Chunyu Hu @ 2016-04-18 8:04 ` Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 8/9] ftrace_stress: add two new tests Chunyu Hu 2016-05-04 16:57 ` [LTP] [PATCH V2 7/9] ftrace_stress: update the trace_options test Cyril Hrubis 2016-05-04 13:34 ` [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator Cyril Hrubis 1 sibling, 2 replies; 32+ messages in thread From: Chunyu Hu @ 2016-04-18 8:04 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. Signed-off-by: Chunyu Hu <chuhu@redhat.com> --- .../ftrace_stress/ftrace_trace_options.sh | 62 ++++++++++++++-------- 1 file changed, 41 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..3b6bc79 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,50 @@ # # ############################################################################### -LOOP=200 - -trace_options=(print-parent sym-offset sym-addr verbose raw hex bin block trace_printk ftrace_preempt branch annotate userstacktrace sym-userobj printk-msg-only context-info latency-format sleep-time graph-time) +. test.sh -NR_TRACE_OPTIONS=19 - -for ((; ; )) -{ - for ((j = 0; j < $LOOP; j++)) - { - num=`date +%N` - num=`printf 1%s $num` +LOOP=200 - for ((i = 0; i < $NR_TRACE_OPTIONS; i++)) - { - n=$(( ( $num >> $i ) % 2 )) +random_gen=tst_random + +while true; do + j=0; + while [ $j -lt $LOOP ]; do + trace_options="$(ls $TRACING_PATH/options/)" + # enable the nop_test_refuse can cause an + # 'write error: Invalid argument'. So don't test it. + trace_options="$(echo $trace_options | sed 's/test_nop_refuse//')" + nr_trace_options=$(echo "${trace_options}" | wc -w) + + option_index=$($random_gen 1 $nr_trace_options) + option=$(echo "$trace_options" | awk "{print \$$option_index}") + i=0 + while [ $i -lt $nr_trace_options ]; do + n=$($random_gen 0 1) + opt_f="$TRACING_PATH"/options/$option + ret_val=0 if [ $n -eq 0 ]; then - echo 0 > "$TRACING_PATH"/options/${trace_options[$i]} + operation="setup" else - echo 1 > "$TRACING_PATH"/options/${trace_options[$i]} + operation="clear" + fi + # On old kernel, some trace option dirs + # won't be made if the option has nothing + # to do with the current tracer. But on newer + # kernel(4.4-rc1), all option dirs will be made. + # So here check it to avoid 'Permision denied' + if [ -f $opt_f ]; then + echo $n > $opt_f + ret_val=$? fi - } - } - - sleep 1 -} + if [ $ret_val -ne 0 ]; then + tst_resm TFAIL "$0: $operation trace option $option failed" + fi + i=$((i + 1)) + done + j=$((j + 1)) + done + # sleep is not needed if ftrace can surrive. + # tst_sleep 1s +done -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 8/9] ftrace_stress: add two new tests 2016-04-18 8:04 ` [LTP] [PATCH V2 7/9] ftrace_stress: update the trace_options test Chunyu Hu @ 2016-04-18 8:04 ` Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API Chunyu Hu 2016-05-04 16:57 ` [LTP] [PATCH V2 7/9] ftrace_stress: update the trace_options test Cyril Hrubis 1 sibling, 1 reply; 32+ messages in thread From: Chunyu Hu @ 2016-04-18 8:04 UTC (permalink / raw) To: ltp 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 | 22 ++++ .../ftrace_stress/ftrace_set_ftrace_filter.sh | 121 +++++++++++++++++++++ .../ftrace_stress/ftrace_tracing_cpumask.sh | 93 ++++++++++++++++ .../tracing/ftrace_test/ftrace_stress_test.sh | 3 +- 4 files changed, 238 insertions(+), 1 deletion(-) create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh create mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh b/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh index b7aef34..8632e24 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh @@ -41,6 +41,11 @@ save_old_setting() old_trace_options=( `cat trace_options` ) old_tracing_on=`cat tracing_on` old_buffer_size=`cat buffer_size_kb` + old_tracing_cpumask=`cat tracing_cpumask` + + if [ -e tracing_cpumask ]; then + old_tracing_cpumask=`cat tracing_cpumask` + fi if [ -e tracing_enabled ]; then old_tracing_enabled=`cat tracing_enabled` @@ -69,6 +74,10 @@ restore_old_setting() echo 0 > events/enable echo 0 > tracing_max_latency 2> /dev/null + if [ -e tracing_cpumask ]; then + echo $old_tracing_cpumask > tracing_cpumask + fi + if [ -e trace_clock ]; then echo local > trace_clock fi @@ -100,6 +109,19 @@ restore_old_setting() echo > trace + if [ -f set_ftrace_filter ]; then + cat set_ftrace_filter | \ + while read flt; do + if [ -n "$flt" ]; then + # the line start with # started is comment. + if echo $flt | grep -e "^#"; then + continue; + fi + echo '!'"$flt" > set_ftrace_filter + fi + done + fi + cd - > /dev/null } 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..32b23d5 --- /dev/null +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh @@ -0,0 +1,121 @@ +#! /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) + +rand_gen=tst_random + +module_pick() +{ + nr_module=$(lsmod | wc -l) + pick_one=$($rand_gen 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=$($rand_gen 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=$($rand_gen 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=$($rand_gen 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=$($rand_gen 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..787a675 --- /dev/null +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh @@ -0,0 +1,93 @@ +#! /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` +rand_gen=tst_random + +# the 32 bit integer count. one integer is not +# enough to restore the mask. + +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=$($rand_gen 1 $((range + 1))) + + local c=0; + local temp_mask=0 + while [ $c -lt $set_cnt ]; do + local group_cpuid=$($rand_gen 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=$($rand_gen 1 $((range_last +1))) + c=0; + temp_mask=0 + while [ $c -lt $set_cnt ]; do + local group_cpuid=$($rand_gen 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 80c914c..eb2c5f6 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] 32+ messages in thread
* [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API 2016-04-18 8:04 ` [LTP] [PATCH V2 8/9] ftrace_stress: add two new tests Chunyu Hu @ 2016-04-18 8:04 ` Chunyu Hu 2016-05-04 14:56 ` Cyril Hrubis 0 siblings, 1 reply; 32+ messages in thread From: Chunyu Hu @ 2016-04-18 8:04 UTC (permalink / raw) To: ltp 1. fix the bashism code style. 2. Use ltp API 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 | 25 ++++++++++++---------- .../ftrace_test/ftrace_stress/ftrace_trace_pipe.sh | 19 ++++++++-------- .../ftrace_test/ftrace_stress/ftrace_trace_stat.sh | 19 ++++++++-------- .../ftrace_stress/ftrace_tracing_enabled.sh | 13 ++++++----- .../ftrace_stress/ftrace_tracing_max_latency.sh | 13 +++++------ .../ftrace_test/ftrace_stress/ftrace_tracing_on.sh | 13 ++++++----- 15 files changed, 124 insertions(+), 141 deletions(-) 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..a0ebc32 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..b2a1cae 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..28aafd5 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..4e84f2f 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..4c2f99c 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..70135c1 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh @@ -13,6 +13,9 @@ # # ############################################################################### +. test.sh + +TRACING_PATH=/sys/kernel/debug/tracing/ LOOP=400 # In kernel which is older than 2.6.32, we set global clock @@ -24,23 +27,23 @@ else old_kernel=0 fi -for ((; ;)) -{ - if [ $old_kernel -eq 1 ]; - then - for ((i = 0; i < $LOOP; i++)) - { +while true; do + i=0; + if [ $old_kernel -eq 1 ]; then + while [ $i -lt $LOOP ]; do echo 1 > "$TRACING_PATH"/options/global-clock echo 0 > "$TRACING_PATH"/options/global-clock - } + i=$((i + 1)) + done else - for ((i = 0; i < $LOOP; i++)) - { + while [ $i -lt $LOOP ]; do echo local > "$TRACING_PATH"/trace_clock echo global > "$TRACING_PATH"/trace_clock - } + i=$((i + 1)) + done + fi sleep 1 -} +done diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh index 47d42bc..a24008a 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh @@ -13,10 +13,11 @@ # # ############################################################################### +. test.sh + ftrace_sleep() { - # usleep is not a standard command? - usleep 200000 2> /dev/null + tst_sleep 200000us if [ $? -ne 0 ]; then sleep 1 fi @@ -33,10 +34,9 @@ trap kill_this_pid SIGUSR1 LOOP=20 -for ((; ;)) -{ - for ((i = 0; i < $LOOP; i++)) - { +while true; do + i=0; + while [ $i -lt $LOOP ]; do cat "$TRACING_PATH"/trace_pipe > /dev/null & this_pid=$! @@ -45,8 +45,7 @@ for ((; ;)) wait $this_pid this_pid=0 ftrace_sleep - } - + i=$((i + 1)) + done sleep 2 -} - +done diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh index d7e6fd3..2691991 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh @@ -16,6 +16,8 @@ LOOP=200 should_skip=0 +rand_gen=tst_random +nr_cpus=`tst_ncpus` if [ ! -e "$TRACING_PATH"/function_profile_enabled ]; then should_skip=1 @@ -28,18 +30,17 @@ if [ $? -eq 0 ]; then should_skip=1 fi -for ((; ;)) -{ +while true; do if [ $should_skip -eq 1 ]; then sleep 2 continue fi - - for ((i = 0; i < $LOOP; i++)) - { - cat "$TRACING_PATH"/trace_stat/function0 > /dev/null 2>&1 - } + cpu=$($rand_gen 0 $((nr_cpus - 1))) + i=0; + while [ $i -lt $LOOP ]; do + cat "$TRACING_PATH"/trace_stat/function${cpu} > /dev/null 2>&1 + i=$((i + 1)) + done sleep 1 -} - +done 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..559cab0 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..6090a91 100755 --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh @@ -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..54e2795 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] 32+ messages in thread
* [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API 2016-04-18 8:04 ` [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API Chunyu Hu @ 2016-05-04 14:56 ` Cyril Hrubis 2016-05-04 15:42 ` Chunyu Hu 0 siblings, 1 reply; 32+ messages in thread From: Cyril Hrubis @ 2016-05-04 14:56 UTC (permalink / raw) To: ltp Hi! > --- 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; The semicolon after i=0 is useless (and in all i=0; lines in this patch). ... > diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh > index de6bbea..70135c1 100755 > --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh > +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh > @@ -13,6 +13,9 @@ > # # > ############################################################################### > > +. test.sh No need to source test.sh for the tst_kvercmp which is a separate binary. > +TRACING_PATH=/sys/kernel/debug/tracing/ Shouldn't this be propagated from the main script? What's the point of redefining it here? > LOOP=400 > > # In kernel which is older than 2.6.32, we set global clock > @@ -24,23 +27,23 @@ else > old_kernel=0 > fi > > -for ((; ;)) > -{ > - if [ $old_kernel -eq 1 ]; > - then > - for ((i = 0; i < $LOOP; i++)) > - { > +while true; do > + i=0; > + if [ $old_kernel -eq 1 ]; then > + while [ $i -lt $LOOP ]; do > echo 1 > "$TRACING_PATH"/options/global-clock > echo 0 > "$TRACING_PATH"/options/global-clock > - } > + i=$((i + 1)) > + done > else > - for ((i = 0; i < $LOOP; i++)) > - { > + while [ $i -lt $LOOP ]; do > echo local > "$TRACING_PATH"/trace_clock > echo global > "$TRACING_PATH"/trace_clock > - } > + i=$((i + 1)) > + done > + > fi > > sleep 1 > -} > +done > > diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh > index 47d42bc..a24008a 100755 > --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh > +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh > @@ -13,10 +13,11 @@ > # # > ############################################################################### > > +. test.sh You don't have to add test.sh for tst_sleep. > ftrace_sleep() > { > - # usleep is not a standard command? > - usleep 200000 2> /dev/null > + tst_sleep 200000us > if [ $? -ne 0 ]; then > sleep 1 > fi You should remove the fallback to sleep 1 if the usleep wasn't found. Ideally the whole function ftrace_sleep should be removed and you should just call tst_sleep from the main loop. > @@ -33,10 +34,9 @@ trap kill_this_pid SIGUSR1 > > LOOP=20 > > -for ((; ;)) > -{ > - for ((i = 0; i < $LOOP; i++)) > - { > +while true; do > + i=0; > + while [ $i -lt $LOOP ]; do > cat "$TRACING_PATH"/trace_pipe > /dev/null & > > this_pid=$! > @@ -45,8 +45,7 @@ for ((; ;)) > wait $this_pid > this_pid=0 > ftrace_sleep > - } > - > + i=$((i + 1)) > + done > sleep 2 > -} > - > +done And you should also fix the kill called by the full path in this script. It should really be just kill not /bin/kill. > diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh > index d7e6fd3..2691991 100755 > --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh > +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh > @@ -16,6 +16,8 @@ > LOOP=200 > > should_skip=0 > +rand_gen=tst_random What's the point of assigning tst_random into a variable instead of using it directly? > +nr_cpus=`tst_ncpus` > > if [ ! -e "$TRACING_PATH"/function_profile_enabled ]; then > should_skip=1 > @@ -28,18 +30,17 @@ if [ $? -eq 0 ]; then > should_skip=1 > fi > > -for ((; ;)) > -{ > +while true; do > if [ $should_skip -eq 1 ]; then > sleep 2 > continue > fi > - > - for ((i = 0; i < $LOOP; i++)) > - { > - cat "$TRACING_PATH"/trace_stat/function0 > /dev/null 2>&1 > - } > + cpu=$($rand_gen 0 $((nr_cpus - 1))) > + i=0; > + while [ $i -lt $LOOP ]; do > + cat "$TRACING_PATH"/trace_stat/function${cpu} > /dev/null 2>&1 > + i=$((i + 1)) > + done > > sleep 1 > -} > - > +done ... > diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh > index fbaceb8..6090a91 100755 > --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh > +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh > @@ -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 > -} > + > +Vdone ^ Typo? -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API 2016-05-04 14:56 ` Cyril Hrubis @ 2016-05-04 15:42 ` Chunyu Hu 2016-05-04 16:32 ` Cyril Hrubis 2016-05-05 7:44 ` Chunyu Hu 0 siblings, 2 replies; 32+ messages in thread From: Chunyu Hu @ 2016-05-04 15:42 UTC (permalink / raw) To: ltp Hi Cyril, Thank you for reading this. But this patch is depending on previous patches, not a dependent one, it can't be applied cleanly without several patches. we can first work on the tst_random, which is totally independent. And will fixes the issues you mentioned in this series. ----- Original Message ----- > From: "Cyril Hrubis" <chrubis@suse.cz> > To: "Chunyu Hu" <chuhu@redhat.com> > Cc: ltp@lists.linux.it, liwan@redhat.com > Sent: Wednesday, May 4, 2016 10:56:30 PM > Subject: Re: [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API > > Hi! > > --- > > 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; > > The semicolon after i=0 is useless (and in all i=0; lines in this > patch). Thanks, new knowledge to me. will do remove. > ... > > > diff --git > > a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh > > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh > > index de6bbea..70135c1 100755 > > --- > > a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh > > +++ > > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh > > @@ -13,6 +13,9 @@ > > # > > # > > ############################################################################### > > > > +. test.sh > > No need to source test.sh for the tst_kvercmp which is a separate > binary. OK. We just remove it in next version, we indeed didn't call it here. > > +TRACING_PATH=/sys/kernel/debug/tracing/ > > Shouldn't this be propagated from the main script? What's the point of > redefining it here? Thanks, I think you are right. this is defined in ftrace_lib.sh and not needed to be redefined here. will remove in next version. > > LOOP=400 > > > > # In kernel which is older than 2.6.32, we set global clock > > @@ -24,23 +27,23 @@ else > > old_kernel=0 > > fi > > > > -for ((; ;)) > > -{ > > - if [ $old_kernel -eq 1 ]; > > - then > > - for ((i = 0; i < $LOOP; i++)) > > - { > > +while true; do > > + i=0; > > + if [ $old_kernel -eq 1 ]; then > > + while [ $i -lt $LOOP ]; do > > echo 1 > "$TRACING_PATH"/options/global-clock > > echo 0 > "$TRACING_PATH"/options/global-clock > > - } > > + i=$((i + 1)) > > + done > > else > > - for ((i = 0; i < $LOOP; i++)) > > - { > > + while [ $i -lt $LOOP ]; do > > echo local > "$TRACING_PATH"/trace_clock > > echo global > "$TRACING_PATH"/trace_clock > > - } > > + i=$((i + 1)) > > + done > > + > > fi > > > > sleep 1 > > -} > > +done > > > > diff --git > > a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh > > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh > > index 47d42bc..a24008a 100755 > > --- > > a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh > > +++ > > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh > > @@ -13,10 +13,11 @@ > > # > > # > > ############################################################################### > > > > +. test.sh > > You don't have to add test.sh for tst_sleep. OK. will remove this. > > ftrace_sleep() > > { > > - # usleep is not a standard command? > > - usleep 200000 2> /dev/null > > + tst_sleep 200000us > > if [ $? -ne 0 ]; then > > sleep 1 > > fi > > You should remove the fallback to sleep 1 if the usleep wasn't found. > Ideally the whole function ftrace_sleep should be removed and you should > just call tst_sleep from the main loop. I think using tst_sleep directly is good way. thanks. > > @@ -33,10 +34,9 @@ trap kill_this_pid SIGUSR1 > > > > LOOP=20 > > > > -for ((; ;)) > > -{ > > - for ((i = 0; i < $LOOP; i++)) > > - { > > +while true; do > > + i=0; > > + while [ $i -lt $LOOP ]; do > > cat "$TRACING_PATH"/trace_pipe > /dev/null & > > > > this_pid=$! > > @@ -45,8 +45,7 @@ for ((; ;)) > > wait $this_pid > > this_pid=0 > > ftrace_sleep > > - } > > - > > + i=$((i + 1)) > > + done > > sleep 2 > > -} > > - > > +done > > And you should also fix the kill called by the full path in this script. > It should really be just kill not /bin/kill. OK. Will fix this. > > diff --git > > a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh > > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh > > index d7e6fd3..2691991 100755 > > --- > > a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh > > +++ > > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh > > @@ -16,6 +16,8 @@ > > LOOP=200 > > > > should_skip=0 > > +rand_gen=tst_random > > What's the point of assigning tst_random into a variable instead of > using it directly? at the moment as this is still not in the test lib,so it is just marking a pending state. If that generator can be included, we can remove this and use it directly. > > +nr_cpus=`tst_ncpus` > > > > if [ ! -e "$TRACING_PATH"/function_profile_enabled ]; then > > should_skip=1 > > @@ -28,18 +30,17 @@ if [ $? -eq 0 ]; then > > should_skip=1 > > fi > > > > -for ((; ;)) > > -{ > > +while true; do > > if [ $should_skip -eq 1 ]; then > > sleep 2 > > continue > > fi > > - > > - for ((i = 0; i < $LOOP; i++)) > > - { > > - cat "$TRACING_PATH"/trace_stat/function0 > /dev/null 2>&1 > > - } > > + cpu=$($rand_gen 0 $((nr_cpus - 1))) > > + i=0; > > + while [ $i -lt $LOOP ]; do > > + cat "$TRACING_PATH"/trace_stat/function${cpu} > /dev/null 2>&1 > > + i=$((i + 1)) > > + done > > > > sleep 1 > > -} > > - > > +done > > ... > > > diff --git > > a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh > > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh > > index fbaceb8..6090a91 100755 > > --- > > a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh > > +++ > > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh > > @@ -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 > > -} > > + > > +Vdone > ^ > Typo? Here it is weird, I checked my repo and my email in ltp list, there is no char 'V', I will have a deeper check. > -- > Cyril Hrubis > chrubis@suse.cz > -- Regards, Chunyu Hu ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API 2016-05-04 15:42 ` Chunyu Hu @ 2016-05-04 16:32 ` Cyril Hrubis 2016-05-05 7:44 ` Chunyu Hu 1 sibling, 0 replies; 32+ messages in thread From: Cyril Hrubis @ 2016-05-04 16:32 UTC (permalink / raw) To: ltp Hi! > > > diff --git > > > a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh > > > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh > > > index fbaceb8..6090a91 100755 > > > --- > > > a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh > > > +++ > > > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh > > > @@ -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 > > > -} > > > + > > > +Vdone > > ^ > > Typo? > > Here it is weird, I checked my repo and my email in ltp list, there is no char 'V', > I will have a deeper check. Looks like this was a typo on my side. I've must have pressed the key by accident when I was editing a reply to the email. Sorry for the confusion. -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API 2016-05-04 15:42 ` Chunyu Hu 2016-05-04 16:32 ` Cyril Hrubis @ 2016-05-05 7:44 ` Chunyu Hu 2016-05-10 14:13 ` Cyril Hrubis 1 sibling, 1 reply; 32+ messages in thread From: Chunyu Hu @ 2016-05-05 7:44 UTC (permalink / raw) To: ltp ----- Original Message ----- > From: "Chunyu Hu" <chuhu@redhat.com> > To: "Cyril Hrubis" <chrubis@suse.cz> > Cc: liwan@redhat.com, ltp@lists.linux.it > Sent: Wednesday, May 4, 2016 11:42:48 PM > Subject: Re: [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API > > > Hi Cyril, > > > diff --git > > > a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh > > > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh > > > index 47d42bc..a24008a 100755 > > > --- > > > a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh > > > +++ > > > b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh > > > @@ -13,10 +13,11 @@ > > > # > > > # > > > ############################################################################### > > > > > > +. test.sh > > > > You don't have to add test.sh for tst_sleep. > > OK. will remove this. > > > > ftrace_sleep() > > > { > > > - # usleep is not a standard command? > > > - usleep 200000 2> /dev/null > > > + tst_sleep 200000us > > > if [ $? -ne 0 ]; then > > > sleep 1 > > > fi > > > > You should remove the fallback to sleep 1 if the usleep wasn't found. > > Ideally the whole function ftrace_sleep should be removed and you should > > just call tst_sleep from the main loop. > > I think using tst_sleep directly is good way. thanks. > > > > @@ -33,10 +34,9 @@ trap kill_this_pid SIGUSR1 > > > > > > LOOP=20 > > > > > > -for ((; ;)) > > > -{ > > > - for ((i = 0; i < $LOOP; i++)) > > > - { > > > +while true; do > > > + i=0; > > > + while [ $i -lt $LOOP ]; do > > > cat "$TRACING_PATH"/trace_pipe > /dev/null & > > > > > > this_pid=$! > > > @@ -45,8 +45,7 @@ for ((; ;)) > > > wait $this_pid > > > this_pid=0 > > > ftrace_sleep > > > - } > > > - > > > + i=$((i + 1)) > > > + done > > > sleep 2 > > > -} > > > - > > > +done > > > > And you should also fix the kill called by the full path in this script. > > It should really be just kill not /bin/kill. > Hi Cyril, After i changing it to kill directly and retest it, i hit err message: ftrace_trace_pipe.sh: line 18: kill: SIGKILL: invalid signal specification then i found that kill is also one of the bash built-in cmd. So we'd better still use /bin/kill in this case. # type kill kill is a shell builtin bash-4.2.46-19.el7.x86_64 ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API 2016-05-05 7:44 ` Chunyu Hu @ 2016-05-10 14:13 ` Cyril Hrubis 2016-05-11 11:01 ` Chunyu Hu 0 siblings, 1 reply; 32+ messages in thread From: Cyril Hrubis @ 2016-05-10 14:13 UTC (permalink / raw) To: ltp Hi! > After i changing it to kill directly and retest it, i hit err message: > > ftrace_trace_pipe.sh: line 18: kill: SIGKILL: invalid signal specification That is because POSIX only accepts symbolic names without the SIG prefix while kill from procps works with both. The correct way to send SIGKILL is 'kill -KILL $pid'. -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API 2016-05-10 14:13 ` Cyril Hrubis @ 2016-05-11 11:01 ` Chunyu Hu 0 siblings, 0 replies; 32+ messages in thread From: Chunyu Hu @ 2016-05-11 11:01 UTC (permalink / raw) To: ltp ----- Original Message ----- > From: "Cyril Hrubis" <chrubis@suse.cz> > To: "Chunyu Hu" <chuhu@redhat.com> > Cc: liwan@redhat.com, ltp@lists.linux.it > Sent: Tuesday, May 10, 2016 10:13:00 PM > Subject: Re: [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API > > Hi! > > After i changing it to kill directly and retest it, i hit err message: > > > > ftrace_trace_pipe.sh: line 18: kill: SIGKILL: invalid signal specification > > That is because POSIX only accepts symbolic names without the SIG prefix > while kill from procps works with both. > > The correct way to send SIGKILL is 'kill -KILL $pid'. Thanks. Really makes sense. Will fix it with V3-2. please ignore the previous V3. that's not complete considering this. > -- > Cyril Hrubis > chrubis@suse.cz > -- Regards, Chunyu Hu ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 7/9] ftrace_stress: update the trace_options test 2016-04-18 8:04 ` [LTP] [PATCH V2 7/9] ftrace_stress: update the trace_options test Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 8/9] ftrace_stress: add two new tests Chunyu Hu @ 2016-05-04 16:57 ` Cyril Hrubis 1 sibling, 0 replies; 32+ messages in thread From: Cyril Hrubis @ 2016-05-04 16:57 UTC (permalink / raw) To: ltp Hi! > + if [ $ret_val -ne 0 ]; then > + tst_resm TFAIL "$0: $operation trace option $option failed" > + fi > + i=$((i + 1)) > + done > + j=$((j + 1)) > + done > + # sleep is not needed if ftrace can surrive. > + # tst_sleep 1s Just remove these lines if they are not needed. -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator 2016-04-18 8:04 ` [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 7/9] ftrace_stress: update the trace_options test Chunyu Hu @ 2016-05-04 13:34 ` Cyril Hrubis 2016-05-04 15:04 ` Chunyu Hu 1 sibling, 1 reply; 32+ messages in thread From: Cyril Hrubis @ 2016-05-04 13:34 UTC (permalink / raw) To: ltp Hi! > 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..91a5247 > --- /dev/null > +++ b/testcases/lib/tst_random.c > @@ -0,0 +1,104 @@ > +/* > + * Copyright (c) 2016 Red Hat Inc. > + * > + * This program is free software; you can redistribute it and/or > + * modify it under the terms of the GNU General Public License as > + * published by the Free Software Foundation; either version 2 of > + * the License, or (at your option) any later version. > + * > + * This program is distributed in the hope that it would be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, write the Free Software Foundation, > + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA > + * > + * Author: Chunyu Hu <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; > + } > + > + if (optind >= argc) { > + fprintf(stderr, "ERROR: Expected one or two range_val arguments\n\n"); > + print_help(); > + return 1; > + } We exit if getopt() finds any options in argv[] so optind == 1 here and since we check for argc < 2 before this this if is never true. > + max = strtol(argv[optind], &end, 10); Here as well optind == 1 by definition. > + if (argv[optind] == end) { > + fprintf(stderr, "ERROR: Invalid range value1 '%s'\n\n", > + argv[optind]); > + print_help(); > + return 1; > + } Well if we bother with strtol() we may check that argv[1] != '\0' and end == '\0' which will ensure that whole parameter was a valid string. > + if (argc == 3) { > + min = strtol(argv[optind+1], &end, 10); Here as well use just 2 instead of optind + 1. > + if (argv[optind+1] == end) { > + fprintf(stderr, "ERROR: Invalid range value2 '%s'\n\n", > + argv[optind+1]); > + print_help(); > + return 1; > + } > + if (min > max) { > + tmp = min; > + min = max; > + max = tmp; > + } Well we may also do: rval = (min > max) ? rand_range(max, min) : rand_range(min, max); In the code below instead, but that is merely cosmetic. > + } > + > + srand(get_seed()); > + rval = rand_range(min, max); > + printf("%ld\n", rval); > + > + return rval; We should just return 0 here since the return value is limited to one byte. Exporting interface that works only in certain cases is a recipe for a disaster. -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator 2016-05-04 13:34 ` [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator Cyril Hrubis @ 2016-05-04 15:04 ` Chunyu Hu 2016-05-04 15:55 ` Cyril Hrubis 0 siblings, 1 reply; 32+ messages in thread From: Chunyu Hu @ 2016-05-04 15:04 UTC (permalink / raw) To: ltp Hi, Thank you for the quick review, will submit a new version soon, Other tests indeed referenced this helper. Also added some comment below. ----- Original Message ----- > From: "Cyril Hrubis" <chrubis@suse.cz> > To: "Chunyu Hu" <chuhu@redhat.com> > Cc: ltp@lists.linux.it, liwan@redhat.com > Sent: Wednesday, May 4, 2016 9:34:53 PM > Subject: Re: [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator > > Hi! > > 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..91a5247 > > --- /dev/null > > +++ b/testcases/lib/tst_random.c > > @@ -0,0 +1,104 @@ > > +/* > > + * Copyright (c) 2016 Red Hat Inc. > > + * > > + * This program is free software; you can redistribute it and/or > > + * modify it under the terms of the GNU General Public License as > > + * published by the Free Software Foundation; either version 2 of > > + * the License, or (at your option) any later version. > > + * > > + * This program is distributed in the hope that it would be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > + * GNU General Public License for more details. > > + * > > + * You should have received a copy of the GNU General Public License > > + * along with this program; if not, write the Free Software Foundation, > > + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA > > + * > > + * Author: Chunyu Hu <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; > > + } > > + > > + if (optind >= argc) { > > + fprintf(stderr, "ERROR: Expected one or two range_val arguments\n\n"); > > + print_help(); > > + return 1; > > + } > > We exit if getopt() finds any options in argv[] so optind == 1 here and > since we check for argc < 2 before this this if is never true. Good analysis, so this should be removed in next step. > > > + max = strtol(argv[optind], &end, 10); > > Here as well optind == 1 by definition. Ok, will use 1 directly next step. > > > + if (argv[optind] == end) { > > + fprintf(stderr, "ERROR: Invalid range value1 '%s'\n\n", > > + argv[optind]); > > + print_help(); > > + return 1; > > + } > > Well if we bother with strtol() we may check that argv[1] != '\0' and > end == '\0' which will ensure that whole parameter was a valid string. Looks like we just need to compare with ( *end != '\0' ), as argv[1] or argv[2] can't be '\0' (NULL) as it has been filtered by (argc <2 || argc > 3). And i just verified this with this debug line: printf("end = %p, *end = %c\n", end, *end); > > + if (argc == 3) { > > + min = strtol(argv[optind+1], &end, 10); > > Here as well use just 2 instead of optind + 1. OK. Agree. > > > + if (argv[optind+1] == end) { > > + fprintf(stderr, "ERROR: Invalid range value2 '%s'\n\n", > > + argv[optind+1]); > > + print_help(); > > + return 1; > > + } > > + if (min > max) { > > + tmp = min; > > + min = max; > > + max = tmp; > > + } > > Well we may also do: > > rval = (min > max) ? rand_range(max, min) : rand_range(min, max); Thanks for this good advise, i really like this style. > In the code below instead, but that is merely cosmetic. Thanks. > > > + } > > + > > + srand(get_seed()); > > + rval = rand_range(min, max); > > + printf("%ld\n", rval); > > + > > + return rval; > > We should just return 0 here since the return value is limited to one > byte. Exporting interface that works only in certain cases is a recipe > for a disaster. Thanks for catching this, can't agree more. Will fix this line in next step. > -- > Cyril Hrubis > chrubis@suse.cz > -- Regards, Chunyu Hu ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator 2016-05-04 15:04 ` Chunyu Hu @ 2016-05-04 15:55 ` Cyril Hrubis 2016-05-04 16:28 ` Chunyu Hu 0 siblings, 1 reply; 32+ messages in thread From: Cyril Hrubis @ 2016-05-04 15:55 UTC (permalink / raw) To: ltp Hi! > Looks like we just need to compare with ( *end != '\0' ), as argv[1] or > argv[2] can't be '\0' (NULL) as it has been filtered by (argc <2 || argc > 3). > > And i just verified this with this debug line: > > printf("end = %p, *end = %c\n", end, *end); What will happen when you call: tst_random "" "" Or more realistic case when FOO is not defined and you do: tst_random "$FOO" Note that empty string in C is an array with first element set to 0. -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator 2016-05-04 15:55 ` Cyril Hrubis @ 2016-05-04 16:28 ` Chunyu Hu 2016-05-04 23:40 ` Chunyu Hu 0 siblings, 1 reply; 32+ messages in thread From: Chunyu Hu @ 2016-05-04 16:28 UTC (permalink / raw) To: ltp ----- Original Message ----- > From: "Cyril Hrubis" <chrubis@suse.cz> > To: "Chunyu Hu" <chuhu@redhat.com> > Cc: ltp@lists.linux.it, liwan@redhat.com > Sent: Wednesday, May 4, 2016 11:55:31 PM > Subject: Re: [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator > > Hi! > > Looks like we just need to compare with ( *end != '\0' ), as argv[1] or > > argv[2] can't be '\0' (NULL) as it has been filtered by (argc <2 || argc > > > 3). > > > > And i just verified this with this debug line: > > > > printf("end = %p, *end = %c\n", end, *end); > > What will happen when you call: > > tst_random "" "" > > Or more realistic case when FOO is not defined and you do: > > tst_random "$FOO" > > Note that empty string in C is an array with first element set to 0. I was so hurried to send out the patch :/. You are right. I missed your mentioned here. I added some debug line, proving you are right. printf("argv[1] = [%d]\n", argv[1][0]); printf("argv[3] = [%d]\n", argv[3]); printf("end = %p, *end = [%d]\n", end, *end); ./a.out "" "" argv[1] = [0] argv[3] = [0] end = 0x7ffc3d49861f, *end = [0] I will reorganize this check later, my brain is so slow now. Thank you. > -- > Cyril Hrubis > chrubis@suse.cz > -- Regards, Chunyu Hu ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator 2016-05-04 16:28 ` Chunyu Hu @ 2016-05-04 23:40 ` Chunyu Hu 0 siblings, 0 replies; 32+ messages in thread From: Chunyu Hu @ 2016-05-04 23:40 UTC (permalink / raw) To: ltp ----- Original Message ----- > From: "Chunyu Hu" <chuhu@redhat.com> > To: "Cyril Hrubis" <chrubis@suse.cz> > Cc: liwan@redhat.com, ltp@lists.linux.it > Sent: Thursday, May 5, 2016 12:28:30 AM > Subject: Re: [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator > > > > ----- Original Message ----- > > From: "Cyril Hrubis" <chrubis@suse.cz> > > To: "Chunyu Hu" <chuhu@redhat.com> > > Cc: ltp@lists.linux.it, liwan@redhat.com > > Sent: Wednesday, May 4, 2016 11:55:31 PM > > Subject: Re: [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical > > integer generator > > > > Hi! > > > Looks like we just need to compare with ( *end != '\0' ), as argv[1] or > > > argv[2] can't be '\0' (NULL) as it has been filtered by (argc <2 || argc > > > > > > > 3). I proved to be wrong, which pointed bye you below. BTW, i also changed the argc check way to if (argc != 2 && argc != 3) I think this clearer than if (argc < 2 || argc > 3 ) > > > And i just verified this with this debug line: > > > > > > printf("end = %p, *end = %c\n", end, *end); > > > > What will happen when you call: > > > > tst_random "" "" > > > > Or more realistic case when FOO is not defined and you do: > > > > tst_random "$FOO" > > > > Note that empty string in C is an array with first element set to 0. > > I was so hurried to send out the patch :/. You are right. I missed your > mentioned here. I added some debug line, proving you are right. > > > printf("argv[1] = [%d]\n", argv[1][0]); > printf("argv[3] = [%d]\n", argv[3]); > printf("end = %p, *end = [%d]\n", end, *end); > > ./a.out "" "" > > argv[1] = [0] > argv[3] = [0] > end = 0x7ffc3d49861f, *end = [0] > > I will reorganize this check later, my brain is so slow now. Thank you. after some rest, i considered it as your suggestion and man page. I think below condition is enough, if you don't have objection for this, i will use this in next step. Thanks. if (!(argv[1][0] != '\0' && *end == '\0')) > > > -- > > Cyril Hrubis > > chrubis@suse.cz > > > > -- > Regards, > Chunyu Hu > > -- > Mailing list info: https://lists.linux.it/listinfo/ltp > -- Regards, Chunyu Hu ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests 2016-04-18 8:04 ` [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 5/9] ftrace_stress: keep the name of testscipt in sync with tracing file Chunyu Hu @ 2016-05-04 16:50 ` Cyril Hrubis 2016-05-05 0:53 ` Chunyu Hu 1 sibling, 1 reply; 32+ messages in thread From: Cyril Hrubis @ 2016-05-04 16:50 UTC (permalink / raw) To: ltp Hi! > diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh > index d9f7f8b..80c914c 100755 > --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh > +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh > @@ -21,87 +21,92 @@ > ## ## > ########################################################################### > > - > export TCID="ftrace-stress-test" > export TST_TOTAL=1 > export TST_COUNT=1 > > . ftrace_lib.sh > > -test_success=true > +test_targets=" \ > +trace_pipe current_tracer ftrace_enabled function_profile_enabled \ > +set_event set_ftrace_pid stack_max_size stack_trace trace trace_clock \ > +trace_options trace_stat tracing_enabled tracing_max_latency \ > +tracing_on function_profile_enabled buffer_size_kb" > > -export_pids() > +get_skip_targets() > { > - export pid1 pid2 pid3 pid4 pid5 pid6 pid7 pid8 pid9 pid10 pid11 pid12 \ > - pid13 pid14 pid15 pid16 > - > - export NR_PIDS=16 > + NR_PIDS=0 > + for target in ${test_targets}; do > + if [ ! -e $TRACING_PATH/$target ] && > + [ ! -e /proc/sys/kernel/$target ]; then > + eval skip_$target=1 > + tst_resm TINFO "$target is not supported. Skip it." > + else > + eval skip_$target=0 > + NR_PIDS=$((NR_PIDS + 1)) > + fi > + done > + # Export it before sub case is lanuched. > + export NR_PIDS > } > > -test_stress() > +should_skip_target() > { > - export_pids > - > - $SPATH/ftrace_trace_clock.sh & > - pid1=$! > - $SPATH/ftrace_current_tracer.sh & > - pid2=$! > - $SPATH/ftrace_trace_options.sh & > - pid3=$! > - $SPATH/ftrace_tracing_max_latency.sh & > - pid4=$! > - $SPATH/ftrace_stack_trace.sh & > - pid5=$! > - $SPATH/ftrace_stack_max_size.sh & > - pid6=$! > - $SPATH/ftrace_tracing_on.sh & > - pid7=$! > - $SPATH/ftrace_tracing_enabled.sh & > - pid8=$! > - $SPATH/ftrace_set_event.sh & > - pid9=$! > - $SPATH/ftrace_buffer_size.sh & > - pid10=$! > - $SPATH/ftrace_trace.sh & > - pid11=$! > - $SPATH/ftrace_trace_pipe.sh & > - pid12=$! > - $SPATH/ftrace_ftrace_enabled.sh & > - pid13=$! > - $SPATH/ftrace_set_ftrace_pid.sh & > - pid14=$! > - $SPATH/ftrace_profile_enabled.sh & > - pid15=$! > - $SPATH/ftrace_trace_stat.sh & > - pid16=$! > + local var=skip_$1 > + local val=${!var} > + [ "$val" = 1 ] > } > > test_kill() > { > - kill -KILL $pid1 || test_success=false > - kill -KILL $pid2 || test_success=false > - kill -KILL $pid3 || test_success=false > - kill -KILL $pid4 || test_success=false > - kill -KILL $pid5 || test_success=false > - kill -KILL $pid6 || test_success=false > - kill -KILL $pid7 || test_success=false > - kill -KILL $pid8 || test_success=false > - kill -KILL $pid9 || test_success=false > - kill -KILL $pid10 || test_success=false > - kill -KILL $pid11 || test_success=false > - kill -USR1 $pid12 || test_success=false > - kill -KILL $pid13 || test_success=false > - kill -KILL $pid14 || test_success=false > - kill -KILL $pid15 || test_success=false > - kill -KILL $pid16 || test_success=false > + tst_resm TINFO "killing ${pid0}" > + kill -USR1 ${pid0} > + wait ${pid0} > + > + local p=1; > + while [ $p -lt $NR_PIDS ]; do > + local kill_pid=pid${p} > + kill -KILL ${!kill_pid} ^ Bashism. > + tst_resm TINFO "killing ${!kill_pid}" > + wait ${!kill_pid} > + p=$((p + 1)) > + done This part seems to have misformatted whitespaces, please fix that. > sleep 2 The wait is done here, OK. But you should have dropped the sleep 2. > clean_up > } > > +test_stress() > +{ > + local index=0; > + > + tst_resm TINFO "Test targets: ${test_targets}" > + > + get_skip_targets > + for target in ${test_targets}; do > + if should_skip_target $target; then > + continue > + fi > + sh ftrace_${target}.sh & > + eval pid${index}=$! > + tst_resm TINFO "Start pid${index}=$! $SPATH/ftrace_${target}.sh" > + index=$((index + 1)) > + done > + export_pids > +} > + > +export_pids() > +{ > + local p=0 > + while [ $p -lt $NR_PIDS ]; do > + export pid${p} > + p=$((p + 1)) > + done > +} > > +cd ftrace_stress/ Why the cd? It does not seem to be needed. > # ---------------------------- > -echo "Ftrace Stress Test Begin" > +tst_resm TINFO "Ftrace Stress Test Begin" > > save_old_setting > > @@ -113,11 +118,6 @@ test_wait > > test_kill > > -echo "Ftrace Stress Test End" > +tst_resm TINFO "Finished running the test. Run dmesg to double-check for bugs" Well most of the things I've pointed out seems to be fixed but I still fail to see the restore_old_setting here. Or do I miss someting? > -if $test_success; then > - tst_resm TPASS "finished running the test. Run dmesg to double-check for bugs" > -else > - tst_resm TFAIL "please check log message." > - exit 1 > -fi > +tst_exit -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests 2016-05-04 16:50 ` [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests Cyril Hrubis @ 2016-05-05 0:53 ` Chunyu Hu 2016-05-10 14:25 ` Cyril Hrubis 0 siblings, 1 reply; 32+ messages in thread From: Chunyu Hu @ 2016-05-05 0:53 UTC (permalink / raw) To: ltp ----- Original Message ----- > From: "Cyril Hrubis" <chrubis@suse.cz> > To: "Chunyu Hu" <chuhu@redhat.com> > Cc: ltp@lists.linux.it, liwan@redhat.com > Sent: Thursday, May 5, 2016 12:50:50 AM > Subject: Re: [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests > > Hi! > > diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh > > b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh > > index d9f7f8b..80c914c 100755 > > --- a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh > > +++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh > > @@ -21,87 +21,92 @@ > > ## > > ## > > ########################################################################### > > > > - > > export TCID="ftrace-stress-test" > > export TST_TOTAL=1 > > export TST_COUNT=1 > > > > . ftrace_lib.sh > > > > -test_success=true > > +test_targets=" \ > > +trace_pipe current_tracer ftrace_enabled function_profile_enabled \ > > +set_event set_ftrace_pid stack_max_size stack_trace trace trace_clock \ > > +trace_options trace_stat tracing_enabled tracing_max_latency \ > > +tracing_on function_profile_enabled buffer_size_kb" > > > > -export_pids() > > +get_skip_targets() > > { > > - export pid1 pid2 pid3 pid4 pid5 pid6 pid7 pid8 pid9 pid10 pid11 pid12 \ > > - pid13 pid14 pid15 pid16 > > - > > - export NR_PIDS=16 > > + NR_PIDS=0 > > + for target in ${test_targets}; do > > + if [ ! -e $TRACING_PATH/$target ] && > > + [ ! -e /proc/sys/kernel/$target ]; then > > + eval skip_$target=1 > > + tst_resm TINFO "$target is not supported. Skip it." > > + else > > + eval skip_$target=0 > > + NR_PIDS=$((NR_PIDS + 1)) > > + fi > > + done > > + # Export it before sub case is lanuched. > > + export NR_PIDS > > } > > > > -test_stress() > > +should_skip_target() > > { > > - export_pids > > - > > - $SPATH/ftrace_trace_clock.sh & > > - pid1=$! > > - $SPATH/ftrace_current_tracer.sh & > > - pid2=$! > > - $SPATH/ftrace_trace_options.sh & > > - pid3=$! > > - $SPATH/ftrace_tracing_max_latency.sh & > > - pid4=$! > > - $SPATH/ftrace_stack_trace.sh & > > - pid5=$! > > - $SPATH/ftrace_stack_max_size.sh & > > - pid6=$! > > - $SPATH/ftrace_tracing_on.sh & > > - pid7=$! > > - $SPATH/ftrace_tracing_enabled.sh & > > - pid8=$! > > - $SPATH/ftrace_set_event.sh & > > - pid9=$! > > - $SPATH/ftrace_buffer_size.sh & > > - pid10=$! > > - $SPATH/ftrace_trace.sh & > > - pid11=$! > > - $SPATH/ftrace_trace_pipe.sh & > > - pid12=$! > > - $SPATH/ftrace_ftrace_enabled.sh & > > - pid13=$! > > - $SPATH/ftrace_set_ftrace_pid.sh & > > - pid14=$! > > - $SPATH/ftrace_profile_enabled.sh & > > - pid15=$! > > - $SPATH/ftrace_trace_stat.sh & > > - pid16=$! > > + local var=skip_$1 > > + local val=${!var} I found here i was using bashism too as your pointed below. > > + [ "$val" = 1 ] > > } > > > > test_kill() > > { > > - kill -KILL $pid1 || test_success=false > > - kill -KILL $pid2 || test_success=false > > - kill -KILL $pid3 || test_success=false > > - kill -KILL $pid4 || test_success=false > > - kill -KILL $pid5 || test_success=false > > - kill -KILL $pid6 || test_success=false > > - kill -KILL $pid7 || test_success=false > > - kill -KILL $pid8 || test_success=false > > - kill -KILL $pid9 || test_success=false > > - kill -KILL $pid10 || test_success=false > > - kill -KILL $pid11 || test_success=false > > - kill -USR1 $pid12 || test_success=false > > - kill -KILL $pid13 || test_success=false > > - kill -KILL $pid14 || test_success=false > > - kill -KILL $pid15 || test_success=false > > - kill -KILL $pid16 || test_success=false > > + tst_resm TINFO "killing ${pid0}" > > + kill -USR1 ${pid0} > > + wait ${pid0} > > + > > + local p=1; > > + while [ $p -lt $NR_PIDS ]; do > > + local kill_pid=pid${p} > > + kill -KILL ${!kill_pid} > ^ > Bashism. I am trying to change to use this way local pid_var=pid${p} eval local kill_pid=\$${pid_var} tst_resm TINFO "killing ${kill_pid}" eval kill -KILL $kill_pid wait ${kill_pid} maybe i'm still using bashism? thanks. if it's ok then i will use this way. Ideally i should find a dash to try. but i have not found the package in rhel. > > > + tst_resm TINFO "killing ${!kill_pid}" > > + wait ${!kill_pid} > > + p=$((p + 1)) > > + done > > This part seems to have misformatted whitespaces, please fix that. OK. Noticed, fixed in my local repo now. > > sleep 2 > > > The wait is done here, OK. But you should have dropped the sleep 2. OK. removed in my local now. Won't see it in next step. > > clean_up Here i will call restore_ path. but i think we'd better move it out of test_kill to main path, it's not appropriate in that func. > > } > > > > +test_stress() > > +{ > > + local index=0; > > + > > + tst_resm TINFO "Test targets: ${test_targets}" > > + > > + get_skip_targets > > + for target in ${test_targets}; do > > + if should_skip_target $target; then > > + continue > > + fi > > + sh ftrace_${target}.sh & > > + eval pid${index}=$! > > + tst_resm TINFO "Start pid${index}=$! $SPATH/ftrace_${target}.sh" > > + index=$((index + 1)) > > + done > > + export_pids > > +} > > + > > +export_pids() > > +{ > > + local p=0 > > + while [ $p -lt $NR_PIDS ]; do > > + export pid${p} > > + p=$((p + 1)) > > + done > > +} > > > > +cd ftrace_stress/ > > Why the cd? It does not seem to be needed. as currently we are in ftrace_test/, but sub stresses cases are in ftrace_test/ftrace_stress/ in test_stress(), i start the sub script using sh ftrace_${target}.sh & This make the path shorter. If you don't have objection, I will move the cd ftrace_stress/ into test_stress(). What do you think of this? > > > # ---------------------------- > > -echo "Ftrace Stress Test Begin" > > +tst_resm TINFO "Ftrace Stress Test Begin" > > > > save_old_setting > > > > @@ -113,11 +118,6 @@ test_wait > > > > test_kill > > > > -echo "Ftrace Stress Test End" > > +tst_resm TINFO "Finished running the test. Run dmesg to double-check for > > bugs" > > Well most of the things I've pointed out seems to be fixed but I still > fail to see the restore_old_setting here. Or do I miss someting? in ftrace_lib.sh , you can see a clean_up which calls the restore path. Looks like leave it in clean_up can make things simpler. you mentioned ltp can setup cleanup callback, if one clean_up can do all. then that's good to put it there with other clean steps together. your opinion? > > -if $test_success; then > > - tst_resm TPASS "finished running the test. Run dmesg to double-check for > > bugs" > > -else > > - tst_resm TFAIL "please check log message." > > - exit 1 > > -fi > > +tst_exit > > > > -- > Cyril Hrubis > chrubis@suse.cz > -- Regards, Chunyu Hu ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests 2016-05-05 0:53 ` Chunyu Hu @ 2016-05-10 14:25 ` Cyril Hrubis 2016-05-11 11:14 ` Chunyu Hu 0 siblings, 1 reply; 32+ messages in thread From: Cyril Hrubis @ 2016-05-10 14:25 UTC (permalink / raw) To: ltp Hi! > > > + local p=1; > > > + while [ $p -lt $NR_PIDS ]; do > > > + local kill_pid=pid${p} > > > + kill -KILL ${!kill_pid} > > ^ > > Bashism. > > I am trying to change to use this way > > local pid_var=pid${p} > eval local kill_pid=\$${pid_var} > tst_resm TINFO "killing ${kill_pid}" > eval kill -KILL $kill_pid > wait ${kill_pid} > > maybe i'm still using bashism? thanks. if it's ok > then i will use this way. > > Ideally i should find a dash to try. but i have not > found the package in rhel. You can always compile it from source: http://gondor.apana.org.au/~herbert/dash/files/ And there also seems to be debian devel perl script that can check for bashism, maybe we can start using it to check shell scripts: https://anonscm.debian.org/cgit/collab-maint/devscripts.git/tree/scripts/checkbashisms.pl > > > +export_pids() > > > +{ > > > + local p=0 > > > + while [ $p -lt $NR_PIDS ]; do > > > + export pid${p} > > > + p=$((p + 1)) > > > + done > > > +} > > > > > > +cd ftrace_stress/ > > > > Why the cd? It does not seem to be needed. > > as currently we are in ftrace_test/, but sub stresses > cases are in ftrace_test/ftrace_stress/ > > in test_stress(), i start the sub script using > > sh ftrace_${target}.sh & > > This make the path shorter. If you don't have objection, > I will move the cd ftrace_stress/ into test_stress(). > What do you think of this? The stress tests are installed into $DESTDIR/testcases/bin/ aren't they? If that is the case these scripts are in $PATH and could be executed without fiddling with full path. -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests 2016-05-10 14:25 ` Cyril Hrubis @ 2016-05-11 11:14 ` Chunyu Hu 0 siblings, 0 replies; 32+ messages in thread From: Chunyu Hu @ 2016-05-11 11:14 UTC (permalink / raw) To: ltp ----- Original Message ----- > From: "Cyril Hrubis" <chrubis@suse.cz> > To: "Chunyu Hu" <chuhu@redhat.com> > Cc: ltp@lists.linux.it, liwan@redhat.com > Sent: Tuesday, May 10, 2016 10:25:04 PM > Subject: Re: [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests > > Hi! > > > > + local p=1; > > > > + while [ $p -lt $NR_PIDS ]; do > > > > + local kill_pid=pid${p} > > > > + kill -KILL ${!kill_pid} > > > ^ > > > Bashism. > > > > I am trying to change to use this way > > > > local pid_var=pid${p} > > eval local kill_pid=\$${pid_var} > > tst_resm TINFO "killing ${kill_pid}" > > eval kill -KILL $kill_pid > > wait ${kill_pid} > > > > maybe i'm still using bashism? thanks. if it's ok > > then i will use this way. > > > > Ideally i should find a dash to try. but i have not > > found the package in rhel. > > You can always compile it from source: > > http://gondor.apana.org.au/~herbert/dash/files/ Thanks. I compiled and tried, although test didn't hit issue, but this is all because it's using sh xxxxx.sh to execute sub tests, if i executed the cmd on bash directly, it would tell me the error. > > And there also seems to be debian devel perl script that can check for > bashism, maybe we can start using it to check shell scripts: > > https://anonscm.debian.org/cgit/collab-maint/devscripts.git/tree/scripts/checkbashisms.pl Thanks for the useful info, I tried the tool, it did find the bashism issue of ${!var}. and it also found another issue in ftrace_tracing_cpu_mask.sh of $(( a | (1 << $b) )), i have changed to use $((a | $(( 1 << $b)) )) instead. > > > > +export_pids() > > > > +{ > > > > + local p=0 > > > > + while [ $p -lt $NR_PIDS ]; do > > > > + export pid${p} > > > > + p=$((p + 1)) > > > > + done > > > > +} > > > > > > > > +cd ftrace_stress/ > > > > > > Why the cd? It does not seem to be needed. > > > > as currently we are in ftrace_test/, but sub stresses > > cases are in ftrace_test/ftrace_stress/ > > > > in test_stress(), i start the sub script using > > > > sh ftrace_${target}.sh & > > > > This make the path shorter. If you don't have objection, > > I will move the cd ftrace_stress/ into test_stress(). > > What do you think of this? > > The stress tests are installed into $DESTDIR/testcases/bin/ aren't they? > > If that is the case these scripts are in $PATH and could be executed > without fiddling with full path. [root@dhcp-chuhu bin]# ls ftrace_* -d ftrace_lib.sh ftrace_regression01.sh ftrace_regression02.sh ftrace_stress ftrace_stress_test.sh [root@dhcp-chuhu bin]# pwd /opt/ltp/testcases/bin tests are under subdir ftrace_stress of bin. so we need a cd. but also can just remove it and use ftrace_stress/${target}.sh instead, ok, i will use this way. Please ignore the previous V3, that's not complete considering this. > -- > Cyril Hrubis > chrubis@suse.cz > -- Regards, Chunyu Hu ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 2/9] tracing/ftrace: add new case for ftrace userstacktrace 2016-04-18 8:04 ` [LTP] [PATCH V2 2/9] tracing/ftrace: add new case for ftrace userstacktrace Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 3/9] tracing/ftrace: add a new case for signal_generate Chunyu Hu @ 2016-05-04 16:00 ` Cyril Hrubis 2016-05-05 6:24 ` Li Wang 1 sibling, 1 reply; 32+ messages in thread From: Cyril Hrubis @ 2016-05-04 16:00 UTC (permalink / raw) To: ltp Hi! > +ftrace_userstacktrace_test() > +{ > + if [ ! -e "$TSTACK_TRACE_PATH" ]; then > + tst_brkm TCONF ignored "Stack Tracer is not cofigured in This kernel" The 'ignored' should really be removed here, it's a leftover when the tst_brkm called the broken-by-design binary. > + 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" > +} -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 2/9] tracing/ftrace: add new case for ftrace userstacktrace 2016-05-04 16:00 ` [LTP] [PATCH V2 2/9] tracing/ftrace: add new case for ftrace userstacktrace Cyril Hrubis @ 2016-05-05 6:24 ` Li Wang 0 siblings, 0 replies; 32+ messages in thread From: Li Wang @ 2016-05-05 6:24 UTC (permalink / raw) To: ltp On Wed, May 04, 2016 at 06:00:27PM +0200, Cyril Hrubis wrote: > Hi! > > +ftrace_userstacktrace_test() > > +{ > > + if [ ! -e "$TSTACK_TRACE_PATH" ]; then > > + tst_brkm TCONF ignored "Stack Tracer is not cofigured in This kernel" > > The 'ignored' should really be removed here, it's a leftover when the > tst_brkm called the broken-by-design binary. ok. thanks for reivewing. > > > + 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" > > +} > > -- > Cyril Hrubis > chrubis@suse.cz ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests 2016-04-18 8:04 ` [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 2/9] tracing/ftrace: add new case for ftrace userstacktrace Chunyu Hu @ 2016-05-04 16:26 ` Cyril Hrubis 2016-05-05 6:21 ` Li Wang 2016-05-05 10:11 ` Chunyu Hu 1 sibling, 2 replies; 32+ messages in thread From: Cyril Hrubis @ 2016-05-04 16:26 UTC (permalink / raw) To: ltp Hi! > 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 ^ The space should be removed > +########################################################################### > +## ## > +## 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" The test must not create files and mount things outside of the test temporary directory. Expecially not in $LTPROOT. You should call tst_tmpdir to create temporary directory instead, then create directory there. Also the ftrace filesystem seems to be mounted on /sys/kernel/debug/tracing/ on recent distributions, why don't we just set TRACING_PATH accodingly if it's already mounted and fallback to mounting it only when debugfs couldn't be found in /proc/mounts? > +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 > + } > +} Why don't we just do sleep $test_interval instead? > +trap clean_up_exit INT > + > +tst_require_root > + > +# Don't run the test on kernels older than 2.6.34, otherwise > +# it can crash the system if the kernel is not latest-stable > +tst_kvercmp 2 6 34 > +if [ $? -eq 0 ]; then > + tst_brkm TCONF ignored "The test should be run in kernels >= 2.6.34. Skip the test..." > + exit 0 > +fi Don't do this. Really the whole point of LTP is to validate kernel, if we skip known bugs by default we would give users false impression that the kernel was thoroughly tested. Also since you include the test.sh here the tst_brkm format is different and it exits the test, so the exit 0 is never reached. > +mkdir $DEBUGFS_PATH > +mount -t debugfs xxx $DEBUGFS_PATH > + > +# Check to see tracing feature is supported or not > +if [ ! -d $TRACING_PATH ]; then > + tst_brkm TCONF ignored "Tracing is not supported. Skip the test..." > + umount $DEBUGFS_PATH > + rmdir $DEBUGFS_PATH > + exit 0 > +fi Here as well, the tst_brkm from test.sh exit the test. Ideally you should setup TST_CLEANUP to point to a cleanup function once you do the test initalization which would be then executed before the test exits automatically. ... > 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 I remember telling you to call wait on each pid instead of the sleep 2 here. > + clean_up > +} > + > + > +# ---------------------------- > +echo "Ftrace Stress Test Begin" That should be tst_resm TINFO "..." but that is very minor. > +save_old_setting > + > +test_begin > + > +test_stress > + > +test_wait > + > +test_kill Hmm, shouldn't you restore old settings here? > +echo "Ftrace Stress Test End" Here as well. > +if $test_success; then > + tst_resm TPASS "finished running the test. Run dmesg to double-check for bugs" > +else > + tst_resm TFAIL "please check log message." > + exit 1 > +fi You should call tst_exit at the end of the test instead of doing exit 1 after the tst_resm. This is another leftover caused by the broken-by-desing tst_resm and tst_brkm binaries. -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests 2016-05-04 16:26 ` [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests Cyril Hrubis @ 2016-05-05 6:21 ` Li Wang 2016-05-05 10:11 ` Chunyu Hu 1 sibling, 0 replies; 32+ messages in thread From: Li Wang @ 2016-05-05 6:21 UTC (permalink / raw) To: ltp On Wed, May 04, 2016 at 06:26:56PM +0200, Cyril Hrubis wrote: > Hi! > > 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 > ^ > The space should be removed This commit rename all of the ftrace file, it is just a preparing for the upcoming patches, we will fix the below issues with some kind of new patches. And sorry for no clear note in the summary before. > > > +########################################################################### > > +## ## > > +## 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" > > The test must not create files and mount things outside of the test > temporary directory. Expecially not in $LTPROOT. You should call > tst_tmpdir to create temporary directory instead, then create directory > there. > > Also the ftrace filesystem seems to be mounted on > /sys/kernel/debug/tracing/ on recent distributions, why don't we just > set TRACING_PATH accodingly if it's already mounted and fallback to > mounting it only when debugfs couldn't be found in /proc/mounts? > > > +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 > > + } > > +} > > Why don't we just do sleep $test_interval instead? > > > +trap clean_up_exit INT > > + > > +tst_require_root > > + > > +# Don't run the test on kernels older than 2.6.34, otherwise > > +# it can crash the system if the kernel is not latest-stable > > +tst_kvercmp 2 6 34 > > +if [ $? -eq 0 ]; then > > + tst_brkm TCONF ignored "The test should be run in kernels >= 2.6.34. Skip the test..." > > + exit 0 > > +fi > > Don't do this. Really the whole point of LTP is to validate kernel, if > we skip known bugs by default we would give users false impression that > the kernel was thoroughly tested. > > Also since you include the test.sh here the tst_brkm format is different > and it exits the test, so the exit 0 is never reached. > > > +mkdir $DEBUGFS_PATH > > +mount -t debugfs xxx $DEBUGFS_PATH > > + > > +# Check to see tracing feature is supported or not > > +if [ ! -d $TRACING_PATH ]; then > > + tst_brkm TCONF ignored "Tracing is not supported. Skip the test..." > > + umount $DEBUGFS_PATH > > + rmdir $DEBUGFS_PATH > > + exit 0 > > +fi > > Here as well, the tst_brkm from test.sh exit the test. Ideally you > should setup TST_CLEANUP to point to a cleanup function once you do the > test initalization which would be then executed before the test exits > automatically. > > ... > > > > 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 > > I remember telling you to call wait on each pid instead of the sleep 2 > here. > > > + clean_up > > +} > > + > > + > > +# ---------------------------- > > +echo "Ftrace Stress Test Begin" > > That should be tst_resm TINFO "..." but that is very minor. > > > +save_old_setting > > + > > +test_begin > > + > > +test_stress > > + > > +test_wait > > + > > +test_kill > > Hmm, shouldn't you restore old settings here? > > > +echo "Ftrace Stress Test End" > > Here as well. > > > +if $test_success; then > > + tst_resm TPASS "finished running the test. Run dmesg to double-check for bugs" > > +else > > + tst_resm TFAIL "please check log message." > > + exit 1 > > +fi > > You should call tst_exit at the end of the test instead of doing exit 1 > after the tst_resm. This is another leftover caused by the > broken-by-desing tst_resm and tst_brkm binaries. > > -- > Cyril Hrubis > chrubis@suse.cz ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests 2016-05-04 16:26 ` [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests Cyril Hrubis 2016-05-05 6:21 ` Li Wang @ 2016-05-05 10:11 ` Chunyu Hu 2016-05-05 10:53 ` Chunyu Hu 1 sibling, 1 reply; 32+ messages in thread From: Chunyu Hu @ 2016-05-05 10:11 UTC (permalink / raw) To: ltp Thanks. Some issue has been done in patch 2/9, will fix other issues you mentioned in next step. ----- Original Message ----- > From: "Cyril Hrubis" <chrubis@suse.cz> > To: "Chunyu Hu" <chuhu@redhat.com> > Cc: ltp@lists.linux.it, liwan@redhat.com > Sent: Thursday, May 5, 2016 12:26:56 AM > Subject: Re: [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests > > Hi! > > 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 > ^ > The space should be removed will fix this in patch 2/9 "skip unsupported tests and early cleanup". > > +########################################################################### > > +## > > ## > > +## 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" > > The test must not create files and mount things outside of the test > temporary directory. Expecially not in $LTPROOT. You should call > tst_tmpdir to create temporary directory instead, then create directory > there. Thanks for the suggestion, will take this way in next version, also add it into patch 2/9. > Also the ftrace filesystem seems to be mounted on > /sys/kernel/debug/tracing/ on recent distributions, why don't we just > set TRACING_PATH accodingly if it's already mounted and fallback to > mounting it only when debugfs couldn't be found in /proc/mounts? Thanks. Will take this way in next version, we check whether the mounting is needed, through /proc/mounts , and then only mount/umount if it's not mounted by default. > > +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 > > + } > > +} > > Why don't we just do sleep $test_interval instead? Good idea, will leave only a tst_sleep in the func in next step. > > +trap clean_up_exit INT > > + > > +tst_require_root > > + > > +# Don't run the test on kernels older than 2.6.34, otherwise > > +# it can crash the system if the kernel is not latest-stable > > +tst_kvercmp 2 6 34 > > +if [ $? -eq 0 ]; then > > + tst_brkm TCONF ignored "The test should be run in kernels >= 2.6.34. Skip > > the test..." > > + exit 0 > > +fi > > Don't do this. Really the whole point of LTP is to validate kernel, if > we skip known bugs by default we would give users false impression that > the kernel was thoroughly tested. OK, will remove the ignore, and remove this skip step, I agree that this skip is not needed. If user found panic, should fix the issue asap. and skip steps should be done in local repo if needed. > Also since you include the test.sh here the tst_brkm format is different > and it exits the test, so the exit 0 is never reached. OK. Will remove this. > > +mkdir $DEBUGFS_PATH > > +mount -t debugfs xxx $DEBUGFS_PATH > > + > > +# Check to see tracing feature is supported or not > > +if [ ! -d $TRACING_PATH ]; then > > + tst_brkm TCONF ignored "Tracing is not supported. Skip the test..." > > + umount $DEBUGFS_PATH > > + rmdir $DEBUGFS_PATH > > + exit 0 > > +fi > > Here as well, the tst_brkm from test.sh exit the test. Ideally you > should setup TST_CLEANUP to point to a cleanup function once you do the > test initalization which would be then executed before the test exits > automatically. OK. I think we can add a function for test initiating. including check/mount debugfs, exporting the env like TRACING_PATH, and setting up the cleanup callback TST_CLEANUP=cleanup > ... > > > > 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 > > I remember telling you to call wait on each pid instead of the sleep 2 > here. The sleep 2 wil be removed in next step into patch 2/9. > > + clean_up > > +} > > + > > + > > +# ---------------------------- > > +echo "Ftrace Stress Test Begin" > > That should be tst_resm TINFO "..." but that is very minor. This has been fixed in patch 2/9 > > +save_old_setting > > + > > +test_begin > > + > > +test_stress > > + > > +test_wait > > + > > +test_kill > > Hmm, shouldn't you restore old settings here? > > > +echo "Ftrace Stress Test End" > > Here as well. Fixed in patch 2/9. > > +if $test_success; then > > + tst_resm TPASS "finished running the test. Run dmesg to double-check for > > bugs" > > +else > > + tst_resm TFAIL "please check log message." > > + exit 1 > > +fi > > You should call tst_exit at the end of the test instead of doing exit 1 > after the tst_resm. This is another leftover caused by the > broken-by-desing tst_resm and tst_brkm binaries. This has been done in 2/9. thank you for the detailed info. > -- > Cyril Hrubis > chrubis@suse.cz > -- Regards, Chunyu Hu ^ permalink raw reply [flat|nested] 32+ messages in thread
* [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests 2016-05-05 10:11 ` Chunyu Hu @ 2016-05-05 10:53 ` Chunyu Hu 0 siblings, 0 replies; 32+ messages in thread From: Chunyu Hu @ 2016-05-05 10:53 UTC (permalink / raw) To: ltp ----- Original Message ----- > From: "Chunyu Hu" <chuhu@redhat.com> > To: "Cyril Hrubis" <chrubis@suse.cz> > Cc: ltp@lists.linux.it > Sent: Thursday, May 5, 2016 6:11:04 PM > Subject: Re: [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests > > > Thanks. Some issue has been done in patch 2/9, will fix > other issues you mentioned in next step. Sorry, for a typo. 2/9 should be 4/9, all the 2/9 is meaning 4/9 here. ^ permalink raw reply [flat|nested] 32+ messages in thread
end of thread, other threads:[~2016-05-11 11:14 UTC | newest] Thread overview: 32+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-04-18 8:04 [LTP] [PATCH V2 0/9] tracing: make ftrace tests to be extended Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 2/9] tracing/ftrace: add new case for ftrace userstacktrace Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 3/9] tracing/ftrace: add a new case for signal_generate Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 5/9] ftrace_stress: keep the name of testscipt in sync with tracing file Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 7/9] ftrace_stress: update the trace_options test Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 8/9] ftrace_stress: add two new tests Chunyu Hu 2016-04-18 8:04 ` [LTP] [PATCH V2 9/9] ftrace_stress: cleanup and use ltp API Chunyu Hu 2016-05-04 14:56 ` Cyril Hrubis 2016-05-04 15:42 ` Chunyu Hu 2016-05-04 16:32 ` Cyril Hrubis 2016-05-05 7:44 ` Chunyu Hu 2016-05-10 14:13 ` Cyril Hrubis 2016-05-11 11:01 ` Chunyu Hu 2016-05-04 16:57 ` [LTP] [PATCH V2 7/9] ftrace_stress: update the trace_options test Cyril Hrubis 2016-05-04 13:34 ` [LTP] [PATCH V2 6/9] testcases/lib: Add tst_random decmical integer generator Cyril Hrubis 2016-05-04 15:04 ` Chunyu Hu 2016-05-04 15:55 ` Cyril Hrubis 2016-05-04 16:28 ` Chunyu Hu 2016-05-04 23:40 ` Chunyu Hu 2016-05-04 16:50 ` [LTP] [PATCH V2 4/9] ftrace_stress: skip unsupported tests Cyril Hrubis 2016-05-05 0:53 ` Chunyu Hu 2016-05-10 14:25 ` Cyril Hrubis 2016-05-11 11:14 ` Chunyu Hu 2016-05-04 16:00 ` [LTP] [PATCH V2 2/9] tracing/ftrace: add new case for ftrace userstacktrace Cyril Hrubis 2016-05-05 6:24 ` Li Wang 2016-05-04 16:26 ` [LTP] [PATCH V2 1/9] tracing: reorganize ftrace-stress tests to general tests Cyril Hrubis 2016-05-05 6:21 ` Li Wang 2016-05-05 10:11 ` Chunyu Hu 2016-05-05 10:53 ` Chunyu Hu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox