• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2
3################################################################################
4#                                                                              #
5# Copyright (c) 2009 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 2 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, but          #
13# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY   #
14# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License     #
15# for more details.                                                            #
16#                                                                              #
17# You should have received a copy of the GNU General Public License            #
18# along with this program;  if not, write to the Free Software                 #
19# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA      #
20#                                                                              #
21# Author: Miao Xie <miaox@cn.fujitsu.com>                                      #
22#                                                                              #
23################################################################################
24
25export TCID="cpuset_sched_domains"
26export TST_TOTAL=19
27export TST_COUNT=1
28
29. cpuset_funcs.sh
30
31check 4 2
32
33exit_status=0
34
35nr_cpus=$NR_CPUS
36nr_mems=$N_NODES
37
38cpus_all="$(seq -s, 0 $((nr_cpus-1)))"
39mems_all="$(seq -s, 0 $((nr_mems-1)))"
40
41# root_load_balance_test <load_balance> <cpuoffline>
42root_load_balance_test()
43{
44	local load_balance=$1
45	local cpuoffline=$2
46
47	local ret=
48
49	# print the test case information
50	cpuset_log "root group load balance test"
51	cpuset_log "     sched load balance:" $load_balance
52	cpuset_log "CPU hotplug:" $cpuoffline
53
54	# setup test environment
55	setup_test_environment $cpuoffline 2> $CPUSET_TMP/stderr
56	if [ $? -ne 0 ]; then
57		cpuset_log_error $CPUSET_TMP/stderr
58		tst_resm TFAIL "setup test environment(offline CPU#$HOTPLUG_CPU) failed"
59		return 1
60	fi
61
62	cpuset_set "$CPUSET" "-" "$mems_all" "$load_balance" 2>$CPUSET_TMP/stderr
63	if [ $? -ne 0 ]; then
64		cpuset_log_error $CPUSET_TMP/stderr
65		tst_resm TFAIL "set root group parameter failed."
66		return 1
67	fi
68
69	cpu_hotplug $HOTPLUG_CPU $cpuoffline 2> $CPUSET_TMP/stderr
70	if [ $? -ne 0 ]; then
71		cpuset_log_error $CPUSET_TMP/stderr
72		tst_resm TFAIL "$cpuoffline CPU#$HOTPLUG_CPU failed."
73		return 1
74	fi
75
76	# check sched domains of every CPU
77	sleep 1
78	cpuset_sched_domains_check 2> $CPUSET_TMP/stderr
79	ret=$?
80	if [ $ret -ne 0 ]; then
81		cpuset_log_error $CPUSET_TMP/stderr
82		tst_resm TFAIL "partition sched domains failed."
83		return $ret
84	fi
85	tst_resm TPASS "partition sched domains succeeded."
86}
87
88# general_load_balance_test1 <g_cpus> <g_balance> <r_balance>
89general_load_balance_test1()
90{
91	local g_cpus="$1"
92	local g_balance="$2"
93	local r_balance="$3"
94	local g_path="$CPUSET/1"
95
96	local ret=
97
98	cpuset_log "general group load balance test"
99	cpuset_log "root group info:"
100	cpuset_log "     sched load balance:" $r_balance
101	cpuset_log "general group info:"
102	cpuset_log "     cpus:" $g_cpus
103	cpuset_log "     sched load balance:" $g_balance
104
105	cpuset_set "$CPUSET" "-" "$mems_all" "$r_balance" 2> $CPUSET_TMP/stderr
106	if [ $? -ne 0 ]; then
107		cpuset_log_error $CPUSET_TMP/stderr
108		tst_resm TFAIL "set root group parameter failed."
109		return 1
110	fi
111
112	cpuset_set "$g_path" "$g_cpus" "$mems_all" "$g_balance" 2> $CPUSET_TMP/stderr
113	if [ $? -ne 0 ]; then
114		cpuset_log_error $CPUSET_TMP/stderr
115		tst_resm TFAIL "set general group parameter failed."
116		return 1
117	fi
118
119	# check sched domains of every CPU
120	sleep 1
121	cpuset_sched_domains_check 2> $CPUSET_TMP/stderr
122	if [ $? -ne 0 ]; then
123		cpuset_log_error $CPUSET_TMP/stderr
124		tst_resm TFAIL "partition sched domains failed."
125		return 1
126	fi
127	tst_resm TPASS "partition sched domains succeeded."
128}
129
130# general_load_balance_test2 <g1_cpus> <g1_balance>
131#			     <g2_cpus> <g2_balance>
132#			     <cpuoffline>
133general_load_balance_test2()
134{
135	local g1_cpus=$1
136	local g1_balance=$2
137	local g1_path="$CPUSET/1"
138
139	local g2_cpus=$3
140	local g2_balance=$4
141	local g2_path="$CPUSET/2"
142
143	local cpuoffline=$5
144
145	local ret=
146
147	cpuset_log "general group load balance test"
148	cpuset_log "root group info:"
149	cpuset_log "     sched load balance:" 0
150	cpuset_log "general group1 info:"
151	cpuset_log "     cpus:" $g1_cpus
152	cpuset_log "     sched load balance:" $g1_balance
153	cpuset_log "general group2 info:"
154	cpuset_log "     cpus:" $g2_cpus
155	cpuset_log "     sched load balance:" $g2_balance
156	cpuset_log "CPU hotplug:" $cpuoffline
157
158	cpuset_set "$CPUSET" "-" "$mems_all" "0" 2> $CPUSET_TMP/stderr
159	if [ $? -ne 0 ]; then
160		cpuset_log_error $CPUSET_TMP/stderr
161		tst_resm TFAIL "set root group parameter failed."
162		return 1
163	fi
164
165	cpuset_set "$g1_path" "$g1_cpus" "$mems_all" "$g1_balance" 2> $CPUSET_TMP/stderr
166	if [ $? -ne 0 ]; then
167		cpuset_log_error $CPUSET_TMP/stderr
168		tst_resm TFAIL "set general group1 parameter failed."
169		return 1
170	fi
171
172	cpuset_set "$g2_path" "$g2_cpus" "$mems_all" "$g2_balance" 2> $CPUSET_TMP/stderr
173	if [ $? -ne 0 ]; then
174		cpuset_log_error $CPUSET_TMP/stderr
175		tst_resm TFAIL "set general group2 parameter failed."
176		return 1
177	fi
178
179	# setup test environment
180	setup_test_environment $cpuoffline 2> $CPUSET_TMP/stderr
181	if [ $? -ne 0 ]; then
182		cpuset_log_error $CPUSET_TMP/stderr
183		tst_resm TFAIL "setup test environment(offline CPU#$HOTPLUG_CPU) failed"
184		return 1
185	fi
186
187	sleep 1
188	cpu_hotplug $HOTPLUG_CPU $cpuoffline 2> $CPUSET_TMP/stderr
189	if [ $? -ne 0 ]; then
190		cpuset_log_error $CPUSET_TMP/stderr
191		tst_resm TFAIL "$cpuoffline CPU#$HOTPLUG_CPU failed."
192		return 1
193	fi
194
195	# check sched domains of every CPU
196	sleep 1
197	cpuset_sched_domains_check > $CPUSET_TMP/stdout
198	if [ $? -ne 0 ]; then
199		cpuset_log_error $CPUSET_TMP/stdout
200		tst_resm TFAIL "partition sched domains failed."
201		return 1
202	fi
203	tst_resm TPASS "partition sched domains succeeded."
204}
205
206base_test()
207{
208	setup
209	if [ $? -ne 0 ]; then
210		exit_status=1
211	else
212		$test_pro "$@"
213		if [ $? -ne 0 ]; then
214			exit_status=1
215		fi
216
217		cleanup
218		if [ $? -ne 0 ]; then
219			exit_status=1
220		fi
221
222		cpu_hotplug_cleanup
223	fi
224	TST_COUNT=$(($TST_COUNT + 1))
225}
226
227# Casee 1-6
228test_root_load_balance()
229{
230	test_pro="root_load_balance_test"
231
232	local isbalance=
233	local hotplug=
234
235	while read isbalance level hotplug
236	do
237		base_test $isbalance $hotplug
238	done <<- EOF
239		0	none
240		1	none
241		0	offline
242		0	online
243		1	offline
244		1	online
245	EOF
246	# while read isbalance level hotplug
247}
248
249# Case 7-13
250test_general_load_balance1()
251{
252	test_pro="general_load_balance_test1"
253
254	local g_cpus=
255	local g_isbalance=
256	local r_isbalance=
257
258	while read g_cpus g_isbalance r_isbalance
259	do
260		base_test $g_cpus $g_isbalance $r_isbalance
261	done <<- EOF
262		-	1	0
263		1	0	0
264		-	1	1
265		1	1	1
266		1,2	0	0
267		1,2	1	0
268		$cpus_all	1	0
269	EOF
270	# while read g_cpus g_isbalance r_isbalance
271}
272
273# Case 14-19
274test_general_load_balance2()
275{
276	test_pro="general_load_balance_test2"
277
278	local g1_cpus=
279	local g1_isbalance=
280
281	local g2_cpus=
282	local g2_isbalance=
283
284	local hotplug=
285
286	while read g1_cpus g1_isbalance g2_cpus g2_isbalance hotplug
287	do
288		base_test $g1_cpus $g1_isbalance $g2_cpus $g2_isbalance $hotplug
289	done <<- EOF
290	1	1	0	1	none
291	1,2	1	0-3	0	none
292	1,2	1	0,3	1	none
293	1,2	1	1,3	1	none
294	1,2	1	1,3	1	offline
295	1,2	1	1,3	1	online
296	EOF
297	# while read g1_cpus g1_isbalance g2_cpus g2_isbalance hotplug
298}
299
300test_root_load_balance
301test_general_load_balance1
302test_general_load_balance2
303
304exit $exit_status
305