• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2
3################################################################################
4##                                                                            ##
5## Copyright (c) 2009 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 Foundation,   ##
19## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
20##                                                                            ##
21## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
22## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
23## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
24##						<risrajak@linux.vnet.ibm.com  ##
25##                                                                            ##
26################################################################################
27
28TCID="memcg_limit_in_bytes"
29TST_TOTAL=15
30
31. memcg_lib.sh
32
33# Test mmap(locked) + alloc_mem > limit_in_bytes
34testcase_1()
35{
36	test_proc_kill $PAGESIZE "--mmap-lock1" $((PAGESIZE*2)) 0
37}
38
39testcase_2()
40{
41	test_proc_kill $PAGESIZE "--mmap-lock2" $((PAGESIZE*2)) 0
42}
43
44# Test swapoff + alloc_mem > limit_in_bytes
45testcase_3()
46{
47	swapoff -a
48	test_proc_kill $PAGESIZE "--mmap-anon" $((PAGESIZE*2)) 0
49	swapon -a
50}
51
52testcase_4()
53{
54	swapoff -a
55	test_proc_kill $PAGESIZE "--mmap-file" $((PAGESIZE*2)) 0
56	swapon -a
57}
58
59testcase_5()
60{
61	swapoff -a
62	test_proc_kill $PAGESIZE "--shm -k 18" $((PAGESIZE*2)) 0
63	swapon -a
64}
65
66# Test limit_in_bytes == 0
67testcase_6()
68{
69	test_proc_kill 0 "--mmap-anon" $PAGESIZE 0
70}
71
72testcase_7()
73{
74	test_proc_kill 0 "--mmap-file" $PAGESIZE 0
75}
76
77testcase_8()
78{
79	test_proc_kill 0 "--shm -k 21" $PAGESIZE 0
80}
81
82# Test limit_in_bytes will be aligned to PAGESIZE
83testcase_9()
84{
85	test_limit_in_bytes $((PAGESIZE-1)) 0
86}
87
88testcase_10()
89{
90	test_limit_in_bytes $((PAGESIZE+1)) 0
91}
92
93testcase_11()
94{
95	test_limit_in_bytes 1 0
96}
97
98# Test invalid memory.limit_in_bytes
99testcase_12()
100{
101	if tst_kvcmp -lt "2.6.31"; then
102		EXPECT_FAIL echo -1 \> memory.limit_in_bytes
103	else
104		EXPECT_PASS echo -1 \> memory.limit_in_bytes
105	fi
106}
107
108testcase_13()
109{
110	EXPECT_FAIL echo 1.0 \> memory.limit_in_bytes
111}
112
113testcase_14()
114{
115	EXPECT_FAIL echo 1xx \> memory.limit_in_bytes
116}
117
118testcase_15()
119{
120	EXPECT_FAIL echo xx \> memory.limit_in_bytes
121}
122
123shmmax_setup
124LOCAL_CLEANUP=shmmax_cleanup
125run_tests
126tst_exit
127