diff options
author | Balbir Singh <balbir@linux.vnet.ibm.com> | 2008-12-17 15:13:58 +0000 |
---|---|---|
committer | Balbir Singh <balbir@linux.vnet.ibm.com> | 2008-12-17 15:13:58 +0000 |
commit | aed9030697e99f35b0c352f74bb0b7b8014d8ccb (patch) | |
tree | 759a2665636fa850919ba23483f2194b4f52fa62 /tests/runlibcgrouptest.sh | |
parent | 484250af210a51f906503c876b9f92e2b2a31f35 (diff) | |
download | libcg-aed9030697e99f35b0c352f74bb0b7b8014d8ccb.tar.gz libcg-aed9030697e99f35b0c352f74bb0b7b8014d8ccb.tar.xz libcg-aed9030697e99f35b0c352f74bb0b7b8014d8ccb.zip |
libcgroup Test: make-controller-use-generic-in-binary
This patch makes the use of controllers available from script more generic.
All possible controllers in Linux kernel are to be kept as enum parameters
and a corresponding mapping is done in both, the script and binary. The
testcases are no more hardcoded with respect to controllers. The function
set_controller() need to be updated with respect to the controllers and
control file.
The challenges yet to be solved are:
(1)Choosing appropriate control file
(2)Choosing appropriate control value dynamicaly.
Thoughts are most welcome.
Signed-off-by: Sudhir Kumar <skumar@linux.vnet.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@259 4f4bb910-9a46-0410-90c8-c897d4f1cd53
Diffstat (limited to 'tests/runlibcgrouptest.sh')
-rw-r--r-- | tests/runlibcgrouptest.sh | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/tests/runlibcgrouptest.sh b/tests/runlibcgrouptest.sh index c661153..843b44b 100644 --- a/tests/runlibcgrouptest.sh +++ b/tests/runlibcgrouptest.sh @@ -29,6 +29,7 @@ CPU=""; MEMORY=""; declare -a allcontrollers; +declare -a targets; debug() { @@ -161,10 +162,10 @@ no_controllers() # no point in running the testcases. At least one of them should be # supported.(or should I run testcases with controllers such as # ns, devices etc? Thoughts???) - if [ $NUM_CTLRS -lt 1 ] + if [ $NUM_CTLRS -lt 2 ] then - echo "Kernel has no controllers enabled"; - echo "Recompile your kernel with at least one controller" + echo "Kernel needs to have 2 controllers enabled"; + echo "Recompile your kernel with at least 2 controllers" echo "Exiting the tests....."; exit 1; fi; @@ -238,6 +239,7 @@ mount_fs () umount_fs; exit -1; fi; + target[$CUR_MOUNT]=$NEWTARGET; CUR_MOUNT=`expr $CUR_MOUNT + 1`; FS_MOUNTED=`expr $FS_MOUNTED + 1`; @@ -260,21 +262,42 @@ mount_fs () } -get_mountpoint() +get_ctl_num() { - # need to handle how to pass multiple mount points to C file - # It will depend on the requirements if any - MOUNTPOINT=`cat /proc/mounts|grep -w cgroup|tr -s [:space:]| \ - cut -d" " -f2`; - debug "mountpoint is $MOUNTPOINT" + ctl1=$1; + ctl2=$2; + if [ -z $ctl1 ] || [ -z $ctl2 ]; then + echo "Null controller passed to function get_ctl_num" + echo "Exiting the testcases....." + fi + + # Add any new controller developed here + declare -a ctl_list; + # Following list has to be in sync with enums in header + ctl_list[0]="memory"; + ctl_list[1]="cpu"; + ctl_list[2]="cpuset"; + + local i=0; + while [ ! -z ${ctl_list[$i]} ]; do + if [ "${ctl_list[$i]}" == "$ctl1" ]; then + ctl1=$i; + fi; + + if [ "${ctl_list[$i]}" == "$ctl2" ]; then + ctl2=$i; + fi; + i=`expr $i + 1`; + done; } + runtest() { MOUNT_INFO=$1; TEST_EXEC=$2; if [ -f $TEST_EXEC ] then - ./$TEST_EXEC $MOUNT_INFO $MOUNTPOINT; + ./$TEST_EXEC $MOUNT_INFO $ctl1 $ctl2 ${target[1]} ${target[2]}; if [ $? -ne 0 ] then echo Error in running ./$TEST_EXEC @@ -341,7 +364,7 @@ runtest() mount_fs $NUM_MOUNT; fi; debug "FS_MOUNTED = $FS_MOUNTED" - get_mountpoint; + get_ctl_num $CTLR1 $CTLR2; runtest $FS_MOUNTED $FILE wait $PID; @@ -371,7 +394,7 @@ runtest() mount_fs $NUM_MOUNT; fi; debug "FS_MOUNTED = $FS_MOUNTED" - get_mountpoint; + get_ctl_num $CTLR1 $CTLR2; runtest $FS_MOUNTED $FILE wait $PID; |