Skip to contentSkip to conversation

selftests: rds selftest

RFC In review [email protected] 2 participants 9 messages Jun 7, 2024 – Jun 9, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index c59dc60ba62e..8ff1b4138c56 100644
@@ -24,6 +24,7 @@
 *.dwo
 *.elf
 *.gcno
+*.gcda
 *.gz
 *.i
 *.ko
Signature · 1 line
2.25.1
#2 lore raw

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.

---
 .gitignore | 1 +

 1 file changed, 1 insertion(+)
.gitignore +1 -0
index c59dc60ba62e..8ff1b4138c56 100644
@@ -24,6 +24,7 @@
  *.dwo
  *.elf
  *.gcno
+*.gcda
  *.gz
  *.i
  *.ko
#3 lore raw

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
index 75cd696963b2..f007730aa2bb 100644
@@ -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
index 8fdc118e2927..3af1ca1d965c 100644
@@ -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
#4 lore raw

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_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 +0 -0
index 75cd696963b2..f007730aa2bb 100644
@@ -26,3 +26,12 @@ config RDS_DEBUG

        bool "RDS debugging messages"
        depends on RDS
        default n

net/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 which

functions/lines
+         are executed.

net/rds/Kconfig +2 -0
+
+         If unsure, say N.
net/rds/Makefile +0 -0
index 8fdc118e2927..3af1ca1d965c 100644
@@ -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

net/rds/Makefile +5 -0
+
+# for GCOV coverage profiling
+ifdef CONFIG_GCOV_PROFILE_RDS
+GCOV_PROFILE := y
+endif
#5 lore raw

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
index 7538152be2f1..009766b77b7e 100644
@@ -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
index 9039f3709aff..5b01fe3277e2 100644
@@ -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
new file mode 100644
index 000000000000..52fe54006eba
@@ -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
new file mode 100644
index 000000000000..e46f980adb3e
@@ -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
new file mode 100755
index 000000000000..c2c36756ba1f
@@ -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
reviewer
#6 lore raw

Re: [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.

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
new file mode 100755
index 000000000000..c2c36756ba1f
@@ -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.

https://www.shellcheck.net/wiki/SC1128

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 olddefconfig
tools/testing/selftests/net/rds/init.sh new file +28 -0
new file mode 100755
index 000000000000..a29e3de81ed5
@@ -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

...

#7 lore raw

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.

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
new file mode 100755
index 000000000000..c2c36756ba1f
@@ -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.

https://urldefense.com/v3/__https://www.shellcheck.net/wiki/SC1128__;!!ACWV5N9M2RV99hQ!OjLySFP6wNEm6wWK90hVJHa9RXAP8310v8V0uKLQ9KvODoyD8hUHX0CRLZpKBl1jQGwfR-vYcBI5w8wRwAI$

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 network

interfaces

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 olddefconfig
tools/testing/selftests/net/rds/init.sh new file +38 -0
new file mode 100755
index 000000000000..a29e3de81ed5
@@ -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 -d
Quoted 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.

https://urldefense.com/v3/__https://www.shellcheck.net/wiki/SC2035__;!!ACWV5N9M2RV99hQ!OjLySFP6wNEm6wWK90hVJHa9RXAP8310v8V0uKLQ9KvODoyD8hUHX0CRLZpKBl1jQGwfR-vYcBI5Es_quwA$

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 > /$f

Again, 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

...

#8 lore raw
In reply to [email protected]

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/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