Skip to content

Commit

Permalink
controllers/cpuacct: add cpuacct tests to default and somecleanup
Browse files Browse the repository at this point in the history
* Change the entry like:
	cpuacct01 run_cpuacct_test.sh 1
	cpuacct02 run_cpuacct_test.sh 2

* Add cpuacct tests to scenario_groups/default

* Add umount_cpuacct_mounted function for umount cpuacct mounted

* Make use of tst_require_root, exists and tst_resm

* Some cleanup

Signed-off-by: Zeng Linggang <[email protected]>
  • Loading branch information
zenglg authored and metan-ucw committed Jun 16, 2014
1 parent d51588c commit 02a4e26
Show file tree
Hide file tree
Showing 4 changed files with 191 additions and 227 deletions.
4 changes: 2 additions & 2 deletions runtest/cpuacct
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CPUACCT01 $LTPROOT/testcases/bin/run_cpuacct_test.sh 1
CPUACCT02 $LTPROOT/testcases/bin/run_cpuacct_test.sh 2
cpuacct01 run_cpuacct_test.sh 1
cpuacct02 run_cpuacct_test.sh 2
1 change: 1 addition & 0 deletions scenario_groups/default
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ modules
fs_ext4
pipes
dma_thread_diotest
cpuacct
37 changes: 23 additions & 14 deletions testcases/kernel/controllers/cpuacct/cpuacct_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# 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 #
# along with this program; if not, write to the Free Software Foundation, #
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #
# #
################################################################################
################################################################################
Expand Down Expand Up @@ -45,18 +45,29 @@
# #
################################################################################

# umount cpuacct if it has been mounted.
umount_cpuacct_mounted()
{
dir=`cat /proc/mounts | grep cpuacct | awk '{print $2}'`
if [ -n "$dir" ]; then
umount "$dir" 2> /dev/null
fi
}

# The cleanup function
cleanup ()
cleanup()
{
echo "Cleanup called"
rm -rf txt*
rmdir /dev/cpuacct/group*/group* 2> /dev/null
rmdir /dev/cpuacct/group* 2> /dev/null
umount /dev/cpuacct/ 2> /dev/null
umount_cpuacct_mounted
rmdir /dev/cpuacct 2> /dev/null
rm -rf tmp2 2> /dev/null
}
task_kill ()

task_kill()
{
for i in `ps -e | grep cpuacct_task | awk '{print $1}'`
do
Expand All @@ -70,33 +81,31 @@ task_kill ()

#clean any group created eralier (if any)

setup ()
setup()
{
if [ -e /dev/cpuacct ]
then
if [ -e /dev/cpuacct ]; then
echo "WARN:/dev/cpuacct already exist..overwriting"
rmdir /dev/cpuacct/group*/group* 2> /dev/null
rmdir /dev/cpuacct/group* 2> /dev/null
rmdir /dev/cpuacct/group* 2> /dev/null
umount /dev/cpuacct/ 2> /dev/null
rmdir /dev/cpuacct 2> /dev/null

rmdir /dev/cpuacct 2> /dev/null
mkdir /dev/cpuacct
else
mkdir /dev/cpuacct
fi
umount_cpuacct_mounted
mount -t cgroup -ocpuacct none /dev/cpuacct 2> /dev/null
if [ $? -ne 0 ]
then
echo "TFAIL: Could not mount cgroup filesystem"
echo "Exiting test"
cleanup
exit -1
exit 1
fi

# Group created earlier may again be visible if not cleaned properly.
#so clean them
if [ -e /dev/cpuacct/group_1 ]
then
if [ -e /dev/cpuacct/group_1 ]; then
rmdir /dev/cpuacct/group*/group* 2> /dev/null
rmdir /dev/cpuacct/group* 2> /dev/null
echo "WARN: Earlier groups found and removed...";
Expand All @@ -108,6 +117,6 @@ setup ()
usage()
{
echo "Could not start cpu account controller test";
echo "usage: run_cpuacct_test.sh $TEST_NUM ";
echo "usage: run_cpuacct_test.sh <TEST_NUM>";
echo "Skipping the cpu account controller test...";
}
Loading

0 comments on commit 02a4e26

Please sign in to comment.