memcg_move_charge_at_immigrate_test.sh revision 94c5708a8dcb6baf61e0e8c7985c1c86685baf5f
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    ##
20##                                                                            ##
21################################################################################
22#
23# File :        memcg_move_charge_at_immigrate_test.sh
24# Description:  Tests memory.move_charge_at_immigrate.
25# Author:       Peng Haitao <penght@cn.fujitsu.com>
26# History:      2012/01/16 - Created.
27#
28
29export TCID="memcg_move_charge_at_immigrate_test"
30export TST_TOTAL=4
31export TST_COUNT=0
32
33. ./memcg_lib.sh || exit 1
34
35# Test disable moving charges
36testcase_1()
37{
38	test_move_charge "--mmap-anon" $PAGESIZE  0 0 0 $PAGESIZE 0
39}
40
41# Test move anon
42testcase_2()
43{
44	test_move_charge "--mmap-anon --shm --mmap-file" $PAGESIZE 1 \
45		$PAGESIZE 0 0 $((PAGESIZE*2))
46}
47
48# Test move file
49testcase_3()
50{
51	test_move_charge "--mmap-anon --shm --mmap-file" $PAGESIZE 2 \
52		0 $((PAGESIZE*2)) $PAGESIZE 0
53}
54
55# Test move anon and file
56testcase_4()
57{
58	test_move_charge "--mmap-anon --shm" $PAGESIZE 3 $PAGESIZE $PAGESIZE 0 0
59}
60
61# Run all the test cases
62for i in $(seq 1 $TST_TOTAL)
63do
64	export TST_COUNT=$(( $TST_COUNT + 1 ))
65	cur_id=$i
66
67	do_mount
68	if [ $? -ne 0 ]; then
69		echo "Cannot create memcg"
70		exit 1
71	fi
72
73	# prepare
74	mkdir /dev/memcg/$i 2> /dev/null
75	cd /dev/memcg/$i
76
77	# run the case
78	testcase_$i
79
80	# clean up
81	sleep 1
82	cd $TEST_PATH
83	rmdir /dev/memcg/$i
84
85	cleanup
86done
87
88if [ $failed -ne 0 ]; then
89	exit $failed
90else
91	exit 0
92fi
93