• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2
3###########################################################################
4##                                                                       ##
5## Copyright (c) 2010 FUJITSU LIMITED                                    ##
6##                                                                       ##
7## This program is free software: you can redistribute it and/or modify  ##
8## it under the terms of the GNU General Public License as published by  ##
9## the Free Software Foundation, either version 3 of the License, or     ##
10## (at your option) any later version.                                   ##
11##                                                                       ##
12## This program is distributed in the hope that it will be useful,       ##
13## but WITHOUT ANY WARRANTY; without even the implied warranty of        ##
14## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          ##
15## GNU General Public License for more details.                          ##
16##                                                                       ##
17## You should have received a copy of the GNU General Public License     ##
18## along with this program. If not, see <http://www.gnu.org/licenses/>.  ##
19##                                                                       ##
20## Author: Li Zefan <lizf@cn.fujitsu.com>                                ##
21##                                                                       ##
22###########################################################################
23
24export TCID="ftrace-stress-test"
25export TST_TOTAL=1
26export TST_COUNT=1
27
28. ftrace_lib.sh
29
30test_targets=" \
31trace_pipe current_tracer ftrace_enabled function_profile_enabled \
32set_event set_ftrace_pid stack_max_size stack_trace trace trace_clock \
33trace_options trace_stat tracing_enabled tracing_max_latency \
34tracing_on function_profile_enabled buffer_size_kb tracing_cpumask \
35set_ftrace_filter"
36
37get_skip_targets()
38{
39	NR_PIDS=0
40	for target in ${test_targets}; do
41		if [ ! -e $TRACING_PATH/$target ] &&
42			[ ! -e /proc/sys/kernel/$target ]; then
43			eval skip_$target=1
44			tst_resm TINFO "$target is not supported. Skip it."
45		else
46			eval skip_$target=0
47			NR_PIDS=$((NR_PIDS + 1))
48		fi
49	done
50	# Export it before sub case is lanuched.
51	export NR_PIDS
52}
53
54should_skip_target()
55{
56	local skip_var=skip_$1
57	eval local skip_val=\$${skip_var}
58	[ "$skip_val" = 1 ]
59}
60
61test_kill()
62{
63	tst_resm TINFO "killing ${pid0}"
64	kill -USR1 ${pid0}
65	wait ${pid0}
66
67	local p=1;
68	while [ $p -lt $NR_PIDS ]; do
69		local pid_var=pid${p}
70		eval local kill_pid=\$${pid_var}
71		tst_resm TINFO "killing ${kill_pid}"
72		kill -KILL $kill_pid
73		wait ${kill_pid}
74		p=$((p + 1))
75	done
76}
77
78test_stress()
79{
80	local index=0;
81
82	tst_resm TINFO "Test targets: ${test_targets}"
83
84	get_skip_targets
85	for target in ${test_targets}; do
86		if should_skip_target $target; then
87			continue
88		fi
89		sh ftrace_${target}.sh &
90		eval pid${index}=$!
91		tst_resm TINFO "Start pid${index}=$! $SPATH/ftrace_${target}.sh"
92		index=$((index + 1))
93	done
94	export_pids
95}
96
97export_pids()
98{
99	local p=0
100	while [ $p -lt $NR_PIDS ]; do
101		export pid${p}
102		p=$((p + 1))
103	done
104}
105
106cd ftrace_stress/
107# ----------------------------
108tst_resm TINFO "Ftrace Stress Test Begin"
109
110test_begin
111
112test_stress
113
114test_wait
115
116test_kill
117
118tst_resm TINFO "Finished running the test. Run dmesg to double-check for bugs"
119
120tst_exit
121
122