From 0bd882131b163d56abbe23aa4a129b7b3b993bb7 Mon Sep 17 00:00:00 2001 From: Ivana Hutarova Varekova Date: Fri, 18 May 2012 17:49:06 +0200 Subject: [PATCH] testsuite: incorporate OPAQUE_HIERARCHY In present version of testsuite OPAQUE_HIERARCHY variable is ignored, thus testsuite is broken in systems where OPAQUE_HIERARCHY is nonempty. The patch fix this problem. CHANGELOG v1: * use ^cgroup instead of cgroup in grep (otherwise it counts also tmpfs /sys/fs/cgroup) * remove obsolete IS_OPAQUE variable Signed-off-by: Ivana Hutarova Varekova Acked-By: Jan Safranek --- tests/runlibcgrouptest.sh | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/tests/runlibcgrouptest.sh b/tests/runlibcgrouptest.sh index 847f9323..df1a9211 100755 --- a/tests/runlibcgrouptest.sh +++ b/tests/runlibcgrouptest.sh @@ -15,6 +15,9 @@ # Description: This script runs the the basic tests for testing libcgroup apis. # +# TODO path to config.h have to be set properly +OPAQUE_HIERARCHY=`grep "OPAQUE_HIERARCHY" ../config.h |\ + cut -d" " -f3 | sed 's|\"||g'` DEBUG=false; # for debug messages FS_MOUNTED=0; # 0 for not mounted, 1 for mounted, 2 for multimounted MOUNTPOINT=/dev/cgroup_controllers; # Just to initialize @@ -72,12 +75,31 @@ check_mount_fs () umount_fs () { - while check_mount_fs + PROC_ENTRY_NUMBER=`cat /proc/mounts|grep ^cgroup | wc -l`; + NUMBER=1; + #go and remove all ot opaque mount points + while [ $PROC_ENTRY_NUMBER -ge $NUMBER ] do - PROC_ENTRY=`cat /proc/mounts|grep cgroup|\ - tr -s [:space:]|cut -d" " -f2`; - # Get first mountpoint in case of multiple mounts - PROC_ENTRY=`echo $PROC_ENTRY|cut -d" " -f1`; + # Get $NUMBER-th mountpoint in case of multiple mount + PROC_ENTRY=`cat /proc/mounts|grep ^cgroup|\ + tr -s [:space:]|cut -d" " -f2 |\ + head -n$NUMBER | tail -n1`; + # if the hierarchy is opaque skip to next item + if [ -n "$OPAQUE_HIERARCHY" ] + then + # find whether is the NUMBER-th item opaque + PROC_ENTRY_OPT=`cat /proc/mounts|grep ^cgroup|\ + tr -s [:space:]|cut -d" " -f4 |\ + head -n$NUMBER | tail -n1`; + echo $PROC_ENTRY_OPT | grep $OPAQUE_HIERARCHY + # if yes skip it to the next item + if [ $? -eq 0 ] + then + let NUMBER=$NUMBER+1 + continue + fi; + fi; + # remove the item if [ ! -z "$PROC_ENTRY" ] then TARGET=$PROC_ENTRY; @@ -87,7 +109,9 @@ umount_fs () rmdir $TARGET; debug "umounted $TARGET"; fi; - done + # go to the next item + let NUMBER=$NUMBER+1 + done; FS_MOUNTED=0; TARGET=/dev/cgroup_controllers; #?? echo "Cleanup done"; -- 2.47.2