Mirsad Todorovac mirsad.todorovac@alu.unizg.hr writes:
Add trap and cleanup for SIGTERM sent by timeout and SIGINT from keyboard, for the test times out and leaves incoherent network stack.
Fixes: 511e8db54036c ("selftests: forwarding: Add test for custom multipath hash") Cc: Ido Schimmel idosch@nvidia.com Cc: netdev@vger.kernel.org
tools/testing/selftests/net/forwarding/custom_multipath_hash.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/forwarding/custom_multipath_hash.sh b/tools/testing/selftests/net/forwarding/custom_multipath_hash.sh index 56eb83d1a3bd..c7ab883d2515 100755 --- a/tools/testing/selftests/net/forwarding/custom_multipath_hash.sh +++ b/tools/testing/selftests/net/forwarding/custom_multipath_hash.sh @@ -363,7 +363,7 @@ custom_hash() custom_hash_v6 } -trap cleanup EXIT +trap cleanup INT TERM EXIT setup_prepare setup_wait
I believe the EXIT trap covers whatever the cause of the exit was, i.e. INT and TERM are implicitly covered:
$ vim tmp/x.sh $ cat tmp/x.sh foo() { date; } trap foo EXIT read -p Ready. $ bash tmp/x.sh Ready.^CTue Jul 25 10:44:20 AM CEST 2023
Also, the interrupt trap seems to prevent the exit actually:
$ cat tmp/x.sh foo() { date; } trap foo INT TERM EXIT read -p Ready. [petr@yaviefel ~]$ bash tmp/x.sh Ready.^CTue Jul 25 10:43:35 AM CEST 2023 ^CTue Jul 25 10:43:35 AM CEST 2023 ^CTue Jul 25 10:43:36 AM CEST 2023 ^CTue Jul 25 10:43:36 AM CEST 2023
(I see the same when I kill -TERM the script.)
This would call cleanup, which would dismantle the configuration, but then would happilly proceed in the script. I might be missing something, but I don't see how this can work.