[LTP] [PATCH 1/4] memcg/functional: rewrite
Stanislav Kholmanskikh
stanislav.kholmanskikh@oracle.com
Tue Jun 14 17:24:50 CEST 2016
* Use the LTP API for shell tests
* Remove memcg_getpagesize binary, since its functionality
can be provided by 'getconf PAGESIZE'
* Move common code to memcg_lib.sh
Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
testcases/kernel/controllers/memcg/.gitignore | 1 -
.../memcg/functional/memcg_function_test.sh | 56 +++------
.../memcg/functional/memcg_getpagesize.c | 30 -----
.../controllers/memcg/functional/memcg_lib.sh | 128 ++++++++++++++------
.../functional/memcg_max_usage_in_bytes_test.sh | 49 +-------
.../functional/memcg_memsw_limit_in_bytes_test.sh | 54 ++-------
.../memcg_move_charge_at_immigrate_test.sh | 40 +------
.../memcg/functional/memcg_stat_test.sh | 49 +-------
.../memcg/functional/memcg_usage_in_bytes_test.sh | 47 +------
.../memcg/functional/memcg_use_hierarchy_test.sh | 39 +-----
10 files changed, 148 insertions(+), 345 deletions(-)
delete mode 100644 testcases/kernel/controllers/memcg/functional/memcg_getpagesize.c
diff --git a/testcases/kernel/controllers/memcg/.gitignore b/testcases/kernel/controllers/memcg/.gitignore
index 6f62034..8730251 100644
--- a/testcases/kernel/controllers/memcg/.gitignore
+++ b/testcases/kernel/controllers/memcg/.gitignore
@@ -1,5 +1,4 @@
/control/mem_process
-/functional/memcg_getpagesize
/functional/memcg_process
/regression/memcg_test_1
/regression/memcg_test_2
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
index 2c2f32a..38fb311 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
@@ -25,11 +25,18 @@
## ##
################################################################################
-export TCID="memcg_function_test"
-export TST_TOTAL=38
-export TST_COUNT=0
+TCID="memcg_function_test"
+TST_TOTAL=38
-. memcg_lib.sh || exit 1
+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()
@@ -205,7 +212,7 @@ testcase_28()
# Case 29 - 35: Test memory.force_empty
testcase_29()
{
- $TEST_PATH/memcg_process --mmap-anon -s $PAGESIZE &
+ memcg_process --mmap-anon -s $PAGESIZE &
pid=$!
sleep 1
echo $pid > tasks
@@ -226,7 +233,7 @@ testcase_29()
testcase_30()
{
- $TEST_PATH/memcg_process --mmap-lock2 -s $PAGESIZE &
+ memcg_process --mmap-lock2 -s $PAGESIZE &
pid=$!
sleep 1
echo $pid > tasks
@@ -293,40 +300,9 @@ testcase_38()
shmmax=`cat /proc/sys/kernel/shmmax`
if [ $shmmax -lt $HUGEPAGESIZE ]; then
- echo $(($HUGEPAGESIZE)) > /proc/sys/kernel/shmmax
+ ROD "$HUGEPAGESIZE" \> /proc/sys/kernel/shmmax
fi
-# Run all the test cases
-for i in $(seq 1 $TST_TOTAL)
-do
- export TST_COUNT=$(( $TST_COUNT + 1 ))
- cur_id=$i
-
- do_mount
- if [ $? -ne 0 ]; then
- echo "Cannot create memcg"
- exit 1
- fi
-
- # prepare
- mkdir /dev/memcg/$i 2> /dev/null
- cd /dev/memcg/$i
-
- # run the case
- testcase_$i
-
- # clean up
- sleep 1
- cd $TEST_PATH
- rmdir /dev/memcg/$i
+run_tests
- cleanup
-done
-
-echo $shmmax > /proc/sys/kernel/shmmax
-
-if [ $failed -ne 0 ]; then
- exit $failed
-else
- exit 0
-fi
+tst_exit
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_getpagesize.c b/testcases/kernel/controllers/memcg/functional/memcg_getpagesize.c
deleted file mode 100644
index 557b540..0000000
--- a/testcases/kernel/controllers/memcg/functional/memcg_getpagesize.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/******************************************************************************/
-/* */
-/* 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> */
-/* */
-/******************************************************************************/
-
-#include <unistd.h>
-#include <stdio.h>
-
-int main(void)
-{
- printf("%d\n", getpagesize());
- return 0;
-}
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
index c90d0a2..5e42fac 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
@@ -22,26 +22,53 @@
## ##
################################################################################
+. test.sh
+
if [ "x$(grep -w memory /proc/cgroups | cut -f4)" != "x1" ]; then
- echo "WARNING:";
- echo "Either Kernel does not support for memory resource controller or feature not enabled";
- echo "Skipping all memcgroup testcases....";
- exit 0
+ tst_brkm TCONF "Kernel does not support the memory resource controller"
fi
-cd $LTPROOT/testcases/bin
+PAGESIZE=$(getconf PAGESIZE)
+if [ $? -ne 0 ]; then
+ tst_brkm TBROK "getconf PAGESIZE failed"
+fi
-TEST_PATH=$PWD
-PAGESIZE=`./memcg_getpagesize`
-HUGEPAGESIZE=`grep Hugepagesize /proc/meminfo | awk '{ print $2 }'`
+HUGEPAGESIZE=$(awk '/Hugepagesize/ {print $2}' /proc/meminfo)
[ -z $HUGEPAGESIZE ] && HUGEPAGESIZE=0
HUGEPAGESIZE=$(( $HUGEPAGESIZE * 1024 ))
PASS=0
FAIL=1
orig_memory_use_hierarchy=""
-cur_id=0
-failed=0
+MEMSW_USAGE_FLAG=0
+MEMSW_LIMIT_FLAG=0
+
+tst_tmpdir
+TMP_DIR="$PWD"
+
+cleanup()
+{
+ if [ -n "$LOCAL_CLEANUP" ]; then
+ $LOCAL_CLEANUP
+ fi
+
+ killall -9 memcg_process 2> /dev/null
+ wait
+
+ cd "$TMP_DIR"
+
+ if [ -n "$TEST_ID" -a -d "/dev/memcg/$TEST_ID" ]; then
+ rmdir "/dev/memcg/$TEST_ID"
+ fi
+
+ if [ -d "/dev/memcg" ]; then
+ umount /dev/memcg
+ rmdir /dev/memcg
+ fi
+
+ tst_rmdir
+}
+TST_CLEANUP=cleanup
# Record the test result of a test case
# $1 - The result of the test case, $PASS or $FAIL
@@ -55,7 +82,6 @@ result()
tst_resm TPASS "$info"
else
tst_resm TFAIL "$info"
- : $(( failed += 1 ))
fi
}
@@ -83,7 +109,7 @@ warmup()
{
pid=$1
- echo "Warming up for test: $cur_id, pid: $pid"
+ tst_resm TINFO "Warming up pid: $pid"
kill -s USR1 $pid 2> /dev/null
sleep 1
kill -s USR1 $pid 2> /dev/null
@@ -91,10 +117,10 @@ warmup()
kill -0 $pid
if [ $? -ne 0 ]; then
- result $FAIL "cur_id=$cur_id"
+ result $FAIL ""
return 1
else
- echo "Process is still here after warm up: $pid"
+ tst_resm TINFO "Process is still here after warm up: $pid"
fi
return 0
@@ -109,8 +135,8 @@ warmup()
# $5 - check after free ?
test_mem_stat()
{
- echo "Running $TEST_PATH/memcg_process $1 -s $2"
- $TEST_PATH/memcg_process $1 -s $2 &
+ tst_resm TINFO "Running memcg_process $1 -s $2"
+ memcg_process $1 -s $2 &
sleep 1
warmup $!
@@ -142,8 +168,8 @@ test_mem_stat()
# $5 - check after free ?
test_max_usage_in_bytes()
{
- echo "Running $TEST_PATH/memcg_process $1 -s $2"
- $TEST_PATH/memcg_process $1 -s $2 &
+ tst_resm TINFO "Running memcg_process $1 -s $2"
+ memcg_process $1 -s $2 &
sleep 1
warmup $!
@@ -173,8 +199,8 @@ test_max_usage_in_bytes()
# $2 - the -s parameter of 'process', such as 4096
malloc_free_memory()
{
- echo "Running $TEST_PATH/memcg_process $1 -s $2"
- $TEST_PATH/memcg_process $1 -s $2 &
+ tst_resm TINFO "Running memcg_process $1 -s $2"
+ memcg_process $1 -s $2 &
sleep 1
echo $! > tasks
@@ -218,7 +244,7 @@ test_proc_kill()
fi
fi
- $TEST_PATH/memcg_process $2 -s $3 &
+ memcg_process $2 -s $3 &
pid=$!
sleep 1
echo $pid > tasks
@@ -271,6 +297,8 @@ test_limit_in_bytes()
fi
}
+# Never used, so untested
+#
# Test memory controller doesn't charge hugepage
# $1 - the value of /proc/sys/vm/nr_hugepages
# $2 - the parameters of 'process', --mmap-file or --shm
@@ -278,7 +306,7 @@ test_limit_in_bytes()
# $4 - 0: expected failure, 1: expected success
test_hugepage()
{
- TMP_FILE=$TEST_PATH/tmp
+ TMP_FILE="$TMP_DIR/tmp"
nr_hugepages=`cat /proc/sys/vm/nr_hugepages`
mkdir /hugetlb
@@ -286,7 +314,7 @@ test_hugepage()
echo $1 > /proc/sys/vm/nr_hugepages
- $TEST_PATH/memcg_process $2 --hugepage -s $3 > $TMP_FILE 2>&1 &
+ memcg_process $2 --hugepage -s $3 > $TMP_FILE 2>&1 &
sleep 1
kill -s USR1 $! 2> /dev/null
@@ -333,8 +361,8 @@ test_subgroup()
echo $1 > memory.limit_in_bytes
echo $2 > subgroup/memory.limit_in_bytes
- echo "Running $TEST_PATH/memcg_process --mmap-anon -s $PAGESIZE"
- $TEST_PATH/memcg_process --mmap-anon -s $PAGESIZE &
+ tst_resm TINFO "Running memcg_process --mmap-anon -s $PAGESIZE"
+ memcg_process --mmap-anon -s $PAGESIZE &
sleep 1
warmup $!
@@ -369,7 +397,8 @@ test_move_charge()
{
mkdir subgroup_a
- $TEST_PATH/memcg_process $1 -s $2 &
+ tst_resm TINFO "Running memcg_process $1 -s $2"
+ memcg_process $1 -s $2 &
sleep 1
warmup $!
if [ $? -ne 0 ]; then
@@ -400,8 +429,10 @@ test_move_charge()
rmdir subgroup_a subgroup_b
}
-cleanup()
+cleanup_test()
{
+ TEST_ID="$1"
+
if [ -n "$orig_memory_use_hierarchy" ];then
echo $orig_memory_use_hierarchy > \
/dev/memcg/memory.use_hierarchy
@@ -413,18 +444,22 @@ cleanup()
fi
killall -9 memcg_process 2>/dev/null
- if [ -e /dev/memcg ]; then
- umount /dev/memcg 2>/dev/null
- rmdir /dev/memcg 2>/dev/null
- fi
+ wait
+
+ ROD cd "$TMP_DIR"
+
+ ROD rmdir "/dev/memcg/$TEST_ID"
+ TEST_ID=""
+ ROD umount /dev/memcg
+ ROD rmdir /dev/memcg
}
-do_mount()
+setup_test()
{
- cleanup
+ TEST_ID="$1"
- mkdir /dev/memcg 2> /dev/null
- mount -t cgroup -omemory memcg /dev/memcg
+ ROD mkdir /dev/memcg
+ ROD mount -t cgroup -omemory memcg /dev/memcg
# The default value for memory.use_hierarchy is 0 and some of tests
# (memcg_stat_test.sh and memcg_use_hierarchy_test.sh) expect it so
@@ -442,4 +477,27 @@ do_mount()
"to 0 failed"
fi
fi
+
+ ROD mkdir "/dev/memcg/$TEST_ID"
+ ROD cd "/dev/memcg/$TEST_ID"
+}
+
+# Run all the test cases
+run_tests()
+{
+ for i in $(seq 1 $TST_TOTAL); do
+ setup_test $i
+
+ if [ -e memory.memsw.limit_in_bytes ]; then
+ MEMSW_LIMIT_FLAG=1
+ fi
+
+ if [ -e memory.memsw.max_usage_in_bytes ]; then
+ MEMSW_USAGE_FLAG=1
+ fi
+
+ testcase_$i
+
+ cleanup_test $i
+ done
}
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_max_usage_in_bytes_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_max_usage_in_bytes_test.sh
index 9e286f5..91112be 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_max_usage_in_bytes_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_max_usage_in_bytes_test.sh
@@ -26,13 +26,10 @@
# History: 2012/01/17 - Created.
#
-export TCID="memcg_max_usage_in_bytes_test"
-export TST_TOTAL=4
-export TST_COUNT=0
+TCID="memcg_max_usage_in_bytes_test"
+TST_TOTAL=4
-. memcg_lib.sh || exit 1
-
-MEM_SWAP_FLAG=0
+. memcg_lib.sh
# Test memory.max_usage_in_bytes
testcase_1()
@@ -44,7 +41,7 @@ testcase_1()
# Test memory.memsw.max_usage_in_bytes
testcase_2()
{
- if [ $MEM_SWAP_FLAG -eq 0 ]; then
+ if [ "$MEMSW_USAGE_FLAG" -eq 0 ]; then
tst_resm TCONF "mem+swap is not enabled"
return
fi
@@ -65,7 +62,7 @@ testcase_3()
# Test reset memory.memsw.max_usage_in_bytes
testcase_4()
{
- if [ $MEM_SWAP_FLAG -eq 0 ]; then
+ if [ "$MEMSW_USAGE_FLAG" -eq 0 ]; then
tst_resm TCONF "mem+swap is not enabled"
return
fi
@@ -76,39 +73,7 @@ testcase_4()
"memory.memsw.max_usage_in_bytes" $((PAGESIZE*1024)) 1
}
-# Run all the test cases
-for i in $(seq 1 $TST_TOTAL)
-do
- export TST_COUNT=$(( $TST_COUNT + 1 ))
- cur_id=$i
-
- do_mount
- if [ $? -ne 0 ]; then
- echo "Cannot create memcg"
- exit 1
- fi
-
- # prepare
- mkdir /dev/memcg/$i 2> /dev/null
- cd /dev/memcg/$i
-
- if [ -e memory.memsw.max_usage_in_bytes ]; then
- MEM_SWAP_FLAG=1
- fi
-
- # run the case
- testcase_$i
-
- # clean up
- sleep 1
- cd $TEST_PATH
- rmdir /dev/memcg/$i
+run_tests
- cleanup
-done
+tst_exit
-if [ $failed -ne 0 ]; then
- exit $failed
-else
- exit 0
-fi
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_memsw_limit_in_bytes_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_memsw_limit_in_bytes_test.sh
index f49508c..23eb095 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_memsw_limit_in_bytes_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_memsw_limit_in_bytes_test.sh
@@ -26,13 +26,10 @@
# History: 2012/01/3 - Created.
#
-export TCID="memcg_memsw_limit_in_bytes_test"
-export TST_TOTAL=12
-export TST_COUNT=0
+TCID="memcg_memsw_limit_in_bytes_test"
+TST_TOTAL=12
-. memcg_lib.sh || exit 1
-
-MEM_SWAP_FLAG=0
+. memcg_lib.sh
testcase_1()
{
@@ -76,7 +73,7 @@ testcase_8()
testcase_9()
{
- if [ $MEM_SWAP_FLAG -eq 0 ]; then
+ if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
tst_resm TCONF "mem+swap is not enabled"
return
fi
@@ -94,7 +91,7 @@ testcase_9()
testcase_10()
{
- if [ $MEM_SWAP_FLAG -eq 0 ]; then
+ if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
tst_resm TCONF "mem+swap is not enabled"
return
fi
@@ -106,7 +103,7 @@ testcase_10()
testcase_11()
{
- if [ $MEM_SWAP_FLAG -eq 0 ]; then
+ if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
tst_resm TCONF "mem+swap is not enabled"
return
fi
@@ -118,7 +115,7 @@ testcase_11()
testcase_12()
{
- if [ $MEM_SWAP_FLAG -eq 0 ]; then
+ if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
tst_resm TCONF "mem+swap is not enabled"
return
fi
@@ -128,39 +125,6 @@ testcase_12()
result $(( !($? != 0) )) "return value is $?"
}
-# Run all the test cases
-for i in $(seq 1 $TST_TOTAL)
-do
- export TST_COUNT=$(( $TST_COUNT + 1 ))
- cur_id=$i
-
- do_mount
- if [ $? -ne 0 ]; then
- echo "Cannot create memcg"
- exit 1
- fi
-
- # prepare
- mkdir /dev/memcg/$i 2> /dev/null
- cd /dev/memcg/$i
-
- if [ -e memory.memsw.limit_in_bytes ]; then
- MEM_SWAP_FLAG=1
- fi
-
- # run the case
- testcase_$i
-
- # clean up
- sleep 1
- cd $TEST_PATH
- rmdir /dev/memcg/$i
-
- cleanup
-done
+run_tests
-if [ $failed -ne 0 ]; then
- exit $failed
-else
- exit 0
-fi
+tst_exit
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 406bd07..aeb7d0f 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
@@ -26,11 +26,10 @@
# History: 2012/01/16 - Created.
#
-export TCID="memcg_move_charge_at_immigrate_test"
-export TST_TOTAL=4
-export TST_COUNT=0
+TCID="memcg_move_charge_at_immigrate_test"
+TST_TOTAL=4
-. memcg_lib.sh || exit 1
+. memcg_lib.sh
# Test disable moving charges
testcase_1()
@@ -58,35 +57,6 @@ testcase_4()
test_move_charge "--mmap-anon --shm" $PAGESIZE 3 $PAGESIZE $PAGESIZE 0 0
}
-# Run all the test cases
-for i in $(seq 1 $TST_TOTAL)
-do
- export TST_COUNT=$(( $TST_COUNT + 1 ))
- cur_id=$i
+run_tests
- do_mount
- if [ $? -ne 0 ]; then
- echo "Cannot create memcg"
- exit 1
- fi
-
- # prepare
- mkdir /dev/memcg/$i 2> /dev/null
- cd /dev/memcg/$i
-
- # run the case
- testcase_$i
-
- # clean up
- sleep 1
- cd $TEST_PATH
- rmdir /dev/memcg/$i
-
- cleanup
-done
-
-if [ $failed -ne 0 ]; then
- exit $failed
-else
- exit 0
-fi
+tst_exit
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh
index 0151f85..1f28aa4 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh
@@ -26,13 +26,10 @@
# History: 2012/01/16 - Created.
#
-export TCID="memcg_stat_test"
-export TST_TOTAL=8
-export TST_COUNT=0
+TCID="memcg_stat_test"
+TST_TOTAL=8
-. memcg_lib.sh || exit 1
-
-MEM_SWAP_FLAG=0
+. memcg_lib.sh
# Test cache
testcase_1()
@@ -93,7 +90,7 @@ testcase_6()
# Test hierarchical_memsw_limit with enabling hierarchical accounting
testcase_7()
{
- if [ $MEM_SWAP_FLAG -eq 0 ]; then
+ if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
tst_resm TCONF "mem+swap is not enabled"
return
fi
@@ -116,7 +113,7 @@ testcase_7()
# Test hierarchical_memsw_limit with disabling hierarchical accounting
testcase_8()
{
- if [ $MEM_SWAP_FLAG -eq 0 ]; then
+ if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
tst_resm TCONF "mem+swap is not enabled"
return
fi
@@ -136,39 +133,7 @@ testcase_8()
rmdir subgroup
}
-# Run all the test cases
-for i in $(seq 1 $TST_TOTAL)
-do
- export TST_COUNT=$(( $TST_COUNT + 1 ))
- cur_id=$i
-
- do_mount
- if [ $? -ne 0 ]; then
- echo "Cannot create memcg"
- exit 1
- fi
-
- # prepare
- mkdir /dev/memcg/$i 2> /dev/null
- cd /dev/memcg/$i
-
- if [ -e memory.memsw.limit_in_bytes ]; then
- MEM_SWAP_FLAG=1
- fi
-
- # run the case
- testcase_$i
-
- # clean up
- sleep 1
- cd $TEST_PATH
- rmdir /dev/memcg/$i
+run_tests
- cleanup
-done
+tst_exit
-if [ $failed -ne 0 ]; then
- exit $failed
-else
- exit 0
-fi
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 a4d0542..ab86318 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
@@ -26,13 +26,10 @@
# History: 2012/01/16 - Created.
#
-export TCID="memcg_usage_in_bytes_test"
-export TST_TOTAL=2
-export TST_COUNT=0
+TCID="memcg_usage_in_bytes_test"
+TST_TOTAL=2
-. memcg_lib.sh || exit 1
-
-MEM_SWAP_FLAG=0
+. memcg_lib.sh
# Test memory.usage_in_bytes
testcase_1()
@@ -44,7 +41,7 @@ testcase_1()
# Test memory.memsw.usage_in_bytes
testcase_2()
{
- if [ $MEM_SWAP_FLAG -eq 0 ]; then
+ if [ "$MEMSW_USAGE_FLAG" -eq 0 ]; then
tst_resm TCONF "mem+swap is not enabled"
return
fi
@@ -55,39 +52,7 @@ testcase_2()
"memory.memsw.usage_in_bytes" $((PAGESIZE*1024)) 0
}
-# Run all the test cases
-for i in $(seq 1 $TST_TOTAL)
-do
- export TST_COUNT=$(( $TST_COUNT + 1 ))
- cur_id=$i
-
- do_mount
- if [ $? -ne 0 ]; then
- echo "Cannot create memcg"
- exit 1
- fi
-
- # prepare
- mkdir /dev/memcg/$i 2> /dev/null
- cd /dev/memcg/$i
-
- if [ -e memory.memsw.usage_in_bytes ]; then
- MEM_SWAP_FLAG=1
- fi
-
- # run the case
- testcase_$i
-
- # clean up
- sleep 1
- cd $TEST_PATH
- rmdir /dev/memcg/$i
+run_tests
- cleanup
-done
+tst_exit
-if [ $failed -ne 0 ]; then
- exit $failed
-else
- exit 0
-fi
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh
index f48c50a..04b456d 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh
@@ -26,11 +26,10 @@
# History: 2012/01/14 - Created.
#
-export TCID="memcg_use_hierarchy_test"
-export TST_TOTAL=3
-export TST_COUNT=0
+TCID="memcg_use_hierarchy_test"
+TST_TOTAL=3
-. memcg_lib.sh || exit 1
+. memcg_lib.sh
# test if one of the ancestors goes over its limit, the proces will be killed
testcase_1()
@@ -67,35 +66,7 @@ testcase_3()
rmdir subgroup
}
-# Run all the test cases
-for i in $(seq 1 $TST_TOTAL)
-do
- export TST_COUNT=$(( $TST_COUNT + 1 ))
- cur_id=$i
+run_tests
- do_mount
- if [ $? -ne 0 ]; then
- echo "Cannot create memcg"
- exit 1
- fi
+tst_exit
- # prepare
- mkdir /dev/memcg/$i 2> /dev/null
- cd /dev/memcg/$i
-
- # run the case
- testcase_$i
-
- # clean up
- sleep 1
- cd $TEST_PATH
- rmdir /dev/memcg/$i
-
- cleanup
-done
-
-if [ $failed -ne 0 ]; then
- exit $failed
-else
- exit 0
-fi
--
1.7.1
More information about the ltp
mailing list