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