[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260120124733.604590-1-gal@nvidia.com>
Date: Tue, 20 Jan 2026 14:47:33 +0200
From: Gal Pressman <gal@...dia.com>
To: "David S. Miller" <davem@...emloft.net>, Eric Dumazet
<edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni
<pabeni@...hat.com>, Andrew Lunn <andrew+netdev@...n.ch>,
<netdev@...r.kernel.org>
CC: Simon Horman <horms@...nel.org>, Shuah Khan <shuah@...nel.org>, Joe Damato
<joe@...a.to>, Stanislav Fomichev <sdf@...ichev.me>,
<linux-kselftest@...r.kernel.org>, Gal Pressman <gal@...dia.com>, Nimrod Oren
<noren@...dia.com>
Subject: [PATCH net] selftests: net: fix wrong boolean evaluation in __exit__
The __exit__ method receives ex_type as the exception class when an
exception occurs. The previous code used implicit boolean evaluation:
terminate = self.terminate or (self._exit_wait and ex_type)
^^^^^^^^^^^
In Python, the and operator can be used with non-boolean values, but it
does not always return a boolean result.
This is probably not what we want, because 'self._exit_wait and ex_type'
could return the actual ex_type value (the exception class) rather than
a boolean True when an exception occurs.
Use explicit `ex_type is not None` check to properly evaluate whether
an exception occurred, returning a boolean result.
Fixes: 6e9a12f85a75 ("selftests: net: terminate bkg() commands on exception")
Reviewed-by: Nimrod Oren <noren@...dia.com>
Signed-off-by: Gal Pressman <gal@...dia.com>
---
tools/testing/selftests/net/lib/py/utils.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/lib/py/utils.py b/tools/testing/selftests/net/lib/py/utils.py
index 106ee1f2df86..dc1db78b5304 100644
--- a/tools/testing/selftests/net/lib/py/utils.py
+++ b/tools/testing/selftests/net/lib/py/utils.py
@@ -137,7 +137,7 @@ class bkg(cmd):
def __exit__(self, ex_type, ex_value, ex_tb):
# Force termination on exception
- terminate = self.terminate or (self._exit_wait and ex_type)
+ terminate = self.terminate or (self._exit_wait and ex_type is not None)
return self.process(terminate=terminate, fail=self.check_fail)
--
2.40.1
Powered by blists - more mailing lists