memcg_lib.sh: Print test number at test start
PATCH v2 1/6 memcg_lib.sh: Print test number at test start
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.
--- testcases/kernel/controllers/memcg/functional/memcg_lib.sh | 3 +++ 1 file changed, 3 insertions(+)
testcases/kernel/controllers/memcg/functional/memcg_lib.sh +3 -0
@@ -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
Signature · 1 line
2.7.3
PATCH v2 2/6 memcg_lib.sh: Move all the kill -s XXX to functions
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
--- .../memcg/functional/memcg_function_test.sh | 10 ++- .../controllers/memcg/functional/memcg_lib.sh | 75 +++++++++++----------- 2 files changed, 41 insertions(+), 44 deletions(-)
testcases/kernel/controllers/memcg/functional/memcg_function_test.sh +4 -6
@@ -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()
testcases/kernel/controllers/memcg/functional/memcg_lib.sh +37 -38
171 lines not on this page · raw message
Signature · 1 line
2.7.3
PATCH v2 3/6 memcg_lib.sh: Get rid of sleep 1 in signal_memcg_process
In reply to Cyril HrubisThe 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.
--- .../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(-)
testcases/kernel/controllers/memcg/functional/memcg_function_test.sh +14 -14
@@ -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
testcases/kernel/controllers/memcg/functional/memcg_lib.sh +72 -42
221 lines not on this page · raw message
testcases/kernel/controllers/memcg/functional/memcg_move_charge_at_immigrate_test.sh +7 -6
@@ -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
testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh +7 -4
@@ -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
testcases/kernel/controllers/memcg/functional/memcg_usage_in_bytes_test.sh +4 -4
@@ -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
Signature · 1 line
2.7.3
PATCH v2 4/6 memcg_function_test.sh: Split
In reply to Cyril HrubisSplit the memcg_function_test.sh into five tests based on what is tested.
--- 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
runtest/controllers +5 -1
@@ -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
testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh new file +58 -0
58 lines not on this page · raw message
testcases/kernel/controllers/memcg/functional/memcg_force_empty.sh new file +90 -0
90 lines not on this page · raw message
testcases/kernel/controllers/memcg/functional/memcg_function_test.sh deleted +0 -286
286 lines not on this page · raw message
testcases/kernel/controllers/memcg/functional/memcg_lib.sh +15 -0
@@ -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
testcases/kernel/controllers/memcg/functional/memcg_limit_in_bytes.sh new file +127 -0
127 lines not on this page · raw message
testcases/kernel/controllers/memcg/functional/memcg_stat_rss.sh new file +89 -0
89 lines not on this page · raw message
testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
2.7.3
PATCH v2 4/6 memcg_function_test.sh: Split
Hi,
Quoted 787 lines · Cyril Hrubis
Split the
memcg_function_test.shinto five tests based on what is tested.Signed-off-by Cyril Hrubis <[email protected]>--- 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.shruntest/controllers +5
-1@@ -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.shtestcases/kernel/controllers/memcg/functional/memcg_failcnt.sh new file +58
-0@@ -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 <[email protected]> ## +## Restructure for LTP: Shi Weihua <[email protected]> ## +## Added memcg enable/disable functinality: Rishikesh K Rajak ## +## <[email protected] ## +## ## +################################################################################ + +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_exittestcases/kernel/controllers/memcg/functional/memcg_force_empty.sh new file +90
-0@@ -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 <[email protected]> ## +## Restructure for LTP: Shi Weihua <[email protected]> ## +## Added memcg enable/disable functinality: Rishikesh K Rajak ## +## <[email protected] ## +## ## +################################################################################ + +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_exittestcases/kernel/controllers/memcg/functional/memcg_function_test.sh deleted +0
-286@@ -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 <[email protected]> ## -## Restructure for LTP: Shi Weihua <[email protected]> ## -## Added memcg enable/disable functinality: Rishikesh K Rajak ## -## <[email protected] ## -## ## -################################################################################ - -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_exittestcases/kernel/controllers/memcg/functional/memcg_lib.sh +15
-0@@ -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 sizetestcases/kernel/controllers/memcg/functional/memcg_limit_in_bytes.sh new file +127
-0@@ -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 <[email protected]> ## +## Restructure for LTP: Shi Weihua <[email protected]> ## +## Added memcg enable/disable functinality: Rishikesh K Rajak ## +## <[email protected] ## +## ## +################################################################################ + +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_exittestcases/kernel/controllers/memcg/functional/memcg_stat_rss.sh new file +89
-0@@ -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 <[email protected]> ## +## Restructure for LTP: Shi Weihua <[email protected]> ## +## Added memcg enable/disable functinality: Rishikesh K Rajak ## +## <[email protected] ## +## ## +################################################################################ + +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_exittestcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh new file +37
-0@@ -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 <[email protected]> ## +## Restructure for LTP: Shi Weihua <[email protected]> ## +## Added memcg enable/disable functinality: Rishikesh K Rajak ## +## <[email protected] ## +## ## +################################################################################ + +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)) +}
testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh line 47
Quoted 10 lines
testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh new file +10
-0+ +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]#
Quoted 4 lines
testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh new file +3
-0+ +run_tests +tst_exit
PATCH v2 4/6 memcg_function_test.sh: Split
Hi!
Quoted 48 lines
Quoted 35 lines
testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh new file +35
-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 <[email protected]> ## +## Restructure for LTP: Shi Weihua <[email protected]> ## +## Added memcg enable/disable functinality: Rishikesh K Rajak ## +## <[email protected] ## +## ## +################################################################################ + +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)) +}testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh line 47
Quoted 10 lines
testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh new file +10
-0+ +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:
Quoted 8 lines
[root@skholman-m7 ltp]#
./testcases/bin/memcg_subgroup_charge.shmemcg_subgroup_charge1 TINFO : Starting test 1/opt/ltp/testcases/bin/memcg_lib.sh: line 536:testcase_1: command not foundmemcg_subgroup_charge1 TINFO : Starting test 2/opt/ltp/testcases/bin/memcg_lib.sh: line 536:testcase_2: command not foundmemcg_subgroup_charge1 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.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 5/6 memcg_lib.sh: Remove subdirectories in cleanup
In reply to Cyril HrubisSome 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.
--- testcases/kernel/controllers/memcg/functional/memcg_lib.sh | 6 ++++++ 1 file changed, 6 insertions(+)
testcases/kernel/controllers/memcg/functional/memcg_lib.sh +6 -0
@@ -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
Signature · 1 line
2.7.3
PATCH 6/6 memcg_control_test.sh: Simplify runtest file
In reply to Cyril HrubisThis 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.
--- 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(-)
runtest/controllers +1 -1
@@ -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
testcases/kernel/controllers/memcg/control/mem_process.c +0 -3
@@ -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" ); }
testcases/kernel/controllers/memcg/control/memcg_control_test.sh +5 -3
@@ -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"
Signature · 1 line
2.7.3
PATCH 6/6 memcg_control_test.sh: Simplify runtest file
Hi!
The entire series looks good, except that issue with the numbering scheme in memcg_subgroup_charge.sh (patch V2 4/6)
Quoted 58 lines · Cyril Hrubis
This commit makes use of $(getconf PAGESIZE) instead of the
mem_processand also moves the parameters to the test itself as there is no need to keep these outside the script.Signed-off-by Cyril Hrubis <[email protected]>--- 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(-)runtest/controllers +1
-1@@ -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 cpusettestcases/kernel/controllers/memcg/control/mem_process.c +0
-3@@ -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" ); }testcases/kernel/controllers/memcg/control/memcg_control_test.sh +5
-3@@ -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"
PATCH 6/6 memcg_control_test.sh: Simplify runtest file
Hi!
Quoted 2 lines
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.
Signature · 2 lines
Cyril Hrubis [email protected]