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_max_usage_in_bytes_test.sh 24# Description: Tests memory.max_usage_in_bytes. 25# Author: Peng Haitao <penght@cn.fujitsu.com> 26# History: 2012/01/17 - Created. 27# 28 29TCID="memcg_max_usage_in_bytes_test" 30TST_TOTAL=4 31 32. memcg_lib.sh 33 34# Test memory.max_usage_in_bytes 35testcase_1() 36{ 37 test_max_usage_in_bytes "--mmap-anon" $((PAGESIZE*1024)) \ 38 "memory.max_usage_in_bytes" $((PAGESIZE*1024)) 0 39} 40 41# Test memory.memsw.max_usage_in_bytes 42testcase_2() 43{ 44 if [ "$MEMSW_USAGE_FLAG" -eq 0 ]; then 45 tst_resm TCONF "mem+swap is not enabled" 46 return 47 fi 48 49 echo $((PAGESIZE*2048)) > memory.limit_in_bytes 50 echo $((PAGESIZE*2048)) > memory.memsw.limit_in_bytes 51 test_max_usage_in_bytes "--mmap-anon" $((PAGESIZE*1024)) \ 52 "memory.memsw.max_usage_in_bytes" $((PAGESIZE*1024)) 0 53} 54 55# Test reset memory.max_usage_in_bytes 56testcase_3() 57{ 58 test_max_usage_in_bytes "--mmap-anon" $((PAGESIZE*1024)) \ 59 "memory.max_usage_in_bytes" $((PAGESIZE*1024)) 1 60} 61 62# Test reset memory.memsw.max_usage_in_bytes 63testcase_4() 64{ 65 if [ "$MEMSW_USAGE_FLAG" -eq 0 ]; then 66 tst_resm TCONF "mem+swap is not enabled" 67 return 68 fi 69 70 echo $((PAGESIZE*2048)) > memory.limit_in_bytes 71 echo $((PAGESIZE*2048)) > memory.memsw.limit_in_bytes 72 test_max_usage_in_bytes "--mmap-anon" $((PAGESIZE*1024)) \ 73 "memory.memsw.max_usage_in_bytes" $((PAGESIZE*1024)) 1 74} 75 76run_tests 77 78tst_exit 79 80