* [PATCH net-next 0/2] selftests: pmtu: Add test choice and captures
@ 2018-10-12 21:54 Stefano Brivio
2018-10-12 21:54 ` [PATCH net-next 1/2] selftests: pmtu: Allow selection of single tests Stefano Brivio
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Stefano Brivio @ 2018-10-12 21:54 UTC (permalink / raw)
To: David S. Miller; +Cc: Sabrina Dubroca, netdev
This series adds a couple of features useful for debugging: 1/2
allows selecting single tests and 2/2 adds optional traffic
captures.
Semantics for current invocation of test script are preserved.
Stefano Brivio (2):
selftests: pmtu: Allow selection of single tests
selftests: pmtu: Add optional traffic captures for single tests
tools/testing/selftests/net/pmtu.sh | 69 ++++++++++++++++++++++++++++-
1 file changed, 68 insertions(+), 1 deletion(-)
--
2.19.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next 1/2] selftests: pmtu: Allow selection of single tests
2018-10-12 21:54 [PATCH net-next 0/2] selftests: pmtu: Add test choice and captures Stefano Brivio
@ 2018-10-12 21:54 ` Stefano Brivio
2018-10-12 21:54 ` [PATCH net-next 2/2] selftests: pmtu: Add optional traffic captures for " Stefano Brivio
2018-10-16 5:38 ` [PATCH net-next 0/2] selftests: pmtu: Add test choice and captures David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Stefano Brivio @ 2018-10-12 21:54 UTC (permalink / raw)
To: David S. Miller; +Cc: Sabrina Dubroca, netdev
As number of tests is growing, it's quite convenient to allow
single tests to be run.
Display usage when the script is run with any invalid argument,
keep existing semantics when no arguments are passed so that
automated runs won't break.
Instead of just looping on the list of requested tests, if any,
check first that they exist, and go through them in a nested
loop to keep the existing way to display test descriptions.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
---
tools/testing/selftests/net/pmtu.sh | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh
index b9cdb68df4c5..8278a24f5ba6 100755
--- a/tools/testing/selftests/net/pmtu.sh
+++ b/tools/testing/selftests/net/pmtu.sh
@@ -641,6 +641,20 @@ test_pmtu_vti6_link_change_mtu() {
return ${fail}
}
+usage() {
+ echo
+ echo "$0 [TEST]..."
+ echo "If no TEST argument is given, all tests will be run."
+ echo
+ echo "Available tests${tests}"
+ exit 1
+}
+
+for arg do
+ # Check first that all requested tests are available before running any
+ command -v > /dev/null "test_${arg}" || { echo "=== Test ${arg} not found"; usage; }
+done
+
trap cleanup EXIT
exitcode=0
@@ -650,6 +664,13 @@ IFS="
for t in ${tests}; do
[ $desc -eq 0 ] && name="${t}" && desc=1 && continue || desc=0
+ run_this=1
+ for arg do
+ [ "${arg}" = "${name}" ] && run_this=1 && break
+ run_this=0
+ done
+ [ $run_this -eq 0 ] && continue
+
(
unset IFS
eval test_${name}
--
2.19.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net-next 2/2] selftests: pmtu: Add optional traffic captures for single tests
2018-10-12 21:54 [PATCH net-next 0/2] selftests: pmtu: Add test choice and captures Stefano Brivio
2018-10-12 21:54 ` [PATCH net-next 1/2] selftests: pmtu: Allow selection of single tests Stefano Brivio
@ 2018-10-12 21:54 ` Stefano Brivio
2018-10-16 5:38 ` [PATCH net-next 0/2] selftests: pmtu: Add test choice and captures David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Stefano Brivio @ 2018-10-12 21:54 UTC (permalink / raw)
To: David S. Miller; +Cc: Sabrina Dubroca, netdev
If --trace is passed as an option and tcpdump is available,
capture traffic for all relevant interfaces to per-test pcap
files named <test>_<interface>.pcap.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
---
tools/testing/selftests/net/pmtu.sh | 60 +++++++++++++++++++++++++----
1 file changed, 53 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh
index 8278a24f5ba6..ed549c03d2a7 100755
--- a/tools/testing/selftests/net/pmtu.sh
+++ b/tools/testing/selftests/net/pmtu.sh
@@ -142,6 +142,7 @@ dummy6_mask="64"
cleanup_done=1
err_buf=
+tcpdump_pids=
err() {
err_buf="${err_buf}${1}
@@ -284,7 +285,24 @@ setup() {
done
}
+trace() {
+ [ $tracing -eq 0 ] && return
+
+ for arg do
+ [ "${ns_cmd}" = "" ] && ns_cmd="${arg}" && continue
+ ${ns_cmd} tcpdump -s 0 -i "${arg}" -w "${name}_${arg}.pcap" 2> /dev/null &
+ tcpdump_pids="${tcpdump_pids} $!"
+ ns_cmd=
+ done
+ sleep 1
+}
+
cleanup() {
+ for pid in ${tcpdump_pids}; do
+ kill ${pid}
+ done
+ tcpdump_pids=
+
[ ${cleanup_done} -eq 1 ] && return
for n in ${NS_A} ${NS_B} ${NS_R1} ${NS_R2}; do
ip netns del ${n} 2> /dev/null
@@ -357,6 +375,10 @@ test_pmtu_ipvX() {
family=${1}
setup namespaces routing || return 2
+ trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
+ "${ns_r1}" veth_R1-B "${ns_b}" veth_B-R1 \
+ "${ns_a}" veth_A-R2 "${ns_r2}" veth_R2-A \
+ "${ns_r2}" veth_R2-B "${ns_b}" veth_B-R2
if [ ${family} -eq 4 ]; then
ping=ping
@@ -445,6 +467,8 @@ test_pmtu_ipv6_exception() {
test_pmtu_vti4_exception() {
setup namespaces veth vti4 xfrm4 || return 2
+ trace "${ns_a}" veth_a "${ns_b}" veth_b \
+ "${ns_a}" vti4_a "${ns_b}" vti4_b
veth_mtu=1500
vti_mtu=$((veth_mtu - 20))
@@ -473,6 +497,8 @@ test_pmtu_vti4_exception() {
test_pmtu_vti6_exception() {
setup namespaces veth vti6 xfrm6 || return 2
+ trace "${ns_a}" veth_a "${ns_b}" veth_b \
+ "${ns_a}" vti6_a "${ns_b}" vti6_b
fail=0
# Create route exception by exceeding link layer MTU
@@ -643,29 +669,49 @@ test_pmtu_vti6_link_change_mtu() {
usage() {
echo
- echo "$0 [TEST]..."
+ echo "$0 [OPTIONS] [TEST]..."
echo "If no TEST argument is given, all tests will be run."
echo
+ echo "Options"
+ echo " --trace: capture traffic to TEST_INTERFACE.pcap"
+ echo
echo "Available tests${tests}"
exit 1
}
+exitcode=0
+desc=0
+IFS="
+"
+
+tracing=0
for arg do
- # Check first that all requested tests are available before running any
- command -v > /dev/null "test_${arg}" || { echo "=== Test ${arg} not found"; usage; }
+ if [ "${arg}" != "${arg#--*}" ]; then
+ opt="${arg#--}"
+ if [ "${opt}" = "trace" ]; then
+ if which tcpdump > /dev/null 2>&1; then
+ tracing=1
+ else
+ echo "=== tcpdump not available, tracing disabled"
+ fi
+ else
+ usage
+ fi
+ else
+ # Check first that all requested tests are available before
+ # running any
+ command -v > /dev/null "test_${arg}" || { echo "=== Test ${arg} not found"; usage; }
+ fi
done
trap cleanup EXIT
-exitcode=0
-desc=0
-IFS="
-"
for t in ${tests}; do
[ $desc -eq 0 ] && name="${t}" && desc=1 && continue || desc=0
run_this=1
for arg do
+ [ "${arg}" != "${arg#--*}" ] && continue
[ "${arg}" = "${name}" ] && run_this=1 && break
run_this=0
done
--
2.19.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 0/2] selftests: pmtu: Add test choice and captures
2018-10-12 21:54 [PATCH net-next 0/2] selftests: pmtu: Add test choice and captures Stefano Brivio
2018-10-12 21:54 ` [PATCH net-next 1/2] selftests: pmtu: Allow selection of single tests Stefano Brivio
2018-10-12 21:54 ` [PATCH net-next 2/2] selftests: pmtu: Add optional traffic captures for " Stefano Brivio
@ 2018-10-16 5:38 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2018-10-16 5:38 UTC (permalink / raw)
To: sbrivio; +Cc: sd, netdev
From: Stefano Brivio <sbrivio@redhat.com>
Date: Fri, 12 Oct 2018 23:54:12 +0200
> This series adds a couple of features useful for debugging: 1/2
> allows selecting single tests and 2/2 adds optional traffic
> captures.
>
> Semantics for current invocation of test script are preserved.
M0AR SELF TESTS!
I love it.
Keep them coming.
Series applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-10-16 13:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-12 21:54 [PATCH net-next 0/2] selftests: pmtu: Add test choice and captures Stefano Brivio
2018-10-12 21:54 ` [PATCH net-next 1/2] selftests: pmtu: Allow selection of single tests Stefano Brivio
2018-10-12 21:54 ` [PATCH net-next 2/2] selftests: pmtu: Add optional traffic captures for " Stefano Brivio
2018-10-16 5:38 ` [PATCH net-next 0/2] selftests: pmtu: Add test choice and captures David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).