]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/net: l2_tos_ttl_inherit.sh: Ensure environment cleanup on failure.
authorGuillaume Nault <gnault@redhat.com>
Sun, 8 Jan 2023 15:45:50 +0000 (16:45 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:58:31 +0000 (11:58 +0100)
commit1249e6b2861f2d02cb6ecc74d943bc99c631d0fa
tree2cbfeba664322683799aafa287e503522aabeb6d
parent455b63781b57b09c63cbcf6fcfea6f4a7b166d71
selftests/net: l2_tos_ttl_inherit.sh: Ensure environment cleanup on failure.

[ Upstream commit 7d33a8052f997e09d0b030a7c3f7c148180ee13a ]

Use 'set -e' and an exit handler to stop the script if a command fails
and ensure the test environment is cleaned up in any case. Also, handle
the case where the script is interrupted by SIGINT.

The only command that's expected to fail is 'wait $ping_pid', since
it's killed by the script. Handle this case with '|| true' to make it
play well with 'set -e'.

Finally, return the Kselftest SKIP code (4) when the script breaks
because of an environment problem or a command line failure. The 0 and
1 return codes should now reliably indicate that all tests have been
run (0: all tests run and passed, 1: all tests run but at least one
failed, 4: test script didn't run completely).

Fixes: d9d28d077179 ("selftests/net: test l2 tunnel TOS/TTL inheriting")
Reported-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Tested-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Signed-off-by: Guillaume Nault <gnault@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/net/l2_tos_ttl_inherit.sh