Add test cases of memory.stat.

Signed-off-by: Peng Haitao <[email protected]>
---
 runtest/controllers                                |    1 +
 .../memcg/functional/memcg_stat_test.sh            |  158 ++++++++++++++++++++
 2 files changed, 159 insertions(+), 0 deletions(-)
 create mode 100644 
testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh

diff --git a/runtest/controllers b/runtest/controllers
index 8cf2dc7..ea08609 100644
--- a/runtest/controllers
+++ b/runtest/controllers
@@ -5,6 +5,7 @@ memcg_function          memcg_function_test.sh
 memcg_max_usage_in_bytes       memcg_max_usage_in_bytes_test.sh
 memcg_move_charge_at_immigrate memcg_move_charge_at_immigrate_test.sh
 memcg_memsw_limit_in_bytes     memcg_memsw_limit_in_bytes_test.sh
+memcg_stat     memcg_stat_test.sh
 memcg_stress           memcg_stress_test.sh
 memcg_control          PAGESIZE=$(mem_process -p);memcg_control_test.sh 
$PAGESIZE $PAGESIZE $((PAGESIZE * 2))
 cgroup_fj      run_cgroup_test_fj.sh
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh 
b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh
new file mode 100644
index 0000000..c58495f
--- /dev/null
+++ b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh
@@ -0,0 +1,158 @@
+#! /bin/sh
+
+################################################################################
+##                                                                            
##
+## Copyright (c) 2012 FUJITSU LIMITED                                         
##
+##                                                                            
##
+## This program is free software;  you can redistribute it and#or modify      
##
+## it under the terms of the GNU General Public License as published by       
##
+## the Free Software Foundation; either version 2 of the License, or          
##
+## (at your option) any later version.                                        
##
+##                                                                            
##
+## This program is distributed in the hope that it will be useful, but        
##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
##
+## or FITNESS FOR A PARTICULAR PURPOSE.  See 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    
##
+##                                                                            
##
+################################################################################
+#
+# File :        memcg_stat_test.sh
+# Description:  Tests memroy.stat. 
+# Author:       Peng Haitao <[email protected]>
+# History:      2012/01/16 - Created.
+#
+
+export TCID="memcg_stat_test"
+export TST_TOTAL=8
+export TST_COUNT=0
+
+. memcg_lib.sh || exit 1
+
+# Test cache 
+testcase_1()
+{
+       test_mem_stat "--shm -k 3" $PAGESIZE "cache" $PAGESIZE 0
+}
+
+# Test mapped_file 
+testcase_2()
+{
+       test_mem_stat "--mmap-file" $PAGESIZE "mapped_file" $PAGESIZE 0
+}
+
+# Test unevictable with MAP_LOCKED 
+testcase_3()
+{
+       test_mem_stat "--mmap-lock1" $PAGESIZE "unevictable" $PAGESIZE 0
+}
+
+# Test unevictable with mlock 
+testcase_4()
+{
+       test_mem_stat "--mmap-lock2" $PAGESIZE "unevictable" $PAGESIZE 0
+}
+
+# Test hierarchical_memory_limit with enabling hierarchical accounting 
+testcase_5()
+{
+       echo 1 > memory.use_hierarchy
+
+       mkdir subgroup
+       echo $PAGESIZE > memory.limit_in_bytes
+       echo $((PAGESIZE*2)) > subgroup/memory.limit_in_bytes
+
+       cd subgroup
+       check_mem_stat "hierarchical_memory_limit" $PAGESIZE
+
+       cd ..
+       rmdir subgroup  
+}
+
+# Test hierarchical_memory_limit with disabling hierarchical accounting 
+testcase_6()
+{
+       echo 0 > memory.use_hierarchy
+
+       mkdir subgroup
+       echo $PAGESIZE > memory.limit_in_bytes
+       echo $((PAGESIZE*2)) > subgroup/memory.limit_in_bytes
+
+       cd subgroup
+       check_mem_stat "hierarchical_memory_limit" $((PAGESIZE*2))
+
+       cd ..
+       rmdir subgroup
+}
+
+# Test hierarchical_memsw_limit with enabling hierarchical accounting 
+testcase_7()
+{
+       echo 1 > memory.use_hierarchy
+
+       mkdir subgroup
+       echo $PAGESIZE > memory.limit_in_bytes
+       echo $PAGESIZE > memory.memsw.limit_in_bytes
+       echo $((PAGESIZE*2)) > subgroup/memory.limit_in_bytes
+       echo $((PAGESIZE*2)) > subgroup/memory.memsw.limit_in_bytes
+
+       cd subgroup
+       check_mem_stat "hierarchical_memsw_limit" $PAGESIZE
+
+       cd ..
+       rmdir subgroup
+}
+
+# Test hierarchical_memsw_limit with disabling hierarchical accounting 
+testcase_8()
+{
+       echo 0 > memory.use_hierarchy
+
+       mkdir subgroup
+       echo $PAGESIZE > memory.limit_in_bytes
+       echo $PAGESIZE > memory.memsw.limit_in_bytes
+       echo $((PAGESIZE*2)) > subgroup/memory.limit_in_bytes
+       echo $((PAGESIZE*2)) > subgroup/memory.memsw.limit_in_bytes
+
+       cd subgroup
+       check_mem_stat "hierarchical_memsw_limit" $((PAGESIZE*2))
+
+       cd ..
+       rmdir subgroup
+}
+
+# Run all the test cases
+for i in $(seq 1 $TST_TOTAL)
+do
+       export TST_COUNT=$(( $TST_COUNT + 1 ))
+       cur_id=$i
+
+       do_mount;
+       if [ $? -ne 0 ]; then
+               echo "Cannot create memcg"
+               exit 1
+       fi
+
+       # prepare
+       mkdir /dev/memcg/$i 2> /dev/null
+       cd /dev/memcg/$i
+
+       # run the case
+       testcase_$i
+
+       # clean up
+       sleep 1
+       cd $TEST_PATH
+       rmdir /dev/memcg/$i
+
+       cleanup;
+done
+
+if [ $failed -ne 0 ]; then
+       exit $failed
+else
+       exit 0
+fi
-- 
1.7.1


-- 
Best Regards,
Peng
Add test cases of memory.stat.

Signed-off-by: Peng Haitao <[email protected]>
---
 runtest/controllers                                |    1 +
 .../memcg/functional/memcg_stat_test.sh            |  158 ++++++++++++++++++++
 2 files changed, 159 insertions(+), 0 deletions(-)
 create mode 100644 
testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh

diff --git a/runtest/controllers b/runtest/controllers
index 8cf2dc7..ea08609 100644
--- a/runtest/controllers
+++ b/runtest/controllers
@@ -5,6 +5,7 @@ memcg_function          memcg_function_test.sh
 memcg_max_usage_in_bytes       memcg_max_usage_in_bytes_test.sh
 memcg_move_charge_at_immigrate memcg_move_charge_at_immigrate_test.sh
 memcg_memsw_limit_in_bytes     memcg_memsw_limit_in_bytes_test.sh
+memcg_stat     memcg_stat_test.sh
 memcg_stress           memcg_stress_test.sh
 memcg_control          PAGESIZE=$(mem_process -p);memcg_control_test.sh 
$PAGESIZE $PAGESIZE $((PAGESIZE * 2))
 cgroup_fj      run_cgroup_test_fj.sh
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh 
b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh
new file mode 100644
index 0000000..c58495f
--- /dev/null
+++ b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh
@@ -0,0 +1,158 @@
+#! /bin/sh
+
+################################################################################
+##                                                                            
##
+## Copyright (c) 2012 FUJITSU LIMITED                                         
##
+##                                                                            
##
+## This program is free software;  you can redistribute it and#or modify      
##
+## it under the terms of the GNU General Public License as published by       
##
+## the Free Software Foundation; either version 2 of the License, or          
##
+## (at your option) any later version.                                        
##
+##                                                                            
##
+## This program is distributed in the hope that it will be useful, but        
##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
##
+## or FITNESS FOR A PARTICULAR PURPOSE.  See 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    
##
+##                                                                            
##
+################################################################################
+#
+# File :        memcg_stat_test.sh
+# Description:  Tests memroy.stat. 
+# Author:       Peng Haitao <[email protected]>
+# History:      2012/01/16 - Created.
+#
+
+export TCID="memcg_stat_test"
+export TST_TOTAL=8
+export TST_COUNT=0
+
+. memcg_lib.sh || exit 1
+
+# Test cache 
+testcase_1()
+{
+       test_mem_stat "--shm -k 3" $PAGESIZE "cache" $PAGESIZE 0
+}
+
+# Test mapped_file 
+testcase_2()
+{
+       test_mem_stat "--mmap-file" $PAGESIZE "mapped_file" $PAGESIZE 0
+}
+
+# Test unevictable with MAP_LOCKED 
+testcase_3()
+{
+       test_mem_stat "--mmap-lock1" $PAGESIZE "unevictable" $PAGESIZE 0
+}
+
+# Test unevictable with mlock 
+testcase_4()
+{
+       test_mem_stat "--mmap-lock2" $PAGESIZE "unevictable" $PAGESIZE 0
+}
+
+# Test hierarchical_memory_limit with enabling hierarchical accounting 
+testcase_5()
+{
+       echo 1 > memory.use_hierarchy
+
+       mkdir subgroup
+       echo $PAGESIZE > memory.limit_in_bytes
+       echo $((PAGESIZE*2)) > subgroup/memory.limit_in_bytes
+
+       cd subgroup
+       check_mem_stat "hierarchical_memory_limit" $PAGESIZE
+
+       cd ..
+       rmdir subgroup  
+}
+
+# Test hierarchical_memory_limit with disabling hierarchical accounting 
+testcase_6()
+{
+       echo 0 > memory.use_hierarchy
+
+       mkdir subgroup
+       echo $PAGESIZE > memory.limit_in_bytes
+       echo $((PAGESIZE*2)) > subgroup/memory.limit_in_bytes
+
+       cd subgroup
+       check_mem_stat "hierarchical_memory_limit" $((PAGESIZE*2))
+
+       cd ..
+       rmdir subgroup
+}
+
+# Test hierarchical_memsw_limit with enabling hierarchical accounting 
+testcase_7()
+{
+       echo 1 > memory.use_hierarchy
+
+       mkdir subgroup
+       echo $PAGESIZE > memory.limit_in_bytes
+       echo $PAGESIZE > memory.memsw.limit_in_bytes
+       echo $((PAGESIZE*2)) > subgroup/memory.limit_in_bytes
+       echo $((PAGESIZE*2)) > subgroup/memory.memsw.limit_in_bytes
+
+       cd subgroup
+       check_mem_stat "hierarchical_memsw_limit" $PAGESIZE
+
+       cd ..
+       rmdir subgroup
+}
+
+# Test hierarchical_memsw_limit with disabling hierarchical accounting 
+testcase_8()
+{
+       echo 0 > memory.use_hierarchy
+
+       mkdir subgroup
+       echo $PAGESIZE > memory.limit_in_bytes
+       echo $PAGESIZE > memory.memsw.limit_in_bytes
+       echo $((PAGESIZE*2)) > subgroup/memory.limit_in_bytes
+       echo $((PAGESIZE*2)) > subgroup/memory.memsw.limit_in_bytes
+
+       cd subgroup
+       check_mem_stat "hierarchical_memsw_limit" $((PAGESIZE*2))
+
+       cd ..
+       rmdir subgroup
+}
+
+# Run all the test cases
+for i in $(seq 1 $TST_TOTAL)
+do
+       export TST_COUNT=$(( $TST_COUNT + 1 ))
+       cur_id=$i
+
+       do_mount;
+       if [ $? -ne 0 ]; then
+               echo "Cannot create memcg"
+               exit 1
+       fi
+
+       # prepare
+       mkdir /dev/memcg/$i 2> /dev/null
+       cd /dev/memcg/$i
+
+       # run the case
+       testcase_$i
+
+       # clean up
+       sleep 1
+       cd $TEST_PATH
+       rmdir /dev/memcg/$i
+
+       cleanup;
+done
+
+if [ $failed -ne 0 ]; then
+       exit $failed
+else
+       exit 0
+fi
-- 
1.7.1

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to