cpuset_sched_domains_test.sh 7.7 KB

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