123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469 |
- #!/bin/sh
- ################################################################################
- # #
- # Copyright (c) 2009 FUJITSU LIMITED #
- # #
- # This program is free software; you can redistribute it and#or modify #
- # it under the terms of the GNU General Public License as published by #
- # the Free Software Foundation; either version 2 of the License, or #
- # (at your option) any later version. #
- # #
- # This program is distributed in the hope that it will be useful, but #
- # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY #
- # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License #
- # for more details. #
- # #
- # You should have received a copy of the GNU General Public License #
- # along with this program; if not, write to the Free Software #
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #
- # #
- # Author: Miao Xie <miaox@cn.fujitsu.com> #
- # #
- ################################################################################
- export TCID="cpuset_hierarchy"
- export TST_TOTAL=32
- export TST_COUNT=1
- . cpuset_funcs.sh
- check
- nr_cpus=$NR_CPUS
- nr_mems=$N_NODES
- cpus_all="$(seq -s, 0 $((nr_cpus-1)))"
- mems_all="$(seq -s, 0 $((nr_mems-1)))"
- exit_status=0
- # test cpus
- test1()
- {
- echo > "$CPUSET/father/cpuset.cpus" || return 1
- echo > "$CPUSET/father/child/cpuset.cpus" || return 1
- cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")"
- cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")"
- test -z "$(cat "$CPUSET/father/cpuset.cpus")" || return 1
- test -z "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1
- }
- test2()
- {
- echo > "$CPUSET/father/cpuset.cpus" || return 1
- echo 0 > "$CPUSET/father/child/cpuset.cpus" 2> /dev/null && return 1
- cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")"
- cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")"
- test -z "$(cat "$CPUSET/father/cpuset.cpus")" || return 1
- test -z "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1
- }
- test3()
- {
- echo 0 > "$CPUSET/father/cpuset.cpus" || return 1
- echo > "$CPUSET/father/child/cpuset.cpus" || return 1
- cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")"
- cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")"
- test 0 = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1
- test -z "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1
- }
- test4()
- {
- echo 0 > "$CPUSET/father/cpuset.cpus" || return 1
- echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1
- cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")"
- cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")"
- test 0 = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1
- test 0 = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1
- }
- test5()
- {
- echo 0 > "$CPUSET/father/cpuset.cpus" || return 1
- echo 1 > "$CPUSET/father/child/cpuset.cpus" 2> /dev/null && return 1
- cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")"
- cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")"
- test 0 = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1
- test -z "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1
- }
- test6()
- {
- echo 0 > "$CPUSET/father/cpuset.cpus" || return 1
- echo 0,1 > "$CPUSET/father/child/cpuset.cpus" 2> /dev/null && return 1
- cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")"
- cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")"
- test 0 = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1
- test -z "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1
- }
- test7()
- {
- echo "0,1" > "$CPUSET/father/cpuset.cpus" || return 1
- echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1
- cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")"
- cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")"
- test "0-1" = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1
- test 0 = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1
- }
- test8()
- {
- echo "0,1" > "$CPUSET/father/cpuset.cpus" || return 1
- echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1
- cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")"
- cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")"
- test "0-1" = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1
- test 0 = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1
- }
- test9()
- {
- echo "$cpus_all" > "$CPUSET/father/cpuset.cpus" || return 1
- echo > "$CPUSET/father/child/cpuset.cpus" || return 1
- echo > "$CPUSET/father/cpuset.cpus" || return 1
- cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")"
- cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")"
- test -z "$(cat "$CPUSET/father/cpuset.cpus")" || return 1
- test -z "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1
- }
- test10()
- {
- echo "$cpus_all" > "$CPUSET/father/cpuset.cpus" || return 1
- echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1
- echo > "$CPUSET/father/cpuset.cpus" 2> /dev/null && return 1
- cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")"
- cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")"
- test "0-$((nr_cpus-1))" = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1
- test 0 = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1
- }
- test11()
- {
- echo "$cpus_all" > "$CPUSET/father/cpuset.cpus" || return 1
- echo > "$CPUSET/father/child/cpuset.cpus" || return 1
- echo 0 > "$CPUSET/father/cpuset.cpus" || return 1
- cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")"
- cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")"
- test 0 = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1
- test -z "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1
- }
- test12()
- {
- echo "$cpus_all" > "$CPUSET/father/cpuset.cpus" || return 1
- echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1
- echo 0 > "$CPUSET/father/cpuset.cpus" || return 1
- cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")"
- cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")"
- test 0 = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1
- test 0 = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1
- }
- test13()
- {
- echo "$cpus_all" > "$CPUSET/father/cpuset.cpus" || return 1
- echo 1 > "$CPUSET/father/child/cpuset.cpus" || return 1
- echo 0 > "$CPUSET/father/cpuset.cpus" 2> /dev/null && return 1
- cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")"
- cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")"
- test "0-$((nr_cpus-1))" = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1
- test 1 = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1
- }
- test14()
- {
- echo "$cpus_all" > "$CPUSET/father/cpuset.cpus" || return 1
- echo 0,1 > "$CPUSET/father/child/cpuset.cpus" || return 1
- echo 0 > "$CPUSET/father/cpuset.cpus" 2> /dev/null && return 1
- cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")"
- cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")"
- test "0-$((nr_cpus-1))" = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1
- test "0-1" = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1
- }
- test15()
- {
- echo "$cpus_all" > "$CPUSET/father/cpuset.cpus" || return 1
- echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1
- echo "0,1" > "$CPUSET/father/cpuset.cpus" || return 1
- cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")"
- cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")"
- test "0-1" = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1
- test 0 = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1
- }
- test16()
- {
- echo "$cpus_all" > "$CPUSET/father/cpuset.cpus" || return 1
- echo 0 > "$CPUSET/father/child/cpuset.cpus" || return 1
- echo "0,1" > "$CPUSET/father/cpuset.cpus" || return 1
- cpuset_log "father cpuset.cpus $(cat "$CPUSET/father/cpuset.cpus")"
- cpuset_log "child cpuset.cpus $(cat "$CPUSET/father/child/cpuset.cpus")"
- test "0-1" = "$(cat "$CPUSET/father/cpuset.cpus")" || return 1
- test 0 = "$(cat "$CPUSET/father/child/cpuset.cpus")" || return 1
- }
- ## test mems
- test17()
- {
- echo > "$CPUSET/father/cpuset.mems" || return 1
- echo > "$CPUSET/father/child/cpuset.mems" || return 1
- cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")"
- cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")"
- test -z "$(cat "$CPUSET/father/cpuset.mems")" || return 1
- test -z "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1
- }
- test18()
- {
- echo > "$CPUSET/father/cpuset.mems" || return 1
- echo 0 > "$CPUSET/father/child/cpuset.mems" 2> /dev/null && return 1
- cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")"
- cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")"
- test -z "$(cat "$CPUSET/father/cpuset.mems")" || return 1
- test -z "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1
- }
- test19()
- {
- echo 0 > "$CPUSET/father/cpuset.mems" || return 1
- echo > "$CPUSET/father/child/cpuset.mems" || return 1
- cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")"
- cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")"
- test 0 = "$(cat "$CPUSET/father/cpuset.mems")" || return 1
- test -z "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1
- }
- test20()
- {
- echo 0 > "$CPUSET/father/cpuset.mems" || return 1
- echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1
- cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")"
- cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")"
- test 0 = "$(cat "$CPUSET/father/cpuset.mems")" || return 1
- test 0 = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1
- }
- test21()
- {
- echo 0 > "$CPUSET/father/cpuset.mems" || return 1
- echo 1 > "$CPUSET/father/child/cpuset.mems" 2> /dev/null && return 1
- cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")"
- cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")"
- test 0 = "$(cat "$CPUSET/father/cpuset.mems")" || return 1
- test -z "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1
- }
- test22()
- {
- echo 0 > "$CPUSET/father/cpuset.mems" || return 1
- echo 0,1 > "$CPUSET/father/child/cpuset.mems" 2> /dev/null && return 1
- cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")"
- cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")"
- test 0 = "$(cat "$CPUSET/father/cpuset.mems")" || return 1
- test -z "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1
- }
- test23()
- {
- echo "0,1" > "$CPUSET/father/cpuset.mems" || return 1
- echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1
- cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")"
- cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")"
- test "0-1" = "$(cat "$CPUSET/father/cpuset.mems")" || return 1
- test 0 = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1
- }
- test24()
- {
- echo "0,1" > "$CPUSET/father/cpuset.mems" || return 1
- echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1
- cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")"
- cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")"
- test "0-1" = "$(cat "$CPUSET/father/cpuset.mems")" || return 1
- test 0 = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1
- }
- test25()
- {
- echo "$mems_all" > "$CPUSET/father/cpuset.mems" || return 1
- echo > "$CPUSET/father/child/cpuset.mems" || return 1
- echo > "$CPUSET/father/cpuset.mems" || return 1
- cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")"
- cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")"
- test -z "$(cat "$CPUSET/father/cpuset.mems")" || return 1
- test -z "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1
- }
- test26()
- {
- echo "$mems_all" > "$CPUSET/father/cpuset.mems" || return 1
- echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1
- echo > "$CPUSET/father/cpuset.mems" 2> /dev/null && return 1
- cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")"
- cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")"
- test "0-$((nr_mems-1))" = "$(cat "$CPUSET/father/cpuset.mems")" || return 1
- test 0 = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1
- }
- test27()
- {
- echo "$mems_all" > "$CPUSET/father/cpuset.mems" || return 1
- echo > "$CPUSET/father/child/cpuset.mems" || return 1
- echo 0 > "$CPUSET/father/cpuset.mems" || return 1
- cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")"
- cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")"
- test 0 = "$(cat "$CPUSET/father/cpuset.mems")" || return 1
- test -z "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1
- }
- test28()
- {
- echo "$mems_all" > "$CPUSET/father/cpuset.mems" || return 1
- echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1
- echo 0 > "$CPUSET/father/cpuset.mems" || return 1
- cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")"
- cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")"
- test 0 = "$(cat "$CPUSET/father/cpuset.mems")" || return 1
- test 0 = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1
- }
- test29()
- {
- echo "$mems_all" > "$CPUSET/father/cpuset.mems" || return 1
- echo 1 > "$CPUSET/father/child/cpuset.mems" || return 1
- echo 0 > "$CPUSET/father/cpuset.mems" 2> /dev/null && return 1
- cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")"
- cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")"
- test "0-$((nr_mems-1))" = "$(cat "$CPUSET/father/cpuset.mems")" || return 1
- test 1 = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1
- }
- test30()
- {
- echo "$mems_all" > "$CPUSET/father/cpuset.mems" || return 1
- echo 0,1 > "$CPUSET/father/child/cpuset.mems" || return 1
- echo 0 > "$CPUSET/father/cpuset.mems" 2> /dev/null && return 1
- cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")"
- cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")"
- test "0-$((nr_mems-1))" = "$(cat "$CPUSET/father/cpuset.mems")" || return 1
- test "0-1" = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1
- }
- test31()
- {
- echo "$mems_all" > "$CPUSET/father/cpuset.mems" || return 1
- echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1
- echo "0,1" > "$CPUSET/father/cpuset.mems" || return 1
- cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")"
- cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")"
- test "0-1" = "$(cat "$CPUSET/father/cpuset.mems")" || return 1
- test 0 = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1
- }
- test32()
- {
- echo "$mems_all" > "$CPUSET/father/cpuset.mems" || return 1
- echo 0 > "$CPUSET/father/child/cpuset.mems" || return 1
- echo "0,1" > "$CPUSET/father/cpuset.mems" || return 1
- cpuset_log "father cpuset.mems $(cat "$CPUSET/father/cpuset.mems")"
- cpuset_log "child cpuset.mems $(cat "$CPUSET/father/child/cpuset.mems")"
- test "0-1" = "$(cat "$CPUSET/father/cpuset.mems")" || return 1
- test 0 = "$(cat "$CPUSET/father/child/cpuset.mems")" || return 1
- }
- for i in $(seq 1 $TST_TOTAL)
- do
- setup
- if [ $? -ne 0 ]; then
- exit_status=1
- else
- mkdir "$CPUSET/father"
- mkdir "$CPUSET/father/child"
- test$i
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Break the hierarchy limit."
- exit_status=1
- else
- tst_resm TPASS "Hierarchy test succeeded."
- fi
- cleanup
- if [ $? -ne 0 ]; then
- exit_status=1
- fi
- fi
- TST_COUNT=$(($TST_COUNT + 1))
- done
- exit $exit_status
|