• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_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/16 - Created.
27#
28
29TCID="memcg_usage_in_bytes_test"
30TST_TOTAL=2
31
32. memcg_lib.sh
33
34# Test memory.usage_in_bytes
35testcase_1()
36{
37	test_mem_stat "--mmap-anon" $((PAGESIZE*1024)) $((PAGESIZE*1024)) \
38		"memory.usage_in_bytes" $((PAGESIZE*1024)) false
39}
40
41# Test memory.memsw.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_mem_stat "--mmap-anon" $((PAGESIZE*1024)) $((PAGESIZE*1024)) \
52		"memory.memsw.usage_in_bytes" $((PAGESIZE*1024)) false
53}
54
55run_tests
56
57tst_exit
58
59