* [LTP] [PATCH] rcu/rcu_torture.sh: Rewrite test
@ 2019-06-02 14:23 Xiao Yang
2019-06-05 17:11 ` Alexey Kodanev
0 siblings, 1 reply; 9+ messages in thread
From: Xiao Yang @ 2019-06-02 14:23 UTC (permalink / raw)
To: ltp
1) Cleanup and convert to new API
2) Update rcutorture types(just rcu, srcu, srcud, tasks,
busted and busted_srcud are supported currently)
Note:
1) rcu, srcu, srcud and tasks expect SUCCESS
2) busted and busted_srcud expect FAILURE
Signed-off-by: Xiao Yang <ice_yangxiao@163.com>
---
testcases/kernel/device-drivers/rcu/rcu_torture.sh | 144 +++++++++------------
1 file changed, 63 insertions(+), 81 deletions(-)
diff --git a/testcases/kernel/device-drivers/rcu/rcu_torture.sh b/testcases/kernel/device-drivers/rcu/rcu_torture.sh
index c3739f9..56656ef 100755
--- a/testcases/kernel/device-drivers/rcu/rcu_torture.sh
+++ b/testcases/kernel/device-drivers/rcu/rcu_torture.sh
@@ -1,20 +1,7 @@
#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2014-2015 Oracle and/or its affiliates. All Rights Reserved.
-#
-# 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 would 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 the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#
+# Copyright (C) 2019 Xiao Yang <ice_yangxiao@163.com>
# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
#
# One of the possible ways to test RCU is to use rcutorture kernel module.
@@ -23,89 +10,84 @@
# dmesg output for module's test results.
# For more information, please read Linux Documentation: RCU/torture.txt
-TCID="rcu_torture"
-TST_TOTAL=14
-TST_CLEANUP=cleanup
+TST_CNT=6
+TST_SETUP=rcutorture_setup
+TST_TESTFUNC=do_test
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="modprobe rmmod dmesg tac sed head"
+TST_OPTS="t:w:"
+TST_USAGE=rcutorture_usage
+TST_PARSE_ARGS=rcutorture_parse_args
-. test.sh
+. tst_test.sh
# default options
-test_time=60
+test_time=30
num_writers=5
-while getopts :ht:w: opt; do
- case "$opt" in
- h)
- echo "Usage:"
- echo "h help"
- echo "t x time in seconds for each test-case"
- echo "w x number of writers"
- exit 0
- ;;
- t) test_time=$OPTARG ;;
- w) num_writers=$OPTARG ;;
- *)
- tst_brkm TBROK "unknown option: $opt"
- ;;
- esac
-done
-
-cleanup()
+rcutorture_usage()
{
- tst_resm TINFO "cleanup"
- rmmod rcutorture > /dev/null 2>&1
+ echo "Usage:"
+ echo "-t x time in seconds for each test-case"
+ echo "-w x number of writers"
}
-tst_require_root
-
-# check if module is present
-modprobe rcutorture > /dev/null 2>&1 || \
- tst_brkm TCONF "Test requires rcutorture module"
-rmmod rcutorture > /dev/null 2>&1
-
-trap cleanup INT
-
-rcu_type="rcu rcu_bh srcu sched"
-
-if tst_kvcmp -lt "3.12"; then
- rcu_type="$rcu_type rcu_sync rcu_expedited rcu_bh_sync rcu_bh_expedited \
- srcu_sync srcu_expedited sched_sync sched_expedited"
+rcutorture_parse_args()
+{
+ case $1 in
+ t) test_time=$2 ;;
+ w) num_writers=$2 ;;
+ esac
+}
- if tst_kvcmp -lt "3.11"; then
- rcu_type="$rcu_type srcu_raw srcu_raw_sync"
- fi
-fi
+rcutorture_setup()
+{
+ # do test by insert and remove rcutorture module so
+ # check that it is not built-in or loaded
+ modprobe -n --first-time rcutorture >/dev/null 2>&1 || \
+ tst_brk TCONF "built-in or loaded rcutorture"
+}
-TST_TOTAL=$(echo "$rcu_type" | wc -w)
+rcutorture_test()
+{
+ local rcu_type=$1
+ local exp_res=$2
-est_time=`echo "scale=2; $test_time * $TST_TOTAL / 60 " | bc`
-tst_resm TINFO "estimate time $est_time min"
+ tst_res TINFO "${rcu_type}-torture: running ${test_time} sec..."
-for type in $rcu_type; do
+ modprobe rcutorture nfakewriters=${num_writers} torture_type=${rcu_type} \
+ >/dev/null 2>&1 || tst_brk TBROK "failed to load module"
- tst_resm TINFO "$type: running $test_time sec..."
+ sleep ${test_time}
- modprobe rcutorture nfakewriters=$num_writers \
- stat_interval=60 test_no_idle_hz=1 shuffle_interval=3 \
- stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 \
- fqs_stutter=3 test_boost=1 test_boost_interval=7 \
- test_boost_duration=4 shutdown_secs=0 \
- stall_cpu=0 stall_cpu_holdoff=10 n_barrier_cbs=0 \
- onoff_interval=0 onoff_holdoff=0 torture_type=$type \
- > /dev/null 2>&1 || tst_brkm TBROK "failed to load module"
+ rmmod rcutorture >/dev/null 2>&1 || \
+ tst_brk TBROK "failed to unload module"
- sleep $test_time
+ # check module status in dmesg
+ local output=$(dmesg | tac | grep " ${rcu_type}-torture:.* End of test" | head -n1)
+ [ -z "$output" ] && tst_brk TBROK "${rcu_type}: incompleted"
- rmmod rcutorture > /dev/null 2>&1 || \
- tst_brkm TBROK "failed to unload module"
+ mod_parms=$(echo "$output" | sed -nE 's/.* End of test: .*: (.*)/\1/p')
+ tst_res TINFO "${rcu_type}-torture with ${mod_parms}"
- # check module status in dmesg
- result_str=`dmesg | sed -nE '$s/.*End of test: ([A-Z]+):.*/\1/p'`
- if [ "$result_str" = "SUCCESS" ]; then
- tst_resm TPASS "$type: completed"
+ act_res=$(echo "$output" | sed -nE 's/.* End of test: (.*): .*/\1/p')
+ if [ "${act_res}" = "${exp_res}" ]; then
+ tst_res TPASS "${rcu_type}-torture: ${act_res}"
else
- tst_resm TFAIL "$type: $result_str, see dmesg"
+ tst_res TFAIL "${rcu_type}-torture: ${act_res}, see dmesg"
fi
-done
+}
+
+do_test()
+{
+ case $1 in
+ 1) rcutorture_test rcu SUCCESS;;
+ 2) rcutorture_test srcu SUCCESS;;
+ 3) rcutorture_test srcud SUCCESS;;
+ 4) rcutorture_test tasks SUCCESS;;
+ 5) rcutorture_test busted FAILURE;;
+ 6) rcutorture_test busted_srcud FAILURE;;
+ esac
+}
-tst_exit
+tst_run
--
1.8.3.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [LTP] [PATCH] rcu/rcu_torture.sh: Rewrite test
2019-06-02 14:23 [LTP] [PATCH] rcu/rcu_torture.sh: Rewrite test Xiao Yang
@ 2019-06-05 17:11 ` Alexey Kodanev
2019-06-06 2:35 ` Xiao Yang
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Alexey Kodanev @ 2019-06-05 17:11 UTC (permalink / raw)
To: ltp
Hi,
On 6/2/19 5:23 PM, Xiao Yang wrote:
> 1) Cleanup and convert to new API
> 2) Update rcutorture types(just rcu, srcu, srcud, tasks,
> busted and busted_srcud are supported currently)
>
> Note:
> 1) rcu, srcu, srcud and tasks expect SUCCESS
> 2) busted and busted_srcud expect FAILURE
>
It would be good to check that the kernel supports these new types before
the test-case starts, TCONF otherwise. For example, "busted_scrud" requires
4.19+.
I'm not sure if we need to run the busted* tests though... they are checking
the test itself? Besides, after they are loaded, we cannot unload rcutorture module?
> Signed-off-by: Xiao Yang <ice_yangxiao@163.com>
> ---
> testcases/kernel/device-drivers/rcu/rcu_torture.sh | 144 +++++++++------------
> 1 file changed, 63 insertions(+), 81 deletions(-)
>
> diff --git a/testcases/kernel/device-drivers/rcu/rcu_torture.sh b/testcases/kernel/device-drivers/rcu/rcu_torture.sh
> index c3739f9..56656ef 100755
> --- a/testcases/kernel/device-drivers/rcu/rcu_torture.sh
> +++ b/testcases/kernel/device-drivers/rcu/rcu_torture.sh
> @@ -1,20 +1,7 @@
> #!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-or-later
> # Copyright (c) 2014-2015 Oracle and/or its affiliates. All Rights Reserved.
> -#
> -# 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 would 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 the Free Software Foundation,
> -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> -#
> +# Copyright (C) 2019 Xiao Yang <ice_yangxiao@163.com>
> # Author: Alexey Kodanev <alexey.kodanev@oracle.com>
> #
> # One of the possible ways to test RCU is to use rcutorture kernel module.
> @@ -23,89 +10,84 @@
> # dmesg output for module's test results.
> # For more information, please read Linux Documentation: RCU/torture.txt
>
> -TCID="rcu_torture"
> -TST_TOTAL=14
> -TST_CLEANUP=cleanup
> +TST_CNT=6
> +TST_SETUP=rcutorture_setup
> +TST_TESTFUNC=do_test
> +TST_NEEDS_ROOT=1
> +TST_NEEDS_CMDS="modprobe rmmod dmesg tac sed head"
TST_NEEDS_DRIVERS="rcutorture"?
> +TST_OPTS="t:w:"
> +TST_USAGE=rcutorture_usage
> +TST_PARSE_ARGS=rcutorture_parse_args
>
> -. test.sh
> +. tst_test.sh
>
> # default options
> -test_time=60
> +test_time=30
> num_writers=5
>
> -while getopts :ht:w: opt; do
> - case "$opt" in
> - h)
> - echo "Usage:"
> - echo "h help"
> - echo "t x time in seconds for each test-case"
> - echo "w x number of writers"
> - exit 0
> - ;;
> - t) test_time=$OPTARG ;;
> - w) num_writers=$OPTARG ;;
> - *)
> - tst_brkm TBROK "unknown option: $opt"
> - ;;
> - esac
> -done
> -
> -cleanup()
> +rcutorture_usage()
> {
> - tst_resm TINFO "cleanup"
> - rmmod rcutorture > /dev/null 2>&1
> + echo "Usage:"
> + echo "-t x time in seconds for each test-case"
> + echo "-w x number of writers"
> }
>
> -tst_require_root
> -
> -# check if module is present
> -modprobe rcutorture > /dev/null 2>&1 || \
> - tst_brkm TCONF "Test requires rcutorture module"
> -rmmod rcutorture > /dev/null 2>&1
> -
> -trap cleanup INT
> -
> -rcu_type="rcu rcu_bh srcu sched"
> -
> -if tst_kvcmp -lt "3.12"; then
> - rcu_type="$rcu_type rcu_sync rcu_expedited rcu_bh_sync rcu_bh_expedited \
> - srcu_sync srcu_expedited sched_sync sched_expedited"
> +rcutorture_parse_args()
> +{
> + case $1 in
> + t) test_time=$2 ;;
> + w) num_writers=$2 ;;
> + esac
> +}
>
> - if tst_kvcmp -lt "3.11"; then
> - rcu_type="$rcu_type srcu_raw srcu_raw_sync"
> - fi
> -fi
> +rcutorture_setup()
> +{
> + # do test by insert and remove rcutorture module so
> + # check that it is not built-in or loaded
> + modprobe -n --first-time rcutorture >/dev/null 2>&1 || \
> + tst_brk TCONF "built-in or loaded rcutorture"
> +}
>
> -TST_TOTAL=$(echo "$rcu_type" | wc -w)
> +rcutorture_test()
> +{
> + local rcu_type=$1
> + local exp_res=$2
>
> -est_time=`echo "scale=2; $test_time * $TST_TOTAL / 60 " | bc`
> -tst_resm TINFO "estimate time $est_time min"
> + tst_res TINFO "${rcu_type}-torture: running ${test_time} sec..."
>
> -for type in $rcu_type; do
> + modprobe rcutorture nfakewriters=${num_writers} torture_type=${rcu_type} \
> + >/dev/null 2>&1 || tst_brk TBROK "failed to load module"
>
> - tst_resm TINFO "$type: running $test_time sec..."
> + sleep ${test_time}
>
> - modprobe rcutorture nfakewriters=$num_writers \
> - stat_interval=60 test_no_idle_hz=1 shuffle_interval=3 \
> - stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 \
> - fqs_stutter=3 test_boost=1 test_boost_interval=7 \
> - test_boost_duration=4 shutdown_secs=0 \
> - stall_cpu=0 stall_cpu_holdoff=10 n_barrier_cbs=0 \
> - onoff_interval=0 onoff_holdoff=0 torture_type=$type \
> - > /dev/null 2>&1 || tst_brkm TBROK "failed to load module"
> + rmmod rcutorture >/dev/null 2>&1 || \
> + tst_brk TBROK "failed to unload module"
>
> - sleep $test_time
> + # check module status in dmesg
> + local output=$(dmesg | tac | grep " ${rcu_type}-torture:.* End of test" | head -n1)
> + [ -z "$output" ] && tst_brk TBROK "${rcu_type}: incompleted"
>
> - rmmod rcutorture > /dev/null 2>&1 || \
> - tst_brkm TBROK "failed to unload module"
> + mod_parms=$(echo "$output" | sed -nE 's/.* End of test: .*: (.*)/\1/p')
> + tst_res TINFO "${rcu_type}-torture with ${mod_parms}"
>
> - # check module status in dmesg
> - result_str=`dmesg | sed -nE '$s/.*End of test: ([A-Z]+):.*/\1/p'`
> - if [ "$result_str" = "SUCCESS" ]; then
> - tst_resm TPASS "$type: completed"
> + act_res=$(echo "$output" | sed -nE 's/.* End of test: (.*): .*/\1/p')
> + if [ "${act_res}" = "${exp_res}" ]; then
> + tst_res TPASS "${rcu_type}-torture: ${act_res}"
> else
> - tst_resm TFAIL "$type: $result_str, see dmesg"
> + tst_res TFAIL "${rcu_type}-torture: ${act_res}, see dmesg"
> fi
> -done
> +}
> +
> +do_test()
> +{
> + case $1 in
> + 1) rcutorture_test rcu SUCCESS;;
> + 2) rcutorture_test srcu SUCCESS;;
> + 3) rcutorture_test srcud SUCCESS;;
> + 4) rcutorture_test tasks SUCCESS;;
> + 5) rcutorture_test busted FAILURE;;
> + 6) rcutorture_test busted_srcud FAILURE;;
> + esac
> +}
>
> -tst_exit
> +tst_run
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [LTP] [PATCH] rcu/rcu_torture.sh: Rewrite test
2019-06-05 17:11 ` Alexey Kodanev
@ 2019-06-06 2:35 ` Xiao Yang
2019-06-07 15:23 ` [LTP] [PATCH v2] " Xiao Yang
2019-06-07 15:40 ` Xiao Yang
2 siblings, 0 replies; 9+ messages in thread
From: Xiao Yang @ 2019-06-06 2:35 UTC (permalink / raw)
To: ltp
Hi Alexey,
Thanks for your review.
On 06/06/2019 01:11 AM, Alexey Kodanev wrote:
> Hi,
> On 6/2/19 5:23 PM, Xiao Yang wrote:
>> 1) Cleanup and convert to new API
>> 2) Update rcutorture types(just rcu, srcu, srcud, tasks,
>> busted and busted_srcud are supported currently)
>>
>> Note:
>> 1) rcu, srcu, srcud and tasks expect SUCCESS
>> 2) busted and busted_srcud expect FAILURE
>>
> It would be good to check that the kernel supports these new types before
> the test-case starts, TCONF otherwise. For example, "busted_scrud" requires
> 4.19+.
Can we match output or dmesg to check if these types are supported by
kernel?
For example:
# modprobe rcutorture torture_type=sched
modprobe: ERROR: could not insert 'rcutorture': Invalid argument
# dmesg | grep "invalid torture type"
[ 2858.593610] rcu-torture: invalid torture type: "sched"
>
> I'm not sure if we need to run the busted* tests though... they are checking
> the test itself? Besides, after they are loaded, we cannot unload rcutorture module?
1) Perhaps, we can remove busted* tests as RCU maintainer said:
https://www.spinics.net/lists/kernel/msg3045252.html
2) I can load and then unload rcutorture module, as below:
# modprobe rcutorture torture_type=rcu
# lsmod | grep rcutorture
rcutorture 221184 0
torture 28672 1 rcutorture
# modprobe -r rcutorture
# lsmod | grep rcutorture
Nothing
# modprobe rcutorture torture_type=busted
# lsmod | grep rcutorture
rcutorture 221184 0
torture 28672 1 rcutorture
# modprobe -r rcutorture
# lsmod | grep rcutorture
Nothing
>
>
>> Signed-off-by: Xiao Yang <ice_yangxiao@163.com>
>> ---
>> testcases/kernel/device-drivers/rcu/rcu_torture.sh | 144 +++++++++------------
>> 1 file changed, 63 insertions(+), 81 deletions(-)
>>
>> diff --git a/testcases/kernel/device-drivers/rcu/rcu_torture.sh b/testcases/kernel/device-drivers/rcu/rcu_torture.sh
>> index c3739f9..56656ef 100755
>> --- a/testcases/kernel/device-drivers/rcu/rcu_torture.sh
>> +++ b/testcases/kernel/device-drivers/rcu/rcu_torture.sh
>> @@ -1,20 +1,7 @@
>> #!/bin/sh
>> +# SPDX-License-Identifier: GPL-2.0-or-later
>> # Copyright (c) 2014-2015 Oracle and/or its affiliates. All Rights Reserved.
>> -#
>> -# 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 would 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 the Free Software Foundation,
>> -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
>> -#
>> +# Copyright (C) 2019 Xiao Yang <ice_yangxiao@163.com>
>> # Author: Alexey Kodanev <alexey.kodanev@oracle.com>
>> #
>> # One of the possible ways to test RCU is to use rcutorture kernel module.
>> @@ -23,89 +10,84 @@
>> # dmesg output for module's test results.
>> # For more information, please read Linux Documentation: RCU/torture.txt
>>
>> -TCID="rcu_torture"
>> -TST_TOTAL=14
>> -TST_CLEANUP=cleanup
>> +TST_CNT=6
>> +TST_SETUP=rcutorture_setup
>> +TST_TESTFUNC=do_test
>> +TST_NEEDS_ROOT=1
>> +TST_NEEDS_CMDS="modprobe rmmod dmesg tac sed head"
> TST_NEEDS_DRIVERS="rcutorture"?
We do test by inserting and removing rcutorture module so I use
rcutorture_setup() instead to ensure that it is not built-in or loaded.
Best Regards,
Xiao Yang
>
>> +TST_OPTS="t:w:"
>> +TST_USAGE=rcutorture_usage
>> +TST_PARSE_ARGS=rcutorture_parse_args
>>
>> -. test.sh
>> +. tst_test.sh
>>
>> # default options
>> -test_time=60
>> +test_time=30
>> num_writers=5
>>
>> -while getopts :ht:w: opt; do
>> - case "$opt" in
>> - h)
>> - echo "Usage:"
>> - echo "h help"
>> - echo "t x time in seconds for each test-case"
>> - echo "w x number of writers"
>> - exit 0
>> - ;;
>> - t) test_time=$OPTARG ;;
>> - w) num_writers=$OPTARG ;;
>> - *)
>> - tst_brkm TBROK "unknown option: $opt"
>> - ;;
>> - esac
>> -done
>> -
>> -cleanup()
>> +rcutorture_usage()
>> {
>> - tst_resm TINFO "cleanup"
>> - rmmod rcutorture > /dev/null 2>&1
>> + echo "Usage:"
>> + echo "-t x time in seconds for each test-case"
>> + echo "-w x number of writers"
>> }
>>
>> -tst_require_root
>> -
>> -# check if module is present
>> -modprobe rcutorture > /dev/null 2>&1 || \
>> - tst_brkm TCONF "Test requires rcutorture module"
>> -rmmod rcutorture > /dev/null 2>&1
>> -
>> -trap cleanup INT
>> -
>> -rcu_type="rcu rcu_bh srcu sched"
>> -
>> -if tst_kvcmp -lt "3.12"; then
>> - rcu_type="$rcu_type rcu_sync rcu_expedited rcu_bh_sync rcu_bh_expedited \
>> - srcu_sync srcu_expedited sched_sync sched_expedited"
>> +rcutorture_parse_args()
>> +{
>> + case $1 in
>> + t) test_time=$2 ;;
>> + w) num_writers=$2 ;;
>> + esac
>> +}
>>
>> - if tst_kvcmp -lt "3.11"; then
>> - rcu_type="$rcu_type srcu_raw srcu_raw_sync"
>> - fi
>> -fi
>> +rcutorture_setup()
>> +{
>> + # do test by insert and remove rcutorture module so
>> + # check that it is not built-in or loaded
>> + modprobe -n --first-time rcutorture >/dev/null 2>&1 || \
>> + tst_brk TCONF "built-in or loaded rcutorture"
>> +}
>>
>> -TST_TOTAL=$(echo "$rcu_type" | wc -w)
>> +rcutorture_test()
>> +{
>> + local rcu_type=$1
>> + local exp_res=$2
>>
>> -est_time=`echo "scale=2; $test_time * $TST_TOTAL / 60 " | bc`
>> -tst_resm TINFO "estimate time $est_time min"
>> + tst_res TINFO "${rcu_type}-torture: running ${test_time} sec..."
>>
>> -for type in $rcu_type; do
>> + modprobe rcutorture nfakewriters=${num_writers} torture_type=${rcu_type} \
>> + >/dev/null 2>&1 || tst_brk TBROK "failed to load module"
>>
>> - tst_resm TINFO "$type: running $test_time sec..."
>> + sleep ${test_time}
>>
>> - modprobe rcutorture nfakewriters=$num_writers \
>> - stat_interval=60 test_no_idle_hz=1 shuffle_interval=3 \
>> - stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 \
>> - fqs_stutter=3 test_boost=1 test_boost_interval=7 \
>> - test_boost_duration=4 shutdown_secs=0 \
>> - stall_cpu=0 stall_cpu_holdoff=10 n_barrier_cbs=0 \
>> - onoff_interval=0 onoff_holdoff=0 torture_type=$type \
>> - > /dev/null 2>&1 || tst_brkm TBROK "failed to load module"
>> + rmmod rcutorture >/dev/null 2>&1 || \
>> + tst_brk TBROK "failed to unload module"
>>
>> - sleep $test_time
>> + # check module status in dmesg
>> + local output=$(dmesg | tac | grep " ${rcu_type}-torture:.* End of test" | head -n1)
>> + [ -z "$output" ] && tst_brk TBROK "${rcu_type}: incompleted"
>>
>> - rmmod rcutorture > /dev/null 2>&1 || \
>> - tst_brkm TBROK "failed to unload module"
>> + mod_parms=$(echo "$output" | sed -nE 's/.* End of test: .*: (.*)/\1/p')
>> + tst_res TINFO "${rcu_type}-torture with ${mod_parms}"
>>
>> - # check module status in dmesg
>> - result_str=`dmesg | sed -nE '$s/.*End of test: ([A-Z]+):.*/\1/p'`
>> - if [ "$result_str" = "SUCCESS" ]; then
>> - tst_resm TPASS "$type: completed"
>> + act_res=$(echo "$output" | sed -nE 's/.* End of test: (.*): .*/\1/p')
>> + if [ "${act_res}" = "${exp_res}" ]; then
>> + tst_res TPASS "${rcu_type}-torture: ${act_res}"
>> else
>> - tst_resm TFAIL "$type: $result_str, see dmesg"
>> + tst_res TFAIL "${rcu_type}-torture: ${act_res}, see dmesg"
>> fi
>> -done
>> +}
>> +
>> +do_test()
>> +{
>> + case $1 in
>> + 1) rcutorture_test rcu SUCCESS;;
>> + 2) rcutorture_test srcu SUCCESS;;
>> + 3) rcutorture_test srcud SUCCESS;;
>> + 4) rcutorture_test tasks SUCCESS;;
>> + 5) rcutorture_test busted FAILURE;;
>> + 6) rcutorture_test busted_srcud FAILURE;;
>> + esac
>> +}
>>
>> -tst_exit
>> +tst_run
>>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [LTP] [PATCH v2] rcu/rcu_torture.sh: Rewrite test
2019-06-05 17:11 ` Alexey Kodanev
2019-06-06 2:35 ` Xiao Yang
@ 2019-06-07 15:23 ` Xiao Yang
2019-06-07 15:38 ` Xiao Yang
2019-06-07 15:40 ` Xiao Yang
2 siblings, 1 reply; 9+ messages in thread
From: Xiao Yang @ 2019-06-07 15:23 UTC (permalink / raw)
To: ltp
1) Cleanup and convert to new API
2) Update valid rcutorture types(rcu, srcu, srcud, tasks)
Note:
Exclude valid busted* types(busted, busted_srcud) that check
the test itself and expect failures, suggested by:
https://www.spinics.net/lists/kernel/msg3045252.html
Signed-off-by: Xiao Yang <ice_yangxiao@163.com>
v2:
1) Add check for invalid rcutorture types
2) Remove unnecessary code and update descriptions
3) Exclude busted* types
---
testcases/kernel/device-drivers/rcu/rcu_torture.sh | 139 +++++++++------------
1 file changed, 59 insertions(+), 80 deletions(-)
diff --git a/testcases/kernel/device-drivers/rcu/rcu_torture.sh b/testcases/kernel/device-drivers/rcu/rcu_torture.sh
index c3739f9..5549bd2 100755
--- a/testcases/kernel/device-drivers/rcu/rcu_torture.sh
+++ b/testcases/kernel/device-drivers/rcu/rcu_torture.sh
@@ -1,20 +1,7 @@
#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2014-2015 Oracle and/or its affiliates. All Rights Reserved.
-#
-# 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 would 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 the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#
+# Copyright (C) 2019 Xiao Yang <ice_yangxiao@163.com>
# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
#
# One of the possible ways to test RCU is to use rcutorture kernel module.
@@ -23,89 +10,81 @@
# dmesg output for module's test results.
# For more information, please read Linux Documentation: RCU/torture.txt
-TCID="rcu_torture"
-TST_TOTAL=14
-TST_CLEANUP=cleanup
+TST_CNT=4
+TST_SETUP=rcutorture_setup
+TST_TESTFUNC=do_test
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="modprobe rmmod dmesg sed tail"
+TST_OPTS="t:w:"
+TST_USAGE=rcutorture_usage
+TST_PARSE_ARGS=rcutorture_parse_args
-. test.sh
+. tst_test.sh
# default options
-test_time=60
+test_time=30
num_writers=5
-while getopts :ht:w: opt; do
- case "$opt" in
- h)
- echo "Usage:"
- echo "h help"
- echo "t x time in seconds for each test-case"
- echo "w x number of writers"
- exit 0
- ;;
- t) test_time=$OPTARG ;;
- w) num_writers=$OPTARG ;;
- *)
- tst_brkm TBROK "unknown option: $opt"
- ;;
- esac
-done
-
-cleanup()
+rcutorture_usage()
{
- tst_resm TINFO "cleanup"
- rmmod rcutorture > /dev/null 2>&1
+ echo "Usage:"
+ echo "-t x time in seconds for each test-case"
+ echo "-w x number of writers"
}
-tst_require_root
+rcutorture_parse_args()
+{
+ case $1 in
+ t) test_time=$2 ;;
+ w) num_writers=$2 ;;
+ esac
+}
-# check if module is present
-modprobe rcutorture > /dev/null 2>&1 || \
- tst_brkm TCONF "Test requires rcutorture module"
-rmmod rcutorture > /dev/null 2>&1
+rcutorture_setup()
+{
+ # do test by inserting and removing rcutorture module
+ # so check if it is built-in, loaded or unbuilt
+ modprobe -n --first-time rcutorture >/dev/null 2>&1 || \
+ tst_brk TCONF "built-in, loaded or unbuilt rcutorture"
+}
-trap cleanup INT
+rcutorture_test()
+{
+ local rcu_type=$1
-rcu_type="rcu rcu_bh srcu sched"
+ tst_res TINFO "${rcu_type}-torture: running ${test_time} sec..."
-if tst_kvcmp -lt "3.12"; then
- rcu_type="$rcu_type rcu_sync rcu_expedited rcu_bh_sync rcu_bh_expedited \
- srcu_sync srcu_expedited sched_sync sched_expedited"
+ modprobe rcutorture nfakewriters=${num_writers} \
+ torture_type=${rcu_type} >/dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ dmesg | grep -q "invalid torture type: \"${rcu_type}\"" && \
+ tst_brk TCONF "invalid ${rcu_type} type"
- if tst_kvcmp -lt "3.11"; then
- rcu_type="$rcu_type srcu_raw srcu_raw_sync"
+ tst_brk TBROK "failed to load module"
fi
-fi
-
-TST_TOTAL=$(echo "$rcu_type" | wc -w)
-
-est_time=`echo "scale=2; $test_time * $TST_TOTAL / 60 " | bc`
-tst_resm TINFO "estimate time $est_time min"
-
-for type in $rcu_type; do
-
- tst_resm TINFO "$type: running $test_time sec..."
-
- modprobe rcutorture nfakewriters=$num_writers \
- stat_interval=60 test_no_idle_hz=1 shuffle_interval=3 \
- stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 \
- fqs_stutter=3 test_boost=1 test_boost_interval=7 \
- test_boost_duration=4 shutdown_secs=0 \
- stall_cpu=0 stall_cpu_holdoff=10 n_barrier_cbs=0 \
- onoff_interval=0 onoff_holdoff=0 torture_type=$type \
- > /dev/null 2>&1 || tst_brkm TBROK "failed to load module"
- sleep $test_time
+ sleep ${test_time}
- rmmod rcutorture > /dev/null 2>&1 || \
- tst_brkm TBROK "failed to unload module"
+ rmmod rcutorture >/dev/null 2>&1 || \
+ tst_brk TBROK "failed to unload module"
# check module status in dmesg
- result_str=`dmesg | sed -nE '$s/.*End of test: ([A-Z]+):.*/\1/p'`
- if [ "$result_str" = "SUCCESS" ]; then
- tst_resm TPASS "$type: completed"
+ local res=$(dmesg | sed -nE "s/.* ${rcu_type}-torture:.* End of test: (.*): .*/\1/p" | tail -n1)
+ if [ "$res" = "SUCCESS" ]; then
+ tst_res TPASS "${rcu_type}-torture: $res"
else
- tst_resm TFAIL "$type: $result_str, see dmesg"
+ tst_res TFAIL "${rcu_type}-torture: $res, see dmesg"
fi
-done
+}
+
+do_test()
+{
+ case $1 in
+ 1) rcutorture_test rcu;;
+ 2) rcutorture_test srcu;;
+ 3) rcutorture_test srcud;;
+ 4) rcutorture_test tasks;;
+ esac
+}
-tst_exit
+tst_run
--
1.8.3.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [LTP] [PATCH v2] rcu/rcu_torture.sh: Rewrite test
2019-06-07 15:23 ` [LTP] [PATCH v2] " Xiao Yang
@ 2019-06-07 15:38 ` Xiao Yang
0 siblings, 0 replies; 9+ messages in thread
From: Xiao Yang @ 2019-06-07 15:38 UTC (permalink / raw)
To: ltp
On 06/07/2019 11:23 PM, Xiao Yang wrote:
> 1) Cleanup and convert to new API
> 2) Update valid rcutorture types(rcu, srcu, srcud, tasks)
>
> Note:
> Exclude valid busted* types(busted, busted_srcud) that check
> the test itself and expect failures, suggested by:
> https://www.spinics.net/lists/kernel/msg3045252.html
>
> Signed-off-by: Xiao Yang <ice_yangxiao@163.com>
>
> v2:
> 1) Add check for invalid rcutorture types
> 2) Remove unnecessary code and update descriptions
> 3) Exclude busted* types
Hi,
Sorry, the changelog was misplaced.
Please ignore it and I will resend the v2 patch.
Best Regards,
Xiao Yang
> ---
> testcases/kernel/device-drivers/rcu/rcu_torture.sh | 139 +++++++++------------
> 1 file changed, 59 insertions(+), 80 deletions(-)
>
> diff --git a/testcases/kernel/device-drivers/rcu/rcu_torture.sh b/testcases/kernel/device-drivers/rcu/rcu_torture.sh
> index c3739f9..5549bd2 100755
> --- a/testcases/kernel/device-drivers/rcu/rcu_torture.sh
> +++ b/testcases/kernel/device-drivers/rcu/rcu_torture.sh
> @@ -1,20 +1,7 @@
> #!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-or-later
> # Copyright (c) 2014-2015 Oracle and/or its affiliates. All Rights Reserved.
> -#
> -# 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 would 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 the Free Software Foundation,
> -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> -#
> +# Copyright (C) 2019 Xiao Yang <ice_yangxiao@163.com>
> # Author: Alexey Kodanev <alexey.kodanev@oracle.com>
> #
> # One of the possible ways to test RCU is to use rcutorture kernel module.
> @@ -23,89 +10,81 @@
> # dmesg output for module's test results.
> # For more information, please read Linux Documentation: RCU/torture.txt
>
> -TCID="rcu_torture"
> -TST_TOTAL=14
> -TST_CLEANUP=cleanup
> +TST_CNT=4
> +TST_SETUP=rcutorture_setup
> +TST_TESTFUNC=do_test
> +TST_NEEDS_ROOT=1
> +TST_NEEDS_CMDS="modprobe rmmod dmesg sed tail"
> +TST_OPTS="t:w:"
> +TST_USAGE=rcutorture_usage
> +TST_PARSE_ARGS=rcutorture_parse_args
>
> -. test.sh
> +. tst_test.sh
>
> # default options
> -test_time=60
> +test_time=30
> num_writers=5
>
> -while getopts :ht:w: opt; do
> - case "$opt" in
> - h)
> - echo "Usage:"
> - echo "h help"
> - echo "t x time in seconds for each test-case"
> - echo "w x number of writers"
> - exit 0
> - ;;
> - t) test_time=$OPTARG ;;
> - w) num_writers=$OPTARG ;;
> - *)
> - tst_brkm TBROK "unknown option: $opt"
> - ;;
> - esac
> -done
> -
> -cleanup()
> +rcutorture_usage()
> {
> - tst_resm TINFO "cleanup"
> - rmmod rcutorture > /dev/null 2>&1
> + echo "Usage:"
> + echo "-t x time in seconds for each test-case"
> + echo "-w x number of writers"
> }
>
> -tst_require_root
> +rcutorture_parse_args()
> +{
> + case $1 in
> + t) test_time=$2 ;;
> + w) num_writers=$2 ;;
> + esac
> +}
>
> -# check if module is present
> -modprobe rcutorture > /dev/null 2>&1 || \
> - tst_brkm TCONF "Test requires rcutorture module"
> -rmmod rcutorture > /dev/null 2>&1
> +rcutorture_setup()
> +{
> + # do test by inserting and removing rcutorture module
> + # so check if it is built-in, loaded or unbuilt
> + modprobe -n --first-time rcutorture >/dev/null 2>&1 || \
> + tst_brk TCONF "built-in, loaded or unbuilt rcutorture"
> +}
>
> -trap cleanup INT
> +rcutorture_test()
> +{
> + local rcu_type=$1
>
> -rcu_type="rcu rcu_bh srcu sched"
> + tst_res TINFO "${rcu_type}-torture: running ${test_time} sec..."
>
> -if tst_kvcmp -lt "3.12"; then
> - rcu_type="$rcu_type rcu_sync rcu_expedited rcu_bh_sync rcu_bh_expedited \
> - srcu_sync srcu_expedited sched_sync sched_expedited"
> + modprobe rcutorture nfakewriters=${num_writers} \
> + torture_type=${rcu_type} >/dev/null 2>&1
> + if [ $? -ne 0 ]; then
> + dmesg | grep -q "invalid torture type: \"${rcu_type}\"" && \
> + tst_brk TCONF "invalid ${rcu_type} type"
>
> - if tst_kvcmp -lt "3.11"; then
> - rcu_type="$rcu_type srcu_raw srcu_raw_sync"
> + tst_brk TBROK "failed to load module"
> fi
> -fi
> -
> -TST_TOTAL=$(echo "$rcu_type" | wc -w)
> -
> -est_time=`echo "scale=2; $test_time * $TST_TOTAL / 60 " | bc`
> -tst_resm TINFO "estimate time $est_time min"
> -
> -for type in $rcu_type; do
> -
> - tst_resm TINFO "$type: running $test_time sec..."
> -
> - modprobe rcutorture nfakewriters=$num_writers \
> - stat_interval=60 test_no_idle_hz=1 shuffle_interval=3 \
> - stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 \
> - fqs_stutter=3 test_boost=1 test_boost_interval=7 \
> - test_boost_duration=4 shutdown_secs=0 \
> - stall_cpu=0 stall_cpu_holdoff=10 n_barrier_cbs=0 \
> - onoff_interval=0 onoff_holdoff=0 torture_type=$type \
> - > /dev/null 2>&1 || tst_brkm TBROK "failed to load module"
>
> - sleep $test_time
> + sleep ${test_time}
>
> - rmmod rcutorture > /dev/null 2>&1 || \
> - tst_brkm TBROK "failed to unload module"
> + rmmod rcutorture >/dev/null 2>&1 || \
> + tst_brk TBROK "failed to unload module"
>
> # check module status in dmesg
> - result_str=`dmesg | sed -nE '$s/.*End of test: ([A-Z]+):.*/\1/p'`
> - if [ "$result_str" = "SUCCESS" ]; then
> - tst_resm TPASS "$type: completed"
> + local res=$(dmesg | sed -nE "s/.* ${rcu_type}-torture:.* End of test: (.*): .*/\1/p" | tail -n1)
> + if [ "$res" = "SUCCESS" ]; then
> + tst_res TPASS "${rcu_type}-torture: $res"
> else
> - tst_resm TFAIL "$type: $result_str, see dmesg"
> + tst_res TFAIL "${rcu_type}-torture: $res, see dmesg"
> fi
> -done
> +}
> +
> +do_test()
> +{
> + case $1 in
> + 1) rcutorture_test rcu;;
> + 2) rcutorture_test srcu;;
> + 3) rcutorture_test srcud;;
> + 4) rcutorture_test tasks;;
> + esac
> +}
>
> -tst_exit
> +tst_run
^ permalink raw reply [flat|nested] 9+ messages in thread
* [LTP] [PATCH v2] rcu/rcu_torture.sh: Rewrite test
2019-06-05 17:11 ` Alexey Kodanev
2019-06-06 2:35 ` Xiao Yang
2019-06-07 15:23 ` [LTP] [PATCH v2] " Xiao Yang
@ 2019-06-07 15:40 ` Xiao Yang
2019-07-09 15:45 ` Cyril Hrubis
2 siblings, 1 reply; 9+ messages in thread
From: Xiao Yang @ 2019-06-07 15:40 UTC (permalink / raw)
To: ltp
1) Cleanup and convert to new API
2) Update valid rcutorture types(rcu, srcu, srcud, tasks)
Note:
Exclude valid busted* types(busted, busted_srcud) that check
the test itself and expect failures, suggested by:
https://www.spinics.net/lists/kernel/msg3045252.html
Signed-off-by: Xiao Yang <ice_yangxiao@163.com>
---
v2:
1) Add check for invalid rcutorture types
2) Remove unnecessary code and update descriptions
3) Exclude busted* types
testcases/kernel/device-drivers/rcu/rcu_torture.sh | 139 +++++++++------------
1 file changed, 59 insertions(+), 80 deletions(-)
diff --git a/testcases/kernel/device-drivers/rcu/rcu_torture.sh b/testcases/kernel/device-drivers/rcu/rcu_torture.sh
index c3739f9..5549bd2 100755
--- a/testcases/kernel/device-drivers/rcu/rcu_torture.sh
+++ b/testcases/kernel/device-drivers/rcu/rcu_torture.sh
@@ -1,20 +1,7 @@
#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2014-2015 Oracle and/or its affiliates. All Rights Reserved.
-#
-# 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 would 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 the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#
+# Copyright (C) 2019 Xiao Yang <ice_yangxiao@163.com>
# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
#
# One of the possible ways to test RCU is to use rcutorture kernel module.
@@ -23,89 +10,81 @@
# dmesg output for module's test results.
# For more information, please read Linux Documentation: RCU/torture.txt
-TCID="rcu_torture"
-TST_TOTAL=14
-TST_CLEANUP=cleanup
+TST_CNT=4
+TST_SETUP=rcutorture_setup
+TST_TESTFUNC=do_test
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="modprobe rmmod dmesg sed tail"
+TST_OPTS="t:w:"
+TST_USAGE=rcutorture_usage
+TST_PARSE_ARGS=rcutorture_parse_args
-. test.sh
+. tst_test.sh
# default options
-test_time=60
+test_time=30
num_writers=5
-while getopts :ht:w: opt; do
- case "$opt" in
- h)
- echo "Usage:"
- echo "h help"
- echo "t x time in seconds for each test-case"
- echo "w x number of writers"
- exit 0
- ;;
- t) test_time=$OPTARG ;;
- w) num_writers=$OPTARG ;;
- *)
- tst_brkm TBROK "unknown option: $opt"
- ;;
- esac
-done
-
-cleanup()
+rcutorture_usage()
{
- tst_resm TINFO "cleanup"
- rmmod rcutorture > /dev/null 2>&1
+ echo "Usage:"
+ echo "-t x time in seconds for each test-case"
+ echo "-w x number of writers"
}
-tst_require_root
+rcutorture_parse_args()
+{
+ case $1 in
+ t) test_time=$2 ;;
+ w) num_writers=$2 ;;
+ esac
+}
-# check if module is present
-modprobe rcutorture > /dev/null 2>&1 || \
- tst_brkm TCONF "Test requires rcutorture module"
-rmmod rcutorture > /dev/null 2>&1
+rcutorture_setup()
+{
+ # do test by inserting and removing rcutorture module
+ # so check if it is built-in, loaded or unbuilt
+ modprobe -n --first-time rcutorture >/dev/null 2>&1 || \
+ tst_brk TCONF "built-in, loaded or unbuilt rcutorture"
+}
-trap cleanup INT
+rcutorture_test()
+{
+ local rcu_type=$1
-rcu_type="rcu rcu_bh srcu sched"
+ tst_res TINFO "${rcu_type}-torture: running ${test_time} sec..."
-if tst_kvcmp -lt "3.12"; then
- rcu_type="$rcu_type rcu_sync rcu_expedited rcu_bh_sync rcu_bh_expedited \
- srcu_sync srcu_expedited sched_sync sched_expedited"
+ modprobe rcutorture nfakewriters=${num_writers} \
+ torture_type=${rcu_type} >/dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ dmesg | grep -q "invalid torture type: \"${rcu_type}\"" && \
+ tst_brk TCONF "invalid ${rcu_type} type"
- if tst_kvcmp -lt "3.11"; then
- rcu_type="$rcu_type srcu_raw srcu_raw_sync"
+ tst_brk TBROK "failed to load module"
fi
-fi
-
-TST_TOTAL=$(echo "$rcu_type" | wc -w)
-
-est_time=`echo "scale=2; $test_time * $TST_TOTAL / 60 " | bc`
-tst_resm TINFO "estimate time $est_time min"
-
-for type in $rcu_type; do
-
- tst_resm TINFO "$type: running $test_time sec..."
-
- modprobe rcutorture nfakewriters=$num_writers \
- stat_interval=60 test_no_idle_hz=1 shuffle_interval=3 \
- stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 \
- fqs_stutter=3 test_boost=1 test_boost_interval=7 \
- test_boost_duration=4 shutdown_secs=0 \
- stall_cpu=0 stall_cpu_holdoff=10 n_barrier_cbs=0 \
- onoff_interval=0 onoff_holdoff=0 torture_type=$type \
- > /dev/null 2>&1 || tst_brkm TBROK "failed to load module"
- sleep $test_time
+ sleep ${test_time}
- rmmod rcutorture > /dev/null 2>&1 || \
- tst_brkm TBROK "failed to unload module"
+ rmmod rcutorture >/dev/null 2>&1 || \
+ tst_brk TBROK "failed to unload module"
# check module status in dmesg
- result_str=`dmesg | sed -nE '$s/.*End of test: ([A-Z]+):.*/\1/p'`
- if [ "$result_str" = "SUCCESS" ]; then
- tst_resm TPASS "$type: completed"
+ local res=$(dmesg | sed -nE "s/.* ${rcu_type}-torture:.* End of test: (.*): .*/\1/p" | tail -n1)
+ if [ "$res" = "SUCCESS" ]; then
+ tst_res TPASS "${rcu_type}-torture: $res"
else
- tst_resm TFAIL "$type: $result_str, see dmesg"
+ tst_res TFAIL "${rcu_type}-torture: $res, see dmesg"
fi
-done
+}
+
+do_test()
+{
+ case $1 in
+ 1) rcutorture_test rcu;;
+ 2) rcutorture_test srcu;;
+ 3) rcutorture_test srcud;;
+ 4) rcutorture_test tasks;;
+ esac
+}
-tst_exit
+tst_run
--
1.8.3.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [LTP] [PATCH v2] rcu/rcu_torture.sh: Rewrite test
2019-06-07 15:40 ` Xiao Yang
@ 2019-07-09 15:45 ` Cyril Hrubis
2019-07-10 5:32 ` Xiao Yang
0 siblings, 1 reply; 9+ messages in thread
From: Cyril Hrubis @ 2019-07-09 15:45 UTC (permalink / raw)
To: ltp
Hi!
> +rcutorture_setup()
> +{
> + # do test by inserting and removing rcutorture module
> + # so check if it is built-in, loaded or unbuilt
> + modprobe -n --first-time rcutorture >/dev/null 2>&1 || \
> + tst_brk TCONF "built-in, loaded or unbuilt rcutorture"
Wouldn't the --first-time disable the test on subsequent runs? Or do I
misunderstand how --first-time is supposed to work?
Also I guess that some modprobe implementations may not support
--first-time e.g. busybox.
> +}
>
> -trap cleanup INT
> +rcutorture_test()
> +{
> + local rcu_type=$1
>
> -rcu_type="rcu rcu_bh srcu sched"
> + tst_res TINFO "${rcu_type}-torture: running ${test_time} sec..."
>
> -if tst_kvcmp -lt "3.12"; then
> - rcu_type="$rcu_type rcu_sync rcu_expedited rcu_bh_sync rcu_bh_expedited \
> - srcu_sync srcu_expedited sched_sync sched_expedited"
> + modprobe rcutorture nfakewriters=${num_writers} \
> + torture_type=${rcu_type} >/dev/null 2>&1
> + if [ $? -ne 0 ]; then
> + dmesg | grep -q "invalid torture type: \"${rcu_type}\"" && \
> + tst_brk TCONF "invalid ${rcu_type} type"
>
> - if tst_kvcmp -lt "3.11"; then
> - rcu_type="$rcu_type srcu_raw srcu_raw_sync"
> + tst_brk TBROK "failed to load module"
> fi
> -fi
> -
> -TST_TOTAL=$(echo "$rcu_type" | wc -w)
> -
> -est_time=`echo "scale=2; $test_time * $TST_TOTAL / 60 " | bc`
> -tst_resm TINFO "estimate time $est_time min"
> -
> -for type in $rcu_type; do
> -
> - tst_resm TINFO "$type: running $test_time sec..."
> -
> - modprobe rcutorture nfakewriters=$num_writers \
> - stat_interval=60 test_no_idle_hz=1 shuffle_interval=3 \
> - stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 \
> - fqs_stutter=3 test_boost=1 test_boost_interval=7 \
> - test_boost_duration=4 shutdown_secs=0 \
> - stall_cpu=0 stall_cpu_holdoff=10 n_barrier_cbs=0 \
> - onoff_interval=0 onoff_holdoff=0 torture_type=$type \
> - > /dev/null 2>&1 || tst_brkm TBROK "failed to load module"
>
> - sleep $test_time
> + sleep ${test_time}
>
> - rmmod rcutorture > /dev/null 2>&1 || \
> - tst_brkm TBROK "failed to unload module"
> + rmmod rcutorture >/dev/null 2>&1 || \
> + tst_brk TBROK "failed to unload module"
This should be modprobe -r, rmmod has been deprecated for quite some
time.
> # check module status in dmesg
> - result_str=`dmesg | sed -nE '$s/.*End of test: ([A-Z]+):.*/\1/p'`
> - if [ "$result_str" = "SUCCESS" ]; then
> - tst_resm TPASS "$type: completed"
> + local res=$(dmesg | sed -nE "s/.* ${rcu_type}-torture:.* End of test: (.*): .*/\1/p" | tail -n1)
> + if [ "$res" = "SUCCESS" ]; then
> + tst_res TPASS "${rcu_type}-torture: $res"
> else
> - tst_resm TFAIL "$type: $result_str, see dmesg"
> + tst_res TFAIL "${rcu_type}-torture: $res, see dmesg"
> fi
> -done
> +}
> +
> +do_test()
> +{
> + case $1 in
> + 1) rcutorture_test rcu;;
> + 2) rcutorture_test srcu;;
> + 3) rcutorture_test srcud;;
> + 4) rcutorture_test tasks;;
> + esac
> +}
>
> -tst_exit
> +tst_run
> --
> 1.8.3.1
>
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 9+ messages in thread
* [LTP] [PATCH v2] rcu/rcu_torture.sh: Rewrite test
2019-07-09 15:45 ` Cyril Hrubis
@ 2019-07-10 5:32 ` Xiao Yang
2019-07-10 9:11 ` Cyril Hrubis
0 siblings, 1 reply; 9+ messages in thread
From: Xiao Yang @ 2019-07-10 5:32 UTC (permalink / raw)
To: ltp
On 2019/07/09 23:45, Cyril Hrubis wrote:
> Hi!
>> +rcutorture_setup()
>> +{
>> + # do test by inserting and removing rcutorture module
>> + # so check if it is built-in, loaded or unbuilt
>> + modprobe -n --first-time rcutorture>/dev/null 2>&1 || \
>> + tst_brk TCONF "built-in, loaded or unbuilt rcutorture"
> Wouldn't the --first-time disable the test on subsequent runs? Or do I
> misunderstand how --first-time is supposed to work?
Hi,
No, -n option doesn't execute any operations.
We has to build rcutorture as a module if we want to run the test, so I
just want to check
if rcutorture is built as a module instead of built-in or unbuilt by
--first-time.
> Also I guess that some modprobe implementations may not support
> --first-time e.g. busybox.
Is there any way to check if rcutorture is only built as a module?
>> +}
>>
>> -trap cleanup INT
>> +rcutorture_test()
>> +{
>> + local rcu_type=$1
>>
>> -rcu_type="rcu rcu_bh srcu sched"
>> + tst_res TINFO "${rcu_type}-torture: running ${test_time} sec..."
>>
>> -if tst_kvcmp -lt "3.12"; then
>> - rcu_type="$rcu_type rcu_sync rcu_expedited rcu_bh_sync rcu_bh_expedited \
>> - srcu_sync srcu_expedited sched_sync sched_expedited"
>> + modprobe rcutorture nfakewriters=${num_writers} \
>> + torture_type=${rcu_type}>/dev/null 2>&1
>> + if [ $? -ne 0 ]; then
>> + dmesg | grep -q "invalid torture type: \"${rcu_type}\""&& \
>> + tst_brk TCONF "invalid ${rcu_type} type"
>>
>> - if tst_kvcmp -lt "3.11"; then
>> - rcu_type="$rcu_type srcu_raw srcu_raw_sync"
>> + tst_brk TBROK "failed to load module"
>> fi
>> -fi
>> -
>> -TST_TOTAL=$(echo "$rcu_type" | wc -w)
>> -
>> -est_time=`echo "scale=2; $test_time * $TST_TOTAL / 60 " | bc`
>> -tst_resm TINFO "estimate time $est_time min"
>> -
>> -for type in $rcu_type; do
>> -
>> - tst_resm TINFO "$type: running $test_time sec..."
>> -
>> - modprobe rcutorture nfakewriters=$num_writers \
>> - stat_interval=60 test_no_idle_hz=1 shuffle_interval=3 \
>> - stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 \
>> - fqs_stutter=3 test_boost=1 test_boost_interval=7 \
>> - test_boost_duration=4 shutdown_secs=0 \
>> - stall_cpu=0 stall_cpu_holdoff=10 n_barrier_cbs=0 \
>> - onoff_interval=0 onoff_holdoff=0 torture_type=$type \
>> - > /dev/null 2>&1 || tst_brkm TBROK "failed to load module"
>>
>> - sleep $test_time
>> + sleep ${test_time}
>>
>> - rmmod rcutorture> /dev/null 2>&1 || \
>> - tst_brkm TBROK "failed to unload module"
>> + rmmod rcutorture>/dev/null 2>&1 || \
>> + tst_brk TBROK "failed to unload module"
> This should be modprobe -r, rmmod has been deprecated for quite some
> time.
I will use modprobe -r instead.
Best Regards,
Xiao Yang
>> # check module status in dmesg
>> - result_str=`dmesg | sed -nE '$s/.*End of test: ([A-Z]+):.*/\1/p'`
>> - if [ "$result_str" = "SUCCESS" ]; then
>> - tst_resm TPASS "$type: completed"
>> + local res=$(dmesg | sed -nE "s/.* ${rcu_type}-torture:.* End of test: (.*): .*/\1/p" | tail -n1)
>> + if [ "$res" = "SUCCESS" ]; then
>> + tst_res TPASS "${rcu_type}-torture: $res"
>> else
>> - tst_resm TFAIL "$type: $result_str, see dmesg"
>> + tst_res TFAIL "${rcu_type}-torture: $res, see dmesg"
>> fi
>> -done
>> +}
>> +
>> +do_test()
>> +{
>> + case $1 in
>> + 1) rcutorture_test rcu;;
>> + 2) rcutorture_test srcu;;
>> + 3) rcutorture_test srcud;;
>> + 4) rcutorture_test tasks;;
>> + esac
>> +}
>>
>> -tst_exit
>> +tst_run
>> --
>> 1.8.3.1
>>
>>
>>
>> --
>> Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* [LTP] [PATCH v2] rcu/rcu_torture.sh: Rewrite test
2019-07-10 5:32 ` Xiao Yang
@ 2019-07-10 9:11 ` Cyril Hrubis
0 siblings, 0 replies; 9+ messages in thread
From: Cyril Hrubis @ 2019-07-10 9:11 UTC (permalink / raw)
To: ltp
Hi!
> > Also I guess that some modprobe implementations may not support
> > --first-time e.g. busybox.
> Is there any way to check if rcutorture is only built as a module?
I guess that we can try to instert the module and then remove it and if
both works fine the module does exists and it's not build in.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2019-07-10 9:11 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-02 14:23 [LTP] [PATCH] rcu/rcu_torture.sh: Rewrite test Xiao Yang
2019-06-05 17:11 ` Alexey Kodanev
2019-06-06 2:35 ` Xiao Yang
2019-06-07 15:23 ` [LTP] [PATCH v2] " Xiao Yang
2019-06-07 15:38 ` Xiao Yang
2019-06-07 15:40 ` Xiao Yang
2019-07-09 15:45 ` Cyril Hrubis
2019-07-10 5:32 ` Xiao Yang
2019-07-10 9:11 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox