cpuset_exclusive_test.sh 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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_exclusive"
  24. export TST_TOTAL=18
  25. export TST_COUNT=1
  26. . cpuset_funcs.sh
  27. check
  28. exit_status=0
  29. # Case 1-9 test cpus
  30. test1()
  31. {
  32. echo 0 > "$CPUSET/father/cpuset.cpu_exclusive" || return 1
  33. echo 0 > "$CPUSET/father/child/cpuset.cpu_exclusive" || return 1
  34. test 0 = $(cat "$CPUSET/father/child/cpuset.cpu_exclusive") || return 1
  35. }
  36. test2()
  37. {
  38. echo 1 > "$CPUSET/father/cpuset.cpu_exclusive" || return 1
  39. echo 0 > "$CPUSET/father/child/cpuset.cpu_exclusive" || return 1
  40. test 0 = $(cat "$CPUSET/father/child/cpuset.cpu_exclusive") || return 1
  41. }
  42. test3()
  43. {
  44. echo 1 > "$CPUSET/father/cpuset.cpu_exclusive" || return 1
  45. echo 1 > "$CPUSET/father/child/cpuset.cpu_exclusive" || return 1
  46. test 1 = $(cat "$CPUSET/father/child/cpuset.cpu_exclusive") || return 1
  47. }
  48. test4()
  49. {
  50. echo 0 > "$CPUSET/father/cpuset.cpu_exclusive" || return 1
  51. echo 1 > "$CPUSET/father/child/cpuset.cpu_exclusive" 2> /dev/null && return 1
  52. test 0 = $(cat "$CPUSET/father/child/cpuset.cpu_exclusive") || return 1
  53. }
  54. test5()
  55. {
  56. echo 1 > "$CPUSET/father/cpuset.cpu_exclusive" || return 1
  57. echo 1 > "$CPUSET/father/child/cpuset.cpu_exclusive" || return 1
  58. echo 0 > "$CPUSET/father/cpuset.cpu_exclusive" 2> /dev/null && return 1
  59. test 1 = $(cat "$CPUSET/father/cpuset.cpu_exclusive") || return 1
  60. }
  61. test6()
  62. {
  63. echo 1 > "$CPUSET/father/cpuset.cpu_exclusive" || return 1
  64. echo 1 > "$CPUSET/father/child/cpuset.cpu_exclusive" || return 1
  65. echo "0-1" > "$CPUSET/father/cpuset.cpus" || return 1
  66. echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1
  67. mkdir "$CPUSET/father/other" || return 1
  68. echo 1 > "$CPUSET/father/other/cpuset.cpus" || return 1
  69. test 0 = $(cat "$CPUSET/father/child/cpuset.cpus") || return 1
  70. test 1 = $(cat "$CPUSET/father/other/cpuset.cpus") || return 1
  71. }
  72. test7()
  73. {
  74. echo 1 > "$CPUSET/father/cpuset.cpu_exclusive" || return 1
  75. echo 1 > "$CPUSET/father/child/cpuset.cpu_exclusive" || return 1
  76. echo "0-1" > "$CPUSET/father/cpuset.cpus" || return 1
  77. echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1
  78. mkdir "$CPUSET/father/other" || return 1
  79. echo "0-1" > "$CPUSET/father/other/cpuset.cpus" 2> /dev/null && return 1
  80. test 0 = $(cat "$CPUSET/father/child/cpuset.cpus") || return 1
  81. test -z $(cat "$CPUSET/father/other/cpuset.cpus") || return 1
  82. }
  83. test8()
  84. {
  85. echo 1 > "$CPUSET/father/cpuset.cpu_exclusive" || return 1
  86. echo "0-1" > "$CPUSET/father/cpuset.cpus" || return 1
  87. echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1
  88. mkdir "$CPUSET/father/other" || return 1
  89. echo 1 > "$CPUSET/father/other/cpuset.cpus" || return 1
  90. echo 1 > "$CPUSET/father/child/cpuset.cpu_exclusive" || return 1
  91. test 1 = $(cat "$CPUSET/father/child/cpuset.cpu_exclusive") || return 1
  92. }
  93. test9()
  94. {
  95. echo 1 > "$CPUSET/father/cpuset.cpu_exclusive" || return 1
  96. echo "0-1" > "$CPUSET/father/cpuset.cpus" || return 1
  97. echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1
  98. mkdir "$CPUSET/father/other" || return 1
  99. echo "0-1" > "$CPUSET/father/other/cpuset.cpus" || return 1
  100. echo 1 > "$CPUSET/father/child/cpuset.cpu_exclusive" 2> /dev/null && return 1
  101. test 0 = $(cat "$CPUSET/father/child/cpuset.cpu_exclusive") || return 1
  102. }
  103. # The following cases test mems
  104. test10()
  105. {
  106. echo 0 > "$CPUSET/father/cpuset.mem_exclusive" || return 1
  107. echo 0 > "$CPUSET/father/child/cpuset.mem_exclusive" || return 1
  108. test 0 = $(cat "$CPUSET/father/child/cpuset.mem_exclusive") || return 1
  109. }
  110. test11()
  111. {
  112. echo 1 > "$CPUSET/father/cpuset.mem_exclusive" || return 1
  113. echo 0 > "$CPUSET/father/child/cpuset.mem_exclusive" || return 1
  114. test 0 = $(cat "$CPUSET/father/child/cpuset.mem_exclusive") || return 1
  115. }
  116. test12()
  117. {
  118. echo 1 > "$CPUSET/father/cpuset.mem_exclusive" || return 1
  119. echo 1 > "$CPUSET/father/child/cpuset.mem_exclusive" || return 1
  120. test 1 = $(cat "$CPUSET/father/child/cpuset.mem_exclusive") || return 1
  121. }
  122. test13()
  123. {
  124. echo 0 > "$CPUSET/father/cpuset.mem_exclusive" || return 1
  125. echo 1 > "$CPUSET/father/child/cpuset.mem_exclusive" 2> /dev/null && return 1
  126. test 0 = $(cat "$CPUSET/father/child/cpuset.mem_exclusive") || return 1
  127. }
  128. test14()
  129. {
  130. echo 1 > "$CPUSET/father/cpuset.mem_exclusive" || return 1
  131. echo 1 > "$CPUSET/father/child/cpuset.mem_exclusive" || return 1
  132. echo 0 > "$CPUSET/father/cpuset.mem_exclusive" 2> /dev/null && return 1
  133. test 1 = $(cat "$CPUSET/father/cpuset.mem_exclusive") || return 1
  134. }
  135. test15()
  136. {
  137. echo 1 > "$CPUSET/father/cpuset.mem_exclusive" || return 1
  138. echo 1 > "$CPUSET/father/child/cpuset.mem_exclusive" || return 1
  139. echo "0-1" > "$CPUSET/father/cpuset.mems" || return 1
  140. echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1
  141. mkdir "$CPUSET/father/other" || return 1
  142. echo 1 > "$CPUSET/father/other/cpuset.mems" || return 1
  143. test 0 = $(cat "$CPUSET/father/child/cpuset.mems") || return 1
  144. test 1 = $(cat "$CPUSET/father/other/cpuset.mems") || return 1
  145. }
  146. test16()
  147. {
  148. echo 1 > "$CPUSET/father/cpuset.mem_exclusive" || return 1
  149. echo 1 > "$CPUSET/father/child/cpuset.mem_exclusive" || return 1
  150. echo "0-1" > "$CPUSET/father/cpuset.mems" || return 1
  151. echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1
  152. mkdir "$CPUSET/father/other" || return 1
  153. echo "0-1" > "$CPUSET/father/other/cpuset.mems" 2> /dev/null && return 1
  154. test 0 = $(cat "$CPUSET/father/child/cpuset.mems") || return 1
  155. test -z $(cat "$CPUSET/father/other/cpuset.mems") || return 1
  156. }
  157. test17()
  158. {
  159. echo 1 > "$CPUSET/father/cpuset.mem_exclusive" || return 1
  160. echo "0-1" > "$CPUSET/father/cpuset.mems" || return 1
  161. echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1
  162. mkdir "$CPUSET/father/other" || return 1
  163. echo 1 > "$CPUSET/father/other/cpuset.mems" || return 1
  164. echo 1 > "$CPUSET/father/child/cpuset.mem_exclusive" || return 1
  165. test 1 = $(cat "$CPUSET/father/child/cpuset.mem_exclusive") || return 1
  166. }
  167. test18()
  168. {
  169. echo 1 > "$CPUSET/father/cpuset.mem_exclusive" || return 1
  170. echo "0-1" > "$CPUSET/father/cpuset.mems" || return 1
  171. echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1
  172. mkdir "$CPUSET/father/other" || return 1
  173. echo "0-1" > "$CPUSET/father/other/cpuset.mems" || return 1
  174. echo 1 > "$CPUSET/father/child/cpuset.mem_exclusive" 2> /dev/null && return 1
  175. test 0 = $(cat "$CPUSET/father/child/cpuset.mem_exclusive") || return 1
  176. }
  177. for i in $(seq 1 $TST_TOTAL)
  178. do
  179. setup
  180. if [ $? -ne 0 ]; then
  181. exit_status=1
  182. else
  183. mkdir "$CPUSET/father"
  184. mkdir "$CPUSET/father/child"
  185. test$i
  186. if [ $? -ne 0 ]; then
  187. tst_resm TFAIL "Break the exclusive feature."
  188. exit_status=1
  189. else
  190. tst_resm TPASS "Exclusive test succeeded."
  191. fi
  192. cleanup
  193. if [ $? -ne 0 ]; then
  194. exit_status=1
  195. fi
  196. fi
  197. TST_COUNT=$(($TST_COUNT + 1))
  198. done
  199. exit $exit_status