From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH vz10 3/4] selftests: net: py: report a refused environment as a skip
Date: Thu, 24 Sep 2026 15:28:07 +0200 [thread overview]
Message-ID: <1a2fa721-96ed-4ef5-a96b-0a32f2042a88@virtuozzo.com> (raw)
In-Reply-To: <20260831225137.1642608-3-eva.kurchatova@virtuozzo.com>
Committed to branch-rh10-6.12.0-211.52.1.22.x.vz10-ovz, will be released in rh10-6.12.0-211.52.1.22.3.vz10
82d64c72dbd1
selftests: net: py: report a refused environment as a skip
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. It is set
when the library is imported, so every test using it gets this without
changes.
https://virtuozzo.atlassian.net/browse/VSTOR-139651
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Link: http://lore.virtuozzo.com/20260831225137.1642608-3-eva.kurchatova@virtuozzo.com
--
Best regards,
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
On 9/1/26 00:50, Eva Kurchatova wrote:
> 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
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-09-24 13:29 UTC|newest]
Thread overview: 9+ 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-09-24 13:27 ` Konstantin Khorenko
2026-08-31 22:50 ` [Devel] [PATCH vz10 3/4] selftests: net: py: report a refused environment as a skip Eva Kurchatova
2026-09-24 13:28 ` Konstantin Khorenko [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
2026-09-24 13:23 ` Konstantin Khorenko
2026-09-24 13:29 ` Konstantin Khorenko
2026-09-24 13:27 ` [Devel] [PATCH vz10 1/4] ms/selftests: net: Add python context manager for netns entering Konstantin Khorenko
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=1a2fa721-96ed-4ef5-a96b-0a32f2042a88@virtuozzo.com \
--to=khorenko@virtuozzo.com \
--cc=devel@openvz.org \
--cc=eva.kurchatova@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