selftests: rds: Log collection, TAP compliance and cleanups
Subsystems (5)
Allison Henderson
maintainerv3 cover selftests: rds: Log collection, TAP compliance and cleanups
This series is a set of bug fixes and improvements for the rds selftests.
Patch 1 bumps the kselftest timeout from 400s to 800s. The original limit was developed against a lean config, but the kselftest harness counts boot time and gcov log collection against the limit, so a default config with gcov enabled needs more headroom.
Patch 2 corrects some typos in the run.sh USAGE string and removes an unused "-g" flag.
Patch 3 silences a handful of pylint warnings in test.py: it adds a module docstring, suppresses the warnings tied to the sys.path.append import trick, marks the long lived tcpdump Popen with disable-next consider-using-with, and drops unused exception variables from two BlockingIOError except clauses.
Patch 4 adds a -t flag to run.sh so the timeout can be overridden if needed.
Patch 5 adds a RDS_LOG_DIR environment variable that specifies where logs should be stored, or skips log collection if left unset
Patch 6 adds a SUDO_USER environment variable that sets the user for tcpdump --relinquish-privileges. This avoid the permissions drop that would leave pcaps empty on 9pfs since 9p does not support chown
Patch 7 removes the initial tmp tcpdumps and instead saves the pcaps directly to the logdir if it is set.
Patch 8 hoists the tcpdump shutdown into a helper and calls it from the timeout signal handler so that the processes are properly terminated and dumps are flushed
Patch 9 fixes gcov collection by ensuring debugfs is mounted, and specifying the --root folder so that gcov can still find the kernel source when it is run from the ksft test directory.
Patch 10 makes the test output TAP compliant so the kselftest runner parses results correctly.
Questions, comments and feedback appreciated!
Thanks everyone!
Allison
Change log:
v2:
[PATCH net-next v2 3/7] selftests: rds: Fix more pylint errors
NEW
[PATCH net-next v2 6/7] selftests: rds: Collect pcaps on timeout
Fixed pylint errors in collect_pcaps()
[PATCH net-next v2 7/7] selftests: rds: Make rds selftests TAP compliant
Fixed pylint errors from ksft import
v3:
[PATCH net-next v3 2/10] selftests: rds: Update USAGE string for run.sh
Same typo fixed in the README.txt file
[PATCH net-next v3 04/10] selftests: rds: Add timeout flag to run.sh
Update README.txt
[PATCH net-next v3 5/10] selftests: rds: Add RDS_LOG_DIR env variable
NEW
[PATCH net-next v3 6/10] selftests: rds: Add SUDO_USER env variable
NEW
[PATCH net-next v3 7/10] selftests: rds: Remove tmp pcaps
NEW
[PATCH net-next v3 8/10] selftests: rds: Stop tcpdump on timeout
Rebased from v2: selftests: rds: Collect pcaps on timeout
[PATCH net-next v3 09/10] selftests: rds: Fix gcov collection
Split from v2: selftests: rds: Fix gcov and pcap collection Use mountpoint instead of test -d for check for debugfs mount
Allison Henderson (10):
selftests: rds: Increase selftest timeout
selftests: rds: Update USAGE string for run.sh
selftests: rds: Fix more pylint errors
selftests: rds: Add timeout flag to run.sh
selftests: rds: Add RDS_LOG_DIR env variable
selftests: rds: Add SUDO_USER env variable
selftests: rds: Remove tmp pcaps
selftests: rds: Stop tcpdump on timeout
selftests: rds: Fix gcov collection
selftests: rds: Make rds selftests TAP compliant
tools/testing/selftests/net/rds/README.txt | 30 +++++- tools/testing/selftests/net/rds/run.sh | 74 ++++++++----- tools/testing/selftests/net/rds/settings | 2 +- tools/testing/selftests/net/rds/test.py | 114 ++++++++++++++------- 4 files changed, 148 insertions(+), 72 deletions(-)
Signature · 1 line
2.25.1
Allison Henderson
maintainerPATCH v3 1/10 selftests: rds: Increase selftest timeout
The 400s time out was originally developed under a leaner kernel config that booted much faster than a default config. Boot up is included as part of the over all test runtime, as well as any log collection done when the test is complete. A slower config combined with the gcov enabled test means we'll need more time to accommodate the boot up and log collection. So, bump time out to 800s.
--- tools/testing/selftests/net/rds/settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/rds/settings +1 -1
@@ -1 +1 @@ -timeout=400 +timeout=800
Signature · 1 line
2.25.1
Allison Henderson
maintainerPATCH v3 2/10 selftests: rds: Update USAGE string for run.sh
In reply to Allison HendersonThe run.sh script does not have a -g flag. Update USAGE string with correct flags. Also fix typo packet_duplcate -> packet_duplicate
--- tools/testing/selftests/net/rds/README.txt | 2 +- tools/testing/selftests/net/rds/run.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/net/rds/README.txt +1 -1
@@ -12,7 +12,7 @@ kernel may optionally be configured to omit the coverage report as well. USAGE: run.sh [-d logdir] [-l packet_loss] [-c packet_corruption] - [-u packet_duplcate] + [-u packet_duplicate] OPTIONS: -d Log directory. Defaults to tools/testing/selftests/net/rds/rds_logs
tools/testing/selftests/net/rds/run.sh +1 -1
@@ -171,7 +171,7 @@ while getopts "d:l:c:u:" opt; do ;; :) echo "USAGE: run.sh [-d logdir] [-l packet_loss] [-c packet_corruption]" \ - "[-u packet_duplcate] [-g]" + "[-u packet_duplicate]" exit 1 ;; ?)
Signature · 1 line
2.25.1
Allison Henderson
maintainerPATCH v3 3/10 selftests: rds: Fix more pylint errors
In reply to Allison HendersonThis patch fixes a few pylint errors in test.py. Remove unused exception variables from except blocks, and disable warnings for imports that cannot appear at the start of the module. Also disable warnings for the tcpdump processes. The suggestion to use a with block does not apply here since the process needs to outlive the parent to collect the dumps. Lastly add the module docstring at the top of the module.
--- tools/testing/selftests/net/rds/test.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
tools/testing/selftests/net/rds/test.py +8 -3
@@ -1,5 +1,8 @@ #! /usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0 +""" +This module provides functional testing for the net/rds component. +""" import argparse import ctypes
@@ -17,7 +20,8 @@ import shutil # Allow utils module to be imported from different directory this_dir = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(this_dir, "../")) -from lib.py.utils import ip +# pylint: disable-next=wrong-import-position,import-error,no-name-in-module +from lib.py.utils import ip # noqa: E402 libc = ctypes.cdll.LoadLibrary('libc.so.6') setns = libc.setns
@@ -129,6 +133,7 @@ tcpdump_procs = [] for net in [NET0, NET1]: pcap = logdir+'/'+net+'.pcap' fd, pcap_tmp = tempfile.mkstemp(suffix=".pcap", prefix=f"{net}-", dir="/tmp") + # pylint: disable-next=consider-using-with p = subprocess.Popen( ['ip', 'netns', 'exec', net, '/usr/sbin/tcpdump', '-i', 'any', '-w', pcap_tmp])
@@ -192,7 +197,7 @@ while nr_send < NUM_PACKETS: send_hashes.setdefault((sender.fileno(), receiver.fileno()), hashlib.sha256()).update(f'<{send_data}>'.encode('utf-8')) nr_send = nr_send + 1 - except BlockingIOError as e: + except BlockingIOError: break except OSError as e: if e.errno in [errno.ENOBUFS, errno.ECONNRESET, errno.EPIPE]:
@@ -214,7 +219,7 @@ while nr_send < NUM_PACKETS: receiver.fileno()), hashlib.sha256()).update( f'<{recv_data}>'.encode('utf-8')) nr_recv = nr_recv + 1 - except BlockingIOError as e: + except BlockingIOError: break # exercise net/rds/tcp.c:rds_tcp_sysctl_reset()
Signature · 1 line
2.25.1
Allison Henderson
maintainerPATCH v3 4/10 selftests: rds: Add timeout flag to run.sh
In reply to Allison HendersonAdd a -t flag to run.sh to optionally override the default timeout. The --timeout flag is already supported in test.py, so just add the shorthand -t flag
--- tools/testing/selftests/net/rds/README.txt | 4 +++- tools/testing/selftests/net/rds/run.sh | 11 ++++++++--- tools/testing/selftests/net/rds/test.py | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-)
tools/testing/selftests/net/rds/README.txt +3 -1
@@ -12,7 +12,7 @@ kernel may optionally be configured to omit the coverage report as well. USAGE: run.sh [-d logdir] [-l packet_loss] [-c packet_corruption] - [-u packet_duplicate] + [-u packet_duplicate] [-t timeout] OPTIONS: -d Log directory. Defaults to tools/testing/selftests/net/rds/rds_logs
@@ -23,6 +23,8 @@ OPTIONS: -u Simulates a percentage of packet duplication. + -t Test timeout. Defaults to tools/testing/selftests/net/rds/settings + EXAMPLE: # Create a suitable gcov enabled .config
tools/testing/selftests/net/rds/run.sh +8 -3
@@ -154,8 +154,9 @@ LOG_DIR="$current_dir"/rds_logs PLOSS=0 PCORRUPT=0 PDUP=0 +TIMEOUT=$timeout GENERATE_GCOV_REPORT=1 -while getopts "d:l:c:u:" opt; do +while getopts "d:l:c:u:t:" opt; do case ${opt} in d) LOG_DIR=${OPTARG}
@@ -166,12 +167,15 @@ while getopts "d:l:c:u:" opt; do c) PCORRUPT=${OPTARG} ;; + t) + TIMEOUT=${OPTARG} + ;; u) PDUP=${OPTARG} ;; :) echo "USAGE: run.sh [-d logdir] [-l packet_loss] [-c packet_corruption]" \ - "[-u packet_duplicate]" + "[-u packet_duplicate] [-t timeout]" exit 1 ;; ?)
@@ -198,7 +202,8 @@ echo running RDS tests... echo Traces will be logged to "$TRACE_FILE" rm -f "$TRACE_FILE" strace -T -tt -o "$TRACE_FILE" python3 "$(dirname "$0")/test.py" \ - --timeout "$timeout" -d "$LOG_DIR" -l "$PLOSS" -c "$PCORRUPT" -u "$PDUP" + -t "$TIMEOUT" -d "$LOG_DIR" -l "$PLOSS" -c "$PCORRUPT" \ + -u "$PDUP" test_rc=$? dmesg > "${LOG_DIR}/dmesg.out"
tools/testing/selftests/net/rds/test.py +1 -1
@@ -83,7 +83,7 @@ parser = argparse.ArgumentParser(description="init script args", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-d", "--logdir", action="store", help="directory to store logs", default="/tmp") -parser.add_argument('--timeout', help="timeout to terminate hung test", +parser.add_argument('-t', '--timeout', help="timeout to terminate hung test", type=int, default=0) parser.add_argument('-l', '--loss', help="Simulate tcp packet loss", type=int, default=0)
Signature · 1 line
2.25.1
Allison Henderson
maintainerPATCH v3 5/10 selftests: rds: Add RDS_LOG_DIR env variable
In reply to Allison HendersonThis patch modifies the rds selftest to look for an env variable RDS_LOG_DIR, and log all traces, pcaps and gcov collections to the folder specified in RDS_LOG_DIR. If RDS_LOG_DIR is unset, logs are not collected.
--- tools/testing/selftests/net/rds/README.txt | 19 +++++++-- tools/testing/selftests/net/rds/run.sh | 45 ++++++++++++---------- tools/testing/selftests/net/rds/test.py | 34 ++++++++-------- 3 files changed, 59 insertions(+), 39 deletions(-)
tools/testing/selftests/net/rds/README.txt +16 -3
@@ -15,7 +15,9 @@ USAGE: [-u packet_duplicate] [-t timeout] OPTIONS: - -d Log directory. Defaults to tools/testing/selftests/net/rds/rds_logs + -d Log directory. If set, logs will be stored in the + given dir, or skipped if unset. Log dir can also be + set through the RDS_LOG_DIR env variable -l Simulates a percentage of packet loss
@@ -25,6 +27,16 @@ OPTIONS: -t Test timeout. Defaults to tools/testing/selftests/net/rds/settings +ENV VARIABLES: + RDS_LOG_DIR Log directory. If set, logs will be stored in + the given dir, or skipped if unset. Log dir + can also be set with the -d flag. + + Use with --rwdir on the CI path to retain logs after + test compleation. Log dir end point must be within + the specified --rwdir path for logs to persist on + the host. + EXAMPLE: # Create a suitable gcov enabled .config
@@ -41,6 +53,7 @@ EXAMPLE: # launch the tests in a VM vng -v --rwdir ./ --run . --user root --cpus 4 -- \ - "export PYTHONPATH=tools/testing/selftests/net/; tools/testing/selftests/net/rds/run.sh" + "export PYTHONPATH=tools/testing/selftests/net/; \ + export RDS_LOG_DIR=tools/testing/selftests/net/rds/rds_logs; \ + tools/testing/selftests/net/rds/run.sh" -An HTML coverage report will be output in tools/testing/selftests/net/rds/rds_logs/coverage/.
tools/testing/selftests/net/rds/run.sh +25 -20
83 lines not on this page · raw message
tools/testing/selftests/net/rds/test.py +18 -16
@@ -82,7 +82,7 @@ def signal_handler(_sig, _frame): parser = argparse.ArgumentParser(description="init script args", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-d", "--logdir", action="store", - help="directory to store logs", default="/tmp") + help="directory to store logs", default=None) parser.add_argument('-t', '--timeout', help="timeout to terminate hung test", type=int, default=0) parser.add_argument('-l', '--loss', help="Simulate tcp packet loss",
@@ -128,16 +128,17 @@ ip(f"-n {NET1} route add {addrs[0][0]}/32 dev {VETH1}") # and communicating by doing a single ping ip(f"netns exec {NET0} ping -c 1 {addrs[1][0]}") -# Start a packet capture on each network tcpdump_procs = [] -for net in [NET0, NET1]: - pcap = logdir+'/'+net+'.pcap' - fd, pcap_tmp = tempfile.mkstemp(suffix=".pcap", prefix=f"{net}-", dir="/tmp") - # pylint: disable-next=consider-using-with - p = subprocess.Popen( - ['ip', 'netns', 'exec', net, - '/usr/sbin/tcpdump', '-i', 'any', '-w', pcap_tmp]) - tcpdump_procs.append((p, pcap_tmp, pcap, fd)) +# Start a packet capture on each network +if logdir is not None: + for net in [NET0, NET1]: + pcap = logdir+'/'+net+'.pcap' + fd, pcap_tmp = tempfile.mkstemp(suffix=".pcap", prefix=f"{net}-", dir="/tmp") + # pylint: disable-next=consider-using-with + p = subprocess.Popen( + ['ip', 'netns', 'exec', net, + '/usr/sbin/tcpdump', '-i', 'any', '-w', pcap_tmp]) + tcpdump_procs.append((p, pcap_tmp, pcap, fd)) # simulate packet loss, duplication and corruption for net, iface in [(NET0, VETH0), (NET1, VETH1)]:
@@ -252,12 +253,13 @@ for s in sockets: print(f"getsockopt(): {nr_success}/{nr_error}") -print("Stopping network packet captures") -for p, pcap_tmp, pcap, fd in tcpdump_procs: - p.terminate() - p.wait() - os.close(fd) - shutil.move(pcap_tmp, pcap) +if logdir is not None: + print("Stopping network packet captures") + for p, pcap_tmp, pcap, fd in tcpdump_procs: + p.terminate() + p.wait() + os.close(fd) + shutil.move(pcap_tmp, pcap) # We're done sending and receiving stuff, now let's check if what # we received is what we sent.
Signature · 1 line
2.25.1
Allison Henderson
maintainerPATCH v3 6/10 selftests: rds: Add SUDO_USER env variable
In reply to Allison HendersonThis patch modifies rds selftests to use the environment variable SUDO_USER for tcpdumps if it is set. This is needed to avoid chown operations on the vng 9pfs which is not supported. Passing a user listed in sudoers avoids the tcpdump privilege drop which may otherwise create empty pcaps
--- tools/testing/selftests/net/rds/README.txt | 7 +++++++ tools/testing/selftests/net/rds/test.py | 11 ++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-)
tools/testing/selftests/net/rds/README.txt +7 -0
@@ -37,6 +37,12 @@ ENV VARIABLES: the specified --rwdir path for logs to persist on the host. + SUDO_USER The user name that should be used for tcpdump + --relinquish-privileges. Set this to a user + belonging to the sudoers group to avoid drop + privilege errors with the vng 9p filesystem + which may result in empty pcaps + EXAMPLE: # Create a suitable gcov enabled .config
@@ -54,6 +60,7 @@ EXAMPLE: # launch the tests in a VM vng -v --rwdir ./ --run . --user root --cpus 4 -- \ "export PYTHONPATH=tools/testing/selftests/net/; \ + export SUDO_USER=example_user; \ export RDS_LOG_DIR=tools/testing/selftests/net/rds/rds_logs; \ tools/testing/selftests/net/rds/run.sh"
tools/testing/selftests/net/rds/test.py +8 -3
@@ -134,10 +134,15 @@ if logdir is not None: for net in [NET0, NET1]: pcap = logdir+'/'+net+'.pcap' fd, pcap_tmp = tempfile.mkstemp(suffix=".pcap", prefix=f"{net}-", dir="/tmp") + + tcpdump_cmd = ['ip', 'netns', 'exec', net, '/usr/sbin/tcpdump'] + sudo_user = os.environ.get('SUDO_USER') + if sudo_user: + tcpdump_cmd.extend(['-Z', sudo_user]) + tcpdump_cmd.extend(['-i', 'any', '-w', pcap_tmp]) + # pylint: disable-next=consider-using-with - p = subprocess.Popen( - ['ip', 'netns', 'exec', net, - '/usr/sbin/tcpdump', '-i', 'any', '-w', pcap_tmp]) + p = subprocess.Popen(tcpdump_cmd) tcpdump_procs.append((p, pcap_tmp, pcap, fd)) # simulate packet loss, duplication and corruption
Signature · 1 line
2.25.1
Allison Henderson
maintainerPATCH v3 7/10 selftests: rds: Remove tmp pcaps
In reply to Allison HendersonThis patch removes the initial tmp tcpdumps and instead saves the pcaps directly to the logdir if it is set.
--- tools/testing/selftests/net/rds/test.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
tools/testing/selftests/net/rds/test.py +3 -8
@@ -14,8 +14,6 @@ import signal import socket import subprocess import sys -import tempfile -import shutil # Allow utils module to be imported from different directory this_dir = os.path.dirname(os.path.realpath(__file__))
@@ -133,17 +131,16 @@ tcpdump_procs = [] if logdir is not None: for net in [NET0, NET1]: pcap = logdir+'/'+net+'.pcap' - fd, pcap_tmp = tempfile.mkstemp(suffix=".pcap", prefix=f"{net}-", dir="/tmp") tcpdump_cmd = ['ip', 'netns', 'exec', net, '/usr/sbin/tcpdump'] sudo_user = os.environ.get('SUDO_USER') if sudo_user: tcpdump_cmd.extend(['-Z', sudo_user]) - tcpdump_cmd.extend(['-i', 'any', '-w', pcap_tmp]) + tcpdump_cmd.extend(['-i', 'any', '-w', pcap]) # pylint: disable-next=consider-using-with p = subprocess.Popen(tcpdump_cmd) - tcpdump_procs.append((p, pcap_tmp, pcap, fd)) + tcpdump_procs.append(p) # simulate packet loss, duplication and corruption for net, iface in [(NET0, VETH0), (NET1, VETH1)]:
@@ -260,11 +257,9 @@ print(f"getsockopt(): {nr_success}/{nr_error}") if logdir is not None: print("Stopping network packet captures") - for p, pcap_tmp, pcap, fd in tcpdump_procs: + for p in tcpdump_procs: p.terminate() p.wait() - os.close(fd) - shutil.move(pcap_tmp, pcap) # We're done sending and receiving stuff, now let's check if what # we received is what we sent.
Signature · 1 line
2.25.1
Allison Henderson
maintainerPATCH v3 8/10 selftests: rds: Stop tcpdump on timeout
In reply to Allison HendersonThe timeout signal handler for the rds selftests currently just exits when the time limit is exceeded, and forgets to stop the network dumps. Fix this by hoisting the tcpdump terminate commands into a helper function, and call it from the signal handler before exiting
Bound proc.wait() with a timeout (and fall back to proc.kill()) so an unresponsive tcpdump cannot hang the timeout path itself.
We also pop() tcpdump_procs as we iterate, so stop_pcaps() is safe to call from both the normal cleanup path and the signal handler, since the second invocation simply has nothing to do
--- tools/testing/selftests/net/rds/test.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
tools/testing/selftests/net/rds/test.py +19 -5
@@ -68,11 +68,29 @@ def netns_socket(netns, *sock_args): u1.close() return socket.fromfd(fds[0], *sock_args) +def stop_pcaps(): + """Stop tcpdump processes. + + We use pop() here to drain the list in the event that the test + completes after the signal handler is fired. List will be empty + if logdir is not set + """ + print("Stopping network packet captures") + while tcpdump_procs: + proc = tcpdump_procs.pop() + proc.terminate() + try: + proc.wait(timeout=5) + except subprocess.TimeoutExpired: + proc.kill() + proc.wait() + def signal_handler(_sig, _frame): """ Test timed out signal handler """ print('Test timed out') + stop_pcaps() sys.exit(1) #Parse out command line arguments. We take an optional
@@ -255,11 +273,7 @@ for s in sockets: print(f"getsockopt(): {nr_success}/{nr_error}") -if logdir is not None: - print("Stopping network packet captures") - for p in tcpdump_procs: - p.terminate() - p.wait() +stop_pcaps() # We're done sending and receiving stuff, now let's check if what # we received is what we sent.
Signature · 1 line
2.25.1
Allison Henderson
maintainerPATCH v3 9/10 selftests: rds: Fix gcov collection
In reply to Allison Hendersondebugfs is not mounted automatically in a virtme-ng guest, so the gcov data copy from /sys/kernel/debug/gcov/ silently finds nothing depending on whether debugfs is mounted by default on the host OS. Fix this by mounting debugfs in run.sh before copying the gcda files.
Finally when invoked through the kselftest runner, the working directory is the test directory rather than the kernel source root. gcovr defaults --root to the current working directory, which causes it to filter out all coverage data for files under net/rds/ since they are not under the test directory. Fix this by passing --root to gcovr explicitly.
--- tools/testing/selftests/net/rds/run.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
tools/testing/selftests/net/rds/run.sh +7 -1
@@ -215,6 +215,12 @@ fi if [[ -n "$LOG_DIR" ]] && [ "$GENERATE_GCOV_REPORT" -eq 1 ]; then echo saving coverage data... + + # Ensure debugfs is mounted before reading gcov data. + if ! mountpoint -q /sys/kernel/debug 2>/dev/null; then + mount -t debugfs debugfs /sys/kernel/debug 2>/dev/null || true + fi + (set +x; cd /sys/kernel/debug/gcov; find ./* -name '*.gcda' | \ while read -r f do
@@ -223,7 +229,7 @@ if [[ -n "$LOG_DIR" ]] && [ "$GENERATE_GCOV_REPORT" -eq 1 ]; then echo running gcovr... gcovr -s --html-details --gcov-executable "$GCOV_CMD" --gcov-ignore-parse-errors \ - -o "${COVR_DIR}/gcovr" "${ksrc_dir}/net/rds/" + --root "${ksrc_dir}" -o "${COVR_DIR}/gcovr" "${ksrc_dir}/net/rds/" else echo "Coverage report will be skipped" fi
Signature · 1 line
2.25.1
Allison Henderson
maintainerPATCH v3 10/10 selftests: rds: Make rds selftests TAP compliant
In reply to Allison HendersonThis patch updates the rds selftests output to be TAP compliant.
Use ksft_pr() to mark debug output with a leading '# ' so that TAP parsers treat it as commentary, and convert all informational print() calls to use ksft_pr(). sys.exit(0) is changed to os._exit(0) to avoid duplicate prints from the buffered TAP output. The console output from the tcpdump subprocess is silenced, and the gcov console output is redirected to a gcovr.log.
Finally adjust the exit path so that the hash check loop sets a return code instead exiting directly. Then print the TAP results and totals lines before exiting.
--- tools/testing/selftests/net/rds/run.sh | 18 ++++---- tools/testing/selftests/net/rds/test.py | 55 ++++++++++++++++--------- 2 files changed, 45 insertions(+), 28 deletions(-)
tools/testing/selftests/net/rds/run.sh +10 -8
@@ -197,14 +197,14 @@ if [[ -n "$LOG_DIR" ]]; then mkdir -p "$LOG_DIR" mkdir -p "$COVR_DIR" - echo Traces will be logged to "${TRACE_FILE}" + echo "#Traces will be logged to ${TRACE_FILE}" rm -f "$TRACE_FILE" TRACE_CMD=(strace -T -tt -o "${TRACE_FILE}") fi set +e -echo running RDS tests... +echo "#running RDS tests..." "${TRACE_CMD[@]}" python3 "$(dirname "$0")/test.py" "${FLAGS[@]}" -t "$TIMEOUT" test_rc=$?
@@ -214,7 +214,7 @@ if [[ -n "$LOG_DIR" ]]; then fi if [[ -n "$LOG_DIR" ]] && [ "$GENERATE_GCOV_REPORT" -eq 1 ]; then - echo saving coverage data... + echo "# saving coverage data..." # Ensure debugfs is mounted before reading gcov data. if ! mountpoint -q /sys/kernel/debug 2>/dev/null; then
@@ -227,17 +227,19 @@ if [[ -n "$LOG_DIR" ]] && [ "$GENERATE_GCOV_REPORT" -eq 1 ]; then cat < "/sys/kernel/debug/gcov/$f" > "/$f" done) - echo running gcovr... + echo "# running gcovr..." gcovr -s --html-details --gcov-executable "$GCOV_CMD" --gcov-ignore-parse-errors \ - --root "${ksrc_dir}" -o "${COVR_DIR}/gcovr" "${ksrc_dir}/net/rds/" + --root "${ksrc_dir}" -o "${COVR_DIR}/gcovr" "${ksrc_dir}/net/rds/" \ + > "${LOG_DIR}/gcovr.log" 2>&1 + echo "# gcovr log: ${LOG_DIR}/gcovr.log" else - echo "Coverage report will be skipped" + echo "# Coverage report will be skipped" fi if [ "$test_rc" -eq 0 ]; then - echo "PASS: Test completed successfully" + echo "# PASS: Test completed successfully" else - echo "FAIL: Test failed" + echo "# FAIL: Test failed" fi exit "$test_rc"
tools/testing/selftests/net/rds/test.py +35 -20
123 lines not on this page · raw message
Signature · 1 line
2.25.1
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Sun, 3 May 2026 22:41:33 -0700 you wrote:
This series is a set of bug fixes and improvements for the rds selftests.
Patch 1 bumps the kselftest timeout from 400s to 800s. The original limit was developed against a lean config, but the kselftest harness counts boot time and gcov log collection against the limit, so a default config with gcov enabled needs more headroom.
[...]
Here is the summary with links:
- [net-next,v3,01/10] selftests: rds: Increase selftest timeout
https://git.kernel.org/netdev/net-next/c/94720e01f5bb - [net-next,v3,02/10] selftests: rds: Update USAGE string for run.sh https://git.kernel.org/netdev/net-next/c/4781c8b037a8 - [net-next,v3,03/10] selftests: rds: Fix more pylint errors https://git.kernel.org/netdev/net-next/c/5bdd59f90633 - [net-next,v3,04/10] selftests: rds: Add timeout flag to run.sh https://git.kernel.org/netdev/net-next/c/7d6a32e7cb45 - [net-next,v3,05/10] selftests: rds: Add RDS_LOG_DIR env variable https://git.kernel.org/netdev/net-next/c/ad070d903759 - [net-next,v3,06/10] selftests: rds: Add SUDO_USER env variable https://git.kernel.org/netdev/net-next/c/d601239dcc26 - [net-next,v3,07/10] selftests: rds: Remove tmp pcaps https://git.kernel.org/netdev/net-next/c/c726bc68fffd - [net-next,v3,08/10] selftests: rds: Stop tcpdump on timeout https://git.kernel.org/netdev/net-next/c/ec91483634fe - [net-next,v3,09/10] selftests: rds: Fix gcov collection https://git.kernel.org/netdev/net-next/c/c8781c61fd60 - [net-next,v3,10/10] selftests: rds: Make rds selftests TAP compliant https://git.kernel.org/netdev/net-next/c/06d5c34517e0
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html