All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH V2 1/6] memcg_lib.sh: Print test number at test start
@ 2016-09-05 15:24 Cyril Hrubis
  2016-09-05 15:24 ` [LTP] [PATCH V2 2/6] memcg_lib.sh: Move all the kill -s XXX to functions Cyril Hrubis
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Cyril Hrubis @ 2016-09-05 15:24 UTC (permalink / raw)
  To: ltp

Given that some of the testcases report more than one TPASS/TFAIL you
cannot easily tell from the log which exact testcase has failed/passed.

This commit fixes that by adding "Starting test $i" TINFO message into
the loop that executes the testcases.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/controllers/memcg/functional/memcg_lib.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
index c71a41b..352960b 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
@@ -476,6 +476,9 @@ setup_test()
 run_tests()
 {
 	for i in $(seq 1 $TST_TOTAL); do
+
+		tst_resm TINFO "Starting test $i"
+
 		setup_test $i
 
 		if [ -e memory.memsw.limit_in_bytes ]; then
-- 
2.7.3


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP] [PATCH V2 2/6] memcg_lib.sh: Move all the kill -s XXX to functions
  2016-09-05 15:24 [LTP] [PATCH V2 1/6] memcg_lib.sh: Print test number at test start Cyril Hrubis
@ 2016-09-05 15:24 ` Cyril Hrubis
  2016-09-05 15:24 ` [LTP] [PATCH V2 3/6] memcg_lib.sh: Get rid of sleep 1 in signal_memcg_process Cyril Hrubis
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Cyril Hrubis @ 2016-09-05 15:24 UTC (permalink / raw)
  To: ltp

This commit adds two functions:

* signal_memcg_process
   which asks the memcg_process to allocate/free memory and waits for
   completion

* stop_memcg_process
   which sends SIGINT to the memcg_process and waits for the pid

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 .../memcg/functional/memcg_function_test.sh        | 10 ++-
 .../controllers/memcg/functional/memcg_lib.sh      | 75 +++++++++++-----------
 2 files changed, 41 insertions(+), 44 deletions(-)

diff --git a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
index 5ee63a9..1bb75d0 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
@@ -211,14 +211,13 @@ testcase_29()
 	pid=$!
 	TST_CHECKPOINT_WAIT 0
 	echo $pid > tasks
-	kill -s USR1 $pid 2> /dev/null
-	sleep 1
+	signal_memcg_process $pid
 	echo $pid > ../tasks
 
 	# This expects that there is swap configured
 	EXPECT_PASS echo 1 \> memory.force_empty
 
-	kill -s INT $pid 2> /dev/null
+	stop_memcg_process $pid
 }
 
 testcase_30()
@@ -227,12 +226,11 @@ testcase_30()
 	pid=$!
 	TST_CHECKPOINT_WAIT 0
 	echo $pid > tasks
-	kill -s USR1 $pid 2> /dev/null
-	sleep 1
+	signal_memcg_process $pid
 
 	EXPECT_FAIL echo 1 \> memory.force_empty
 
-	kill -s INT $pid 2> /dev/null
+	stop_memcg_process $pid
 }
 
 testcase_31()
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
index 352960b..26d2783 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
@@ -87,15 +87,27 @@ check_mem_stat()
 	fi
 }
 
+signal_memcg_process()
+{
+	pid=$1
+	kill -s USR1 $pid 2> /dev/null
+	sleep 1
+}
+
+stop_memcg_process()
+{
+	pid=$1
+	kill -s INT $pid 2> /dev/null
+	wait $pid
+}
+
 warmup()
 {
 	pid=$1
 
 	tst_resm TINFO "Warming up pid: $pid"
-	kill -s USR1 $pid 2> /dev/null
-	sleep 1
-	kill -s USR1 $pid 2> /dev/null
-	sleep 1
+	signal_memcg_process $pid
+	signal_memcg_process $pid
 
 	kill -0 $pid
 	if [ $? -ne 0 ]; then
@@ -128,18 +140,16 @@ test_mem_stat()
 	fi
 
 	echo $! > tasks
-	kill -s USR1 $! 2> /dev/null
-	sleep 1
+	signal_memcg_process $!
 
 	check_mem_stat $3 $4
 
-	kill -s USR1 $! 2> /dev/null
-	sleep 1
+	signal_memcg_process $!
 	if [ $5 -eq 1 ]; then
 		check_mem_stat $3 0
 	fi
 
-	kill -s INT $! 2> /dev/null
+	stop_memcg_process $!
 }
 
 # Run test cases which checks memory.max_usage_in_bytes after make
@@ -161,11 +171,8 @@ test_max_usage_in_bytes()
 	fi
 
 	echo $! > tasks
-	kill -s USR1 $! 2> /dev/null
-	sleep 1
-
-	kill -s USR1 $! 2> /dev/null
-	sleep 1
+	signal_memcg_process $!
+	signal_memcg_process $!
 
 	check_mem_stat $3 $4
 
@@ -174,7 +181,7 @@ test_max_usage_in_bytes()
 		check_mem_stat $3 0
 	fi
 
-	kill -s INT $! 2> /dev/null
+	stop_memcg_process $!
 }
 
 # make some memory allocation
@@ -187,13 +194,10 @@ malloc_free_memory()
 	TST_CHECKPOINT_WAIT 0
 
 	echo $! > tasks
-	kill -s USR1 $! 2> /dev/null
-	sleep 1
-
-	kill -s USR1 $! 2> /dev/null
-	sleep 1
+	signal_memcg_process $!
+	signal_memcg_process $!
 
-	kill -s INT $! 2> /dev/null
+	stop_memcg_process $!
 }
 
 # Test if failcnt > 0, which means page reclamation occured
@@ -230,7 +234,7 @@ test_proc_kill()
 	TST_CHECKPOINT_WAIT 0
 	echo $pid > tasks
 
-	kill -s USR1 $pid 2> /dev/null
+	signal_memcg_process $pid
 
 	tpk_pid_exists=1
 	for tpk_iter in $(seq 20); do
@@ -254,7 +258,7 @@ test_proc_kill()
 			tst_resm TPASS "process $pid is killed"
 		fi
 	else
-		kill -s INT $pid 2> /dev/null
+		stop_memcg_process $!
 		tst_resm TFAIL "process $pid is not killed"
 	fi
 }
@@ -307,8 +311,7 @@ test_hugepage()
 	memcg_process $2 --hugepage -s $3 > $TMP_FILE 2>&1 &
 	TST_CHECKPOINT_WAIT 0
 
-	kill -s USR1 $! 2> /dev/null
-	sleep 1
+	signal_memcg_process $!
 
 	check_mem_stat "rss" 0
 
@@ -320,15 +323,15 @@ test_hugepage()
 		if [ $? -eq 0 ]; then
 			tst_resm TPASS "allocate hugepage failed as expected"
 		else
-			kill -s USR1 $! 2> /dev/null
-			kill -s INT $! 2> /dev/null
+			signal_memcg_process $!
+			stop_memcg_process $!
 			tst_resm TFAIL "allocate hugepage should fail"
 		fi
 	else
 		test ! -s $TMP_FILE
 		if [ $? -eq 0 ]; then
-			kill -s USR1 $! 2> /dev/null
-			kill -s INT $! 2> /dev/null
+			signal_memcg_process $!
+			stop_memcg_process $!
 			tst_resm TPASS "allocate hugepage succeeded"
 		else
 			tst_resm TFAIL "allocate hugepage failed"
@@ -361,8 +364,7 @@ test_subgroup()
 	fi
 
 	echo $! > tasks
-	kill -s USR1 $! 2> /dev/null
-	sleep 1
+	signal_memcg_process $!
 	check_mem_stat "rss" $PAGESIZE
 
 	cd subgroup
@@ -372,8 +374,7 @@ test_subgroup()
 	# cleanup
 	cd ..
 	echo $! > tasks
-	kill -s INT $! 2> /dev/null
-	sleep 1
+	stop_memcg_process $!
 	rmdir subgroup
 }
 
@@ -397,8 +398,7 @@ test_move_charge()
 	fi
 
 	echo $! > subgroup_a/tasks
-	kill -s USR1 $!
-	sleep 1
+	signal_memcg_process $!
 
 	mkdir subgroup_b
 	echo $3 > subgroup_b/memory.move_charge_at_immigrate
@@ -413,9 +413,8 @@ test_move_charge()
 
 	cd ..
 	echo $! > tasks
-	kill -s USR1 $!
-	kill -s INT $!
-	sleep 1
+	signal_memcg_process $!
+	stop_memcg_process $!
 	rmdir subgroup_a subgroup_b
 }
 
-- 
2.7.3


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP] [PATCH V2 3/6] memcg_lib.sh: Get rid of sleep 1 in signal_memcg_process
  2016-09-05 15:24 [LTP] [PATCH V2 1/6] memcg_lib.sh: Print test number at test start Cyril Hrubis
  2016-09-05 15:24 ` [LTP] [PATCH V2 2/6] memcg_lib.sh: Move all the kill -s XXX to functions Cyril Hrubis
@ 2016-09-05 15:24 ` Cyril Hrubis
  2016-09-05 15:24 ` [LTP] [PATCH V2 4/6] memcg_function_test.sh: Split Cyril Hrubis
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Cyril Hrubis @ 2016-09-05 15:24 UTC (permalink / raw)
  To: ltp

The signal_memcg_process function, if passed a size parameter, now polls the
memory.usage_in_bytes file until it increases or decreases by a given amount
(the amount the memcg_process is expected to allocate/free) or until the
process is killed.

We now sleep only in the warmup and only after we send second signal to
the memcg_process.

This further brings down the test runtime down by another minute, now
the tests finish in about 30 second while we also assert that the
usage_in_bytes gets incremented as process consumes memory.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 .../memcg/functional/memcg_function_test.sh        |  28 ++---
 .../controllers/memcg/functional/memcg_lib.sh      | 114 +++++++++++++--------
 .../memcg_move_charge_at_immigrate_test.sh         |  13 +--
 .../memcg/functional/memcg_stat_test.sh            |  11 +-
 .../memcg/functional/memcg_usage_in_bytes_test.sh  |   8 +-
 5 files changed, 104 insertions(+), 70 deletions(-)

diff --git a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
index 1bb75d0..fadbcea 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
@@ -41,54 +41,54 @@ LOCAL_CLEANUP=shmmax_cleanup
 # Case 1 - 10: Test the management and counting of memory
 testcase_1()
 {
-	test_mem_stat "--mmap-anon" $PAGESIZE "rss" $PAGESIZE 0
+	test_mem_stat "--mmap-anon" $PAGESIZE $PAGESIZE "rss" $PAGESIZE false
 }
 
 testcase_2()
 {
-	test_mem_stat "--mmap-file" $PAGESIZE "rss" 0 0
+	test_mem_stat "--mmap-file" $PAGESIZE $PAGESIZE "rss" 0 false
 }
 
 testcase_3()
 {
-	test_mem_stat "--shm -k 3" $PAGESIZE "rss" 0 0
+	test_mem_stat "--shm -k 3" $PAGESIZE $PAGESIZE "rss" 0 false
 }
 
 testcase_4()
 {
-	test_mem_stat "--mmap-anon --mmap-file --shm" $PAGESIZE "rss" \
-		$PAGESIZE 0
+	test_mem_stat "--mmap-anon --mmap-file --shm" \
+		$PAGESIZE $((PAGESIZE*3)) "rss" $PAGESIZE false
 }
 
 testcase_5()
 {
-	test_mem_stat "--mmap-lock1" $PAGESIZE "rss" $PAGESIZE 0
+	test_mem_stat "--mmap-lock1" $PAGESIZE $PAGESIZE "rss" $PAGESIZE false
 }
 
 testcase_6()
 {
-	test_mem_stat "--mmap-anon" $PAGESIZE "rss" $PAGESIZE 1
+	test_mem_stat "--mmap-anon" $PAGESIZE $PAGESIZE "rss" $PAGESIZE true
 }
 
 testcase_7()
 {
-	test_mem_stat "--mmap-file" $PAGESIZE "rss" 0 1
+	test_mem_stat "--mmap-file" $PAGESIZE $PAGESIZE "rss" 0 true
 }
 
 testcase_8()
 {
-	test_mem_stat "--shm -k 8" $PAGESIZE "rss" 0 1
+	test_mem_stat "--shm -k 8" $PAGESIZE $PAGESIZE "rss" 0 true
 }
 
 testcase_9()
 {
-	test_mem_stat "--mmap-anon --mmap-file --shm" $PAGESIZE "rss" \
-		$PAGESIZE 1
+	test_mem_stat "--mmap-anon --mmap-file --shm" \
+		$PAGESIZE $((PAGESIZE*3)) "rss" $PAGESIZE true
 }
 
 testcase_10()
 {
-	test_mem_stat "--mmap-lock1" $PAGESIZE "rss" $PAGESIZE 1
+	test_mem_stat "--mmap-lock1" $PAGESIZE $PAGESIZE "rss" $PAGESIZE true
 }
 
 # Case 11 - 13: Test memory.failcnt
@@ -211,7 +211,7 @@ testcase_29()
 	pid=$!
 	TST_CHECKPOINT_WAIT 0
 	echo $pid > tasks
-	signal_memcg_process $pid
+	signal_memcg_process $pid $PAGESIZE
 	echo $pid > ../tasks
 
 	# This expects that there is swap configured
@@ -226,7 +226,7 @@ testcase_30()
 	pid=$!
 	TST_CHECKPOINT_WAIT 0
 	echo $pid > tasks
-	signal_memcg_process $pid
+	signal_memcg_process $pid $PAGESIZE
 
 	EXPECT_FAIL echo 1 \> memory.force_empty
 
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
index 26d2783..c34198a 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
@@ -89,25 +89,52 @@ check_mem_stat()
 
 signal_memcg_process()
 {
-	pid=$1
+	local pid=$1
+	local size=$2
+	local path=$3
+	local usage_start=$(cat ${path}memory.usage_in_bytes)
+
 	kill -s USR1 $pid 2> /dev/null
-	sleep 1
+
+	if [ -z "$size" ]; then
+		return
+	fi
+
+	local loops=100
+
+	while kill -0 $pid 2> /dev/null; do
+		local usage=$(cat ${path}memory.usage_in_bytes)
+		local diff_a=$((usage_start - usage))
+		local diff_b=$((usage - usage_start))
+
+		if [ "$diff_a" -ge "$size" -o "$diff_b" -ge "$size" ]; then
+			return
+		fi
+
+		tst_sleep 100ms
+
+		loops=$((loops - 1))
+		if [ $loops -le 0 ]; then
+			tst_brkm TBROK "timeouted on memory.usage_in_bytes"
+		fi
+	done
 }
 
 stop_memcg_process()
 {
-	pid=$1
+	local pid=$1
 	kill -s INT $pid 2> /dev/null
 	wait $pid
 }
 
 warmup()
 {
-	pid=$1
+	local pid=$1
 
 	tst_resm TINFO "Warming up pid: $pid"
 	signal_memcg_process $pid
 	signal_memcg_process $pid
+	sleep 1
 
 	kill -0 $pid
 	if [ $? -ne 0 ]; then
@@ -123,15 +150,17 @@ warmup()
 
 # Run test cases which checks memory.stat after make
 # some memory allocation
-# $1 - the parameters of 'process', such as --shm
-# $2 - the -s parameter of 'process', such as 4096
-# $3 - item name in memory.stat
-# $4 - the expected size
-# $5 - check after free ?
 test_mem_stat()
 {
-	tst_resm TINFO "Running memcg_process $1 -s $2"
-	memcg_process $1 -s $2 &
+	local memtypes="$1"
+	local size=$2
+	local total_size=$3
+	local stat_name=$4
+	local exp_stat_size=$5
+	local check_after_free=$6
+
+	tst_resm TINFO "Running memcg_process $memtypes -s $size"
+	memcg_process $memtypes -s $size &
 	TST_CHECKPOINT_WAIT 0
 
 	warmup $!
@@ -140,13 +169,13 @@ test_mem_stat()
 	fi
 
 	echo $! > tasks
-	signal_memcg_process $!
+	signal_memcg_process $! $size
 
-	check_mem_stat $3 $4
+	check_mem_stat $stat_name $exp_stat_size
 
-	signal_memcg_process $!
-	if [ $5 -eq 1 ]; then
-		check_mem_stat $3 0
+	signal_memcg_process $! $size
+	if $check_after_free; then
+		check_mem_stat $stat_name 0
 	fi
 
 	stop_memcg_process $!
@@ -171,8 +200,8 @@ test_max_usage_in_bytes()
 	fi
 
 	echo $! > tasks
-	signal_memcg_process $!
-	signal_memcg_process $!
+	signal_memcg_process $! $2
+	signal_memcg_process $! $2
 
 	check_mem_stat $3 $4
 
@@ -194,8 +223,8 @@ malloc_free_memory()
 	TST_CHECKPOINT_WAIT 0
 
 	echo $! > tasks
-	signal_memcg_process $!
-	signal_memcg_process $!
+	signal_memcg_process $! $2
+	signal_memcg_process $! $2
 
 	stop_memcg_process $!
 }
@@ -234,7 +263,7 @@ test_proc_kill()
 	TST_CHECKPOINT_WAIT 0
 	echo $pid > tasks
 
-	signal_memcg_process $pid
+	signal_memcg_process $pid $3
 
 	tpk_pid_exists=1
 	for tpk_iter in $(seq 20); do
@@ -311,7 +340,7 @@ test_hugepage()
 	memcg_process $2 --hugepage -s $3 > $TMP_FILE 2>&1 &
 	TST_CHECKPOINT_WAIT 0
 
-	signal_memcg_process $!
+	signal_memcg_process $! $3
 
 	check_mem_stat "rss" 0
 
@@ -323,14 +352,14 @@ test_hugepage()
 		if [ $? -eq 0 ]; then
 			tst_resm TPASS "allocate hugepage failed as expected"
 		else
-			signal_memcg_process $!
+			signal_memcg_process $! $3
 			stop_memcg_process $!
 			tst_resm TFAIL "allocate hugepage should fail"
 		fi
 	else
 		test ! -s $TMP_FILE
 		if [ $? -eq 0 ]; then
-			signal_memcg_process $!
+			signal_memcg_process $! $3
 			stop_memcg_process $!
 			tst_resm TPASS "allocate hugepage succeeded"
 		else
@@ -358,13 +387,13 @@ test_subgroup()
 	memcg_process --mmap-anon -s $PAGESIZE &
 	TST_CHECKPOINT_WAIT 0
 
-	warmup $!
+	warmup $! $PAGESIZE
 	if [ $? -ne 0 ]; then
 		return
 	fi
 
 	echo $! > tasks
-	signal_memcg_process $!
+	signal_memcg_process $! $PAGESIZE
 	check_mem_stat "rss" $PAGESIZE
 
 	cd subgroup
@@ -379,17 +408,21 @@ test_subgroup()
 }
 
 # Run test cases which test memory.move_charge_at_immigrate
-# $1 - the parameters of 'process', such as --shm
-# $2 - the -s parameter of 'process', such as 4096
-# $3 - some positive value, such as 1
-# $4 - the expected size
-# $5 - the expected size
 test_move_charge()
 {
+	local memtypes="$1"
+	local size=$2
+	local total_size=$3
+	local move_charge_mask=$4
+	local b_rss=$5
+	local b_cache=$6
+	local a_rss=$7
+	local a_cache=$8
+
 	mkdir subgroup_a
 
-	tst_resm TINFO "Running memcg_process $1 -s $2"
-	memcg_process $1 -s $2 &
+	tst_resm TINFO "Running memcg_process $memtypes -s $size"
+	memcg_process $memtypes -s $size &
 	TST_CHECKPOINT_WAIT 0
 	warmup $!
 	if [ $? -ne 0 ]; then
@@ -398,22 +431,19 @@ test_move_charge()
 	fi
 
 	echo $! > subgroup_a/tasks
-	signal_memcg_process $!
+	signal_memcg_process $! $total_size "subgroup_a/"
 
 	mkdir subgroup_b
-	echo $3 > subgroup_b/memory.move_charge_at_immigrate
+	echo $move_charge_mask > subgroup_b/memory.move_charge_at_immigrate
 	echo $! > subgroup_b/tasks
 
 	cd subgroup_b
-	check_mem_stat "rss" $4
-	check_mem_stat "cache" $5
+	check_mem_stat "rss" $b_rss
+	check_mem_stat "cache" $b_cache
 	cd ../subgroup_a
-	check_mem_stat "rss" $6
-	check_mem_stat "cache" $7
-
+	check_mem_stat "rss" $a_rss
+	check_mem_stat "cache" $a_cache
 	cd ..
-	echo $! > tasks
-	signal_memcg_process $!
 	stop_memcg_process $!
 	rmdir subgroup_a subgroup_b
 }
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_move_charge_at_immigrate_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_move_charge_at_immigrate_test.sh
index aeb7d0f..6cdc7ed 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_move_charge_at_immigrate_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_move_charge_at_immigrate_test.sh
@@ -34,27 +34,28 @@ TST_TOTAL=4
 # Test disable moving charges
 testcase_1()
 {
-	test_move_charge "--mmap-anon" $PAGESIZE  0 0 0 $PAGESIZE 0
+	test_move_charge "--mmap-anon" $PAGESIZE $PAGESIZE 0 0 0 $PAGESIZE 0
 }
 
 # Test move anon
 testcase_2()
 {
-	test_move_charge "--mmap-anon --shm --mmap-file" $PAGESIZE 1 \
-		$PAGESIZE 0 0 $((PAGESIZE*2))
+	test_move_charge "--mmap-anon --shm --mmap-file" $PAGESIZE \
+		$((PAGESIZE*3)) 1 $PAGESIZE 0 0 $((PAGESIZE*2))
 }
 
 # Test move file
 testcase_3()
 {
-	test_move_charge "--mmap-anon --shm --mmap-file" $PAGESIZE 2 \
-		0 $((PAGESIZE*2)) $PAGESIZE 0
+	test_move_charge "--mmap-anon --shm --mmap-file" $PAGESIZE \
+		$((PAGESIZE*3)) 2 0 $((PAGESIZE*2)) $PAGESIZE 0
 }
 
 # Test move anon and file
 testcase_4()
 {
-	test_move_charge "--mmap-anon --shm" $PAGESIZE 3 $PAGESIZE $PAGESIZE 0 0
+	test_move_charge "--mmap-anon --shm" $PAGESIZE \
+		$((PAGESIZE*2)) 3 $PAGESIZE $PAGESIZE 0 0
 }
 
 run_tests
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh
index 1f28aa4..2c47a92 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh
@@ -34,25 +34,28 @@ TST_TOTAL=8
 # Test cache
 testcase_1()
 {
-	test_mem_stat "--shm -k 3" $PAGESIZE "cache" $PAGESIZE 0
+	test_mem_stat "--shm -k 3" $PAGESIZE $PAGESIZE "cache" $PAGESIZE false
 }
 
 # Test mapped_file
 testcase_2()
 {
-	test_mem_stat "--mmap-file" $PAGESIZE "mapped_file" $PAGESIZE 0
+	test_mem_stat "--mmap-file" $PAGESIZE $PAGESIZE \
+		"mapped_file" $PAGESIZE false
 }
 
 # Test unevictable with MAP_LOCKED
 testcase_3()
 {
-	test_mem_stat "--mmap-lock1" $PAGESIZE "unevictable" $PAGESIZE 0
+	test_mem_stat "--mmap-lock1" $PAGESIZE $PAGESIZE \
+		"unevictable" $PAGESIZE false
 }
 
 # Test unevictable with mlock
 testcase_4()
 {
-	test_mem_stat "--mmap-lock2" $PAGESIZE "unevictable" $PAGESIZE 0
+	test_mem_stat "--mmap-lock2" $PAGESIZE $PAGESIZE \
+		"unevictable" $PAGESIZE false
 }
 
 # Test hierarchical_memory_limit with enabling hierarchical accounting
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_usage_in_bytes_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_usage_in_bytes_test.sh
index ab86318..8e2e628 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_usage_in_bytes_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_usage_in_bytes_test.sh
@@ -34,8 +34,8 @@ TST_TOTAL=2
 # Test memory.usage_in_bytes
 testcase_1()
 {
-	test_mem_stat "--mmap-anon" $((PAGESIZE*1024)) \
-		"memory.usage_in_bytes" $((PAGESIZE*1024)) 0
+	test_mem_stat "--mmap-anon" $((PAGESIZE*1024)) $((PAGESIZE*1024)) \
+		"memory.usage_in_bytes" $((PAGESIZE*1024)) false
 }
 
 # Test memory.memsw.usage_in_bytes
@@ -48,8 +48,8 @@ testcase_2()
 
 	echo $((PAGESIZE*2048)) > memory.limit_in_bytes
 	echo $((PAGESIZE*2048)) > memory.memsw.limit_in_bytes
-	test_mem_stat "--mmap-anon" $((PAGESIZE*1024)) \
-		"memory.memsw.usage_in_bytes" $((PAGESIZE*1024)) 0
+	test_mem_stat "--mmap-anon" $((PAGESIZE*1024)) $((PAGESIZE*1024)) \
+		"memory.memsw.usage_in_bytes" $((PAGESIZE*1024)) false
 }
 
 run_tests
-- 
2.7.3


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP] [PATCH V2 4/6] memcg_function_test.sh: Split
  2016-09-05 15:24 [LTP] [PATCH V2 1/6] memcg_lib.sh: Print test number at test start Cyril Hrubis
  2016-09-05 15:24 ` [LTP] [PATCH V2 2/6] memcg_lib.sh: Move all the kill -s XXX to functions Cyril Hrubis
  2016-09-05 15:24 ` [LTP] [PATCH V2 3/6] memcg_lib.sh: Get rid of sleep 1 in signal_memcg_process Cyril Hrubis
@ 2016-09-05 15:24 ` Cyril Hrubis
  2016-09-08  9:10   ` Stanislav Kholmanskikh
  2016-09-05 15:24 ` [LTP] [PATCH 5/6] memcg_lib.sh: Remove subdirectories in cleanup Cyril Hrubis
  2016-09-05 15:24 ` [LTP] [PATCH 6/6] memcg_control_test.sh: Simplify runtest file Cyril Hrubis
  4 siblings, 1 reply; 10+ messages in thread
From: Cyril Hrubis @ 2016-09-05 15:24 UTC (permalink / raw)
  To: ltp

Split the memcg_function_test.sh into five tests based on what is
tested.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 runtest/controllers                                |   6 +-
 .../controllers/memcg/functional/memcg_failcnt.sh  |  58 +++++
 .../memcg/functional/memcg_force_empty.sh          |  90 +++++++
 .../memcg/functional/memcg_function_test.sh        | 286 ---------------------
 .../controllers/memcg/functional/memcg_lib.sh      |  15 ++
 .../memcg/functional/memcg_limit_in_bytes.sh       | 127 +++++++++
 .../controllers/memcg/functional/memcg_stat_rss.sh |  89 +++++++
 .../memcg/functional/memcg_subgroup_charge.sh      |  50 ++++
 8 files changed, 434 insertions(+), 287 deletions(-)
 create mode 100755 testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh
 create mode 100755 testcases/kernel/controllers/memcg/functional/memcg_force_empty.sh
 delete mode 100755 testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
 create mode 100755 testcases/kernel/controllers/memcg/functional/memcg_limit_in_bytes.sh
 create mode 100755 testcases/kernel/controllers/memcg/functional/memcg_stat_rss.sh
 create mode 100755 testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh

diff --git a/runtest/controllers b/runtest/controllers
index bec883b..d14d81e 100644
--- a/runtest/controllers
+++ b/runtest/controllers
@@ -1,7 +1,11 @@
 #DESCRIPTION:Resource Management testing
 cgroup		cgroup_regression_test.sh
 memcg_regression	memcg_regression_test.sh
-memcg_function		memcg_function_test.sh
+memcg_failcnt memcg_failcnt.sh
+memcg_force_empty memcg_force_empty.sh
+memcg_limit_in_bytes memcg_limit_in_bytes.sh
+memcg_stat_rss memcg_stat_rss.sh
+memcg_subgroup_charge memcg_subgroup_charge.sh
 memcg_max_usage_in_bytes	memcg_max_usage_in_bytes_test.sh
 memcg_move_charge_at_immigrate	memcg_move_charge_at_immigrate_test.sh
 memcg_memsw_limit_in_bytes	memcg_memsw_limit_in_bytes_test.sh
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh b/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh
new file mode 100755
index 0000000..d5034a5
--- /dev/null
+++ b/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+################################################################################
+##                                                                            ##
+## Copyright (c) 2009 FUJITSU LIMITED                                         ##
+##                                                                            ##
+## This program is free software;  you can redistribute it and#or modify      ##
+## it under the terms of the GNU General Public License as published by       ##
+## the Free Software Foundation; either version 2 of the License, or          ##
+## (at your option) any later version.                                        ##
+##                                                                            ##
+## This program is distributed in the hope that it will be useful, but        ##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
+## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
+## for more details.                                                          ##
+##                                                                            ##
+## You should have received a copy of the GNU General Public License          ##
+## along with this program;  if not, write to the Free Software Foundation,   ##
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
+##                                                                            ##
+## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
+## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
+## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
+##						<risrajak@linux.vnet.ibm.com  ##
+##                                                                            ##
+################################################################################
+
+TCID="memcg_failcnt"
+TST_TOTAL=3
+
+. memcg_lib.sh
+
+# Test memory.failcnt
+testcase_1()
+{
+	echo $PAGESIZE > memory.limit_in_bytes
+	malloc_free_memory "--mmap-anon" $(($PAGESIZE*2))
+	test_failcnt "memory.failcnt"
+}
+
+testcase_2()
+{
+	echo $PAGESIZE > memory.limit_in_bytes
+	malloc_free_memory "--mmap-file" $(($PAGESIZE*2))
+	test_failcnt "memory.failcnt"
+}
+
+testcase_3()
+{
+	echo $PAGESIZE > memory.limit_in_bytes
+	malloc_free_memory "--shm" $(($PAGESIZE*2))
+	test_failcnt "memory.failcnt"
+}
+
+shmmax_setup
+LOCAL_CLEANUP=shmmax_cleanup
+run_tests
+tst_exit
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_force_empty.sh b/testcases/kernel/controllers/memcg/functional/memcg_force_empty.sh
new file mode 100755
index 0000000..59cb0b5
--- /dev/null
+++ b/testcases/kernel/controllers/memcg/functional/memcg_force_empty.sh
@@ -0,0 +1,90 @@
+#!/bin/sh
+
+################################################################################
+##                                                                            ##
+## Copyright (c) 2009 FUJITSU LIMITED                                         ##
+##                                                                            ##
+## This program is free software;  you can redistribute it and#or modify      ##
+## it under the terms of the GNU General Public License as published by       ##
+## the Free Software Foundation; either version 2 of the License, or          ##
+## (at your option) any later version.                                        ##
+##                                                                            ##
+## This program is distributed in the hope that it will be useful, but        ##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
+## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
+## for more details.                                                          ##
+##                                                                            ##
+## You should have received a copy of the GNU General Public License          ##
+## along with this program;  if not, write to the Free Software Foundation,   ##
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
+##                                                                            ##
+## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
+## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
+## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
+##						<risrajak@linux.vnet.ibm.com  ##
+##                                                                            ##
+################################################################################
+
+TCID="memcg_force_empty"
+TST_TOTAL=6
+
+. memcg_lib.sh
+
+# Test memory.force_empty
+testcase_1()
+{
+	memcg_process --mmap-anon -s $PAGESIZE &
+	pid=$!
+	TST_CHECKPOINT_WAIT 0
+	echo $pid > tasks
+	signal_memcg_process $pid $PAGESIZE
+	echo $pid > ../tasks
+
+	# This expects that there is swap configured
+	EXPECT_PASS echo 1 \> memory.force_empty
+
+	stop_memcg_process $pid
+}
+
+testcase_2()
+{
+	memcg_process --mmap-lock2 -s $PAGESIZE &
+	pid=$!
+	TST_CHECKPOINT_WAIT 0
+	echo $pid > tasks
+	signal_memcg_process $pid $PAGESIZE
+
+	EXPECT_FAIL echo 1 \> memory.force_empty
+
+	stop_memcg_process $pid
+}
+
+testcase_3()
+{
+	EXPECT_PASS echo 0 \> memory.force_empty
+}
+
+testcase_4()
+{
+	EXPECT_PASS echo 1.0 \> memory.force_empty
+}
+
+testcase_4()
+{
+	EXPECT_PASS echo 1xx \> memory.force_empty
+}
+
+testcase_5()
+{
+	EXPECT_PASS echo xx \> memory.force_empty
+}
+
+testcase_6()
+{
+	# writing to non-empty top mem cgroup's force_empty
+	# should return failure
+	EXPECT_FAIL echo 1 \> /dev/memcg/memory.force_empty
+}
+
+run_tests
+tst_exit
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
deleted file mode 100755
index fadbcea..0000000
--- a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
+++ /dev/null
@@ -1,286 +0,0 @@
-#! /bin/sh
-
-################################################################################
-##                                                                            ##
-## Copyright (c) 2009 FUJITSU LIMITED                                         ##
-##                                                                            ##
-## This program is free software;  you can redistribute it and#or modify      ##
-## it under the terms of the GNU General Public License as published by       ##
-## the Free Software Foundation; either version 2 of the License, or          ##
-## (at your option) any later version.                                        ##
-##                                                                            ##
-## This program is distributed in the hope that it will be useful, but        ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
-## for more details.                                                          ##
-##                                                                            ##
-## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
-##                                                                            ##
-## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
-## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
-## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
-##						<risrajak@linux.vnet.ibm.com  ##
-##                                                                            ##
-################################################################################
-
-TCID="memcg_function_test"
-TST_TOTAL=38
-
-shmmax_cleanup()
-{
-	if [ -n "$shmmax" ]; then
-		echo "$shmmax" > /proc/sys/kernel/shmmax
-	fi
-}
-LOCAL_CLEANUP=shmmax_cleanup
-
-. memcg_lib.sh
-
-# Case 1 - 10: Test the management and counting of memory
-testcase_1()
-{
-	test_mem_stat "--mmap-anon" $PAGESIZE $PAGESIZE "rss" $PAGESIZE false
-}
-
-testcase_2()
-{
-	test_mem_stat "--mmap-file" $PAGESIZE $PAGESIZE "rss" 0 false
-}
-
-testcase_3()
-{
-	test_mem_stat "--shm -k 3" $PAGESIZE $PAGESIZE "rss" 0 false
-}
-
-testcase_4()
-{
-	test_mem_stat "--mmap-anon --mmap-file --shm" \
-		$PAGESIZE $((PAGESIZE*3)) "rss" $PAGESIZE false
-}
-
-testcase_5()
-{
-	test_mem_stat "--mmap-lock1" $PAGESIZE $PAGESIZE "rss" $PAGESIZE false
-}
-
-testcase_6()
-{
-	test_mem_stat "--mmap-anon" $PAGESIZE $PAGESIZE "rss" $PAGESIZE true
-}
-
-testcase_7()
-{
-	test_mem_stat "--mmap-file" $PAGESIZE $PAGESIZE "rss" 0 true
-}
-
-testcase_8()
-{
-	test_mem_stat "--shm -k 8" $PAGESIZE $PAGESIZE "rss" 0 true
-}
-
-testcase_9()
-{
-	test_mem_stat "--mmap-anon --mmap-file --shm" \
-		$PAGESIZE $((PAGESIZE*3)) "rss" $PAGESIZE true
-}
-
-testcase_10()
-{
-	test_mem_stat "--mmap-lock1" $PAGESIZE $PAGESIZE "rss" $PAGESIZE true
-}
-
-# Case 11 - 13: Test memory.failcnt
-testcase_11()
-{
-	echo $PAGESIZE > memory.limit_in_bytes
-	malloc_free_memory "--mmap-anon" $(($PAGESIZE*2))
-	test_failcnt "memory.failcnt"
-}
-
-testcase_12()
-{
-	echo $PAGESIZE > memory.limit_in_bytes
-	malloc_free_memory "--mmap-file" $(($PAGESIZE*2))
-	test_failcnt "memory.failcnt"
-}
-
-testcase_13()
-{
-	echo $PAGESIZE > memory.limit_in_bytes
-	malloc_free_memory "--shm" $(($PAGESIZE*2))
-	test_failcnt "memory.failcnt"
-}
-
-# Case 14 - 15: Test mmap(locked) + alloc_mem > limit_in_bytes
-testcase_14()
-{
-	test_proc_kill $PAGESIZE "--mmap-lock1" $((PAGESIZE*2)) 0
-}
-
-testcase_15()
-{
-	test_proc_kill $PAGESIZE "--mmap-lock2" $((PAGESIZE*2)) 0
-}
-
-# Case 16 - 18: Test swapoff + alloc_mem > limi_in_bytes
-testcase_16()
-{
-	swapoff -a
-	test_proc_kill $PAGESIZE "--mmap-anon" $((PAGESIZE*2)) 0
-	swapon -a
-}
-
-testcase_17()
-{
-	swapoff -a
-	test_proc_kill $PAGESIZE "--mmap-file" $((PAGESIZE*2)) 0
-	swapon -a
-}
-
-testcase_18()
-{
-	swapoff -a
-	test_proc_kill $PAGESIZE "--shm -k 18" $((PAGESIZE*2)) 0
-	swapon -a
-}
-
-# Case 19 - 21: Test limit_in_bytes == 0
-testcase_19()
-{
-	test_proc_kill 0 "--mmap-anon" $PAGESIZE 0
-}
-
-testcase_20()
-{
-	test_proc_kill 0 "--mmap-file" $PAGESIZE 0
-}
-
-testcase_21()
-{
-	test_proc_kill 0 "--shm -k 21" $PAGESIZE 0
-}
-
-# Case 22 - 24: Test limit_in_bytes will be aligned to PAGESIZE
-testcase_22()
-{
-	test_limit_in_bytes $((PAGESIZE-1)) 0
-}
-
-testcase_23()
-{
-	test_limit_in_bytes $((PAGESIZE+1)) 0
-}
-
-testcase_24()
-{
-	test_limit_in_bytes 1 0
-}
-
-# Case 25 - 28: Test invaild memory.limit_in_bytes
-testcase_25()
-{
-	tst_kvercmp 2 6 31
-	if [ $? -eq 0 ]; then
-		EXPECT_FAIL echo -1 \> memory.limit_in_bytes
-	else
-		EXPECT_PASS echo -1 \> memory.limit_in_bytes
-	fi
-}
-
-testcase_26()
-{
-	EXPECT_FAIL echo 1.0 \> memory.limit_in_bytes
-}
-
-testcase_27()
-{
-	EXPECT_FAIL echo 1xx \> memory.limit_in_bytes
-}
-
-testcase_28()
-{
-	EXPECT_FAIL echo xx \> memory.limit_in_bytes
-}
-
-# Case 29 - 35: Test memory.force_empty
-testcase_29()
-{
-	memcg_process --mmap-anon -s $PAGESIZE &
-	pid=$!
-	TST_CHECKPOINT_WAIT 0
-	echo $pid > tasks
-	signal_memcg_process $pid $PAGESIZE
-	echo $pid > ../tasks
-
-	# This expects that there is swap configured
-	EXPECT_PASS echo 1 \> memory.force_empty
-
-	stop_memcg_process $pid
-}
-
-testcase_30()
-{
-	memcg_process --mmap-lock2 -s $PAGESIZE &
-	pid=$!
-	TST_CHECKPOINT_WAIT 0
-	echo $pid > tasks
-	signal_memcg_process $pid $PAGESIZE
-
-	EXPECT_FAIL echo 1 \> memory.force_empty
-
-	stop_memcg_process $pid
-}
-
-testcase_31()
-{
-	EXPECT_PASS echo 0 \> memory.force_empty
-}
-
-testcase_32()
-{
-	EXPECT_PASS echo 1.0 \> memory.force_empty
-}
-
-testcase_33()
-{
-	EXPECT_PASS echo 1xx \> memory.force_empty
-}
-
-testcase_34()
-{
-	EXPECT_PASS echo xx \> memory.force_empty
-}
-
-testcase_35()
-{
-	# writing to non-empty top mem cgroup's force_empty
-	# should return failure
-	EXPECT_FAIL echo 1 \> /dev/memcg/memory.force_empty
-}
-
-# Case 36 - 38: Test that group and subgroup have no relationship
-testcase_36()
-{
-	test_subgroup $PAGESIZE $((2*PAGESIZE))
-}
-
-testcase_37()
-{
-	test_subgroup $PAGESIZE $PAGESIZE
-}
-
-testcase_38()
-{
-	test_subgroup $PAGESIZE 0
-}
-
-shmmax=`cat /proc/sys/kernel/shmmax`
-if [ $shmmax -lt $HUGEPAGESIZE ]; then
-	ROD echo "$HUGEPAGESIZE" \> /proc/sys/kernel/shmmax
-fi
-
-run_tests
-
-tst_exit
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
index c34198a..1bf0143 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
@@ -69,6 +69,21 @@ cleanup()
 }
 TST_CLEANUP=cleanup
 
+shmmax_setup()
+{
+	shmmax=`cat /proc/sys/kernel/shmmax`
+	if [ $shmmax -lt $HUGEPAGESIZE ]; then
+		ROD echo "$HUGEPAGESIZE" \> /proc/sys/kernel/shmmax
+	fi
+}
+
+shmmax_cleanup()
+{
+	if [ -n "$shmmax" ]; then
+		echo "$shmmax" > /proc/sys/kernel/shmmax
+	fi
+}
+
 # Check size in memcg
 # $1 - Item name
 # $2 - Expected size
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_limit_in_bytes.sh b/testcases/kernel/controllers/memcg/functional/memcg_limit_in_bytes.sh
new file mode 100755
index 0000000..8ada7d1
--- /dev/null
+++ b/testcases/kernel/controllers/memcg/functional/memcg_limit_in_bytes.sh
@@ -0,0 +1,127 @@
+#!/bin/sh
+
+################################################################################
+##                                                                            ##
+## Copyright (c) 2009 FUJITSU LIMITED                                         ##
+##                                                                            ##
+## This program is free software;  you can redistribute it and#or modify      ##
+## it under the terms of the GNU General Public License as published by       ##
+## the Free Software Foundation; either version 2 of the License, or          ##
+## (at your option) any later version.                                        ##
+##                                                                            ##
+## This program is distributed in the hope that it will be useful, but        ##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
+## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
+## for more details.                                                          ##
+##                                                                            ##
+## You should have received a copy of the GNU General Public License          ##
+## along with this program;  if not, write to the Free Software Foundation,   ##
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
+##                                                                            ##
+## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
+## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
+## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
+##						<risrajak@linux.vnet.ibm.com  ##
+##                                                                            ##
+################################################################################
+
+TCID="memcg_limit_in_bytes"
+TST_TOTAL=15
+
+. memcg_lib.sh
+
+# Test mmap(locked) + alloc_mem > limit_in_bytes
+testcase_1()
+{
+	test_proc_kill $PAGESIZE "--mmap-lock1" $((PAGESIZE*2)) 0
+}
+
+testcase_2()
+{
+	test_proc_kill $PAGESIZE "--mmap-lock2" $((PAGESIZE*2)) 0
+}
+
+# Test swapoff + alloc_mem > limit_in_bytes
+testcase_3()
+{
+	swapoff -a
+	test_proc_kill $PAGESIZE "--mmap-anon" $((PAGESIZE*2)) 0
+	swapon -a
+}
+
+testcase_4()
+{
+	swapoff -a
+	test_proc_kill $PAGESIZE "--mmap-file" $((PAGESIZE*2)) 0
+	swapon -a
+}
+
+testcase_5()
+{
+	swapoff -a
+	test_proc_kill $PAGESIZE "--shm -k 18" $((PAGESIZE*2)) 0
+	swapon -a
+}
+
+# Test limit_in_bytes == 0
+testcase_6()
+{
+	test_proc_kill 0 "--mmap-anon" $PAGESIZE 0
+}
+
+testcase_7()
+{
+	test_proc_kill 0 "--mmap-file" $PAGESIZE 0
+}
+
+testcase_8()
+{
+	test_proc_kill 0 "--shm -k 21" $PAGESIZE 0
+}
+
+# Test limit_in_bytes will be aligned to PAGESIZE
+testcase_9()
+{
+	test_limit_in_bytes $((PAGESIZE-1)) 0
+}
+
+testcase_10()
+{
+	test_limit_in_bytes $((PAGESIZE+1)) 0
+}
+
+testcase_11()
+{
+	test_limit_in_bytes 1 0
+}
+
+# Test invalid memory.limit_in_bytes
+testcase_12()
+{
+	tst_kvercmp 2 6 31
+	if [ $? -eq 0 ]; then
+		EXPECT_FAIL echo -1 \> memory.limit_in_bytes
+	else
+		EXPECT_PASS echo -1 \> memory.limit_in_bytes
+	fi
+}
+
+testcase_13()
+{
+	EXPECT_FAIL echo 1.0 \> memory.limit_in_bytes
+}
+
+testcase_14()
+{
+	EXPECT_FAIL echo 1xx \> memory.limit_in_bytes
+}
+
+testcase_15()
+{
+	EXPECT_FAIL echo xx \> memory.limit_in_bytes
+}
+
+shmmax_setup
+LOCAL_CLEANUP=shmmax_cleanup
+run_tests
+tst_exit
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_stat_rss.sh b/testcases/kernel/controllers/memcg/functional/memcg_stat_rss.sh
new file mode 100755
index 0000000..a41e157
--- /dev/null
+++ b/testcases/kernel/controllers/memcg/functional/memcg_stat_rss.sh
@@ -0,0 +1,89 @@
+#!/bin/sh
+
+################################################################################
+##                                                                            ##
+## Copyright (c) 2009 FUJITSU LIMITED                                         ##
+##                                                                            ##
+## This program is free software;  you can redistribute it and#or modify      ##
+## it under the terms of the GNU General Public License as published by       ##
+## the Free Software Foundation; either version 2 of the License, or          ##
+## (at your option) any later version.                                        ##
+##                                                                            ##
+## This program is distributed in the hope that it will be useful, but        ##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
+## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
+## for more details.                                                          ##
+##                                                                            ##
+## You should have received a copy of the GNU General Public License          ##
+## along with this program;  if not, write to the Free Software Foundation,   ##
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
+##                                                                            ##
+## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
+## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
+## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
+##						<risrajak@linux.vnet.ibm.com  ##
+##                                                                            ##
+################################################################################
+
+TCID="memcg_stat_rss"
+TST_TOTAL=10
+
+. memcg_lib.sh
+
+# Test the management and counting of memory
+testcase_1()
+{
+	test_mem_stat "--mmap-anon" $PAGESIZE $PAGESIZE "rss" $PAGESIZE false
+}
+
+testcase_2()
+{
+	test_mem_stat "--mmap-file" $PAGESIZE $PAGESIZE "rss" 0 false
+}
+
+testcase_3()
+{
+	test_mem_stat "--shm -k 3" $PAGESIZE $PAGESIZE "rss" 0 false
+}
+
+testcase_4()
+{
+	test_mem_stat "--mmap-anon --mmap-file --shm" \
+		$PAGESIZE $((PAGESIZE*3)) "rss" $PAGESIZE false
+}
+
+testcase_5()
+{
+	test_mem_stat "--mmap-lock1" $PAGESIZE $PAGESIZE "rss" $PAGESIZE false
+}
+
+testcase_6()
+{
+	test_mem_stat "--mmap-anon" $PAGESIZE $PAGESIZE "rss" $PAGESIZE true
+}
+
+testcase_7()
+{
+	test_mem_stat "--mmap-file" $PAGESIZE $PAGESIZE "rss" 0 true
+}
+
+testcase_8()
+{
+	test_mem_stat "--shm -k 8" $PAGESIZE $PAGESIZE "rss" 0 true
+}
+
+testcase_9()
+{
+	test_mem_stat "--mmap-anon --mmap-file --shm" \
+		$PAGESIZE $((PAGESIZE*3)) "rss" $PAGESIZE true
+}
+
+testcase_10()
+{
+	test_mem_stat "--mmap-lock1" $PAGESIZE $PAGESIZE "rss" $PAGESIZE true
+}
+
+shmmax_setup
+LOCAL_CLEANUP=shmmax_cleanup
+run_tests
+tst_exit
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
new file mode 100755
index 0000000..2efe291
--- /dev/null
+++ b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+################################################################################
+##                                                                            ##
+## Copyright (c) 2009 FUJITSU LIMITED                                         ##
+##                                                                            ##
+## This program is free software;  you can redistribute it and#or modify      ##
+## it under the terms of the GNU General Public License as published by       ##
+## the Free Software Foundation; either version 2 of the License, or          ##
+## (at your option) any later version.                                        ##
+##                                                                            ##
+## This program is distributed in the hope that it will be useful, but        ##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
+## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
+## for more details.                                                          ##
+##                                                                            ##
+## You should have received a copy of the GNU General Public License          ##
+## along with this program;  if not, write to the Free Software Foundation,   ##
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
+##                                                                            ##
+## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
+## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
+## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
+##						<risrajak@linux.vnet.ibm.com  ##
+##                                                                            ##
+################################################################################
+
+TCID="memcg_subgroup_charge"
+TST_TOTAL=3
+
+. memcg_lib.sh
+
+# Case 36 - 38: Test that group and subgroup have no relationship
+testcase_36()
+{
+	test_subgroup $PAGESIZE $((2*PAGESIZE))
+}
+
+testcase_37()
+{
+	test_subgroup $PAGESIZE $PAGESIZE
+}
+
+testcase_38()
+{
+	test_subgroup $PAGESIZE 0
+}
+
+run_tests
+tst_exit
-- 
2.7.3


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP] [PATCH 5/6] memcg_lib.sh: Remove subdirectories in cleanup
  2016-09-05 15:24 [LTP] [PATCH V2 1/6] memcg_lib.sh: Print test number at test start Cyril Hrubis
                   ` (2 preceding siblings ...)
  2016-09-05 15:24 ` [LTP] [PATCH V2 4/6] memcg_function_test.sh: Split Cyril Hrubis
@ 2016-09-05 15:24 ` Cyril Hrubis
  2016-09-05 15:24 ` [LTP] [PATCH 6/6] memcg_control_test.sh: Simplify runtest file Cyril Hrubis
  4 siblings, 0 replies; 10+ messages in thread
From: Cyril Hrubis @ 2016-09-05 15:24 UTC (permalink / raw)
  To: ltp

Some tests create subdirectories in the memcg directory created for the
testcase, namely the move_charge_at_immigrate ones. Hence we need to
remove all subdirectories before we attempt to remove the test
directory. Otherwise the test will not clean up properly on TBROK.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/controllers/memcg/functional/memcg_lib.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
index 1bf0143..b785fe3 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
@@ -57,6 +57,12 @@ cleanup()
 	cd "$TMP_DIR"
 
 	if [ -n "$TEST_ID" -a -d "/dev/memcg/$TEST_ID" ]; then
+		for i in "/dev/memcg/$TEST_ID/"*; do
+			if [ -d "$i" ]; then
+				rmdir "$i"
+			fi
+		done
+
 		rmdir "/dev/memcg/$TEST_ID"
 	fi
 
-- 
2.7.3


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP] [PATCH 6/6] memcg_control_test.sh: Simplify runtest file
  2016-09-05 15:24 [LTP] [PATCH V2 1/6] memcg_lib.sh: Print test number at test start Cyril Hrubis
                   ` (3 preceding siblings ...)
  2016-09-05 15:24 ` [LTP] [PATCH 5/6] memcg_lib.sh: Remove subdirectories in cleanup Cyril Hrubis
@ 2016-09-05 15:24 ` Cyril Hrubis
  2016-09-08  9:20   ` Stanislav Kholmanskikh
  4 siblings, 1 reply; 10+ messages in thread
From: Cyril Hrubis @ 2016-09-05 15:24 UTC (permalink / raw)
  To: ltp

This commit makes use of $(getconf PAGESIZE) instead of the mem_process
and also moves the parameters to the test itself as there is no need to
keep these outside the script.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 runtest/controllers                                              | 2 +-
 testcases/kernel/controllers/memcg/control/mem_process.c         | 3 ---
 testcases/kernel/controllers/memcg/control/memcg_control_test.sh | 8 +++++---
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/runtest/controllers b/runtest/controllers
index d14d81e..b904e05 100644
--- a/runtest/controllers
+++ b/runtest/controllers
@@ -13,7 +13,7 @@ memcg_stat	memcg_stat_test.sh
 memcg_use_hierarchy	memcg_use_hierarchy_test.sh
 memcg_usage_in_bytes	memcg_usage_in_bytes_test.sh
 memcg_stress		memcg_stress_test.sh
-memcg_control		PAGESIZE=$(mem_process -p);memcg_control_test.sh $PAGESIZE $PAGESIZE $((PAGESIZE * 2))
+memcg_control		memcg_control_test.sh
 
 cgroup_fj_function_debug cgroup_fj_function.sh debug
 cgroup_fj_function_cpuset cgroup_fj_function.sh cpuset
diff --git a/testcases/kernel/controllers/memcg/control/mem_process.c b/testcases/kernel/controllers/memcg/control/mem_process.c
index 48cdea8..9007c2c 100644
--- a/testcases/kernel/controllers/memcg/control/mem_process.c
+++ b/testcases/kernel/controllers/memcg/control/mem_process.c
@@ -60,9 +60,6 @@ void process_options(int argc, char **argv)
 			if (*end != '\0')
 				errx(2, "invalid -m usage");
 			break;
-		case 'p':
-			printf("%d\n", getpagesize());
-			exit(0);
 		default:
 			errx(2, "invalid option specifed");
 		}
diff --git a/testcases/kernel/controllers/memcg/control/memcg_control_test.sh b/testcases/kernel/controllers/memcg/control/memcg_control_test.sh
index 168efe3..1d15872 100644
--- a/testcases/kernel/controllers/memcg/control/memcg_control_test.sh
+++ b/testcases/kernel/controllers/memcg/control/memcg_control_test.sh
@@ -41,9 +41,11 @@ export TST_COUNT=0
 export TMP=${TMP:-/tmp}
 cd $TMP
 
-TOT_MEM_LIMIT=$1
-ACTIVE_MEM_LIMIT=$2
-PROC_MEM=$3
+PAGE_SIZE=$(getconf PAGESIZE)
+
+TOT_MEM_LIMIT=$PAGE_SIZE
+ACTIVE_MEM_LIMIT=$PAGE_SIZE
+PROC_MEM=$((PAGE_SIZE * 2))
 
 TST_PATH=$PWD
 STATUS_PIPE="$TMP/status_pipe"
-- 
2.7.3


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP] [PATCH V2 4/6] memcg_function_test.sh: Split
  2016-09-05 15:24 ` [LTP] [PATCH V2 4/6] memcg_function_test.sh: Split Cyril Hrubis
@ 2016-09-08  9:10   ` Stanislav Kholmanskikh
  2016-09-08  9:16     ` Cyril Hrubis
  0 siblings, 1 reply; 10+ messages in thread
From: Stanislav Kholmanskikh @ 2016-09-08  9:10 UTC (permalink / raw)
  To: ltp

Hi,

On 09/05/2016 06:24 PM, Cyril Hrubis wrote:
> Split the memcg_function_test.sh into five tests based on what is
> tested.
> 
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
>  runtest/controllers                                |   6 +-
>  .../controllers/memcg/functional/memcg_failcnt.sh  |  58 +++++
>  .../memcg/functional/memcg_force_empty.sh          |  90 +++++++
>  .../memcg/functional/memcg_function_test.sh        | 286 ---------------------
>  .../controllers/memcg/functional/memcg_lib.sh      |  15 ++
>  .../memcg/functional/memcg_limit_in_bytes.sh       | 127 +++++++++
>  .../controllers/memcg/functional/memcg_stat_rss.sh |  89 +++++++
>  .../memcg/functional/memcg_subgroup_charge.sh      |  50 ++++
>  8 files changed, 434 insertions(+), 287 deletions(-)
>  create mode 100755 testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh
>  create mode 100755 testcases/kernel/controllers/memcg/functional/memcg_force_empty.sh
>  delete mode 100755 testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
>  create mode 100755 testcases/kernel/controllers/memcg/functional/memcg_limit_in_bytes.sh
>  create mode 100755 testcases/kernel/controllers/memcg/functional/memcg_stat_rss.sh
>  create mode 100755 testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
> 
> diff --git a/runtest/controllers b/runtest/controllers
> index bec883b..d14d81e 100644
> --- a/runtest/controllers
> +++ b/runtest/controllers
> @@ -1,7 +1,11 @@
>  #DESCRIPTION:Resource Management testing
>  cgroup		cgroup_regression_test.sh
>  memcg_regression	memcg_regression_test.sh
> -memcg_function		memcg_function_test.sh
> +memcg_failcnt memcg_failcnt.sh
> +memcg_force_empty memcg_force_empty.sh
> +memcg_limit_in_bytes memcg_limit_in_bytes.sh
> +memcg_stat_rss memcg_stat_rss.sh
> +memcg_subgroup_charge memcg_subgroup_charge.sh
>  memcg_max_usage_in_bytes	memcg_max_usage_in_bytes_test.sh
>  memcg_move_charge_at_immigrate	memcg_move_charge_at_immigrate_test.sh
>  memcg_memsw_limit_in_bytes	memcg_memsw_limit_in_bytes_test.sh
> diff --git a/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh b/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh
> new file mode 100755
> index 0000000..d5034a5
> --- /dev/null
> +++ b/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh
> @@ -0,0 +1,58 @@
> +#!/bin/sh
> +
> +################################################################################
> +##                                                                            ##
> +## Copyright (c) 2009 FUJITSU LIMITED                                         ##
> +##                                                                            ##
> +## This program is free software;  you can redistribute it and#or modify      ##
> +## it under the terms of the GNU General Public License as published by       ##
> +## the Free Software Foundation; either version 2 of the License, or          ##
> +## (at your option) any later version.                                        ##
> +##                                                                            ##
> +## This program is distributed in the hope that it will be useful, but        ##
> +## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
> +## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
> +## for more details.                                                          ##
> +##                                                                            ##
> +## You should have received a copy of the GNU General Public License          ##
> +## along with this program;  if not, write to the Free Software Foundation,   ##
> +## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
> +##                                                                            ##
> +## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
> +## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
> +## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
> +##						<risrajak@linux.vnet.ibm.com  ##
> +##                                                                            ##
> +################################################################################
> +
> +TCID="memcg_failcnt"
> +TST_TOTAL=3
> +
> +. memcg_lib.sh
> +
> +# Test memory.failcnt
> +testcase_1()
> +{
> +	echo $PAGESIZE > memory.limit_in_bytes
> +	malloc_free_memory "--mmap-anon" $(($PAGESIZE*2))
> +	test_failcnt "memory.failcnt"
> +}
> +
> +testcase_2()
> +{
> +	echo $PAGESIZE > memory.limit_in_bytes
> +	malloc_free_memory "--mmap-file" $(($PAGESIZE*2))
> +	test_failcnt "memory.failcnt"
> +}
> +
> +testcase_3()
> +{
> +	echo $PAGESIZE > memory.limit_in_bytes
> +	malloc_free_memory "--shm" $(($PAGESIZE*2))
> +	test_failcnt "memory.failcnt"
> +}
> +
> +shmmax_setup
> +LOCAL_CLEANUP=shmmax_cleanup
> +run_tests
> +tst_exit
> diff --git a/testcases/kernel/controllers/memcg/functional/memcg_force_empty.sh b/testcases/kernel/controllers/memcg/functional/memcg_force_empty.sh
> new file mode 100755
> index 0000000..59cb0b5
> --- /dev/null
> +++ b/testcases/kernel/controllers/memcg/functional/memcg_force_empty.sh
> @@ -0,0 +1,90 @@
> +#!/bin/sh
> +
> +################################################################################
> +##                                                                            ##
> +## Copyright (c) 2009 FUJITSU LIMITED                                         ##
> +##                                                                            ##
> +## This program is free software;  you can redistribute it and#or modify      ##
> +## it under the terms of the GNU General Public License as published by       ##
> +## the Free Software Foundation; either version 2 of the License, or          ##
> +## (at your option) any later version.                                        ##
> +##                                                                            ##
> +## This program is distributed in the hope that it will be useful, but        ##
> +## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
> +## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
> +## for more details.                                                          ##
> +##                                                                            ##
> +## You should have received a copy of the GNU General Public License          ##
> +## along with this program;  if not, write to the Free Software Foundation,   ##
> +## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
> +##                                                                            ##
> +## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
> +## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
> +## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
> +##						<risrajak@linux.vnet.ibm.com  ##
> +##                                                                            ##
> +################################################################################
> +
> +TCID="memcg_force_empty"
> +TST_TOTAL=6
> +
> +. memcg_lib.sh
> +
> +# Test memory.force_empty
> +testcase_1()
> +{
> +	memcg_process --mmap-anon -s $PAGESIZE &
> +	pid=$!
> +	TST_CHECKPOINT_WAIT 0
> +	echo $pid > tasks
> +	signal_memcg_process $pid $PAGESIZE
> +	echo $pid > ../tasks
> +
> +	# This expects that there is swap configured
> +	EXPECT_PASS echo 1 \> memory.force_empty
> +
> +	stop_memcg_process $pid
> +}
> +
> +testcase_2()
> +{
> +	memcg_process --mmap-lock2 -s $PAGESIZE &
> +	pid=$!
> +	TST_CHECKPOINT_WAIT 0
> +	echo $pid > tasks
> +	signal_memcg_process $pid $PAGESIZE
> +
> +	EXPECT_FAIL echo 1 \> memory.force_empty
> +
> +	stop_memcg_process $pid
> +}
> +
> +testcase_3()
> +{
> +	EXPECT_PASS echo 0 \> memory.force_empty
> +}
> +
> +testcase_4()
> +{
> +	EXPECT_PASS echo 1.0 \> memory.force_empty
> +}
> +
> +testcase_4()
> +{
> +	EXPECT_PASS echo 1xx \> memory.force_empty
> +}
> +
> +testcase_5()
> +{
> +	EXPECT_PASS echo xx \> memory.force_empty
> +}
> +
> +testcase_6()
> +{
> +	# writing to non-empty top mem cgroup's force_empty
> +	# should return failure
> +	EXPECT_FAIL echo 1 \> /dev/memcg/memory.force_empty
> +}
> +
> +run_tests
> +tst_exit
> diff --git a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
> deleted file mode 100755
> index fadbcea..0000000
> --- a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
> +++ /dev/null
> @@ -1,286 +0,0 @@
> -#! /bin/sh
> -
> -################################################################################
> -##                                                                            ##
> -## Copyright (c) 2009 FUJITSU LIMITED                                         ##
> -##                                                                            ##
> -## This program is free software;  you can redistribute it and#or modify      ##
> -## it under the terms of the GNU General Public License as published by       ##
> -## the Free Software Foundation; either version 2 of the License, or          ##
> -## (at your option) any later version.                                        ##
> -##                                                                            ##
> -## This program is distributed in the hope that it will be useful, but        ##
> -## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
> -## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
> -## for more details.                                                          ##
> -##                                                                            ##
> -## You should have received a copy of the GNU General Public License          ##
> -## along with this program;  if not, write to the Free Software               ##
> -## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
> -##                                                                            ##
> -## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
> -## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
> -## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
> -##						<risrajak@linux.vnet.ibm.com  ##
> -##                                                                            ##
> -################################################################################
> -
> -TCID="memcg_function_test"
> -TST_TOTAL=38
> -
> -shmmax_cleanup()
> -{
> -	if [ -n "$shmmax" ]; then
> -		echo "$shmmax" > /proc/sys/kernel/shmmax
> -	fi
> -}
> -LOCAL_CLEANUP=shmmax_cleanup
> -
> -. memcg_lib.sh
> -
> -# Case 1 - 10: Test the management and counting of memory
> -testcase_1()
> -{
> -	test_mem_stat "--mmap-anon" $PAGESIZE $PAGESIZE "rss" $PAGESIZE false
> -}
> -
> -testcase_2()
> -{
> -	test_mem_stat "--mmap-file" $PAGESIZE $PAGESIZE "rss" 0 false
> -}
> -
> -testcase_3()
> -{
> -	test_mem_stat "--shm -k 3" $PAGESIZE $PAGESIZE "rss" 0 false
> -}
> -
> -testcase_4()
> -{
> -	test_mem_stat "--mmap-anon --mmap-file --shm" \
> -		$PAGESIZE $((PAGESIZE*3)) "rss" $PAGESIZE false
> -}
> -
> -testcase_5()
> -{
> -	test_mem_stat "--mmap-lock1" $PAGESIZE $PAGESIZE "rss" $PAGESIZE false
> -}
> -
> -testcase_6()
> -{
> -	test_mem_stat "--mmap-anon" $PAGESIZE $PAGESIZE "rss" $PAGESIZE true
> -}
> -
> -testcase_7()
> -{
> -	test_mem_stat "--mmap-file" $PAGESIZE $PAGESIZE "rss" 0 true
> -}
> -
> -testcase_8()
> -{
> -	test_mem_stat "--shm -k 8" $PAGESIZE $PAGESIZE "rss" 0 true
> -}
> -
> -testcase_9()
> -{
> -	test_mem_stat "--mmap-anon --mmap-file --shm" \
> -		$PAGESIZE $((PAGESIZE*3)) "rss" $PAGESIZE true
> -}
> -
> -testcase_10()
> -{
> -	test_mem_stat "--mmap-lock1" $PAGESIZE $PAGESIZE "rss" $PAGESIZE true
> -}
> -
> -# Case 11 - 13: Test memory.failcnt
> -testcase_11()
> -{
> -	echo $PAGESIZE > memory.limit_in_bytes
> -	malloc_free_memory "--mmap-anon" $(($PAGESIZE*2))
> -	test_failcnt "memory.failcnt"
> -}
> -
> -testcase_12()
> -{
> -	echo $PAGESIZE > memory.limit_in_bytes
> -	malloc_free_memory "--mmap-file" $(($PAGESIZE*2))
> -	test_failcnt "memory.failcnt"
> -}
> -
> -testcase_13()
> -{
> -	echo $PAGESIZE > memory.limit_in_bytes
> -	malloc_free_memory "--shm" $(($PAGESIZE*2))
> -	test_failcnt "memory.failcnt"
> -}
> -
> -# Case 14 - 15: Test mmap(locked) + alloc_mem > limit_in_bytes
> -testcase_14()
> -{
> -	test_proc_kill $PAGESIZE "--mmap-lock1" $((PAGESIZE*2)) 0
> -}
> -
> -testcase_15()
> -{
> -	test_proc_kill $PAGESIZE "--mmap-lock2" $((PAGESIZE*2)) 0
> -}
> -
> -# Case 16 - 18: Test swapoff + alloc_mem > limi_in_bytes
> -testcase_16()
> -{
> -	swapoff -a
> -	test_proc_kill $PAGESIZE "--mmap-anon" $((PAGESIZE*2)) 0
> -	swapon -a
> -}
> -
> -testcase_17()
> -{
> -	swapoff -a
> -	test_proc_kill $PAGESIZE "--mmap-file" $((PAGESIZE*2)) 0
> -	swapon -a
> -}
> -
> -testcase_18()
> -{
> -	swapoff -a
> -	test_proc_kill $PAGESIZE "--shm -k 18" $((PAGESIZE*2)) 0
> -	swapon -a
> -}
> -
> -# Case 19 - 21: Test limit_in_bytes == 0
> -testcase_19()
> -{
> -	test_proc_kill 0 "--mmap-anon" $PAGESIZE 0
> -}
> -
> -testcase_20()
> -{
> -	test_proc_kill 0 "--mmap-file" $PAGESIZE 0
> -}
> -
> -testcase_21()
> -{
> -	test_proc_kill 0 "--shm -k 21" $PAGESIZE 0
> -}
> -
> -# Case 22 - 24: Test limit_in_bytes will be aligned to PAGESIZE
> -testcase_22()
> -{
> -	test_limit_in_bytes $((PAGESIZE-1)) 0
> -}
> -
> -testcase_23()
> -{
> -	test_limit_in_bytes $((PAGESIZE+1)) 0
> -}
> -
> -testcase_24()
> -{
> -	test_limit_in_bytes 1 0
> -}
> -
> -# Case 25 - 28: Test invaild memory.limit_in_bytes
> -testcase_25()
> -{
> -	tst_kvercmp 2 6 31
> -	if [ $? -eq 0 ]; then
> -		EXPECT_FAIL echo -1 \> memory.limit_in_bytes
> -	else
> -		EXPECT_PASS echo -1 \> memory.limit_in_bytes
> -	fi
> -}
> -
> -testcase_26()
> -{
> -	EXPECT_FAIL echo 1.0 \> memory.limit_in_bytes
> -}
> -
> -testcase_27()
> -{
> -	EXPECT_FAIL echo 1xx \> memory.limit_in_bytes
> -}
> -
> -testcase_28()
> -{
> -	EXPECT_FAIL echo xx \> memory.limit_in_bytes
> -}
> -
> -# Case 29 - 35: Test memory.force_empty
> -testcase_29()
> -{
> -	memcg_process --mmap-anon -s $PAGESIZE &
> -	pid=$!
> -	TST_CHECKPOINT_WAIT 0
> -	echo $pid > tasks
> -	signal_memcg_process $pid $PAGESIZE
> -	echo $pid > ../tasks
> -
> -	# This expects that there is swap configured
> -	EXPECT_PASS echo 1 \> memory.force_empty
> -
> -	stop_memcg_process $pid
> -}
> -
> -testcase_30()
> -{
> -	memcg_process --mmap-lock2 -s $PAGESIZE &
> -	pid=$!
> -	TST_CHECKPOINT_WAIT 0
> -	echo $pid > tasks
> -	signal_memcg_process $pid $PAGESIZE
> -
> -	EXPECT_FAIL echo 1 \> memory.force_empty
> -
> -	stop_memcg_process $pid
> -}
> -
> -testcase_31()
> -{
> -	EXPECT_PASS echo 0 \> memory.force_empty
> -}
> -
> -testcase_32()
> -{
> -	EXPECT_PASS echo 1.0 \> memory.force_empty
> -}
> -
> -testcase_33()
> -{
> -	EXPECT_PASS echo 1xx \> memory.force_empty
> -}
> -
> -testcase_34()
> -{
> -	EXPECT_PASS echo xx \> memory.force_empty
> -}
> -
> -testcase_35()
> -{
> -	# writing to non-empty top mem cgroup's force_empty
> -	# should return failure
> -	EXPECT_FAIL echo 1 \> /dev/memcg/memory.force_empty
> -}
> -
> -# Case 36 - 38: Test that group and subgroup have no relationship
> -testcase_36()
> -{
> -	test_subgroup $PAGESIZE $((2*PAGESIZE))
> -}
> -
> -testcase_37()
> -{
> -	test_subgroup $PAGESIZE $PAGESIZE
> -}
> -
> -testcase_38()
> -{
> -	test_subgroup $PAGESIZE 0
> -}
> -
> -shmmax=`cat /proc/sys/kernel/shmmax`
> -if [ $shmmax -lt $HUGEPAGESIZE ]; then
> -	ROD echo "$HUGEPAGESIZE" \> /proc/sys/kernel/shmmax
> -fi
> -
> -run_tests
> -
> -tst_exit
> diff --git a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
> index c34198a..1bf0143 100755
> --- a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
> +++ b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
> @@ -69,6 +69,21 @@ cleanup()
>  }
>  TST_CLEANUP=cleanup
>  
> +shmmax_setup()
> +{
> +	shmmax=`cat /proc/sys/kernel/shmmax`
> +	if [ $shmmax -lt $HUGEPAGESIZE ]; then
> +		ROD echo "$HUGEPAGESIZE" \> /proc/sys/kernel/shmmax
> +	fi
> +}
> +
> +shmmax_cleanup()
> +{
> +	if [ -n "$shmmax" ]; then
> +		echo "$shmmax" > /proc/sys/kernel/shmmax
> +	fi
> +}
> +
>  # Check size in memcg
>  # $1 - Item name
>  # $2 - Expected size
> diff --git a/testcases/kernel/controllers/memcg/functional/memcg_limit_in_bytes.sh b/testcases/kernel/controllers/memcg/functional/memcg_limit_in_bytes.sh
> new file mode 100755
> index 0000000..8ada7d1
> --- /dev/null
> +++ b/testcases/kernel/controllers/memcg/functional/memcg_limit_in_bytes.sh
> @@ -0,0 +1,127 @@
> +#!/bin/sh
> +
> +################################################################################
> +##                                                                            ##
> +## Copyright (c) 2009 FUJITSU LIMITED                                         ##
> +##                                                                            ##
> +## This program is free software;  you can redistribute it and#or modify      ##
> +## it under the terms of the GNU General Public License as published by       ##
> +## the Free Software Foundation; either version 2 of the License, or          ##
> +## (at your option) any later version.                                        ##
> +##                                                                            ##
> +## This program is distributed in the hope that it will be useful, but        ##
> +## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
> +## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
> +## for more details.                                                          ##
> +##                                                                            ##
> +## You should have received a copy of the GNU General Public License          ##
> +## along with this program;  if not, write to the Free Software Foundation,   ##
> +## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
> +##                                                                            ##
> +## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
> +## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
> +## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
> +##						<risrajak@linux.vnet.ibm.com  ##
> +##                                                                            ##
> +################################################################################
> +
> +TCID="memcg_limit_in_bytes"
> +TST_TOTAL=15
> +
> +. memcg_lib.sh
> +
> +# Test mmap(locked) + alloc_mem > limit_in_bytes
> +testcase_1()
> +{
> +	test_proc_kill $PAGESIZE "--mmap-lock1" $((PAGESIZE*2)) 0
> +}
> +
> +testcase_2()
> +{
> +	test_proc_kill $PAGESIZE "--mmap-lock2" $((PAGESIZE*2)) 0
> +}
> +
> +# Test swapoff + alloc_mem > limit_in_bytes
> +testcase_3()
> +{
> +	swapoff -a
> +	test_proc_kill $PAGESIZE "--mmap-anon" $((PAGESIZE*2)) 0
> +	swapon -a
> +}
> +
> +testcase_4()
> +{
> +	swapoff -a
> +	test_proc_kill $PAGESIZE "--mmap-file" $((PAGESIZE*2)) 0
> +	swapon -a
> +}
> +
> +testcase_5()
> +{
> +	swapoff -a
> +	test_proc_kill $PAGESIZE "--shm -k 18" $((PAGESIZE*2)) 0
> +	swapon -a
> +}
> +
> +# Test limit_in_bytes == 0
> +testcase_6()
> +{
> +	test_proc_kill 0 "--mmap-anon" $PAGESIZE 0
> +}
> +
> +testcase_7()
> +{
> +	test_proc_kill 0 "--mmap-file" $PAGESIZE 0
> +}
> +
> +testcase_8()
> +{
> +	test_proc_kill 0 "--shm -k 21" $PAGESIZE 0
> +}
> +
> +# Test limit_in_bytes will be aligned to PAGESIZE
> +testcase_9()
> +{
> +	test_limit_in_bytes $((PAGESIZE-1)) 0
> +}
> +
> +testcase_10()
> +{
> +	test_limit_in_bytes $((PAGESIZE+1)) 0
> +}
> +
> +testcase_11()
> +{
> +	test_limit_in_bytes 1 0
> +}
> +
> +# Test invalid memory.limit_in_bytes
> +testcase_12()
> +{
> +	tst_kvercmp 2 6 31
> +	if [ $? -eq 0 ]; then
> +		EXPECT_FAIL echo -1 \> memory.limit_in_bytes
> +	else
> +		EXPECT_PASS echo -1 \> memory.limit_in_bytes
> +	fi
> +}
> +
> +testcase_13()
> +{
> +	EXPECT_FAIL echo 1.0 \> memory.limit_in_bytes
> +}
> +
> +testcase_14()
> +{
> +	EXPECT_FAIL echo 1xx \> memory.limit_in_bytes
> +}
> +
> +testcase_15()
> +{
> +	EXPECT_FAIL echo xx \> memory.limit_in_bytes
> +}
> +
> +shmmax_setup
> +LOCAL_CLEANUP=shmmax_cleanup
> +run_tests
> +tst_exit
> diff --git a/testcases/kernel/controllers/memcg/functional/memcg_stat_rss.sh b/testcases/kernel/controllers/memcg/functional/memcg_stat_rss.sh
> new file mode 100755
> index 0000000..a41e157
> --- /dev/null
> +++ b/testcases/kernel/controllers/memcg/functional/memcg_stat_rss.sh
> @@ -0,0 +1,89 @@
> +#!/bin/sh
> +
> +################################################################################
> +##                                                                            ##
> +## Copyright (c) 2009 FUJITSU LIMITED                                         ##
> +##                                                                            ##
> +## This program is free software;  you can redistribute it and#or modify      ##
> +## it under the terms of the GNU General Public License as published by       ##
> +## the Free Software Foundation; either version 2 of the License, or          ##
> +## (at your option) any later version.                                        ##
> +##                                                                            ##
> +## This program is distributed in the hope that it will be useful, but        ##
> +## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
> +## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
> +## for more details.                                                          ##
> +##                                                                            ##
> +## You should have received a copy of the GNU General Public License          ##
> +## along with this program;  if not, write to the Free Software Foundation,   ##
> +## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
> +##                                                                            ##
> +## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
> +## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
> +## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
> +##						<risrajak@linux.vnet.ibm.com  ##
> +##                                                                            ##
> +################################################################################
> +
> +TCID="memcg_stat_rss"
> +TST_TOTAL=10
> +
> +. memcg_lib.sh
> +
> +# Test the management and counting of memory
> +testcase_1()
> +{
> +	test_mem_stat "--mmap-anon" $PAGESIZE $PAGESIZE "rss" $PAGESIZE false
> +}
> +
> +testcase_2()
> +{
> +	test_mem_stat "--mmap-file" $PAGESIZE $PAGESIZE "rss" 0 false
> +}
> +
> +testcase_3()
> +{
> +	test_mem_stat "--shm -k 3" $PAGESIZE $PAGESIZE "rss" 0 false
> +}
> +
> +testcase_4()
> +{
> +	test_mem_stat "--mmap-anon --mmap-file --shm" \
> +		$PAGESIZE $((PAGESIZE*3)) "rss" $PAGESIZE false
> +}
> +
> +testcase_5()
> +{
> +	test_mem_stat "--mmap-lock1" $PAGESIZE $PAGESIZE "rss" $PAGESIZE false
> +}
> +
> +testcase_6()
> +{
> +	test_mem_stat "--mmap-anon" $PAGESIZE $PAGESIZE "rss" $PAGESIZE true
> +}
> +
> +testcase_7()
> +{
> +	test_mem_stat "--mmap-file" $PAGESIZE $PAGESIZE "rss" 0 true
> +}
> +
> +testcase_8()
> +{
> +	test_mem_stat "--shm -k 8" $PAGESIZE $PAGESIZE "rss" 0 true
> +}
> +
> +testcase_9()
> +{
> +	test_mem_stat "--mmap-anon --mmap-file --shm" \
> +		$PAGESIZE $((PAGESIZE*3)) "rss" $PAGESIZE true
> +}
> +
> +testcase_10()
> +{
> +	test_mem_stat "--mmap-lock1" $PAGESIZE $PAGESIZE "rss" $PAGESIZE true
> +}
> +
> +shmmax_setup
> +LOCAL_CLEANUP=shmmax_cleanup
> +run_tests
> +tst_exit
> diff --git a/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
> new file mode 100755
> index 0000000..2efe291
> --- /dev/null
> +++ b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
> @@ -0,0 +1,50 @@
> +#!/bin/sh
> +
> +################################################################################
> +##                                                                            ##
> +## Copyright (c) 2009 FUJITSU LIMITED                                         ##
> +##                                                                            ##
> +## This program is free software;  you can redistribute it and#or modify      ##
> +## it under the terms of the GNU General Public License as published by       ##
> +## the Free Software Foundation; either version 2 of the License, or          ##
> +## (at your option) any later version.                                        ##
> +##                                                                            ##
> +## This program is distributed in the hope that it will be useful, but        ##
> +## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
> +## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
> +## for more details.                                                          ##
> +##                                                                            ##
> +## You should have received a copy of the GNU General Public License          ##
> +## along with this program;  if not, write to the Free Software Foundation,   ##
> +## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
> +##                                                                            ##
> +## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
> +## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
> +## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
> +##						<risrajak@linux.vnet.ibm.com  ##
> +##                                                                            ##
> +################################################################################
> +
> +TCID="memcg_subgroup_charge"
> +TST_TOTAL=3
> +
> +. memcg_lib.sh
> +
> +# Case 36 - 38: Test that group and subgroup have no relationship
> +testcase_36()
> +{
> +	test_subgroup $PAGESIZE $((2*PAGESIZE))
> +}
> +
> +testcase_37()
> +{
> +	test_subgroup $PAGESIZE $PAGESIZE
> +}
> +
> +testcase_38()
> +{
> +	test_subgroup $PAGESIZE 0
> +}

I believe you've missed my comment for V1 about the numbering scheme here:

[root@skholman-m7 ltp]# ./testcases/bin/memcg_subgroup_charge.sh
memcg_subgroup_charge 1 TINFO : Starting test 1
/opt/ltp/testcases/bin/memcg_lib.sh: line 536: testcase_1: command not found
memcg_subgroup_charge 1 TINFO : Starting test 2
/opt/ltp/testcases/bin/memcg_lib.sh: line 536: testcase_2: command not found
memcg_subgroup_charge 1 TINFO : Starting test 3
/opt/ltp/testcases/bin/memcg_lib.sh: line 536: testcase_3: command not found
[root@skholman-m7 ltp]#




> +
> +run_tests
> +tst_exit
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [LTP] [PATCH V2 4/6] memcg_function_test.sh: Split
  2016-09-08  9:10   ` Stanislav Kholmanskikh
@ 2016-09-08  9:16     ` Cyril Hrubis
  0 siblings, 0 replies; 10+ messages in thread
From: Cyril Hrubis @ 2016-09-08  9:16 UTC (permalink / raw)
  To: ltp

Hi!
> > +################################################################################
> > +##                                                                            ##
> > +## Copyright (c) 2009 FUJITSU LIMITED                                         ##
> > +##                                                                            ##
> > +## This program is free software;  you can redistribute it and#or modify      ##
> > +## it under the terms of the GNU General Public License as published by       ##
> > +## the Free Software Foundation; either version 2 of the License, or          ##
> > +## (at your option) any later version.                                        ##
> > +##                                                                            ##
> > +## This program is distributed in the hope that it will be useful, but        ##
> > +## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
> > +## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
> > +## for more details.                                                          ##
> > +##                                                                            ##
> > +## You should have received a copy of the GNU General Public License          ##
> > +## along with this program;  if not, write to the Free Software Foundation,   ##
> > +## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
> > +##                                                                            ##
> > +## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
> > +## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
> > +## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
> > +##						<risrajak@linux.vnet.ibm.com  ##
> > +##                                                                            ##
> > +################################################################################
> > +
> > +TCID="memcg_subgroup_charge"
> > +TST_TOTAL=3
> > +
> > +. memcg_lib.sh
> > +
> > +# Case 36 - 38: Test that group and subgroup have no relationship
> > +testcase_36()
> > +{
> > +	test_subgroup $PAGESIZE $((2*PAGESIZE))
> > +}
> > +
> > +testcase_37()
> > +{
> > +	test_subgroup $PAGESIZE $PAGESIZE
> > +}
> > +
> > +testcase_38()
> > +{
> > +	test_subgroup $PAGESIZE 0
> > +}
> 
> I believe you've missed my comment for V1 about the numbering scheme here:
> 
> [root@skholman-m7 ltp]# ./testcases/bin/memcg_subgroup_charge.sh
> memcg_subgroup_charge 1 TINFO : Starting test 1
> /opt/ltp/testcases/bin/memcg_lib.sh: line 536: testcase_1: command not found
> memcg_subgroup_charge 1 TINFO : Starting test 2
> /opt/ltp/testcases/bin/memcg_lib.sh: line 536: testcase_2: command not found
> memcg_subgroup_charge 1 TINFO : Starting test 3
> /opt/ltp/testcases/bin/memcg_lib.sh: line 536: testcase_3: command not found
> [root@skholman-m7 ltp]#

My bad, the test is broken that way.


BTW part of the problem is that the shell library reports TPASS even if
the test haven't reported any results so this is hidden until you check
the logs. I guess that we should turn the bitflags to counters in
test.sh and actually check that the test reported something at the end.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [LTP] [PATCH 6/6] memcg_control_test.sh: Simplify runtest file
  2016-09-08  9:20   ` Stanislav Kholmanskikh
@ 2016-09-08  9:17     ` Cyril Hrubis
  0 siblings, 0 replies; 10+ messages in thread
From: Cyril Hrubis @ 2016-09-08  9:17 UTC (permalink / raw)
  To: ltp

Hi!
> The entire series looks good, except that issue with the numbering
> scheme in memcg_subgroup_charge.sh (patch V2 4/6)

I will push fixed version, thanks for the review.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [LTP] [PATCH 6/6] memcg_control_test.sh: Simplify runtest file
  2016-09-05 15:24 ` [LTP] [PATCH 6/6] memcg_control_test.sh: Simplify runtest file Cyril Hrubis
@ 2016-09-08  9:20   ` Stanislav Kholmanskikh
  2016-09-08  9:17     ` Cyril Hrubis
  0 siblings, 1 reply; 10+ messages in thread
From: Stanislav Kholmanskikh @ 2016-09-08  9:20 UTC (permalink / raw)
  To: ltp

Hi!

The entire series looks good, except that issue with the numbering
scheme in memcg_subgroup_charge.sh (patch V2 4/6)

On 09/05/2016 06:24 PM, Cyril Hrubis wrote:
> This commit makes use of $(getconf PAGESIZE) instead of the mem_process
> and also moves the parameters to the test itself as there is no need to
> keep these outside the script.
> 
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
>  runtest/controllers                                              | 2 +-
>  testcases/kernel/controllers/memcg/control/mem_process.c         | 3 ---
>  testcases/kernel/controllers/memcg/control/memcg_control_test.sh | 8 +++++---
>  3 files changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/runtest/controllers b/runtest/controllers
> index d14d81e..b904e05 100644
> --- a/runtest/controllers
> +++ b/runtest/controllers
> @@ -13,7 +13,7 @@ memcg_stat	memcg_stat_test.sh
>  memcg_use_hierarchy	memcg_use_hierarchy_test.sh
>  memcg_usage_in_bytes	memcg_usage_in_bytes_test.sh
>  memcg_stress		memcg_stress_test.sh
> -memcg_control		PAGESIZE=$(mem_process -p);memcg_control_test.sh $PAGESIZE $PAGESIZE $((PAGESIZE * 2))
> +memcg_control		memcg_control_test.sh
>  
>  cgroup_fj_function_debug cgroup_fj_function.sh debug
>  cgroup_fj_function_cpuset cgroup_fj_function.sh cpuset
> diff --git a/testcases/kernel/controllers/memcg/control/mem_process.c b/testcases/kernel/controllers/memcg/control/mem_process.c
> index 48cdea8..9007c2c 100644
> --- a/testcases/kernel/controllers/memcg/control/mem_process.c
> +++ b/testcases/kernel/controllers/memcg/control/mem_process.c
> @@ -60,9 +60,6 @@ void process_options(int argc, char **argv)
>  			if (*end != '\0')
>  				errx(2, "invalid -m usage");
>  			break;
> -		case 'p':
> -			printf("%d\n", getpagesize());
> -			exit(0);
>  		default:
>  			errx(2, "invalid option specifed");
>  		}
> diff --git a/testcases/kernel/controllers/memcg/control/memcg_control_test.sh b/testcases/kernel/controllers/memcg/control/memcg_control_test.sh
> index 168efe3..1d15872 100644
> --- a/testcases/kernel/controllers/memcg/control/memcg_control_test.sh
> +++ b/testcases/kernel/controllers/memcg/control/memcg_control_test.sh
> @@ -41,9 +41,11 @@ export TST_COUNT=0
>  export TMP=${TMP:-/tmp}
>  cd $TMP
>  
> -TOT_MEM_LIMIT=$1
> -ACTIVE_MEM_LIMIT=$2
> -PROC_MEM=$3
> +PAGE_SIZE=$(getconf PAGESIZE)
> +
> +TOT_MEM_LIMIT=$PAGE_SIZE
> +ACTIVE_MEM_LIMIT=$PAGE_SIZE
> +PROC_MEM=$((PAGE_SIZE * 2))
>  
>  TST_PATH=$PWD
>  STATUS_PIPE="$TMP/status_pipe"
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-09-08  9:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-05 15:24 [LTP] [PATCH V2 1/6] memcg_lib.sh: Print test number at test start Cyril Hrubis
2016-09-05 15:24 ` [LTP] [PATCH V2 2/6] memcg_lib.sh: Move all the kill -s XXX to functions Cyril Hrubis
2016-09-05 15:24 ` [LTP] [PATCH V2 3/6] memcg_lib.sh: Get rid of sleep 1 in signal_memcg_process Cyril Hrubis
2016-09-05 15:24 ` [LTP] [PATCH V2 4/6] memcg_function_test.sh: Split Cyril Hrubis
2016-09-08  9:10   ` Stanislav Kholmanskikh
2016-09-08  9:16     ` Cyril Hrubis
2016-09-05 15:24 ` [LTP] [PATCH 5/6] memcg_lib.sh: Remove subdirectories in cleanup Cyril Hrubis
2016-09-05 15:24 ` [LTP] [PATCH 6/6] memcg_control_test.sh: Simplify runtest file Cyril Hrubis
2016-09-08  9:20   ` Stanislav Kholmanskikh
2016-09-08  9:17     ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.