--- /dev/null
+#!/bin/bash
+# test cgclear with multiple config files
+
+. `dirname $0`/../testenv.sh
+
+# start a process to torture
+/bin/sleep 10000 &
+PID=$!
+
+# STEP1: parse three config files and cgclear them at once (in reverse order!)
+$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_multi_1.conf` \
+ || die "STEP1: cgconfigparser multi_1 failed"
+$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_multi_2.conf` \
+ || die "STEP1: cgconfigparser multi_2 failed"
+$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_multi_3.conf` \
+ || die "STEP1: cgconfigparser multi_3 failed"
+$TOOLSDIR/lscgroup > $TMP/groups.log
+grep 1/2/3 <$TMP/groups.log >/dev/null \
+ || die "STEP1: cannot find group '1/2/3'"
+
+# clear it all
+$TOOLSDIR/cgclear -e -l `prepare_config cgclear/cgclear_config_multi_1.conf` \
+ -l `prepare_config cgclear/cgclear_config_multi_2.conf` \
+ -l `prepare_config cgclear/cgclear_config_multi_3.conf` \
+ || die "STEP1: cgclear failed"
+
+# check all is gone
+$TOOLSDIR/lscgroup 2>/dev/null \
+ && die "STEP1: something is mounted after cgclear"
+
+
+# STEP2: same as step1, but in wrong order - cgclear should fail
+$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_multi_1.conf` \
+ || die "STEP2: cgconfigparser multi_1 failed"
+$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_multi_2.conf` \
+ || die "STEP2: cgconfigparser multi_2 failed"
+$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_multi_3.conf` \
+ || die "STEP2: cgconfigparser multi_3 failed"
+$TOOLSDIR/lscgroup > $TMP/groups.log
+grep 1/2/3 <$TMP/groups.log >/dev/null \
+ || die "STEP2: cannot find group '1/2/3'"
+
+# clear it all
+$TOOLSDIR/cgclear -e -l `prepare_config cgclear/cgclear_config_multi_3.conf` \
+ -l `prepare_config cgclear/cgclear_config_multi_2.conf` \
+ -l `prepare_config cgclear/cgclear_config_multi_1.conf` \
+ && die "STEP2: cgclear should fail!"
+
+$TOOLSDIR/cgclear
+
+
+cleanup
+kill -9 $PID
+exit 0
--- /dev/null
+#!/bin/bash
+# test cgclear with one config file
+
+. `dirname $0`/../testenv.sh
+
+# start a process to torture
+/bin/sleep 10000 &
+PID=$!
+
+# STEP1: parse one simple config with mount and cgclear it (incl. unmount)
+$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_one.conf` \
+ || die "STEP1: cgconfigparser failed"
+$TOOLSDIR/lscgroup > $TMP/groups.log
+grep first <$TMP/groups.log >/dev/null \
+ || die "STEP1: cannot find group 'first'"
+
+# unmount it
+$TOOLSDIR/cgclear -l `prepare_config cgclear/cgclear_config_one.conf` \
+ || die "STEP1: cgclear failed"
+
+# check all is gone
+$TOOLSDIR/lscgroup 2>/dev/null \
+ && die "STEP1: something is mounted after cgclear"
+
+
+# STEP2: create a cgroup out of config's tree - it must survive cgclear
+$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_one.conf` \
+ || die "STEP2: cgconfigparser failed"
+$TOOLSDIR/lscgroup > $TMP/groups.log
+grep first <$TMP/groups.log >/dev/null \
+ || die "STEP2: cannot find group 'first'"
+
+$TOOLSDIR/cgcreate -g cpu:/evil \
+ || die "STEP2: cgcreate failed"
+
+# clear it - 'evil' should survive
+$TOOLSDIR/cgclear -l `prepare_config cgclear/cgclear_config_one.conf` \
+ || die "STEP2: cgclear1 failed"
+
+# check evil is there
+$TOOLSDIR/lscgroup > $TMP/groups.log
+grep evil <$TMP/groups.log >/dev/null \
+ || die "STEP2: evil not found"
+
+# clear everything
+$TOOLSDIR/cgclear || die "STEP2: cgclear2 failed"
+$TOOLSDIR/lscgroup 2>/dev/null \
+ && die "STEP2: something is mounted after cgclear"
+
+
+# STEP3: leave a process and a subgroup somewhere and check cgclear *without* -e clears it
+$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_one.conf` \
+ || die "STEP3: cgconfigparser failed"
+$TOOLSDIR/lscgroup > $TMP/groups.log
+grep first <$TMP/groups.log >/dev/null \
+ || die "STEP3: cannot find group 'first'"
+
+$TOOLSDIR/cgclassify -g cpu:first $PID \
+ || die "STEP3: cgclassify failed"
+$TOOLSDIR/cgcreate -g cpu:first/evil \
+ || die "STEP3: cgcreate failed"
+
+# unmount it
+$TOOLSDIR/cgclear -l `prepare_config cgclear/cgclear_config_one.conf` \
+ || die "STEP3: cgclear failed"
+
+# check all is gone
+$TOOLSDIR/lscgroup 2>/dev/null \
+ && die "STEP3: something is mounted after cgclear"
+
+
+
+# STEP4: leave a process somewhere and check cgclear with -e doesn't clear it
+$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_one.conf` \
+ || die "STEP4: cgconfigparser failed"
+$TOOLSDIR/lscgroup > $TMP/groups.log
+grep first <$TMP/groups.log >/dev/null \
+ || die "STEP4: cannot find group 'first'"
+
+$TOOLSDIR/cgclassify -g cpu:first $PID \
+ || die "STEP4: cgclassify failed"
+
+# try to clear it - cgclear should fail
+$TOOLSDIR/cgclear -e -l `prepare_config cgclear/cgclear_config_one.conf` \
+ && die "STEP4: cgclear did not fail!"
+
+# cpu:first should survive
+$TOOLSDIR/lscgroup > $TMP/groups.log
+grep first <$TMP/groups.log >/dev/null \
+ || die "STEP4: cannot find group 'first'"
+# cpu:second should *not* survive
+grep second <$TMP/groups.log >/dev/null \
+ && die "STEP4: unexpected group 'second' found"
+# cpu:first/subgroup should *not* survive
+grep first/subgroup <$TMP/groups.log >/dev/null \
+ && die "STEP4: unexpected group 'first/subgroup' found"
+
+$TOOLSDIR/cgclear
+
+# check all is gone
+$TOOLSDIR/lscgroup 2>/dev/null \
+ && die "STEP4: something is mounted after cgclear"
+
+
+
+# STEP5: leave a subgroup somewhere and check cgclear with -e doesn't clear it
+$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_one.conf` \
+ || die "STEP5: cgconfigparser failed"
+$TOOLSDIR/lscgroup > $TMP/groups.log
+grep first <$TMP/groups.log >/dev/null \
+ || die "STEP5: cannot find group 'first'"
+
+$TOOLSDIR/cgcreate -g cpu:first/evil \
+ || die "STEP5: cgcreate failed"
+
+# try to clear it - cgclear should fail
+$TOOLSDIR/cgclear -e -l `prepare_config cgclear/cgclear_config_one.conf` \
+ && die "STEP5: cgclear did not fail!"
+
+# cpu:first/evil should survive
+$TOOLSDIR/lscgroup > $TMP/groups.log
+grep first/evil <$TMP/groups.log >/dev/null \
+ || die "STEP5: cannot find group 'first/evil'"
+# cpu:second should *not* survive
+grep second <$TMP/groups.log >/dev/null \
+ && die "STEP5: unexpected group 'second' found"
+# cpu:first/subgroup should *not* survive
+grep first/subgroup <$TMP/groups.log >/dev/null \
+ && die "STEP5: unexpected group 'first/subgroup' found"
+
+$TOOLSDIR/cgclear
+
+# check all is gone
+$TOOLSDIR/lscgroup 2>/dev/null \
+ && die "STEP4: something is mounted after cgclear"
+
+kill -9 $PID
+
+cleanup
+exit 0
--- /dev/null
+#!/bin/bash
+# test cgconfigparser with multiple config files
+
+. `dirname $0`/../testenv.sh
+
+# prepare config files in a temporary directory
+mkdir -p $TMP/conf.d
+for i in $TESTDIR/tools/cgconfigparser/multiconfig/*.conf; do
+ mv `prepare_config $i` $TMP/conf.d/
+done
+
+$TOOLSDIR/cgconfigparser -L $TMP/conf.d/ \
+ || die "cgconfigparser failed"
+
+# check that all expected groups exist
+$TOOLSDIR/lscgroup > $TMP/groups.out
+grep "cpu,cpuacct:/1$" <$TMP/groups.out >/dev/null \
+ || die "cannot find group 1"
+grep "freezer:/22$" <$TMP/groups.out >/dev/null \
+ || die "cannot find group 2"
+grep "net_cls:/333$" <$TMP/groups.out >/dev/null \
+ || die "cannot find group 3"
+grep "cpu,cpuacct:/1/4$" <$TMP/groups.out >/dev/null \
+ || die "cannot find group 1/4"
+grep "freezer:/22/4$" <$TMP/groups.out >/dev/null \
+ || die "cannot find group 22/4"
+grep "net_cls:/333/4$" <$TMP/groups.out >/dev/null \
+ || die "cannot find group 333/4"
+grep "cpu,cpuacct:/5$" <$TMP/groups.out >/dev/null \
+ || die "cannot find group 5"
+grep "freezer:/55$" <$TMP/groups.out >/dev/null \
+ || die "cannot find group 55"
+grep "net_cls:/555$" <$TMP/groups.out >/dev/null \
+ || die "cannot find group 555"
+
+# clear it at once
+$TOOLSDIR/cgclear -e -L $TMP/conf.d/ \
+ || die "cgclear failed"
+
+cleanup
+exit 0