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_hierarchy" 26export TST_TOTAL=32 27export TST_COUNT=1 28 29. cpuset_funcs.sh 30 31check 32 33nr_cpus=$NR_CPUS 34nr_mems=$N_NODES 35 36cpus_all="$(seq -s, 0 $((nr_cpus-1)))" 37mems_all="$(seq -s, 0 $((nr_mems-1)))" 38 39exit_status=0 40 41# test cpus 42 43test1() 44{ 45 echo > "$CPUSET/father/cpuset.cpus" || return 1 46 echo > "$CPUSET/father/child/cpuset.cpus" || return 1 47 48 cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")" 49 cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")" 50 51 test -z "$(cat "$CPUSET/father/cpuset.cpus")" || return 1 52 test -z "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1 53} 54 55test2() 56{ 57 echo > "$CPUSET/father/cpuset.cpus" || return 1 58 echo 0 > "$CPUSET/father/child/cpuset.cpus" 2> /dev/null && return 1 59 60 cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")" 61 cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")" 62 63 test -z "$(cat "$CPUSET/father/cpuset.cpus")" || return 1 64 test -z "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1 65} 66 67test3() 68{ 69 echo 0 > "$CPUSET/father/cpuset.cpus" || return 1 70 echo > "$CPUSET/father/child/cpuset.cpus" || return 1 71 72 cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")" 73 cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")" 74 75 test 0 = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1 76 test -z "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1 77} 78 79test4() 80{ 81 echo 0 > "$CPUSET/father/cpuset.cpus" || return 1 82 echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1 83 84 cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")" 85 cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")" 86 87 test 0 = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1 88 test 0 = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1 89} 90 91test5() 92{ 93 echo 0 > "$CPUSET/father/cpuset.cpus" || return 1 94 echo 1 > "$CPUSET/father/child/cpuset.cpus" 2> /dev/null && return 1 95 96 cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")" 97 cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")" 98 99 test 0 = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1 100 test -z "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1 101} 102 103test6() 104{ 105 echo 0 > "$CPUSET/father/cpuset.cpus" || return 1 106 echo 0,1 > "$CPUSET/father/child/cpuset.cpus" 2> /dev/null && return 1 107 108 cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")" 109 cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")" 110 111 test 0 = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1 112 test -z "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1 113} 114 115test7() 116{ 117 echo "0,1" > "$CPUSET/father/cpuset.cpus" || return 1 118 echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1 119 120 cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")" 121 cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")" 122 123 test "0-1" = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1 124 test 0 = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1 125} 126 127test8() 128{ 129 echo "0,1" > "$CPUSET/father/cpuset.cpus" || return 1 130 echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1 131 132 cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")" 133 cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")" 134 135 test "0-1" = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1 136 test 0 = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1 137} 138 139test9() 140{ 141 echo "$cpus_all" > "$CPUSET/father/cpuset.cpus" || return 1 142 echo > "$CPUSET/father/child/cpuset.cpus" || return 1 143 echo > "$CPUSET/father/cpuset.cpus" || return 1 144 145 cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")" 146 cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")" 147 148 test -z "$(cat "$CPUSET/father/cpuset.cpus")" || return 1 149 test -z "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1 150} 151 152test10() 153{ 154 echo "$cpus_all" > "$CPUSET/father/cpuset.cpus" || return 1 155 echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1 156 echo > "$CPUSET/father/cpuset.cpus" 2> /dev/null && return 1 157 158 cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")" 159 cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")" 160 161 test "0-$((nr_cpus-1))" = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1 162 test 0 = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1 163} 164 165test11() 166{ 167 echo "$cpus_all" > "$CPUSET/father/cpuset.cpus" || return 1 168 echo > "$CPUSET/father/child/cpuset.cpus" || return 1 169 echo 0 > "$CPUSET/father/cpuset.cpus" || return 1 170 171 cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")" 172 cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")" 173 174 test 0 = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1 175 test -z "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1 176} 177 178test12() 179{ 180 echo "$cpus_all" > "$CPUSET/father/cpuset.cpus" || return 1 181 echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1 182 echo 0 > "$CPUSET/father/cpuset.cpus" || return 1 183 184 cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")" 185 cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")" 186 187 test 0 = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1 188 test 0 = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1 189} 190 191test13() 192{ 193 echo "$cpus_all" > "$CPUSET/father/cpuset.cpus" || return 1 194 echo 1 > "$CPUSET/father/child/cpuset.cpus" || return 1 195 echo 0 > "$CPUSET/father/cpuset.cpus" 2> /dev/null && return 1 196 197 cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")" 198 cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")" 199 200 test "0-$((nr_cpus-1))" = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1 201 test 1 = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1 202} 203 204test14() 205{ 206 echo "$cpus_all" > "$CPUSET/father/cpuset.cpus" || return 1 207 echo 0,1 > "$CPUSET/father/child/cpuset.cpus" || return 1 208 echo 0 > "$CPUSET/father/cpuset.cpus" 2> /dev/null && return 1 209 210 cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")" 211 cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")" 212 213 test "0-$((nr_cpus-1))" = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1 214 test "0-1" = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1 215} 216 217test15() 218{ 219 echo "$cpus_all" > "$CPUSET/father/cpuset.cpus" || return 1 220 echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1 221 echo "0,1" > "$CPUSET/father/cpuset.cpus" || return 1 222 223 cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")" 224 cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")" 225 226 test "0-1" = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1 227 test 0 = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1 228} 229 230test16() 231{ 232 echo "$cpus_all" > "$CPUSET/father/cpuset.cpus" || return 1 233 echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1 234 echo "0,1" > "$CPUSET/father/cpuset.cpus" || return 1 235 236 cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")" 237 cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")" 238 239 test "0-1" = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1 240 test 0 = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1 241} 242 243## test mems 244 245test17() 246{ 247 echo > "$CPUSET/father/cpuset.mems" || return 1 248 echo > "$CPUSET/father/child/cpuset.mems" || return 1 249 250 cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")" 251 cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")" 252 253 test -z "$(cat "$CPUSET/father/cpuset.mems")" || return 1 254 test -z "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1 255} 256 257test18() 258{ 259 echo > "$CPUSET/father/cpuset.mems" || return 1 260 echo 0 > "$CPUSET/father/child/cpuset.mems" 2> /dev/null && return 1 261 262 cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")" 263 cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")" 264 265 test -z "$(cat "$CPUSET/father/cpuset.mems")" || return 1 266 test -z "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1 267} 268 269test19() 270{ 271 echo 0 > "$CPUSET/father/cpuset.mems" || return 1 272 echo > "$CPUSET/father/child/cpuset.mems" || return 1 273 274 cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")" 275 cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")" 276 277 test 0 = "$(cat "$CPUSET/father/cpuset.mems")" || return 1 278 test -z "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1 279} 280 281test20() 282{ 283 echo 0 > "$CPUSET/father/cpuset.mems" || return 1 284 echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1 285 286 cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")" 287 cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")" 288 289 test 0 = "$(cat "$CPUSET/father/cpuset.mems")" || return 1 290 test 0 = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1 291} 292 293test21() 294{ 295 echo 0 > "$CPUSET/father/cpuset.mems" || return 1 296 echo 1 > "$CPUSET/father/child/cpuset.mems" 2> /dev/null && return 1 297 298 cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")" 299 cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")" 300 301 test 0 = "$(cat "$CPUSET/father/cpuset.mems")" || return 1 302 test -z "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1 303} 304 305test22() 306{ 307 echo 0 > "$CPUSET/father/cpuset.mems" || return 1 308 echo 0,1 > "$CPUSET/father/child/cpuset.mems" 2> /dev/null && return 1 309 310 cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")" 311 cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")" 312 313 test 0 = "$(cat "$CPUSET/father/cpuset.mems")" || return 1 314 test -z "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1 315} 316 317test23() 318{ 319 echo "0,1" > "$CPUSET/father/cpuset.mems" || return 1 320 echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1 321 322 cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")" 323 cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")" 324 325 test "0-1" = "$(cat "$CPUSET/father/cpuset.mems")" || return 1 326 test 0 = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1 327} 328 329test24() 330{ 331 echo "0,1" > "$CPUSET/father/cpuset.mems" || return 1 332 echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1 333 334 cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")" 335 cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")" 336 337 test "0-1" = "$(cat "$CPUSET/father/cpuset.mems")" || return 1 338 test 0 = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1 339} 340 341test25() 342{ 343 echo "$mems_all" > "$CPUSET/father/cpuset.mems" || return 1 344 echo > "$CPUSET/father/child/cpuset.mems" || return 1 345 echo > "$CPUSET/father/cpuset.mems" || return 1 346 347 cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")" 348 cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")" 349 350 test -z "$(cat "$CPUSET/father/cpuset.mems")" || return 1 351 test -z "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1 352} 353 354test26() 355{ 356 echo "$mems_all" > "$CPUSET/father/cpuset.mems" || return 1 357 echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1 358 echo > "$CPUSET/father/cpuset.mems" 2> /dev/null && return 1 359 360 cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")" 361 cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")" 362 363 test "0-$((nr_mems-1))" = "$(cat "$CPUSET/father/cpuset.mems")" || return 1 364 test 0 = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1 365} 366 367test27() 368{ 369 echo "$mems_all" > "$CPUSET/father/cpuset.mems" || return 1 370 echo > "$CPUSET/father/child/cpuset.mems" || return 1 371 echo 0 > "$CPUSET/father/cpuset.mems" || return 1 372 373 cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")" 374 cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")" 375 376 test 0 = "$(cat "$CPUSET/father/cpuset.mems")" || return 1 377 test -z "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1 378} 379 380test28() 381{ 382 echo "$mems_all" > "$CPUSET/father/cpuset.mems" || return 1 383 echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1 384 echo 0 > "$CPUSET/father/cpuset.mems" || return 1 385 386 cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")" 387 cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")" 388 389 test 0 = "$(cat "$CPUSET/father/cpuset.mems")" || return 1 390 test 0 = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1 391} 392 393test29() 394{ 395 echo "$mems_all" > "$CPUSET/father/cpuset.mems" || return 1 396 echo 1 > "$CPUSET/father/child/cpuset.mems" || return 1 397 echo 0 > "$CPUSET/father/cpuset.mems" 2> /dev/null && return 1 398 399 cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")" 400 cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")" 401 402 test "0-$((nr_mems-1))" = "$(cat "$CPUSET/father/cpuset.mems")" || return 1 403 test 1 = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1 404} 405 406test30() 407{ 408 echo "$mems_all" > "$CPUSET/father/cpuset.mems" || return 1 409 echo 0,1 > "$CPUSET/father/child/cpuset.mems" || return 1 410 echo 0 > "$CPUSET/father/cpuset.mems" 2> /dev/null && return 1 411 412 cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")" 413 cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")" 414 415 test "0-$((nr_mems-1))" = "$(cat "$CPUSET/father/cpuset.mems")" || return 1 416 test "0-1" = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1 417} 418 419test31() 420{ 421 echo "$mems_all" > "$CPUSET/father/cpuset.mems" || return 1 422 echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1 423 echo "0,1" > "$CPUSET/father/cpuset.mems" || return 1 424 425 cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")" 426 cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")" 427 428 test "0-1" = "$(cat "$CPUSET/father/cpuset.mems")" || return 1 429 test 0 = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1 430} 431 432test32() 433{ 434 echo "$mems_all" > "$CPUSET/father/cpuset.mems" || return 1 435 echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1 436 echo "0,1" > "$CPUSET/father/cpuset.mems" || return 1 437 438 cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")" 439 cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")" 440 441 test "0-1" = "$(cat "$CPUSET/father/cpuset.mems")" || return 1 442 test 0 = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1 443} 444 445for i in $(seq 1 $TST_TOTAL) 446do 447 setup 448 if [ $? -ne 0 ]; then 449 exit_status=1 450 else 451 mkdir "$CPUSET/father" 452 mkdir "$CPUSET/father/child" 453 test$i 454 if [ $? -ne 0 ]; then 455 tst_resm TFAIL "Break the hierarchy limit." 456 exit_status=1 457 else 458 tst_resm TPASS "Hierarchy test succeeded." 459 fi 460 461 cleanup 462 if [ $? -ne 0 ]; then 463 exit_status=1 464 fi 465 fi 466 TST_COUNT=$(($TST_COUNT + 1)) 467done 468 469exit $exit_status 470