Home | History | Annotate | Download | only in functional
      1 #! /bin/sh
      2 
      3 ################################################################################
      4 ##                                                                            ##
      5 ## Copyright (c) 2012 FUJITSU LIMITED                                         ##
      6 ##                                                                            ##
      7 ## This program is free software;  you can redistribute it and#or modify      ##
      8 ## it under the terms of the GNU General Public License as published by       ##
      9 ## the Free Software Foundation; either version 2 of the License, or          ##
     10 ## (at your option) any later version.                                        ##
     11 ##                                                                            ##
     12 ## This program is distributed in the hope that it will be useful, but        ##
     13 ## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
     14 ## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
     15 ## for more details.                                                          ##
     16 ##                                                                            ##
     17 ## You should have received a copy of the GNU General Public License          ##
     18 ## along with this program;  if not, write to the Free Software               ##
     19 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
     20 ##                                                                            ##
     21 ################################################################################
     22 #
     23 # File :        memcg_use_hierarchy_test.sh
     24 # Description:  Tests memory.use_hierarchy.
     25 # Author:       Peng Haitao <penght (at] cn.fujitsu.com>
     26 # History:      2012/01/14 - Created.
     27 #
     28 
     29 TCID="memcg_use_hierarchy_test"
     30 TST_TOTAL=3
     31 
     32 . memcg_lib.sh
     33 
     34 # test if one of the ancestors goes over its limit, the proces will be killed
     35 testcase_1()
     36 {
     37 	echo 1 > memory.use_hierarchy
     38 	echo $PAGESIZE > memory.limit_in_bytes
     39 
     40 	mkdir subgroup
     41 	cd subgroup
     42 	test_proc_kill $((PAGESIZE*3)) "--mmap-lock1" $((PAGESIZE*2)) 0
     43 
     44 	cd ..
     45 	rmdir subgroup
     46 }
     47 
     48 # test Enabling will fail if the cgroup already has other cgroups
     49 testcase_2()
     50 {
     51 	mkdir subgroup
     52 	EXPECT_FAIL echo 1 \> memory.use_hierarchy
     53 
     54 	rmdir subgroup
     55 }
     56 
     57 # test disabling will fail if the parent cgroup has enabled hierarchy.
     58 testcase_3()
     59 {
     60 	echo 1 > memory.use_hierarchy
     61 	mkdir subgroup
     62 	EXPECT_FAIL echo 0 \> subgroup/memory.use_hierarchy
     63 
     64 	rmdir subgroup
     65 }
     66 
     67 run_tests
     68 
     69 tst_exit
     70 
     71