# 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
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;
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";