From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
To: khorenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH vz10 3/4] selftests: net: py: report a refused environment as a skip
Date: Tue, 1 Sep 2026 01:50:53 +0300 [thread overview]
Message-ID: <20260831225137.1642608-3-eva.kurchatova@virtuozzo.com> (raw)
In-Reply-To: <20260831225137.1642608-1-eva.kurchatova@virtuozzo.com>
A KsftSkipEx or KsftXfailEx raised outside ksft_run(), which is where an
environment check belongs, reaches the interpreter and is printed as a
traceback with exit status 1. A test that only wanted to say that this
machine cannot run it is then reported as a failure.
Install an excepthook that turns those two into the "1..0 # SKIP" or
XFAIL line the runner expects and exits with the skip status.
https://virtuozzo.atlassian.net/browse/VSTOR-139651
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
tools/testing/selftests/net/lib/py/ksft.py | 27 ++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/tools/testing/selftests/net/lib/py/ksft.py b/tools/testing/selftests/net/lib/py/ksft.py
index 61287c203b6e..332f8c105512 100644
--- a/tools/testing/selftests/net/lib/py/ksft.py
+++ b/tools/testing/selftests/net/lib/py/ksft.py
@@ -10,6 +10,8 @@ import traceback
from .consts import KSFT_MAIN_NAME
from .utils import global_defer_queue
+KSFT_SKIP = 4
+
KSFT_RESULT = None
KSFT_RESULT_ALL = True
KSFT_DISRUPTIVE = True
@@ -278,3 +280,28 @@ def ksft_run(cases=None, globs=None, case_pfx=None, args=()):
def ksft_exit():
global KSFT_RESULT_ALL
sys.exit(0 if KSFT_RESULT_ALL else 1)
+
+
+def _ksft_no_tests_ran(comment):
+ print("TAP version 13")
+ print("1..0 # " + comment)
+ sys.exit(KSFT_SKIP)
+
+
+def _ksft_excepthook(exc_type, exc_value, tb):
+ """
+ A test whose environment refuses it, e.g. one that needs a real
+ device and is handed netdevsim, raises while the environment is
+ being built, before there is a ksft_run() to catch anything. The
+ traceback that then leaves main() is reported as a failed test,
+ although the test never ran. Say what happened and exit the way
+ the kselftest runner expects for a test that did not run.
+ """
+ if issubclass(exc_type, KsftSkipEx):
+ _ksft_no_tests_ran("SKIP " + str(exc_value))
+ if issubclass(exc_type, KsftXfailEx):
+ _ksft_no_tests_ran("XFAIL " + str(exc_value))
+ sys.__excepthook__(exc_type, exc_value, tb)
+
+
+sys.excepthook = _ksft_excepthook
--
2.55.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-08-31 22:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 22:50 [Devel] [PATCH vz10 1/4] ms/selftests: net: Add python context manager for netns entering Eva Kurchatova
2026-08-31 22:50 ` [Devel] [PATCH vz10 2/4] selftests: net: py: add the missing ksft_is() and ksft_not_in() helpers Eva Kurchatova
2026-08-31 22:50 ` Eva Kurchatova [this message]
2026-08-31 22:50 ` [Devel] [PATCH vz10 4/4] selftests: drv-net-hw: skip the tests that need a real interface Eva Kurchatova
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260831225137.1642608-3-eva.kurchatova@virtuozzo.com \
--to=eva.kurchatova@virtuozzo.com \
--cc=devel@openvz.org \
--cc=khorenko@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox