Add test cases of memory.move_charge_at_immigrate.

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

diff --git a/runtest/controllers b/runtest/controllers
index 33ac6fd..1ea7914 100644
--- a/runtest/controllers
+++ b/runtest/controllers
@@ -3,6 +3,7 @@ cgroup          cgroup_regression_test.sh
 memcg_regression       memcg_regression_test.sh
 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_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_move_charge_at_immigrate_test.sh
 
b/testcases/kernel/controllers/memcg/functional/memcg_move_charge_at_immigrate_test.sh
new file mode 100644
index 0000000..04e8b38
--- /dev/null
+++ 
b/testcases/kernel/controllers/memcg/functional/memcg_move_charge_at_immigrate_test.sh
@@ -0,0 +1,194 @@
+#! /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_move_charge_at_immigrate_test.sh
+# Description:  Tests memory.move_charge_at_immigrate. 
+# Author:       Peng Haitao <[email protected]>
+# History:      2012/01/16 - Created.
+#
+
+export TCID="memcg_move_charge_at_immigrate_test"
+export TST_TOTAL=4
+export TST_COUNT=0
+
+. memcg_lib.sh || exit 1
+
+# Test disable moving charges
+testcase_1()
+{
+       mkdir subgroup_a
+
+       $TEST_PATH/memcg_process --mmap-anon -s $PAGESIZE &
+       warmup $!
+       if [ $? -ne 0 ]; then
+               rmdir subgroup_a
+               return
+       fi
+
+       echo $! > subgroup_a/tasks
+       /bin/kill -s SIGUSR1 $!
+       sleep 1
+
+       mkdir subgroup_b
+       echo 0 > subgroup_b/memory.move_charge_at_immigrate
+       echo $! > subgroup_b/tasks
+
+       cd subgroup_a
+       check_mem_stat memory.usage_in_bytes $PAGESIZE
+       cd ../subgroup_b
+       check_mem_stat memory.usage_in_bytes 0
+
+       cd ..
+       echo $! > tasks
+       rmdir subgroup_a subgroup_b
+       /bin/kill -s SIGUSR1 $!
+       /bin/kill -s SIGINT $!
+}
+
+# Test move anon
+testcase_2()
+{
+       mkdir subgroup_a
+
+       $TEST_PATH/memcg_process --mmap-anon --shm --mmap-file -s $PAGESIZE &
+       warmup $!
+       if [ $? -ne 0 ]; then
+               rmdir subgroup_a
+               return
+       fi
+
+       echo $! > subgroup_a/tasks
+       /bin/kill -s SIGUSR1 $!
+       sleep 1
+
+       mkdir subgroup_b
+       echo 1 > subgroup_b/memory.move_charge_at_immigrate
+       echo $! > subgroup_b/tasks
+
+       cd subgroup_b
+       check_mem_stat memory.usage_in_bytes $PAGESIZE
+       cd ../subgroup_a
+       check_mem_stat memory.usage_in_bytes $((PAGESIZE*2))
+
+       cd ..
+       echo $! > tasks
+       rmdir subgroup_a subgroup_b
+       /bin/kill -s SIGUSR1 $!
+       /bin/kill -s SIGINT $!
+}
+
+# Test move file
+testcase_3()
+{
+       mkdir subgroup_a
+
+       $TEST_PATH/memcg_process --mmap-anon --shm --mmap-file -s $PAGESIZE &
+       warmup $!
+       if [ $? -ne 0 ]; then
+               rmdir subgroup_a
+               return
+       fi
+
+       echo $! > subgroup_a/tasks
+       /bin/kill -s SIGUSR1 $!
+       sleep 1
+
+       mkdir subgroup_b
+       echo 2 > subgroup_b/memory.move_charge_at_immigrate
+       echo $! > subgroup_b/tasks
+
+       cd subgroup_b
+       check_mem_stat memory.usage_in_bytes $((PAGESIZE*2))
+       cd ../subgroup_a
+       check_mem_stat memory.usage_in_bytes $PAGESIZE
+
+       cd ..
+       echo $! > tasks
+       rmdir subgroup_a subgroup_b
+       /bin/kill -s SIGUSR1 $!
+       /bin/kill -s SIGINT $!
+}
+
+# Test move anon and file
+testcase_4()
+{
+       mkdir subgroup_a
+
+       $TEST_PATH/memcg_process --mmap-anon --shm -s $PAGESIZE &
+       warmup $!
+       if [ $? -ne 0 ]; then
+               rmdir subgroup_a
+               return
+       fi
+
+       echo $! > subgroup_a/tasks
+       /bin/kill -s SIGUSR1 $!
+       sleep 1
+
+       mkdir subgroup_b
+       echo 3 > subgroup_b/memory.move_charge_at_immigrate
+       echo $! > subgroup_b/tasks
+
+       cd subgroup_b
+       check_mem_stat memory.usage_in_bytes $((PAGESIZE*2))
+       cd ../subgroup_a
+       check_mem_stat memory.usage_in_bytes 0
+
+       cd ..
+       echo $! > tasks
+       rmdir subgroup_a subgroup_b
+       /bin/kill -s SIGUSR1 $!
+       /bin/kill -s SIGINT $!
+}
+
+# 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.move_charge_at_immigrate.

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

diff --git a/runtest/controllers b/runtest/controllers
index 33ac6fd..1ea7914 100644
--- a/runtest/controllers
+++ b/runtest/controllers
@@ -3,6 +3,7 @@ cgroup          cgroup_regression_test.sh
 memcg_regression       memcg_regression_test.sh
 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_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_move_charge_at_immigrate_test.sh
 
b/testcases/kernel/controllers/memcg/functional/memcg_move_charge_at_immigrate_test.sh
new file mode 100644
index 0000000..04e8b38
--- /dev/null
+++ 
b/testcases/kernel/controllers/memcg/functional/memcg_move_charge_at_immigrate_test.sh
@@ -0,0 +1,194 @@
+#! /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_move_charge_at_immigrate_test.sh
+# Description:  Tests memory.move_charge_at_immigrate. 
+# Author:       Peng Haitao <[email protected]>
+# History:      2012/01/16 - Created.
+#
+
+export TCID="memcg_move_charge_at_immigrate_test"
+export TST_TOTAL=4
+export TST_COUNT=0
+
+. memcg_lib.sh || exit 1
+
+# Test disable moving charges
+testcase_1()
+{
+       mkdir subgroup_a
+
+       $TEST_PATH/memcg_process --mmap-anon -s $PAGESIZE &
+       warmup $!
+       if [ $? -ne 0 ]; then
+               rmdir subgroup_a
+               return
+       fi
+
+       echo $! > subgroup_a/tasks
+       /bin/kill -s SIGUSR1 $!
+       sleep 1
+
+       mkdir subgroup_b
+       echo 0 > subgroup_b/memory.move_charge_at_immigrate
+       echo $! > subgroup_b/tasks
+
+       cd subgroup_a
+       check_mem_stat memory.usage_in_bytes $PAGESIZE
+       cd ../subgroup_b
+       check_mem_stat memory.usage_in_bytes 0
+
+       cd ..
+       echo $! > tasks
+       rmdir subgroup_a subgroup_b
+       /bin/kill -s SIGUSR1 $!
+       /bin/kill -s SIGINT $!
+}
+
+# Test move anon
+testcase_2()
+{
+       mkdir subgroup_a
+
+       $TEST_PATH/memcg_process --mmap-anon --shm --mmap-file -s $PAGESIZE &
+       warmup $!
+       if [ $? -ne 0 ]; then
+               rmdir subgroup_a
+               return
+       fi
+
+       echo $! > subgroup_a/tasks
+       /bin/kill -s SIGUSR1 $!
+       sleep 1
+
+       mkdir subgroup_b
+       echo 1 > subgroup_b/memory.move_charge_at_immigrate
+       echo $! > subgroup_b/tasks
+
+       cd subgroup_b
+       check_mem_stat memory.usage_in_bytes $PAGESIZE
+       cd ../subgroup_a
+       check_mem_stat memory.usage_in_bytes $((PAGESIZE*2))
+
+       cd ..
+       echo $! > tasks
+       rmdir subgroup_a subgroup_b
+       /bin/kill -s SIGUSR1 $!
+       /bin/kill -s SIGINT $!
+}
+
+# Test move file
+testcase_3()
+{
+       mkdir subgroup_a
+
+       $TEST_PATH/memcg_process --mmap-anon --shm --mmap-file -s $PAGESIZE &
+       warmup $!
+       if [ $? -ne 0 ]; then
+               rmdir subgroup_a
+               return
+       fi
+
+       echo $! > subgroup_a/tasks
+       /bin/kill -s SIGUSR1 $!
+       sleep 1
+
+       mkdir subgroup_b
+       echo 2 > subgroup_b/memory.move_charge_at_immigrate
+       echo $! > subgroup_b/tasks
+
+       cd subgroup_b
+       check_mem_stat memory.usage_in_bytes $((PAGESIZE*2))
+       cd ../subgroup_a
+       check_mem_stat memory.usage_in_bytes $PAGESIZE
+
+       cd ..
+       echo $! > tasks
+       rmdir subgroup_a subgroup_b
+       /bin/kill -s SIGUSR1 $!
+       /bin/kill -s SIGINT $!
+}
+
+# Test move anon and file
+testcase_4()
+{
+       mkdir subgroup_a
+
+       $TEST_PATH/memcg_process --mmap-anon --shm -s $PAGESIZE &
+       warmup $!
+       if [ $? -ne 0 ]; then
+               rmdir subgroup_a
+               return
+       fi
+
+       echo $! > subgroup_a/tasks
+       /bin/kill -s SIGUSR1 $!
+       sleep 1
+
+       mkdir subgroup_b
+       echo 3 > subgroup_b/memory.move_charge_at_immigrate
+       echo $! > subgroup_b/tasks
+
+       cd subgroup_b
+       check_mem_stat memory.usage_in_bytes $((PAGESIZE*2))
+       cd ../subgroup_a
+       check_mem_stat memory.usage_in_bytes 0
+
+       cd ..
+       echo $! > tasks
+       rmdir subgroup_a subgroup_b
+       /bin/kill -s SIGUSR1 $!
+       /bin/kill -s SIGINT $!
+}
+
+# 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