test_controllers.sh revision 36670807662c06ba6d931560b0cfb8321ebd237f
1#!/bin/bash
2#usage ./test_controllers.sh
3##################################################################################
4#  Copyright (c) International Business Machines  Corp., 2007                    #
5#                                                                                #
6#  This program is free software;  you can redistribute it and/or modify         #
7#  it under the terms of the GNU General Public License as published by          #
8#  the Free Software Foundation; either version 2 of the License, or             #
9#  (at your option) any later version.                                           #
10#                                                                                #
11#  This program is distributed in the hope that it will be useful,               #
12#  but WITHOUT ANY WARRANTY;  without even the implied warranty of               #
13#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                     #
14#  the GNU General Public License for more details.                              #
15#                                                                                #
16#  You should have received a copy of the GNU General Public License             #
17#  along with this program;  if not, write to the Free Software                  #
18#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA       #
19#                                                                                #
20##################################################################################
21# Name Of File: test_controllers.sh                                              #
22#                                                                                #
23# Description:                                                                   #
24#               This file runs the tests for resource management ie to test cpu  #
25#               controller and memory controller. (for now cpu controller only)  #
26#                                                                                #
27# Author:       Sudhir Kumar    <sudhirkumarmalik@In.ibm.com>                    #
28#                                                                                #
29# History:                                                                       #
30#                                                                                #
31#  DATE        NAME            EMAIL                         DESC                #
32#                                                                                #
33#  20/12/07  Sudhir Kumar <sudhirkumarmalik@in.ibm.com>   Created this test      #
34#  02/03/09  Miao Xie     <miaox@cn.fujitsu.com>          Add cpuset testset     #
35#  07/07/09  Shi Weihua   <shiwh@cn.fujitsu.com>      Add cpu testset of Fujitsu #
36#  30/12/09  Rishikesh    <risrajak@linux.vnet.ibm.com> Added enable/disable     #
37#                                                                                #
38##################################################################################
39
40if [ -f /proc/cgroups ]
41then
42	CPU_CONTROLLER=`grep -w cpu /proc/cgroups | cut -f1`;
43	CPU_CONTROLLER_VALUE=`grep -w cpu /proc/cgroups | cut -f4`;
44	MEM_CONTROLLER=`grep -w memory /proc/cgroups | cut -f1`;
45	MEM_CONTROLLER_VALUE=`grep -w memory /proc/cgroups | cut -f4`;
46	IOTHROTTLE_CONTROLLER=`grep -w blockio /proc/cgroups | cut -f1`;
47	IOTHROTTLE_CONTROLLER_VALUE=`grep -w blockio /proc/cgroups | cut -f4`;
48	FREEZER=`grep -w freezer /proc/cgroups | cut -f1`;
49	FREEZER_VALUE=`grep -w freezer /proc/cgroups | cut -f4`;
50	CPUSET_CONTROLLER=`grep -w cpuset /proc/cgroups | cut -f1`
51	CPUSET_CONTROLLER_VALUE=`grep -w cpuset /proc/cgroups | cut -f4`
52	CPUACCOUNT_CONTROLLER=`grep -w cpuacct /proc/cgroups | cut -f1`
53	CPUACCOUNT_CONTROLLER_VALUE=`grep -w cpuacct /proc/cgroups | cut -f4`
54
55	if [ "$CPU_CONTROLLER" = "cpu" ] && [ "$CPU_CONTROLLER_VALUE" = "1" ]
56	then
57		$LTPROOT/testcases/bin/run_cpuctl_test.sh 1;
58		$LTPROOT/testcases/bin/run_cpuctl_test.sh 3;
59		$LTPROOT/testcases/bin/run_cpuctl_test.sh 4;
60		$LTPROOT/testcases/bin/run_cpuctl_test.sh 5;
61		$LTPROOT/testcases/bin/run_cpuctl_stress_test.sh 6;
62		$LTPROOT/testcases/bin/run_cpuctl_stress_test.sh 7;
63		$LTPROOT/testcases/bin/run_cpuctl_stress_test.sh 8;
64		$LTPROOT/testcases/bin/run_cpuctl_stress_test.sh 9;
65		$LTPROOT/testcases/bin/run_cpuctl_stress_test.sh 10;
66		# Add the latency testcase to be run
67		$LTPROOT/testcases/bin/run_cpuctl_latency_test.sh 1;
68		$LTPROOT/testcases/bin/run_cpuctl_latency_test.sh 2;
69		# Add the testcases from Fujitsu
70		$LTPROOT/testcases/bin/run_cpuctl_test_fj.sh
71	else
72		echo "CONTROLLERS TESTCASES: WARNING";
73		echo "Either Kernel does not support for cpu controller or functionality is not enabled";
74		echo "Skipping all cpu controller testcases....";
75	fi;
76
77	if [ "$MEM_CONTROLLER" = "memory" ] && [ "$MEM_CONTROLLER_VALUE" = "1" ]
78	then
79		$LTPROOT/testcases/bin/run_memctl_test.sh 1;
80		$LTPROOT/testcases/bin/run_memctl_test.sh 2;
81		$LTPROOT/testcases/bin/run_memctl_test.sh 3;
82		$LTPROOT/testcases/bin/run_memctl_test.sh 4;
83	else
84		echo "CONTROLLERS TESTCASES: WARNING";
85		echo "Either Kernel does not support for memory controller or functionality is not enabled";
86		echo "Skipping all memory controller testcases....";
87	fi
88
89	if [ "$IOTHROTTLE_CONTROLLER" = "blockio" ] && [ "$IOTHROTTLE_CONTROLLER_VALUE" = "1" ]
90	then
91		$LTPROOT/testcases/bin/run_io_throttle_test.sh;
92	else
93		echo "CONTROLLERS TESTCASES: WARNING";
94		echo "Either Kernel does not support for io controller or functionality is not enabled";
95		echo "Skipping all block device I/O throttling testcases....";
96	fi
97
98	if [ "$FREEZER" = "freezer" ] && [ "$FREEZER_VALUE" = "1" ]
99	then
100		"$LTPROOT/testcases/bin/run_freezer.sh"
101	else
102		echo "CONTROLLERS TESTCASES: WARNING";
103		echo "Either Kernel does not support for freezer or functionality is not enabled";
104		echo "Kernel does not support freezer controller";
105		echo "Skipping all freezer testcases....";
106	fi
107	if [ "$CPUSET_CONTROLLER" = "cpuset" ] && [ "$CPUSET_CONTROLLER_VALUE" = "1" ]
108	then
109		$LTPROOT/testcases/bin/run_cpuset_test.sh 1;
110		$LTPROOT/testcases/bin/run_cpuset_test.sh 2;
111		$LTPROOT/testcases/bin/run_cpuset_test.sh 3;
112		$LTPROOT/testcases/bin/run_cpuset_test.sh 4;
113		$LTPROOT/testcases/bin/run_cpuset_test.sh 5;
114		$LTPROOT/testcases/bin/run_cpuset_test.sh 6;
115		$LTPROOT/testcases/bin/run_cpuset_test.sh 7;
116		$LTPROOT/testcases/bin/run_cpuset_test.sh 8;
117		$LTPROOT/testcases/bin/run_cpuset_test.sh 9;
118		$LTPROOT/testcases/bin/run_cpuset_test.sh 10;
119		$LTPROOT/testcases/bin/run_cpuset_test.sh 11;
120	else
121		echo "CONTROLLERS TESTCASES: WARNING";
122		echo "Either Kernel does not support for cpuset controller or functionality is not enabled";
123		echo "Skipping all cpuset controller testcases....";
124	fi
125	if [ "$CPUACCOUNT_CONTROLLER" = "cpuacct" ] && [ "$CPUACCOUNT_CONTROLLER_VALUE" = "1" ]
126        then
127                $LTPROOT/testcases/bin/run_cpuacct_test.sh 1;
128                $LTPROOT/testcases/bin/run_cpuacct_test.sh 2;
129        else
130                echo "Could not start cpu accounting controller test";
131		echo "Either Kernel does not support for cpu accounting controller or functionality is not enabled";
132                echo "usage: run_cpuacct_test.sh $TEST_NUM ";
133                echo "Skipping the cpu accounting controller test...";
134        fi
135else
136	echo "CONTROLLERS TESTCASES: WARNING"
137	echo "Kernel does not support any controller";
138	echo "Skipping all controllers testcases....";
139fi
140
141exit 0;
142