selftests: rds selftest
Subsystems (4)
cover selftests: rds selftest
From: Allison Henderson <[email protected]>
Hi All,
This series is a new selftest that Vegard, Chuck and myself have been working on to provide some test coverage for rds. It still has a few bugs to work out, so it's not quite ready for submission yet. But we thought an RFC would be a good idea just to collect some feed back to see what people think. Some things to be aware of that we are still working through:
Occasionally we see intermittent hangs during the send and recv. So we still need to track down and address the cause
We may still add a time out to handle unexpected hangs
We've been having some trouble getting gcov to generate a report if the version of gcov doesn't match the version of gcc installed. So we may further adapt the test to omit the coverage report if the required dependencies are not met
Some distros are still not collecting meaningfull gcda data and generate an empty report, so we are still trying to figure out the cause of that
May still add more exit codes for PASS/FAIL/BROKEN/CONFIG conditions
Questions and comments appreciated. Thanks everyone!
Allison
Vegard Nossum (3):
.gitignore: add .gcda files
net: rds: add option for GCOV profiling
selftests: rds: add testing infrastructure
.gitignore | 1 + MAINTAINERS | 1 + net/rds/Kconfig | 9 + net/rds/Makefile | 5 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/net/rds/Makefile | 13 ++ tools/testing/selftests/net/rds/README.txt | 15 ++ tools/testing/selftests/net/rds/config.sh | 33 +++ tools/testing/selftests/net/rds/init.sh | 49 +++++ tools/testing/selftests/net/rds/run.sh | 168 ++++++++++++++ tools/testing/selftests/net/rds/test.py | 244 +++++++++++++++++++++ 11 files changed, 539 insertions(+) create mode 100644 tools/testing/selftests/net/rds/Makefile create mode 100644 tools/testing/selftests/net/rds/README.txt create mode 100755 tools/testing/selftests/net/rds/config.sh create mode 100755 tools/testing/selftests/net/rds/init.sh create mode 100755 tools/testing/selftests/net/rds/run.sh create mode 100644 tools/testing/selftests/net/rds/test.py
Signature · 1 line
2.25.1
RFC 1/3 .gitignore: add .gcda files
From: Vegard Nossum <[email protected]>
These files contain the runtime coverage data generated by gcov.
--- .gitignore | 1 + 1 file changed, 1 insertion(+)
.gitignore +1 -0
@@ -24,6 +24,7 @@ *.dwo *.elf *.gcno +*.gcda *.gz *.i *.ko
Signature · 1 line
2.25.1
Re: [RFC net-next 1/3] .gitignore: add .gcda files
On Thu, 2024-06-06 at 17:36 -0700, [email protected] wrote:
+cc Chuck Lever, Peter Oberparleiter, Vegard Nossum, rds-devel
Quoted 24 lines
From: Vegard Nossum <[email protected]>
These files contain the runtime coverage data generated by gcov.
Signed-off-by Vegard Nossum <[email protected]>Reviewed-by Allison Henderson <[email protected]>Reviewed-by Chuck Lever <[email protected]>Signed-off-by Allison Henderson <[email protected]>---
.gitignore | 1 +1 file changed, 1 insertion(+).gitignore +1
-0@@ -24,6 +24,7 @@ *.dwo *.elf *.gcno +*.gcda *.gz *.i *.ko
RFC 2/3 net: rds: add option for GCOV profiling
In reply to [email protected]From: Vegard Nossum <[email protected]>
This commit basically implements what ftrace does with CONFIG_GCOV_PROFILE_FTRACE for RDS.
We need this in order to better be able to understand what code paths our unit tests are hitting (or not hitting).
--- net/rds/Kconfig | 9 +++++++++ net/rds/Makefile | 5 +++++ 2 files changed, 14 insertions(+)
net/rds/Kconfig +9 -0
@@ -26,3 +26,12 @@ config RDS_DEBUG bool "RDS debugging messages" depends on RDS default n + +config GCOV_PROFILE_RDS + bool "Enable GCOV profiling on RDS" + depends on GCOV_KERNEL + help + Enable GCOV profiling on RDS for checking which functions/lines + are executed. + + If unsure, say N.
net/rds/Makefile +5 -0
@@ -15,3 +15,8 @@ rds_tcp-y := tcp.o tcp_connect.o tcp_listen.o tcp_recv.o \ tcp_send.o tcp_stats.o ccflags-$(CONFIG_RDS_DEBUG) := -DRDS_DEBUG + +# for GCOV coverage profiling +ifdef CONFIG_GCOV_PROFILE_RDS +GCOV_PROFILE := y +endif
Signature · 1 line
2.25.1
Re: [RFC net-next 2/3] net: rds: add option for GCOV profiling
On Thu, 2024-06-06 at 17:36 -0700, [email protected] wrote:
+cc Chuck Lever, Peter Oberparleiter, Vegard Nossum, rds-devel
Quoted 49 lines
From: Vegard Nossum <[email protected]>
This commit basically implements what ftrace does with
CONFIG_GCOV_PROFILE_FTRACEfor RDS.We need this in order to better be able to understand what code paths our unit tests are hitting (or not hitting).
Signed-off-by Vegard Nossum <[email protected]>Reviewed-by Allison Henderson <[email protected]>Reviewed-by Chuck Lever <[email protected]>Signed-off-by Allison Henderson <[email protected]>---
net/rds/Kconfig | 9 +++++++++
net/rds/Makefile | 5 +++++2 files changed, 14 insertions(+)net/rds/Kconfig +0
-0@@ -26,3 +26,12 @@ config RDS_DEBUGbool "RDS debugging messages"
depends on RDS
default nnet/rds/Kconfig +6
-0+ +config GCOV_PROFILE_RDS + bool "Enable GCOV profiling on RDS" + depends on GCOV_KERNEL + help + Enable GCOV profiling on RDS for checking whichfunctions/lines
+ are executed.net/rds/Kconfig +2
-0+ + If unsure, say N.net/rds/Makefile +0
-0@@ -15,3 +15,8 @@ rds_tcp-y := tcp.o tcp_connect.o tcp_listen.o tcp_recv.o \tcp_send.o tcp_stats.o
ccflags-$(CONFIG_RDS_DEBUG) := -DRDS_DEBUGnet/rds/Makefile +5
-0+ +# for GCOV coverage profiling +ifdef CONFIG_GCOV_PROFILE_RDS +GCOV_PROFILE := y +endif
RFC 3/3 selftests: rds: add testing infrastructure
In reply to [email protected]From: Vegard Nossum <[email protected]>
This adds some basic self-testing infrastructure for RDS.
--- MAINTAINERS | 1 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/net/rds/Makefile | 13 ++ tools/testing/selftests/net/rds/README.txt | 15 ++ tools/testing/selftests/net/rds/config.sh | 33 +++ tools/testing/selftests/net/rds/init.sh | 49 +++++ tools/testing/selftests/net/rds/run.sh | 168 ++++++++++++++ tools/testing/selftests/net/rds/test.py | 244 +++++++++++++++++++++ 8 files changed, 524 insertions(+)
MAINTAINERS +1 -0
@@ -18851,6 +18851,7 @@ S: Supported W: https://oss.oracle.com/projects/rds/ F: Documentation/networking/rds.rst F: net/rds/ +F: tools/testing/selftests/net/rds/ RDT - RESOURCE ALLOCATION M: Fenghua Yu <[email protected]>
tools/testing/selftests/Makefile +1 -0
@@ -66,6 +66,7 @@ TARGETS += net/mptcp TARGETS += net/openvswitch TARGETS += net/tcp_ao TARGETS += net/netfilter +TARGETS += net/rds TARGETS += nsfs TARGETS += perf_events TARGETS += pidfd
tools/testing/selftests/net/rds/Makefile new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0 + +all: + @echo mk_build_dir="$(shell pwd)" > include.sh + +TEST_PROGS := run.sh \ + include.sh \ + test.py \ + init.sh + +EXTRA_CLEAN := /tmp/rds_logs + +include ../../lib.mk
tools/testing/selftests/net/rds/README.txt new file +15 -0
@@ -0,0 +1,15 @@ +RDS self-tests +============== + +Usage: + + # create a suitable .config + tools/testing/selftests/net/rds/config.sh + + # build the kernel + make -j128 + + # launch the tests in a VM + tools/testing/selftests/net/rds/run.sh + +An HTML coverage report will be output in /tmp/rds_logs/coverage/.
tools/testing/selftests/net/rds/config.sh new file +33 -0
@@ -0,0 +1,33 @@ +# SPDX-License-Identifier: GPL-2.0 +#! /bin/bash + +set -e +set -u +set -x + +unset KBUILD_OUTPUT + +# start with a default config +make defconfig + +# no modules +scripts/config --disable CONFIG_MODULES + +# enable RDS +scripts/config --enable CONFIG_RDS +scripts/config --enable CONFIG_RDS_TCP + +# instrument RDS and only RDS +scripts/config --enable CONFIG_GCOV_KERNEL +scripts/config --disable GCOV_PROFILE_ALL +scripts/config --enable GCOV_PROFILE_RDS + +# need network namespaces to run tests with veth network interfaces +scripts/config --enable CONFIG_NET_NS +scripts/config --enable CONFIG_VETH + +# simulate packet loss +scripts/config --enable CONFIG_NET_SCH_NETEM + +# generate real .config without asking any questions +make olddefconfig
tools/testing/selftests/net/rds/init.sh new file +49 -0
49 lines not on this page · raw message
tools/testing/selftests/net/rds/run.sh new file +168 -0
168 lines not on this page · raw message
tools/testing/selftests/net/rds/test.py new file +244 -0
244 lines not on this page · raw message
Signature · 1 line
2.25.1
Simon Horman
reviewerRe: [RFC net-next 3/3] selftests: rds: add testing infrastructure
Quoted 7 lines · On Thu, Jun 06, 2024 at 05:36:31PM -0700, [email protected] wrote:
From: Vegard Nossum <[email protected]>
This adds some basic self-testing infrastructure for RDS.
Signed-off-by Vegard Nossum <[email protected]>Signed-off-by Allison Henderson <[email protected]>Signed-off-by Chuck Lever <[email protected]>
Hi Allison,
Some minor nits from my side.
tools/testing/selftests/net/rds/config.sh line 2
Quoted 8 lines
tools/testing/selftests/net/rds/config.sh new file +2
-0@@ -0,0 +1,33 @@ +# SPDX-License-Identifier: GPL-2.0 +#! /bin/bash
#! line needs to be the first line for it to take effect
Flagged by shellcheck.
Quoted 65 lines
tools/testing/selftests/net/rds/config.sh new file +31
-0+ +set -e +set -u +set -x + +unset KBUILD_OUTPUT + +# start with a default config +make defconfig + +# no modules +scripts/config --disable CONFIG_MODULES + +# enable RDS +scripts/config --enable CONFIG_RDS +scripts/config --enable CONFIG_RDS_TCP + +# instrument RDS and only RDS +scripts/config --enable CONFIG_GCOV_KERNEL +scripts/config --disable GCOV_PROFILE_ALL +scripts/config --enable GCOV_PROFILE_RDS + +# need network namespaces to run tests with veth network interfaces +scripts/config --enable CONFIG_NET_NS +scripts/config --enable CONFIG_VETH + +# simulate packet loss +scripts/config --enable CONFIG_NET_SCH_NETEM + +# generate real .config without asking any questions +make olddefconfigtools/testing/selftests/net/rds/init.sh new file +28
-0@@ -0,0 +1,49 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 + +set -e +set -u + +LOG_DIR=/tmp +PY_CMD="/usr/bin/python3" +while getopts "d:p:" opt; do + case ${opt} in + d) + LOG_DIR=${OPTARG} + ;; + p) + PY_CMD=${OPTARG} + ;; + :) + echo "USAGE: init.sh [-d logdir] [-p python_cmd]" + exit 1 + ;; + ?) + echo "Invalid option: -${OPTARG}." + exit 1 + ;; + esac +done + +LOG_FILE=$LOG_DIR/rds-strace.txt
tools/testing/selftests/net/rds/init.sh line 38
Quoted 10 lines
tools/testing/selftests/net/rds/init.sh new file +10
-0+ +mount -t proc none /proc +mount -t sysfs none /sys +mount -t tmpfs none /var/run +mount -t debugfs none /sys/kernel/debug + +echo running RDS tests... +echo Traces will be logged to $LOG_FILE +rm -f $LOG_FILE +strace -T -tt -o "$LOG_FILE" $PY_CMD $(dirname "$0")/test.py -d "$LOG_DIR" || true
Perhaps it can't occur, but I don't think this will behave as expected if the out put of dirname includes spaces.
Flagged by shellecheck.
https://www.shellcheck.net/wiki/SC2046
Also, $LOG_DIR is quoted here, but not elsewhere, which seems inconsistent.
tools/testing/selftests/net/rds/init.sh line 41
Quoted 3 lines
tools/testing/selftests/net/rds/init.sh new file +3
-0+ +echo saving coverage data... +(set +x; cd /sys/kernel/debug/gcov; find * -name '*.gcda' | \
shellcheck warns that:
SC2035 (info): Use ./*glob* or -- *glob* so names with dashes won't become options.
https://www.shellcheck.net/wiki/SC2035
Although I guess in practice there are no filenames with dashes in that directory.
tools/testing/selftests/net/rds/init.sh line 44
Quoted 3 lines
tools/testing/selftests/net/rds/init.sh new file +3
-0+while read f +do + cat < /sys/kernel/debug/gcov/$f > /$f
Again, I guess it doesn't occur in practice. But should $f be quoted in case it includes whitespace?
Quoted 5 lines
tools/testing/selftests/net/rds/init.sh new file +5
-0+done) + +dmesg > $LOG_DIR/dmesg.out + +/usr/sbin/poweroff --no-wtmp --force
...
Re: [RFC net-next 3/3] selftests: rds: add testing infrastructure
On Fri, 2024-06-07 at 21:24 +0100, Simon Horman wrote:
+cc Chuck Lever, Peter Oberparleiter, Vegard Nossum, rds-devel
Quoted 26 lines
Quoted 7 lines · On Thu, Jun 06, 2024 at 05:36:31PM -0700, [email protected] wrote:
From: Vegard Nossum <[email protected]>
This adds some basic self-testing infrastructure for RDS.
Signed-off-by Vegard Nossum <[email protected]>Signed-off-by Allison Henderson <[email protected]>Signed-off-by Chuck Lever <[email protected]>Hi Allison,
Some minor nits from my side.
tools/testing/selftests/net/rds/config.sh line 2
Quoted 9 lines
tools/testing/selftests/net/rds/config.sh new file +2
-0@@ -0,0 +1,33 @@ +# SPDX-License-Identifier: GPL-2.0 +#! /bin/bash#! line needs to be the first line for it to take effect
Quoted 5 lines
Flagged by shellcheck.
Ah, alrighty I will go through and fix all the shell check nits
Quoted 82 lines
Quoted 77 lines
tools/testing/selftests/net/rds/config.sh new file +23
-0+ +set -e +set -u +set -x + +unset KBUILD_OUTPUT + +# start with a default config +make defconfig + +# no modules +scripts/config --disable CONFIG_MODULES + +# enable RDS +scripts/config --enable CONFIG_RDS +scripts/config --enable CONFIG_RDS_TCP + +# instrument RDS and only RDS +scripts/config --enable CONFIG_GCOV_KERNEL +scripts/config --disable GCOV_PROFILE_ALL +scripts/config --enable GCOV_PROFILE_RDS + +# need network namespaces to run tests with veth networkinterfaces
tools/testing/selftests/net/rds/config.sh new file +8
-0+scripts/config --enable CONFIG_NET_NS +scripts/config --enable CONFIG_VETH + +# simulate packet loss +scripts/config --enable CONFIG_NET_SCH_NETEM + +# generate real .config without asking any questions +make olddefconfigtools/testing/selftests/net/rds/init.sh new file +38
-0@@ -0,0 +1,49 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 + +set -e +set -u + +LOG_DIR=/tmp +PY_CMD="/usr/bin/python3" +while getopts "d:p:" opt; do + case ${opt} in + d) + LOG_DIR=${OPTARG} + ;; + p) + PY_CMD=${OPTARG} + ;; + :) + echo "USAGE: init.sh [-d logdir] [-p python_cmd]" + exit 1 + ;; + ?) + echo "Invalid option: -${OPTARG}." + exit 1 + ;; + esac +done + +LOG_FILE=$LOG_DIR/rds-strace.txt + +mount -t proc none /proc +mount -t sysfs none /sys +mount -t tmpfs none /var/run +mount -t debugfs none /sys/kernel/debug + +echo running RDS tests... +echo Traces will be logged to $LOG_FILE +rm -f $LOG_FILE +strace -T -tt -o "$LOG_FILE" $PY_CMD $(dirname "$0")/test.py -dQuoted 1 line
"$LOG_DIR" || true
Perhaps it can't occur, but I don't think this will behave as expected if the out put of dirname includes spaces.
Quoted 6 lines
Flagged by shellecheck.
https://urldefense.com/v3/__https://www.shellcheck.net/wiki/SC2046__;!!ACWV5N9M2RV99hQ!OjLySFP6wNEm6wWK90hVJHa9RXAP8310v8V0uKLQ9KvODoyD8hUHX0CRLZpKBl1jQGwfR-vYcBI5005wM3k$Also, $LOG_DIR is quoted here, but not elsewhere, which seems inconsistent.
Noted, yes it should probably be quoted
Quoted 7 lines
tools/testing/selftests/net/rds/init.sh line 41
Quoted 4 lines
tools/testing/selftests/net/rds/init.sh new file +3
-0+ +echo saving coverage data... +(set +x; cd /sys/kernel/debug/gcov; find * -name '*.gcda' | \shellcheck warns that:
Quoted 8 lines
SC2035 (info): Use ./*glob* or -- *glob* so names with dashes won't become options.
Although I guess in practice there are no filenames with dashes in that directory.
Not at the moment, but its always possible that such a file could be introduced later. Will fix :-)
Quoted 7 lines
tools/testing/selftests/net/rds/init.sh line 44
Quoted 4 lines
tools/testing/selftests/net/rds/init.sh new file +3
-0+while read f +do + cat < /sys/kernel/debug/gcov/$f > /$fAgain, I guess it doesn't occur in practice. But should $f be quoted in case it includes whitespace?
Yes, I think so. Even if it's not an issue now, it would be nice to not deal will testcase breakage if file name were to change in the future. Will fix this too.
Thanks for the review! :-)
Allison
Quoted 8 lines
Quoted 6 lines
tools/testing/selftests/net/rds/init.sh new file +5
-0+done) + +dmesg > $LOG_DIR/dmesg.out + +/usr/sbin/poweroff --no-wtmp --force...
On Thu, 2024-06-06 at 17:36 -0700, [email protected] wrote:
+cc Chuck Lever, Peter Oberparleiter, Vegard Nossum, rds-devel
Quoted 57 lines
From: Allison Henderson <[email protected]>
Hi All,
This series is a new selftest that Vegard, Chuck and myself have been working on to provide some test coverage for rds. It still has a few bugs to work out, so it's not quite ready for submission yet. But we thought an RFC would be a good idea just to collect some feed back to see what people think. Some things to be aware of that we are still working through:
Occasionally we see intermittent hangs during the send and recv. So we still need to track down and address the cause
We may still add a time out to handle unexpected hangs
We've been having some trouble getting gcov to generate a report if the version of gcov doesn't match the version of gcc installed. So we may further adapt the test to omit the coverage report if the required dependencies are not met
Some distros are still not collecting meaningfull gcda data and generate an empty report, so we are still trying to figure out the cause of that
May still add more exit codes for PASS/FAIL/BROKEN/CONFIG conditions
Questions and comments appreciated. Thanks everyone!
Allison
Vegard Nossum (3):
.gitignore: add .gcda files
net: rds: add option for GCOV profiling
selftests: rds: add testing infrastructure.gitignore | 1 + MAINTAINERS | 1 + net/rds/Kconfig | 9 + net/rds/Makefile | 5 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/net/rds/Makefile | 13 ++
tools/testing/selftests/net/rds/README.txt| 15 ++ tools/testing/selftests/net/rds/config.sh | 33 +++ tools/testing/selftests/net/rds/init.sh | 49 +++++ tools/testing/selftests/net/rds/run.sh | 168 ++++++++++++++ tools/testing/selftests/net/rds/test.py | 244
+++++++++++++++++++++11 files changed, 539 insertions(+)create mode 100644
tools/testing/selftests/net/rds/Makefilecreate mode 100644tools/testing/selftests/net/rds/README.txtcreate mode 100755tools/testing/selftests/net/rds/config.shcreate mode 100755tools/testing/selftests/net/rds/init.shcreate mode 100755tools/testing/selftests/net/rds/run.shcreate mode 100644tools/testing/selftests/net/rds/test.py