From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] test: self: provide selftest_is_running()
Date: Tue, 13 Sep 2022 10:14:02 +0200 [thread overview]
Message-ID: <20220913081402.GI6477@pengutronix.de> (raw)
In-Reply-To: <20220905070125.537483-1-a.fatoum@pengutronix.de>
On Mon, Sep 05, 2022 at 09:01:25AM +0200, Ahmad Fatoum wrote:
> For debugging during self-test run, it can be useful to enable select
> logging only when the selftest is running. Provide a selftest_is_running()
> function that can be used to determine whether a test is running.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> commands/selftest.c | 2 +-
> include/bselftest.h | 5 +++++
> test/self/core.c | 26 +++++++++++++++++++++++++-
> 3 files changed, 31 insertions(+), 2 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/commands/selftest.c b/commands/selftest.c
> index a10f1467fece..bb62575aa7bb 100644
> --- a/commands/selftest.c
> +++ b/commands/selftest.c
> @@ -24,7 +24,7 @@ static int run_selftest(const char *match, bool list)
> if (match && strcmp(test->name, match))
> continue;
>
> - err |= test->func();
> + err |= selftest_run(test);
> matches++;
> }
>
> diff --git a/include/bselftest.h b/include/bselftest.h
> index 21eeba0526ef..f03c803b6553 100644
> --- a/include/bselftest.h
> +++ b/include/bselftest.h
> @@ -15,6 +15,7 @@ struct selftest {
> const char *name;
> int (*func)(void);
> struct list_head list;
> + bool running;
> };
>
> static inline int selftest_report(unsigned int total_tests, unsigned int failed_tests,
> @@ -71,4 +72,8 @@ static inline void selftests_run(void)
> } \
> __bselftest_initcall(_func##_bselftest_register);
>
> +
> +int selftest_run(struct selftest *test);
> +bool selftest_is_running(struct selftest *test);
> +
> #endif
> diff --git a/test/self/core.c b/test/self/core.c
> index caa4c27f6def..40f5ee842d16 100644
> --- a/test/self/core.c
> +++ b/test/self/core.c
> @@ -7,6 +7,30 @@
>
> LIST_HEAD(selftests);
>
> +int selftest_run(struct selftest *test)
> +{
> + int err;
> +
> + test->running = true;
> + err = test->func();
> + test->running = false;
> +
> + return err;
> +}
> +
> +bool selftest_is_running(struct selftest *test)
> +{
> + if (test)
> + return test->running;
> +
> + list_for_each_entry(test, &selftests, list) {
> + if (selftest_is_running(test))
> + return true;
> + }
> +
> + return false;
> +}
> +
> void selftests_run(void)
> {
> struct selftest *test;
> @@ -15,7 +39,7 @@ void selftests_run(void)
> pr_notice("Configured tests will run now\n");
>
> list_for_each_entry(test, &selftests, list)
> - err |= test->func();
> + err |= selftest_run(test);
>
> if (err)
> pr_err("Some selftests failed\n");
> --
> 2.30.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2022-09-13 8:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-05 7:01 Ahmad Fatoum
2022-09-13 8:14 ` Sascha Hauer [this message]
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=20220913081402.GI6477@pengutronix.de \
--to=sha@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.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