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