From: Stanislav Fomichev <sdf@fomichev.me>
To: Petr Machata <petrm@nvidia.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, Shuah Khan <shuah@kernel.org>,
Joe Damato <jdamato@fastly.com>,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next v2 2/2] selftests: net: ksft: support marking tests as disruptive
Date: Wed, 31 Jul 2024 13:47:44 -0700 [thread overview]
Message-ID: <Zqqi8LhvSn1MXu9B@mini-arch> (raw)
In-Reply-To: <878qxh7mf4.fsf@nvidia.com>
On 07/31, Petr Machata wrote:
>
> Stanislav Fomichev <sdf@fomichev.me> writes:
>
> > Add new @ksft_disruptive decorator to mark the tests that might
> > be disruptive to the system. Depending on how well the previous
> > test works in the CI we might want to disable disruptive tests
> > by default and only let the developers run them manually.
> >
> > KSFT framework runs disruptive tests by default. DISRUPTIVE=False
> > environment (or config file) can be used to disable these tests.
> > ksft_setup should be called by the test cases that want to use
> > new decorator (ksft_setup is only called via NetDrvEnv/NetDrvEpEnv for now).
>
> Is that something that tests would want to genuinely do, manage this
> stuff by hand? I don't really mind having the helper globally
> accessible, but default I'd keep it inside env.py and expect others to
> inherit appropriately.
Hard to say how well it's gonna work tbh. But at least from
what I've seen, large code bases (outside of kernel) usually
have some way to attach metadata to the testcase to indicate
various things. For example, this is how the timeout
can be controlled:
https://bazel.build/reference/test-encyclopedia#role-test-runner
So I'd imagine we can eventually have @kstf_short/@ksft_long to
control that using similar techniques.
Regarding keeping it inside env.py: can you expand more on what
you mean by having the default in env.py?
> > @@ -127,6 +129,36 @@ KSFT_RESULT_ALL = True
> > KSFT_RESULT = False
> >
> >
> > +def ksft_disruptive(func):
> > + """
> > + Decorator that marks the test as disruptive (e.g. the test
> > + that can down the interface). Disruptive tests can be skipped
> > + by passing DISRUPTIVE=False environment variable.
> > + """
> > +
> > + @functools.wraps(func)
> > + def wrapper(*args, **kwargs):
> > + if not KSFT_DISRUPTIVE:
> > + raise KsftSkipEx(f"marked as disruptive")
>
> Since this is a skip, it will fail the overall run. But that happened
> because the user themselves set DISRUPTIVE=0 to avoid, um, disruption to
> the system. I think it should either be xfail, or something else
> dedicated that conveys the idea that we didn't run the test, but that's
> fine.
>
> Using xfail for this somehow doesn't seem correct, nothing failed. Maybe
> we need KsftOmitEx, which would basically be an xfail with a more
> appropriate name?
Are you sure skip will fail the overall run? At least looking at
tools/testing/selftests/net/lib/py/ksft.py, both skip and xfail are
considered KSFT_RESULT=True. Or am I looking at the wrong place?
> > +def ksft_setup(env):
> > + """
> > + Setup test framework global state from the environment.
> > + """
> > +
> > + def get_bool(env, name):
> > + return env.get(name, "").lower() in ["true", "1"]
>
> "yes" should alse be considered, for compatibility with the bash
> selftests.
>
> It's also odd that 0 is false, 1 is true, but 2 is false again. How
> about something like this?
>
> def get_bool(env, name):
> value = env.get(name, "").lower()
> if value in ["yes", "true"]:
> return True
> if value in ["no", "false"]:
> return False
>
> try:
> return bool(int(value))
> except:
> raise something something invalid value
>
> So that people at least know if they set it to nonsense that it's
> nonsense?
>
> Dunno. The bash selftests just take "yes" and don't care about being
> very user friendly in that regard at all. _load_env_file() likewise
> looks like it just takes strings and doesn't care about the semantics.
> So I don't feel too strongly about this at all. Besides the "yes" bit,
> that should be recognized.
Sure, will do!
(will also apply your suggestions for 1/2 so want reply separately)
next prev parent reply other threads:[~2024-07-31 20:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-30 22:39 [PATCH net-next v2 1/2] selftests: net-drv: exercise queue stats when the device is down Stanislav Fomichev
2024-07-30 22:39 ` [PATCH net-next v2 2/2] selftests: net: ksft: support marking tests as disruptive Stanislav Fomichev
2024-07-31 11:55 ` Petr Machata
2024-07-31 20:47 ` Stanislav Fomichev [this message]
2024-08-01 8:36 ` Petr Machata
2024-08-01 14:07 ` Jakub Kicinski
2024-08-01 21:31 ` Petr Machata
2024-07-31 11:34 ` [PATCH net-next v2 1/2] selftests: net-drv: exercise queue stats when the device is down Petr Machata
2024-08-01 0:32 ` Jakub Kicinski
2024-08-01 1:23 ` Stanislav Fomichev
2024-08-01 8:50 ` Petr Machata
2024-08-01 15:34 ` Stanislav Fomichev
2024-08-01 21:38 ` Petr Machata
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=Zqqi8LhvSn1MXu9B@mini-arch \
--to=sdf@fomichev.me \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jdamato@fastly.com \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.com \
--cc=shuah@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).