cgroup tests newlib-porting
v2 cover cgroup tests newlib-porting
This series converts cgroup/ regression tests to LTP newlib and performs a general cleanup as follows:
- remove bashism from all tests' scripts
- mostly remove usage of global vars
- convert to SPDX headers
- expose a controllers' common /proc/mounts parsing function
- rename tests' helpers prefixing them with a test-specific tag to avoid name clashes on install: I have not renamed the tests' helpers using more specific meaningful name, since all of them performs really trivial ops needed and meaningful in the context of the regression-test subcase they serve; so I thought it would have been better to keep their names as they are now, bound to the subcase they help.
Cristian Marussi (4):
[LTP] cgroup_regression_test.sh ported to newlib [LTP] cgroup_regression_test.sh cleanup [LTP] cgroup_regression_test.sh: added helper [LTP] cgroup: helpers various fixes
PATCH v2 1/4 cgroup_regression_test.sh ported to newlib
Ported to newlib and removed most global vars usage.
--- .../cgroup/cgroup_regression_test.sh | 217 +++++++++--------- 1 file changed, 110 insertions(+), 107 deletions(-)
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +110 -107
@@ -22,71 +22,83 @@ ## ## ################################################################################ -cd $LTPROOT/testcases/bin +TST_TESTFUNC=do_test +TST_SETUP=do_setup +TST_CLEANUP=do_cleanup +TST_CNT=10 +TST_NEEDS_ROOT=1 +TST_NEEDS_CMDS="dmesg mountpoint mount umount cat kill find mkdir rmdir grep" -export TCID="cgroup_regression_test" -export TST_TOTAL=10 -export TST_COUNT=1 +. tst_test.sh -failed=0 +do_setup() +{ + cd $LTPROOT/testcases/bin -if tst_kvcmp -lt "2.6.29"; then - tst_brkm TCONF ignored "test must be run with kernel 2.6.29 or newer" - exit 32 -fi + mkdir cgroup/ -if [ ! -f /proc/cgroups ]; then - tst_brkm TCONF ignored "Kernel does not support for control groups; skipping testcases"; - exit 32 -fi + if tst_kvcmp -lt "2.6.29"; then + tst_brk TCONF ignored "test must be run with kernel 2.6.29 or newer" + fi -if [ "x$(id -ru)" != x0 ]; then - tst_brkm TCONF ignored "Test must be run as root" - exit 32 -fi + if [ ! -f /proc/cgroups ]; then + tst_brk TCONF ignored "Kernel does not support for control groups; skipping testcases"; + fi -dmesg -c > /dev/null -nr_bug=`dmesg | grep -c "kernel BUG"` -nr_null=`dmesg | grep -c "kernel NULL pointer dereference"` -nr_warning=`dmesg | grep -c "^WARNING"` -nr_lockdep=`dmesg | grep -c "possible recursive locking detected"` + dmesg -c > /dev/null + NR_BUG=`dmesg | grep -c "kernel BUG"` + NR_NULL=`dmesg | grep -c "kernel NULL pointer dereference"` + NR_WARNING=`dmesg | grep -c "^WARNING"` + NR_LOCKDEP=`dmesg | grep -c "possible recursive locking detected"` +} + +do_cleanup() +{ + cd $LTPROOT/testcases/bin + + if mountpoint -q cgroup/ + then + find cgroup/ -maxdepth 1 -depth -exec rmdir {} + + umount cgroup/ + rmdir cgroup/ + fi +} # check_kernel_bug - check if some kind of kernel bug happened check_kernel_bug() { - new_bug=`dmesg | grep -c "kernel BUG"` - new_null=`dmesg | grep -c "kernel NULL pointer dereference"` - new_warning=`dmesg | grep -c "^WARNING"` - new_lockdep=`dmesg | grep -c "possible recursive locking detected"` + local new_bug=`dmesg | grep -c "kernel BUG"` + local new_null=`dmesg | grep -c "kernel NULL pointer dereference"` + local new_warning=`dmesg | grep -c "^WARNING"` + local new_lockdep=`dmesg | grep -c "possible recursive locking detected"` # no kernel bug is detected - if [ $new_bug -eq $nr_bug -a $new_warning -eq $nr_warning -a \ - $new_null -eq $nr_null -a $new_lockdep -eq $nr_lockdep ]; then + if [ $new_bug -eq $NR_BUG -a $new_warning -eq $NR_WARNING -a \ + $new_null -eq $NR_NULL -a $new_lockdep -eq $NR_LOCKDEP ]; then return 1 fi # some kernel bug is detected - if [ $new_bug -gt $nr_bug ]; then - tst_resm TFAIL "kernel BUG was detected!" + if [ $new_bug -gt $NR_BUG ]; then + tst_res TFAIL "kernel BUG was detected!" fi - if [ $new_warning -gt $nr_warning ]; then - tst_resm TFAIL "kernel WARNING was detected!" + if [ $new_warning -gt $NR_WARNING ]; then + tst_res TFAIL "kernel WARNING was detected!" fi - if [ $new_null -gt $nr_null ]; then - tst_resm TFAIL "kernel NULL pointer dereference!" + if [ $new_null -gt $NR_NULL ]; then + tst_res TFAIL "kernel NULL pointer dereference!" fi - if [ $new_lockdep -gt $nr_lockdep ]; then - tst_resm TFAIL "kernel lockdep warning was detected!" + if [ $new_lockdep -gt $NR_LOCKDEP ]; then + tst_res TFAIL "kernel lockdep warning was detected!" fi - nr_bug=$new_bug - nr_null=$new_null - nr_warning=$new_warning - nr_lockdep=$new_lockdep + NR_BUG=$new_bug + NR_NULL=$new_null + NR_WARNING=$new_warning + NR_LOCKDEP=$new_lockdep echo "check_kernel_bug found something!" dmesg - failed=1 return 0 }
@@ -107,8 +119,7 @@ test_1() mount -t cgroup -o none,name=foo cgroup cgroup/ if [ $? -ne 0 ]; then - tst_resm TFAIL "failed to mount cgroup filesystem" - failed=1 + tst_res TFAIL "failed to mount cgroup filesystem" /bin/kill -SIGTERM $! return fi
@@ -116,7 +127,7 @@ test_1() check_kernel_bug if [ $? -eq 1 ]; then - tst_resm TPASS "no kernel bug was found" + tst_res TPASS "no kernel bug was found" fi /bin/kill -SIGTERM $!
@@ -132,11 +143,13 @@ test_1() #--------------------------------------------------------------------------- test_2() { + local val1 + local val2 + mount -t cgroup -o none,name=foo cgroup cgroup/ if [ $? -ne 0 ]; then - tst_resm TFAIL "Failed to mount cgroup filesystem" - failed=1 - return 1 + tst_res TFAIL "Failed to mount cgroup filesystem" + return fi echo 0 > cgroup/notify_on_release
@@ -148,16 +161,15 @@ test_2() val2=`cat cgroup/1/notify_on_release` if [ $val1 -ne 0 -o $val2 -ne 1 ]; then - tst_resm TFAIL "wrong notify_on_release value" - failed=1 + tst_res TFAIL "wrong notify_on_release value" else - tst_resm TPASS "notify_on_release is inherited" + tst_res TPASS "notify_on_release is inherited" fi rmdir cgroup/0 cgroup/1 umount cgroup/ - return $failed + return } #---------------------------------------------------------------------------
@@ -173,14 +185,14 @@ test_3() local cpu_subsys_path if [ ! -e /proc/sched_debug ]; then - tst_resm TCONF "CONFIG_SCHED_DEBUG is not enabled" + tst_res TCONF "CONFIG_SCHED_DEBUG is not enabled" return fi if grep -q -w "cpu" /proc/cgroups ; then cpu_subsys_path=$(grep -w cpu /proc/mounts | awk '{ print $2 }') else - tst_resm TCONF "CONFIG_CGROUP_SCHED is not enabled" + tst_res TCONF "CONFIG_CGROUP_SCHED is not enabled" return fi
@@ -188,8 +200,7 @@ test_3() if [ -z "$cpu_subsys_path" ]; then mount -t cgroup -o cpu xxx cgroup/ if [ $? -ne 0 ]; then - tst_resm TFAIL "Failed to mount cpu subsys" - failed=1 + tst_res TFAIL "Failed to mount cpu subsys" return fi cpu_subsys_path=cgroup
@@ -207,7 +218,7 @@ test_3() check_kernel_bug if [ $? -eq 1 ]; then - tst_resm TPASS "no kernel bug was found" + tst_res TPASS "no kernel bug was found" fi rmdir $cpu_subsys_path/* 2> /dev/null
@@ -223,15 +234,17 @@ test_3() #--------------------------------------------------------------------------- test_4() { + local lines + if [ ! -e /proc/lockdep ]; then - tst_resm TCONF "CONFIG_LOCKDEP is not enabled" + tst_res TCONF "CONFIG_LOCKDEP is not enabled" return fi # MAX_LOCKDEP_SUBCLASSES is 8, so number of subsys should be > 8 lines=`cat /proc/cgroups | wc -l` if [ $lines -le 9 ]; then - tst_resm TCONF "require more than 8 cgroup subsystems" + tst_res TCONF "require more than 8 cgroup subsystems" return fi
@@ -242,11 +255,10 @@ test_4() dmesg | grep -q "MAX_LOCKDEP_SUBCLASSES too low" if [ $? -eq 0 ]; then - tst_resm TFAIL "lockdep BUG was found" - failed=1 + tst_res TFAIL "lockdep BUG was found" return else - tst_resm TPASS "no lockdep BUG was found" + tst_res TPASS "no lockdep BUG was found" fi }
@@ -264,14 +276,14 @@ test_5() local failing local mntpoint - lines=`cat /proc/cgroups | wc -l` + local lines=`cat /proc/cgroups | wc -l` if [ $lines -le 2 ]; then - tst_resm TCONF "require at least 2 cgroup subsystems" + tst_res TCONF "require at least 2 cgroup subsystems" return fi - subsys1=`tail -n 1 /proc/cgroups | awk '{ print $1 }'` - subsys2=`tail -n 2 /proc/cgroups | head -1 | awk '{ print $1 }'` + local subsys1=`tail -n 1 /proc/cgroups | awk '{ print $1 }'` + local subsys2=`tail -n 2 /proc/cgroups | head -1 | awk '{ print $1 }'` # Accounting here for the fact that the chosen subsystems could # have been already previously mounted at boot time: in such a
@@ -287,8 +299,7 @@ test_5() failing=$subsys1 mount -t cgroup -o $subsys1,$subsys2 xxx $mntpoint/ if [ $? -ne 0 ]; then - tst_resm TFAIL "mount $subsys1 and $subsys2 failed" - failed=1 + tst_res TFAIL "mount $subsys1 and $subsys2 failed" return fi else
@@ -302,10 +313,9 @@ test_5() # This 2nd mount has been properly configured to fail mount -t cgroup -o $failing xxx $mntpoint/ 2> /dev/null if [ $? -eq 0 ]; then - tst_resm TFAIL "mount $failing should fail" + tst_res TFAIL "mount $failing should fail" # Do NOT unmount pre-existent mountpoints... - [ -z "$mounted" ] && umount $mntpoint - failed=1 + [ -z "$mounted" ] && umount $mntpoint/ return fi
@@ -321,7 +331,7 @@ test_5() check_kernel_bug if [ $? -eq 1 ]; then - tst_resm TPASS "no kernel bug was found" + tst_res TPASS "no kernel bug was found" fi # clean up
@@ -329,7 +339,7 @@ test_5() wait $! rmdir $mntpoint/0 # Do NOT unmount pre-existent mountpoints... - [ -z "$mounted" ] && umount $mntpoint + [ -z "$mounted" ] && umount $mntpoint/ } #---------------------------------------------------------------------------
@@ -342,15 +352,15 @@ test_6() { grep -q -w "ns" /proc/cgroups if [ $? -ne 0 ]; then - tst_resm TCONF "CONFIG_CGROUP_NS" + tst_res TCONF "CONFIG_CGROUP_NS" return fi # run the test for 30 secs ./test_6_1.sh & - pid1=$! + local pid1=$! ./test_6_2 & - pid2=$! + local pid2=$! sleep 30 /bin/kill -SIGUSR1 $pid1
@@ -360,7 +370,7 @@ test_6() check_kernel_bug if [ $? -eq 1 ]; then - tst_resm TPASS "no kernel bug was found" + tst_res TPASS "no kernel bug was found" fi # clean up
@@ -379,12 +389,12 @@ test_6() #--------------------------------------------------------------------------- test_7_1() { - subsys_path=$(grep -w $subsys /proc/mounts | cut -d ' ' -f 2) + local subsys=$1 + local subsys_path=$(grep -w $subsys /proc/mounts | cut -d ' ' -f 2) if [ -z "$subsys_path" ]; then mount -t cgroup -o $subsys xxx cgroup/ if [ $? -ne 0 ]; then - tst_resm TFAIL "failed to mount $subsys" - failed=1 + tst_res TFAIL "failed to mount $subsys" return fi subsys_path=cgroup
@@ -407,10 +417,11 @@ test_7_1() test_7_2() { + local subsys=$1 + mount -t cgroup -o none,name=foo cgroup cgroup/ if [ $? -ne 0 ]; then - tst_resm TFAIL "failed to mount cgroup" - failed=1 + tst_res TFAIL "failed to mount cgroup" return fi
@@ -441,19 +452,19 @@ test_7_2() test_7() { - lines=`cat /proc/cgroups | wc -l` + local lines=`cat /proc/cgroups | wc -l` if [ $lines -le 2 ]; then - tst_resm TCONF "require at least 2 cgroup subsystems" + tst_res TCONF "require at least 2 cgroup subsystems" slt_result $SLT_Untested return fi - subsys=`tail -n 1 /proc/cgroups | awk '{ print $1 }'` + local subsys=`tail -n 1 /proc/cgroups | awk '{ print $1 }'` # remount to add new subsystems to the hierarchy - i=1 + local i=1 while [ $i -le 2 ] ; do - test_7_$i + test_7_$i $subsys if [ $? -ne 0 ]; then return fi
@@ -465,7 +476,7 @@ test_7() : $(( i += 1 )) done - tst_resm TPASS "no kernel bug was found" + tst_res TPASS "no kernel bug was found" } #---------------------------------------------------------------------------
@@ -478,22 +489,20 @@ test_8() { mount -t cgroup -o none,name=foo cgroup cgroup/ if [ $? -ne 0 ]; then - tst_resm TFAIL "failed to mount cgroup filesystem" - failed=1 + tst_res TFAIL "failed to mount cgroup filesystem" return fi ./getdelays -C cgroup/tasks > /dev/null 2>&1 if [ $? -eq 0 ]; then - tst_resm TFAIL "should have failed to get cgroupstat of tasks file" + tst_res TFAIL "should have failed to get cgroupstat of tasks file" umount cgroup/ - failed=1 return fi check_kernel_bug if [ $? -eq 1 ]; then - tst_resm TPASS "no kernel bug was found" + tst_res TPASS "no kernel bug was found" fi umount cgroup/
@@ -510,9 +519,9 @@ test_8() test_9() { ./test_9_1.sh & - pid1=$! + local pid1=$! ./test_9_2.sh & - pid2=$! + local pid2=$! sleep 30 /bin/kill -SIGUSR1 $pid1 $pid2
@@ -523,7 +532,7 @@ test_9() check_kernel_bug if [ $? -eq 1 ]; then - tst_resm TPASS "no kernel warning was found" + tst_res TPASS "no kernel warning was found" fi }
@@ -537,9 +546,9 @@ test_9() test_10() { ./test_10_1.sh & - pid1=$! + local pid1=$! ./test_10_2.sh & - pid2=$! + local pid2=$! sleep 30 /bin/kill -SIGUSR1 $pid1 $pid2
@@ -552,21 +561,15 @@ test_10() check_kernel_bug if [ $? -eq 1 ]; then - tst_resm TPASS "no kernel warning was found" + tst_res TPASS "no kernel warning was found" fi } -# main - -mkdir cgroup/ - -for ((cur = 1; cur <= $TST_TOTAL; cur++)) +do_test() { - export TST_COUNT=$cur + local cur=$1 test_$cur } -find cgroup/ -maxdepth 1 -depth -exec rmdir {} + - -exit $failed +tst_run
Signature · 1 line
2.17.1
PATCH v2 1/4 cgroup_regression_test.sh ported to newlib
Hi Cristian,
...
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test_6() · line 357
Quoted 8 lines
---
a/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh
{testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +1
-1grep -q -w "ns" /proc/cgroups if [ $? -ne 0 ]; then - tst_resm TCONF "CONFIG_CGROUP_NS" + tst_res TCONF "CONFIG_CGROUP_NS" return fi
This could be just
grep -q -w "ns" /proc/cgroups || tst_res TCONF "CONFIG_CGROUP_NS is not enabled"
But CONFIG_CGROUP_NS was removed in a77aea92010a ("cgroup: remove the ns_cgroup") in v3.0. We don't have TST_MAX_KVER, so we cannot use TST_MAX_KVER="3.0", but maybe compare kernel version with tst_kvcmp (see doc) and adjust warning for new kernels.
Kind regards,
Petr
PATCH v2 1/4 cgroup_regression_test.sh ported to newlib
Hi
Quoted 14 lines · Petr Vorel
Hi Cristian,
...
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test_6() · line 357
Quoted 8 lines
---
a/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh
{testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +1
-1grep -q -w "ns" /proc/cgroups if [ $? -ne 0 ]; then - tst_resm TCONF "CONFIG_CGROUP_NS" + tst_res TCONF "CONFIG_CGROUP_NS" return fiThis could be just
Quoted 5 lines
grep -q -w "ns"
/proc/cgroups||tst_resTCONF "CONFIG_CGROUP_NSis not enabled"But
CONFIG_CGROUP_NSwas removed ina77aea92010a("cgroup: remove thens_cgroup") in v3.0. We don't haveTST_MAX_KVER, so we cannot use TST_MAX_KVER="3.0", but maybe compare kernel version withtst_kvcmp(see doc) and adjust warning for new kernels.
Fine I'll do. In fact I could see it working properly only when testing on QEMU 2.6.39.
Regards
Cristian
Quoted 4 lines
Kind regards,
Petr
PATCH v2 1/4 cgroup_regression_test.sh ported to newlib
Hi
Quoted 17 lines · Cristian Marussi
Hi
Quoted 14 lines · Petr Vorel
Hi Cristian,
...
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test_6() · line 357
Quoted 8 lines
---
a/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh
{testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +1
-1grep -q -w "ns" /proc/cgroups if [ $? -ne 0 ]; then - tst_resm TCONF "CONFIG_CGROUP_NS" + tst_res TCONF "CONFIG_CGROUP_NS" return fiThis could be just
Quoted 8 lines
Quoted 5 lines
grep -q -w "ns"
/proc/cgroups||tst_resTCONF "CONFIG_CGROUP_NSis not enabled"But
CONFIG_CGROUP_NSwas removed ina77aea92010a("cgroup: remove thens_cgroup") in v3.0. We don't haveTST_MAX_KVER, so we cannot use TST_MAX_KVER="3.0", but maybe compare kernel version withtst_kvcmp(see doc) and adjust warning for new kernels.Fine I'll do. In fact I could see it working properly only when testing on QEMU 2.6.39.
Done with test_kvcmp BUT regarding the grep --q ... || tst_res, it turns out it needs anyway a return afterwards to end the testcase function ...so I've left the if block (even if I could have appended the return after the || tst_res)
Regards
Cristian
Quoted 10 lines
Regards
Cristian
Quoted 4 lines
Kind regards,
Petr
PATCH v2 1/4 cgroup_regression_test.sh ported to newlib
In reply to Cristian MarussiHi Cristian,
...
Quoted 1 line
+++
b/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh
...
Quoted 1 line
-cd $LTPROOT/testcases/bin
You left this even after second commit. It's not needed.
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh line 30
Quoted 6 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +6
-0+TST_TESTFUNC=do_test +TST_SETUP=do_setup +TST_CLEANUP=do_cleanup +TST_CNT=10 +TST_NEEDS_ROOT=1 +TST_NEEDS_CMDS="dmesg mountpoint mount umount cat kill find mkdir rmdir grep"
Test needs also using temporary directory (as it creates directories):
TST_NEEDS_TMPDIR=1
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh line 36
Quoted 9 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +4
-4-export TCID="cgroup_regression_test" -export TST_TOTAL=10 -export TST_COUNT=1 +. tst_test.sh -failed=0 +do_setup() +{ + cd $LTPROOT/testcases/bin
And here.
...
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh line 57
Quoted 3 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +3
-0+do_cleanup() +{ + cd $LTPROOT/testcases/bin
One more time.
...
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test_10() · line 573
Quoted 8 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +2
-2-for ((cur = 1; cur <= $TST_TOTAL; cur++)) +do_test() { - export TST_COUNT=$cur + local cur=$1 test_$cur }
do_test() function is not needed at all, looping can be done automatically:
Remove underscore from test functions (s/test_([0-9]+)/test$1/) and change setup: TST_TESTFUNC=test
Kind regards,
Petr
PATCH v2 1/4 cgroup_regression_test.sh ported to newlib
Hi Petr
Quoted 7 lines · Petr Vorel
Hi Cristian,
...
Quoted 1 line
+++
b/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh...
Quoted 1 line
-cd $LTPROOT/testcases/bin
You left this even after second commit. It's not needed.
because I misunderstood your indication in the previous mail
Quoted 1 line
Quoted 1 line
* Remove absolute (
/bin/kill) and relative paths and cd into
$LTPROOT/testcases/bin
getting it like "remove A and remove B AND then CD into..." o.O
my bad ...:D I'll fix it
Quoted 9 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh line 30
Quoted 7 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +6
-0+TST_TESTFUNC=do_test +TST_SETUP=do_setup +TST_CLEANUP=do_cleanup +TST_CNT=10 +TST_NEEDS_ROOT=1 +TST_NEEDS_CMDS="dmesg mountpoint mount umount cat kill find mkdir rmdir grep"Test needs also using temporary directory (as it creates directories):
TST_NEEDS_TMPDIR=1
Fine. I missed that.
Quoted 7 lines
Quoted 6 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +1
-3-export TCID="cgroup_regression_test" -export TST_TOTAL=10 -export TST_COUNT=1 +. tst_test.sh
Quoted 6 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh line 36
Quoted 4 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +3
-1-failed=0 +do_setup() +{ + cd $LTPROOT/testcases/binAnd here.
o.O
Quoted 6 lines
...
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh line 57
Quoted 3 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +3
-0+do_cleanup() +{ + cd $LTPROOT/testcases/binOne more time.
o.O
Quoted 10 lines
...
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test_10() · line 573
Quoted 8 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +2
-2-for ((cur = 1; cur <= $TST_TOTAL; cur++)) +do_test() { - export TST_COUNT=$cur + local cur=$1 test_$cur }
Quoted 7 lines
do_test()function is not needed at all, looping can be done automatically:
Remove underscore from test functions (s/test_([0-9]+)/test$1/) and change setup: TST_TESTFUNC=test
Sure.
Quoted 4 lines
Kind regards,
Petr
Regards
Cristian
PATCH v2 2/4 cgroup_regression_test.sh cleanup
In reply to Cristian MarussiCleanups:
- removed absolute/relative commands invocations
- avoid bashism
+ removed bash shebang
+ giving up 'kill' bash-builtin: this needs redefining used sigspec strings
--- .../cgroup/cgroup_regression_test.sh | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-)
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +13 -13
@@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh ################################################################################ ## ##
@@ -114,13 +114,13 @@ check_kernel_bug() #--------------------------------------------------------------------------- test_1() { - ./fork_processes & + fork_processes & sleep 1 mount -t cgroup -o none,name=foo cgroup cgroup/ if [ $? -ne 0 ]; then tst_res TFAIL "failed to mount cgroup filesystem" - /bin/kill -SIGTERM $! + kill -TERM $! return fi cat cgroup/tasks > /dev/null
@@ -130,7 +130,7 @@ test_1() tst_res TPASS "no kernel bug was found" fi - /bin/kill -SIGTERM $! + kill -TERM $! wait $! umount cgroup/ }
@@ -212,7 +212,7 @@ test_3() pid2=$! sleep 30 - /bin/kill -SIGUSR1 $pid1 $pid2 + kill -USR1 $pid1 $pid2 wait $pid1 wait $pid2
@@ -335,7 +335,7 @@ test_5() fi # clean up - /bin/kill -SIGTERM $! > /dev/null + kill -TERM $! > /dev/null wait $! rmdir $mntpoint/0 # Do NOT unmount pre-existent mountpoints...
@@ -363,8 +363,8 @@ test_6() local pid2=$! sleep 30 - /bin/kill -SIGUSR1 $pid1 - /bin/kill -SIGTERM $pid2 + kill -USR1 $pid1 + kill -TERM $pid2 wait $pid1 wait $pid2
@@ -409,7 +409,7 @@ test_7_1() if [ "$subsys_path" = "cgroup" ]; then mount -t cgroup -o remount xxx cgroup/ 2> /dev/null - /bin/kill -SIGTERM $! + kill -TERM $! wait $! umount cgroup/ fi
@@ -432,7 +432,7 @@ test_7_2() # remount with some subsystems removed # since 2.6.28, this remount will fail mount -t cgroup -o remount,$subsys xxx cgroup/ 2> /dev/null - /bin/kill -SIGTERM $! + kill -TERM $! wait $! umount cgroup/
@@ -493,7 +493,7 @@ test_8() return fi - ./getdelays -C cgroup/tasks > /dev/null 2>&1 + getdelays -C cgroup/tasks > /dev/null 2>&1 if [ $? -eq 0 ]; then tst_res TFAIL "should have failed to get cgroupstat of tasks file" umount cgroup/
@@ -524,7 +524,7 @@ test_9() local pid2=$! sleep 30 - /bin/kill -SIGUSR1 $pid1 $pid2 + kill -USR1 $pid1 $pid2 wait $pid1 wait $pid2
@@ -551,7 +551,7 @@ test_10() local pid2=$! sleep 30 - /bin/kill -SIGUSR1 $pid1 $pid2 + kill -USR1 $pid1 $pid2 wait $pid1 wait $pid2
Signature · 1 line
2.17.1
PATCH v2 3/4 cgroup_regression_test.sh: added helper
In reply to Cristian MarussiA common function 'get_cgroup_mountpoint' is added to help parse /proc/mounts in search of specific cgroup subsystems mountpoints. It is added as part of a common cgroup_lib.sh.
--- .../cgroup/cgroup_regression_test.sh | 17 +++++++--- testcases/kernel/controllers/cgroup_lib.sh | 33 +++++++++++++++++++ 2 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 testcases/kernel/controllers/cgroup_lib.sh
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +12 -5
@@ -30,6 +30,7 @@ TST_NEEDS_ROOT=1 TST_NEEDS_CMDS="dmesg mountpoint mount umount cat kill find mkdir rmdir grep" . tst_test.sh +. cgroup_lib.sh do_setup() {
@@ -190,7 +191,7 @@ test_3() fi if grep -q -w "cpu" /proc/cgroups ; then - cpu_subsys_path=$(grep -w cpu /proc/mounts | awk '{ print $2 }') + cpu_subsys_path=$(get_cgroup_mountpoint "cpu") else tst_res TCONF "CONFIG_CGROUP_SCHED is not enabled" return
@@ -292,8 +293,8 @@ test_5() # $failing params to be used in the following expected-to-fail # mount action. Note that the subsysN name itself will be listed # amongst mounts options. - cat /proc/mounts | grep cgroup | grep -q $subsys1 && mounted=$subsys1 - [ -z "$mounted" ] && cat /proc/mounts | grep cgroup | grep -q $subsys2 && mounted=$subsys2 + get_cgroup_mountpoint $subsys1 >/dev/null && mounted=$subsys1 + [ -z "$mounted" ] && get_cgroup_mountpoint $subsys2 >/dev/null && mounted=$subsys2 if [ -z "$mounted" ]; then mntpoint=cgroup failing=$subsys1
@@ -306,7 +307,7 @@ test_5() # Use the pre-esistent mountpoint as $mntpoint and use a # co-mount with $failing: this way the 2nd mount will # also fail (as expected) in this 'mirrored' configuration. - mntpoint=$(cat /proc/mounts | grep cgroup | grep $mounted | awk '{ print $2 }') + mntpoint=$(get_cgroup_mountpoint $mounted) failing=$subsys1,$subsys2 fi
@@ -390,7 +391,13 @@ test_6() test_7_1() { local subsys=$1 - local subsys_path=$(grep -w $subsys /proc/mounts | cut -d ' ' -f 2) + # we should be careful to select a $subsys_path which is related to + # cgroup only: if cgroup debugging is enabled a 'debug' $subsys + # could be passed here as params and this will lead to ambiguity and + # errors when grepping simply for 'debug' in /proc/mounts since we'll + # find also /sys/kernel/debug. Helper takes care of this. + local subsys_path=$(get_cgroup_mountpoint $subsys) + if [ -z "$subsys_path" ]; then mount -t cgroup -o $subsys xxx cgroup/ if [ $? -ne 0 ]; then
testcases/kernel/controllers/cgroup_lib.sh new file +33 -0
@@ -0,0 +1,33 @@ +#!/bin/sh + +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2018-2019 ARM Ltd. All Rights Reserved. + +# +# Helper to parse /proc/mounts to find the mountpoints (if any) +# associated with the cgroup subsystem passed as param. +# +# It expects as single argument the cgroup subsytem for +# which to search in /proc/mounts the mountpoint (if any). +# +# - returns true|false depending if any mountpoint has been found. +# - echos back the mountpoint itself if any found +# +get_cgroup_mountpoint() +{ + local mntpoint + local line + local ret=1 + local subsystem=$1 + + # fail straight away with no args + [ $# -eq 0 ] && return $ret + + line=$(grep cgroup /proc/mounts | grep -w $subsystem) + ret=$? + # extract mountpoint if any exist + [ $ret = 0 ] && mntpoint=$(echo $line | awk '{ print $2 }') && echo $mntpoint + + return $ret +} +
Signature · 1 line
2.17.1
PATCH v2 4/4 cgroup: helpers various fixes
In reply to Cristian MarussiRegarding cgroup/ helpers:
- converted Copyright headers to SPDX
- removed residual bashism
- renamed each helper to include a tag prefix (cgroup_regress_) in order to avoid possible name clashes once installed all together into testcases/bin
--- testcases/kernel/controllers/cgroup/Makefile | 22 ++------ .../cgroup/cgroup_regress_test_10_1.sh | 14 +++++ .../cgroup/cgroup_regress_test_10_2.sh | 12 +++++ .../cgroup/cgroup_regress_test_3_1.sh | 14 +++++ .../cgroup/cgroup_regress_test_3_2.sh | 11 ++++ .../cgroup/cgroup_regress_test_6_1.sh | 13 +++++ .../cgroup/cgroup_regress_test_6_2.c | 37 +++++++++++++ .../cgroup/cgroup_regress_test_9_1.sh | 14 +++++ .../cgroup/cgroup_regress_test_9_2.sh | 13 +++++ .../cgroup/cgroup_regression_test.sh | 43 +++++---------- .../controllers/cgroup/fork_processes.c | 27 +++------- .../kernel/controllers/cgroup/getdelays.c | 1 + .../kernel/controllers/cgroup/test_10_1.sh | 33 ------------ .../kernel/controllers/cgroup/test_10_2.sh | 31 ----------- .../kernel/controllers/cgroup/test_3_1.sh | 33 ------------ .../kernel/controllers/cgroup/test_3_2.sh | 30 ----------- .../kernel/controllers/cgroup/test_6_1.sh | 32 ------------ .../kernel/controllers/cgroup/test_6_2.c | 52 ------------------- .../kernel/controllers/cgroup/test_9_1.sh | 33 ------------ .../kernel/controllers/cgroup/test_9_2.sh | 32 ------------ 20 files changed, 150 insertions(+), 347 deletions(-) create mode 100755 testcases/kernel/controllers/cgroup/cgroup_regress_test_10_1.sh create mode 100755 testcases/kernel/controllers/cgroup/cgroup_regress_test_10_2.sh create mode 100755 testcases/kernel/controllers/cgroup/cgroup_regress_test_3_1.sh create mode 100755 testcases/kernel/controllers/cgroup/cgroup_regress_test_3_2.sh create mode 100755 testcases/kernel/controllers/cgroup/cgroup_regress_test_6_1.sh create mode 100644 testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c create mode 100755 testcases/kernel/controllers/cgroup/cgroup_regress_test_9_1.sh create mode 100755 testcases/kernel/controllers/cgroup/cgroup_regress_test_9_2.sh delete mode 100755 testcases/kernel/controllers/cgroup/test_10_1.sh delete mode 100755 testcases/kernel/controllers/cgroup/test_10_2.sh delete mode 100755 testcases/kernel/controllers/cgroup/test_3_1.sh delete mode 100755 testcases/kernel/controllers/cgroup/test_3_2.sh delete mode 100755 testcases/kernel/controllers/cgroup/test_6_1.sh delete mode 100644 testcases/kernel/controllers/cgroup/test_6_2.c delete mode 100755 testcases/kernel/controllers/cgroup/test_9_1.sh delete mode 100755 testcases/kernel/controllers/cgroup/test_9_2.sh
testcases/kernel/controllers/cgroup/Makefile +3 -19
@@ -1,24 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2009, Cisco Systems Inc. +# Author: Ngie Cooper, July 2009 # # kernel/controllers/cgroup test suite Makefile. -# -# Copyright (C) 2009, Cisco Systems Inc. -# -# 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. -# -# Ngie Cooper, July 2009 -# top_srcdir ?= ../../../..
testcases/kernel/controllers/cgroup/cgroup_regress_test_10_1.sh new file +14 -0
@@ -0,0 +1,14 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2009 FUJITSU LIMITED +# Author: Li Zefan <[email protected]> + +trap exit USR1 +while true +do + mount -t cgroup xxx cgroup/ > /dev/null 2>&1 + mkdir cgroup/0 > /dev/null 2>&1 + rmdir cgroup/0 > /dev/null 2>&1 + umount cgroup/ > /dev/null 2>&1 +done +
testcases/kernel/controllers/cgroup/cgroup_regress_test_10_2.sh new file +12 -0
@@ -0,0 +1,12 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2009 FUJITSU LIMITED +# Author: Li Zefan <[email protected]> + +trap exit USR1 +while true +do + mount -t cgroup xxx cgroup/ > /dev/null 2>&1 + umount cgroup/ > /dev/null 2>&1 +done +
testcases/kernel/controllers/cgroup/cgroup_regress_test_3_1.sh new file +14 -0
@@ -0,0 +1,14 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2009 FUJITSU LIMITED +# Author: Li Zefan <[email protected]> + +trap exit USR1 + +path=$1 + +while true +do + mkdir $path/0 + rmdir $path/0 +done
testcases/kernel/controllers/cgroup/cgroup_regress_test_3_2.sh new file +11 -0
@@ -0,0 +1,11 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2009 FUJITSU LIMITED +# Author: Li Zefan <[email protected]> + +trap exit USR1 +while true +do + cat /proc/sched_debug > /dev/null +done +
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_1.sh new file +13 -0
@@ -0,0 +1,13 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2009 FUJITSU LIMITED +# Author: Li Zefan <[email protected]> + +trap exit USR1 +while true +do + mount -t cgroup -o ns xxx cgroup/ > /dev/null 2>&1 + rmdir cgroup/[1-9]* > /dev/null 2>&1 + umount cgroup/ > /dev/null 2>&1 +done +
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +37 -0
@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2009 FUJITSU LIMITED +* +* Author: Li Zefan <[email protected]> +*/ + +#define _GNU_SOURCE + +#include <sched.h> +#include <stdlib.h> +#include <unistd.h> +#include "test.h" + +#define DEFAULT_USEC 30000 + +int foo (void __attribute__ ((unused)) * arg) +{ +return 0 ; +} + +int main (int argc,char **argv) +{ +int usec; + +if (argc ==2 ) + usec =atoi (argv[1 ]); +else + usec =DEFAULT_USEC ; + +while (1 ) { +usleep (usec); +ltp_clone_quick (CLONE_NEWNS , foo,NULL ); + } + +tst_exit (); +}
testcases/kernel/controllers/cgroup/cgroup_regress_test_9_1.sh new file +14 -0
@@ -0,0 +1,14 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2009 FUJITSU LIMITED +# Author: Li Zefan <[email protected]> + +trap exit USR1 +while true +do +# mount -t cgroup -o debug xxx cgroup/ > /dev/null 2>&1 + mount -t cgroup xxx cgroup/ > /dev/null 2>&1 + cat cgroup/release_agent > /dev/null 2>&1 + umount cgroup/ > /dev/null 2>&1 +done +
testcases/kernel/controllers/cgroup/cgroup_regress_test_9_2.sh new file +13 -0
@@ -0,0 +1,13 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2009 FUJITSU LIMITED +# Author: Li Zefan <[email protected]> + +trap exit USR1 +while true +do +# mount -t cgroup -o debug xxx cgroup/ > /dev/null 2>&1 + mount -t cgroup xxx cgroup/ > /dev/null 2>&1 + umount cgroup/ > /dev/null 2>&1 +done +
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +12 -31
74 lines not on this page · raw message
testcases/kernel/controllers/cgroup/fork_processes.c +6 -21
@@ -1,24 +1,9 @@ -/******************************************************************************/ -/* */ -/* 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]> */ -/* */ -/******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2009 FUJITSU LIMITED +* +* Author: Li Zefan <[email protected]> +*/ #include <sys/types.h> #include <sys/wait.h>
testcases/kernel/controllers/cgroup/getdelays.c +1 -0
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* getdelays.c * * Utility to get per-pid and per-tgid delay accounting statistics
testcases/kernel/controllers/cgroup/test_10_1.sh deleted +0 -33
@@ -1,33 +0,0 @@ -#! /bin/bash - -################################################################################ -## ## -## 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]> ## -## ## -################################################################################ - -trap exit SIGUSR1 -for ((; ;)) -{ - mount -t cgroup xxx cgroup/ > /dev/null 2>&1 - mkdir cgroup/0 > /dev/null 2>&1 - rmdir cgroup/0 > /dev/null 2>&1 - umount cgroup/ > /dev/null 2>&1 -} -
testcases/kernel/controllers/cgroup/test_10_2.sh deleted +0 -31
@@ -1,31 +0,0 @@ -#! /bin/bash - -################################################################################ -## ## -## 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]> ## -## ## -################################################################################ - -trap exit SIGUSR1 -for ((; ;)) -{ - mount -t cgroup xxx cgroup/ > /dev/null 2>&1 - umount cgroup/ > /dev/null 2>&1 -} -
testcases/kernel/controllers/cgroup/test_3_1.sh deleted +0 -33
@@ -1,33 +0,0 @@ -#! /bin/bash - -################################################################################ -## ## -## 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]> ## -## ## -################################################################################ - -trap exit SIGUSR1 - -path=$1 - -for ((; ;)) -{ - mkdir $path/0 - rmdir $path/0 -}
testcases/kernel/controllers/cgroup/test_3_2.sh deleted +0 -30
@@ -1,30 +0,0 @@ -#! /bin/bash - -################################################################################ -## ## -## 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]> ## -## ## -################################################################################ - -trap exit SIGUSR1 -for ((; ;)) -{ - cat /proc/sched_debug > /dev/null -} -
testcases/kernel/controllers/cgroup/test_6_1.sh deleted +0 -32
@@ -1,32 +0,0 @@ -#! /bin/bash - -################################################################################ -## ## -## 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]> ## -## ## -################################################################################ - -trap exit SIGUSR1 -for ((; ;)) -{ - mount -t cgroup -o ns xxx cgroup/ > /dev/null 2>&1 - rmdir cgroup/[1-9]* > /dev/null 2>&1 - umount cgroup/ > /dev/null 2>&1 -} -
testcases/kernel/controllers/cgroup/test_6_2.c deleted +0 -52
52 lines not on this page · raw message
testcases/kernel/controllers/cgroup/test_9_1.sh deleted +0 -33
@@ -1,33 +0,0 @@ -#! /bin/bash - -################################################################################ -## ## -## 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]> ## -## ## -################################################################################ - -trap exit SIGUSR1 -for ((; ;)) -{ -# mount -t cgroup -o debug xxx cgroup/ > /dev/null 2>&1 - mount -t cgroup xxx cgroup/ > /dev/null 2>&1 - cat cgroup/release_agent > /dev/null 2>&1 - umount cgroup/ > /dev/null 2>&1 -} -
testcases/kernel/controllers/cgroup/test_9_2.sh deleted +0 -32
@@ -1,32 +0,0 @@ -#! /bin/bash - -################################################################################ -## ## -## 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]> ## -## ## -################################################################################ - -trap exit SIGUSR1 -for ((; ;)) -{ -# mount -t cgroup -o debug xxx cgroup/ > /dev/null 2>&1 - mount -t cgroup xxx cgroup/ > /dev/null 2>&1 - umount cgroup/ > /dev/null 2>&1 -} -
Signature · 1 line
2.17.1
PATCH v2 4/4 cgroup: helpers various fixes
Hi Cristian,
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c
Quoted 2 lines
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +0
-0
When you add new file, you need to put it also into .gitignore.
+ Remove /test_6_2 from it (original file).
...
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c line 8
Quoted 10 lines
+++
b/testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.ctestcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +8
-0@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2009 FUJITSU LIMITED +* +* Author: Li Zefan <[email protected]> +*/ + +#define _GNU_SOURCE
Is _GNU_SOURCE really needed?
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c line 13
Quoted 4 lines
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +4
-0+#include <sched.h> +#include <stdlib.h> +#include <unistd.h> +#include "test.h"
Please don't use legacy API.
Quoted 24 lines
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +24
-0+ +#define DEFAULT_USEC 30000 + +int foo (void __attribute__ ((unused)) * arg) +{ +return 0 ; +} + +int main (int argc,char **argv) +{ +int usec; + +if (argc ==2 ) + usec =atoi (argv[1 ]); +else + usec =DEFAULT_USEC ; + +while (1 ) { +usleep (usec); +ltp_clone_quick (CLONE_NEWNS , foo,NULL ); + } + +tst_exit (); +}
...
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c line 2
Quoted 4 lines
+++
b/testcases/kernel/controllers/cgroup/getdelays.ctestcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +1
-0@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* getdelays.c
There is build warning, can you please fix it:
getdelays.c: In function ‘get_family_id’:
getdelays.c:177:14: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
int id = 0, rc;
^~
getdelays.c: In function ‘main’:
getdelays.c:418:7: warning: variable ‘i’ set but not used [-Wunused-but-set-variable]
int i;
^Kind regards,
Petr
PATCH v2 4/4 cgroup: helpers various fixes
Hi
Quoted 7 lines · Petr Vorel
Hi Cristian,
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c
Quoted 2 lines
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +0
-0When you add new file, you need to put it also into .gitignore.
+ Remove /test_6_2 from it (original file).
Didn't know. I'll do that.
Quoted 13 lines
...
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c line 8
Quoted 10 lines
+++
b/testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.ctestcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +8
-0@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2009 FUJITSU LIMITED +* +* Author: Li Zefan <[email protected]> +*/ + +#define _GNU_SOURCEIs
_GNU_SOURCEreally needed?
I'll have a better look.
Quoted 6 lines
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c line 13
Quoted 4 lines
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +4
-0+#include <sched.h> +#include <stdlib.h> +#include <unistd.h> +#include "test.h" Please don't use legacy API.
Ok.
Quoted 34 lines
Quoted 24 lines
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +24
-0+ +#define DEFAULT_USEC 30000 + +int foo (void __attribute__ ((unused)) * arg) +{ +return 0 ; +} + +int main (int argc,char **argv) +{ +int usec; + +if (argc ==2 ) + usec =atoi (argv[1 ]); +else + usec =DEFAULT_USEC ; + +while (1 ) { +usleep (usec); +ltp_clone_quick (CLONE_NEWNS , foo,NULL ); + } + +tst_exit (); +}...
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c line 2
Quoted 4 lines
+++
b/testcases/kernel/controllers/cgroup/getdelays.ctestcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +1
-0@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* getdelays.c There is build warning, can you please fix it:
Quoted 9 lines
getdelays.c: In function ‘get_family_id’:
getdelays.c:177:14: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]int id = 0, rc; ^~ getdelays.c: In function ‘main’: getdelays.c:418:7: warning: variable ‘i’ set but not used [-Wunused-but-set-variable] int i; ^
Fine.
Quoted 3 lines
Kind regards,
Petr
Regards
Cristian
PATCH v2 4/4 cgroup: helpers various fixes
In reply to Petr VorelHi
Quoted 8 lines · Petr Vorel
Hi Cristian,
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c
Quoted 2 lines
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +0
-0When you add new file, you need to put it also into .gitignore.
+ Remove /test_6_2 from it (original file)....
Quoted 12 lines
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c line 8
Quoted 10 lines
+++
b/testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.ctestcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +8
-0@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2009 FUJITSU LIMITED +* +* Author: Li Zefan <[email protected]> +*/ + +#define _GNU_SOURCEIs
_GNU_SOURCEreally needed?
Yes..needed to compile the CLONE_NEWNS flag passed down the newlib function ltp_clone_quick()
Quoted 5 lines
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c line 13
Quoted 4 lines
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +4
-0+#include <sched.h> +#include <stdlib.h> +#include <unistd.h> +#include "test.h" Please don't use legacy API.
Done.
Quoted 35 lines
Quoted 25 lines
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +24
-0+ +#define DEFAULT_USEC 30000 + +int foo (void __attribute__ ((unused)) * arg) +{ +return 0 ; +} + +int main (int argc,char **argv) +{ +int usec; + +if (argc ==2 ) + usec =atoi (argv[1 ]); +else + usec =DEFAULT_USEC ; + +while (1 ) { +usleep (usec); +ltp_clone_quick (CLONE_NEWNS , foo,NULL ); + } + +tst_exit (); +}...
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c line 2
Quoted 4 lines
+++
b/testcases/kernel/controllers/cgroup/getdelays.ctestcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +1
-0@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* getdelays.c There is build warning, can you please fix it:
Quoted 9 lines
getdelays.c: In function ‘get_family_id’:
getdelays.c:177:14: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]int id = 0, rc; ^~ getdelays.c: In function ‘main’: getdelays.c:418:7: warning: variable ‘i’ set but not used [-Wunused-but-set-variable] int i; ^
Done.
Regards
Cristian
Quoted 3 lines
Kind regards,
Petr
v2 cover cgroup tests newlib-porting
In reply to Cristian MarussiHi Cristian,
thanks for your work, good work. I have some comments bellow.
Quoted 6 lines
This series converts cgroup/ regression tests to LTP newlib and performs a general cleanup as follows:
- remove bashism from all tests' scripts
- mostly remove usage of global vars
- convert to SPDX headers
You left big copyright in cpuacct.sh.
Quoted 8 lines
- expose a controllers' common
/proc/mountsparsing function
- rename tests' helpers prefixing them with a test-specific tag to avoid name clashes on install: I have not renamed the tests' helpers using more specific meaningful name, since all of them performs really trivial ops needed and meaningful in the context of the regression-test subcase they serve; so I thought it would have been better to keep their names as they are now, bound to the subcase they help.
Quoted 5 lines
Cristian Marussi (4):
[LTP]cgroup_regression_test.shported to newlib [LTP]cgroup_regression_test.shcleanup [LTP]cgroup_regression_test.sh: added helper [LTP] cgroup: helpers various fixes
Can you please squash it into single commit?
Or in two (first cleanup & rewrite of group_regression_test.sh, second for helpers). It does not bring much to split it like this.
I guess fork_processes.c and getdelays.c can be using new C API as well. You don't have to do it, but it can bring benefits (using tst_res(), info about command).
During cleanup please delete useless comments (getdelays.c: Compile with ...). I personally take SPDX license as sign that test has been cleanup from bad code and useless comments and ported into new API.
NOTE: you can add your copyright to the files.
Kind regards,
Petr
v2 cover cgroup tests newlib-porting
Hi Petr,
Quoted 3 lines · Petr Vorel
Hi Cristian,
thanks for your work, good work. I have some comments bellow.
Thanks for you review.
Quoted 8 lines
Quoted 7 lines
This series converts cgroup/ regression tests to LTP newlib and performs a general cleanup as follows:
- remove bashism from all tests' scripts
- mostly remove usage of global vars
- convert to SPDX headersYou left big copyright in
cpuacct.sh.
In this patch I have NOT touched anything else than the content of testcases/kernel/controllers/cgroup which are files related to the cgroup_regression_test.sh testcase; the file you mentioned is in testcases/kernel/controllers/cpuacct/ ... am I missing something ?
Quoted 15 lines
Quoted 9 lines
- expose a controllers' common
/proc/mountsparsing function
- rename tests' helpers prefixing them with a test-specific tag to avoid name clashes on install: I have not renamed the tests' helpers using more specific meaningful name, since all of them performs really trivial ops needed and meaningful in the context of the regression-test subcase they serve; so I thought it would have been better to keep their names as they are now, bound to the subcase they help.Quoted 5 lines
Cristian Marussi (4):
[LTP]cgroup_regression_test.shported to newlib [LTP]cgroup_regression_test.shcleanup [LTP]cgroup_regression_test.sh: added helper [LTP] cgroup: helpers various fixes
Quoted 3 lines
Can you please squash it into single commit?
Or in two (first cleanup & rewrite ofgroup_regression_test.sh, second for helpers). It does not bring much to split it like this.
Ok I'll squash..I splitted thinking it could have been complained of being not splitted :D
Quoted 4 lines
I guess
fork_processes.candgetdelays.ccan be using new C API as well. You don't have to do it, but it can bring benefits (usingtst_res(), info about command).
I'll review those too...I focused only on the shell-scripts logic ... not sure why in fact.
Quoted 5 lines
During cleanup please delete useless comments (
getdelays.c: Compile with ...). I personally take SPDX license as sign that test has been cleanup from bad code and useless comments and ported into new API.
ok
Quoted 5 lines
NOTE: you can add your copyright to the files.
Kind regards,
Petr
Regards
Cristian
v2 cover cgroup tests newlib-porting
Hi Cristian,
Quoted 5 lines
Quoted 1 line
You left big copyright in
cpuacct.sh.In this patch I have NOT touched anything else than the content of testcases/kernel/controllers/cgroup which are files related to the
cgroup_regression_test.shtestcase; the file you mentioned is in testcases/kernel/controllers/cpuacct/ ... am I missing something ?
Sorry, I was wrong.
Quoted 6 lines
Quoted 3 lines
Can you please squash it into single commit?
Or in two (first cleanup & rewrite ofgroup_regression_test.sh, second for helpers). It does not bring much to split it like this.Ok I'll squash..I splitted thinking it could have been complained of being not splitted :D
For small changes we like to have it atomic (split), but rewrite is IMHO better do it in one commit or two (group_regression_test.sh and then the rest - that's up to you). I focus too much on details for tests which are for very old kernel.
Quoted 6 lines
Quoted 3 lines
I guess
fork_processes.candgetdelays.ccan be using new C API as well. You don't have to do it, but it can bring benefits (usingtst_res(), info about command).I'll review those too...I focused only on the shell-scripts logic ... not sure why in fact.
I'd prefer to convert it to new C API or leave it as they are.
Kind regards,
Petr
v2 cover cgroup tests newlib-porting
Hi
Quoted 21 lines · Petr Vorel
Hi Cristian,
Quoted 5 lines
Quoted 1 line
You left big copyright in
cpuacct.sh.In this patch I have NOT touched anything else than the content of testcases/kernel/controllers/cgroup which are files related to the
cgroup_regression_test.shtestcase; the file you mentioned is in testcases/kernel/controllers/cpuacct/ ... am I missing something ?Sorry, I was wrong.
Quoted 6 lines
Quoted 3 lines
Can you please squash it into single commit?
Or in two (first cleanup & rewrite ofgroup_regression_test.sh, second for helpers). It does not bring much to split it like this.Ok I'll squash..I splitted thinking it could have been complained of being not splitted :D
For small changes we like to have it atomic (split), but rewrite is IMHO better do it in one commit or two (
group_regression_test.shand then the rest - that's up to you). I focus too much on details for tests which are for very old kernel.
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
I guess
fork_processes.candgetdelays.ccan be using new C API as well. You don't have to do it, but it can bring benefits (usingtst_res(), info about command).I'll review those too...I focused only on the shell-scripts logic ... not sure why in fact.
I'd prefer to convert it to new C API or leave it as they are.
I removed usage/references of the old API from fork_processes while getdelay it was completely unrelated from LTP API; in fact both are helpers launched by the LTP test scripts merely as background processes without any direct feedback reported to the testcase caller.
How could I use the new C API in this case ?
Regards
Cristian
Quoted 5 lines
Kind regards,
Petr