linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests: txtimestamp: tear down setup() 'tc' and 'ip' env on EXIT
@ 2020-07-21 14:52 Paolo Pisati
  2020-07-21 15:04 ` Willem de Bruijn
  0 siblings, 1 reply; 7+ messages in thread
From: Paolo Pisati @ 2020-07-21 14:52 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Shuah Khan, Willem de Bruijn,
	Jian Yang
  Cc: netdev, linux-kselftest, linux-kernel

Add a cleanup() path upon exit, making it possible to run the test twice in a
row:

$ sudo bash -x ./txtimestamp.sh
+ set -e
++ ip netns identify
+ [[ '' == \r\o\o\t ]]
+ main
+ [[ 0 -eq 0 ]]
+ run_test_all
+ setup
+ tc qdisc add dev lo root netem delay 1ms
Error: Exclusivity flag on, cannot modify.

Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
---
 tools/testing/selftests/net/txtimestamp.sh | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/testing/selftests/net/txtimestamp.sh b/tools/testing/selftests/net/txtimestamp.sh
index eea6f5193693..77f29cabff87 100755
--- a/tools/testing/selftests/net/txtimestamp.sh
+++ b/tools/testing/selftests/net/txtimestamp.sh
@@ -23,6 +23,14 @@ setup() {
 		action mirred egress redirect dev ifb_netem0
 }
 
+cleanup() {
+	tc filter del dev lo parent ffff:
+	tc qdisc del dev lo handle ffff: ingress
+	tc qdisc del dev ifb_netem0 root
+	ip link del ifb_netem0
+	tc qdisc del dev lo root
+}
+
 run_test_v4v6() {
 	# SND will be delayed 1000us
 	# ACK will be delayed 6000us: 1 + 2 ms round-trip
@@ -75,6 +83,8 @@ main() {
 	fi
 }
 
+trap cleanup EXIT
+
 if [[ "$(ip netns identify)" == "root" ]]; then
 	./in_netns.sh $0 $@
 else
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-07-22 12:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-21 14:52 [PATCH] selftests: txtimestamp: tear down setup() 'tc' and 'ip' env on EXIT Paolo Pisati
2020-07-21 15:04 ` Willem de Bruijn
2020-07-21 16:17   ` [PATCH v2] selftest: txtimestamp: fix net ns entry logic Paolo Pisati
2020-07-21 16:25     ` Willem de Bruijn
2020-07-22  8:37       ` Paolo Pisati
2020-07-22 12:49         ` Willem de Bruijn
2020-07-21 23:11     ` 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).