linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] selftest: fib_tests: Always cleanup before exit
@ 2023-02-20 11:03 Roxana Nicolescu
  2023-02-20 11:04 ` [PATCH 1/1] " Roxana Nicolescu
  2023-02-21 11:20 ` [PATCH 0/1] " patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Roxana Nicolescu @ 2023-02-20 11:03 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, shuah
  Cc: netdev, linux-kselftest, linux-kernel

Usually when a subtest is executed, setup and cleanup functions
are linearly called at the beginning and end of it.
In some of them, `set -e` is used before executing commands.
If one of the commands returns a non zero code, the whole script exists
without cleaning up the resources allocated at setup.
This can affect the next tests that use the same resources,
leading to a chain of failures.

To be consistent with other tests, calling cleanup function when the
script exists fixes the issue.

Steps to reproduce it:
1. Build with CONFIG_IP_ROUTE_MULTIPATH disabled.
2. Run net kselftest suite
3. fib_tests:fib_unreg_multipath_test fails when executing
`ip -netns ns1 route add 203.0.113.0/24 nexthop via 198.51.100.2 dev
dummy0 nexthop via 192.0.2.2 dev dummy1` because
CONFIG_IP_ROUTE_MULTIPATH is disabled.
This results in resources allocated during setup (e.g namespace ns1)
not being cleaned up.
4. When icmp.sh tries to create namespace ns1 during its setup, it fails
with the following error:
Cannot create namespace file "/run/netns/ns1": File exists

Roxana Nicolescu (1):
  selftest: fib_tests: Always cleanup before exit

 tools/testing/selftests/net/fib_tests.sh | 2 ++
 1 file changed, 2 insertions(+)

-- 
2.34.1


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

* [PATCH 1/1] selftest: fib_tests: Always cleanup before exit
  2023-02-20 11:03 [PATCH 0/1] selftest: fib_tests: Always cleanup before exit Roxana Nicolescu
@ 2023-02-20 11:04 ` Roxana Nicolescu
  2023-02-21 11:20 ` [PATCH 0/1] " patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Roxana Nicolescu @ 2023-02-20 11:04 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, shuah
  Cc: netdev, linux-kselftest, linux-kernel

Usage of `set -e` before executing a command causes immediate exit
on failure, without cleanup up the resources allocated at setup.
This can affect the next tests that use the same resources,
leading to a chain of failures.

A simple fix is to always call cleanup function when the script exists.
This approach is already used by other existing tests.

Fixes: 1056691b2680 ("selftests: fib_tests: Make test results more verbose")
Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
---
 tools/testing/selftests/net/fib_tests.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh
index 5637b5dadabd..70ea8798b1f6 100755
--- a/tools/testing/selftests/net/fib_tests.sh
+++ b/tools/testing/selftests/net/fib_tests.sh
@@ -2065,6 +2065,8 @@ EOF
 ################################################################################
 # main
 
+trap cleanup EXIT
+
 while getopts :t:pPhv o
 do
 	case $o in
-- 
2.34.1


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

* Re: [PATCH 0/1] selftest: fib_tests: Always cleanup before exit
  2023-02-20 11:03 [PATCH 0/1] selftest: fib_tests: Always cleanup before exit Roxana Nicolescu
  2023-02-20 11:04 ` [PATCH 1/1] " Roxana Nicolescu
@ 2023-02-21 11:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-02-21 11:20 UTC (permalink / raw)
  To: Roxana Nicolescu
  Cc: davem, edumazet, kuba, pabeni, shuah, netdev, linux-kselftest,
	linux-kernel

Hello:

This patch was applied to netdev/net.git (master)
by Paolo Abeni <pabeni@redhat.com>:

On Mon, 20 Feb 2023 12:03:59 +0100 you wrote:
> Usually when a subtest is executed, setup and cleanup functions
> are linearly called at the beginning and end of it.
> In some of them, `set -e` is used before executing commands.
> If one of the commands returns a non zero code, the whole script exists
> without cleaning up the resources allocated at setup.
> This can affect the next tests that use the same resources,
> leading to a chain of failures.
> 
> [...]

Here is the summary with links:
  - [1/1] selftest: fib_tests: Always cleanup before exit
    https://git.kernel.org/netdev/net/c/b60417a9f2b8

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-02-21 11:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-20 11:03 [PATCH 0/1] selftest: fib_tests: Always cleanup before exit Roxana Nicolescu
2023-02-20 11:04 ` [PATCH 1/1] " Roxana Nicolescu
2023-02-21 11:20 ` [PATCH 0/1] " patchwork-bot+netdevbpf

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).