public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nam Cao <namcao@linutronix.de>
To: Gabriele Monaco <gmonaco@redhat.com>,
	linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	Gabriele Monaco <gmonaco@redhat.com>,
	Masami Hiramatsu <mhiramat@kernel.org>
Cc: Thomas Weissschuh <thomas.weissschuh@linutronix.de>,
	Tomas Glozar <tglozar@redhat.com>, John Kacur <jkacur@redhat.com>,
	Wen Yang <wen.yang@linux.dev>
Subject: Re: [RFC PATCH 10/12] rv: Add KUnit tests for some DA/HA monitors
Date: Mon, 04 May 2026 10:39:27 +0200	[thread overview]
Message-ID: <875x531scg.fsf@yellow.woof> (raw)
In-Reply-To: <20260427151134.192971-11-gmonaco@redhat.com>

Gabriele Monaco <gmonaco@redhat.com> writes:
> +#ifdef CONFIG_RV_MONITORS_KUNIT_TEST
> +#include <kunit/test.h>
> +
> +/*
> + * rv_prepare_test - Disable the monitor for a kunit test
      ^^^^^^^^^^^^^^^
      wrong name

> +obj-$(CONFIG_RV_MONITORS_KUNIT_TEST) += rv_monitors_test.o
> +# Stubbing rv_react triggers the error
> +CFLAGS_rv_monitors_test.o += -Wno-suggest-attribute=format

I try removing this flag, but my compiler does not produce any
warning. Which warning did you see?

If it is not a hassle, I would prefer to address the warning in C code.
Grep tells me the rest of the kernel does not use this, how do other
subsystems not suffer from this warning?

> +void rv_test_opid(struct kunit *test)
> +{
> +	struct rv_kunit_ctx *ctx = test->priv;
> +
> +	da_prepare_test(test, &rv_this);
> +
> +	/*
> +	 * The handlers are called with an additional level of preemption,
> +	 * ensure we start from 0 but apply it here to avoid warnings.
> +	 */
> +	KUNIT_ASSERT_TRUE(test, preemptible());
> +	guard(preempt)();
> +
> +	/* Wakeup with preemption and interrupts enabled */
> +	handle_sched_waking(NULL, NULL);
> +	RV_KUNIT_EXPECT_REACTION(test, ctx);
> +
> +	/* Need resched with interrupts enabled */
> +	scoped_guard(preempt)
> +		handle_sched_need_resched(NULL, NULL, 0, TIF_NEED_RESCHED);

From my understanding, this last one is testing that need_resched with
interrupt enabled does not invoke the reactor? And if the monitor is
broken and the reactor is invoked, we would have no test failure here,
but instead we have test failure the next time
RV_KUNIT_EXPECT_REACTION() is called. And if this is the last test, we
would not see a failure?

If so, should we perhaps have something like RV_KUNIT_EXPECT_NO_REACTION()
here? So that if the monitor is broken and the reactor is called, then
the kunit test will fail exactly where the failure is.

Reading the patch further down below, we actually do have that
macro! Shouldn't we use it here?

> +#ifdef CONFIG_RV_MON_SCO
> +extern void rv_test_sco(struct kunit *test);
> +#else
> +static inline void rv_test_sco(struct kunit *test)
> +{
> +	kunit_skip(test, "Monitor not enabled\n");
> +}
> +#endif

Instead of these, I would prefer we have something like

#define KUNIT_CASE_IF(test_name, enabled) \
	{ .run_case = enabled ? test_name : some_stub, ... }

and

static struct kunit_case rv_trigger_test_cases[] = {
	KUNIT_CASE_IF(rv_test_sco, CONFIG_RV_MON_SCO),
        ...
	{}
};

or something like that. But no big deal.

Nam

  reply	other threads:[~2026-05-04  8:39 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27 15:11 [RFC PATCH 00/12] rv: Add selftests to tools and KUnit tests Gabriele Monaco
2026-04-27 15:11 ` [RFC PATCH 01/12] tools/rv: Fix substring match bug in monitor name search Gabriele Monaco
2026-04-27 15:11 ` [RFC PATCH 02/12] tools/rv: Fix substring match when listing container monitors Gabriele Monaco
2026-04-27 15:11 ` [RFC PATCH 03/12] tools/rv: Fix exit status when monitor execution fails Gabriele Monaco
2026-04-27 15:11 ` [RFC PATCH 04/12] tools/rv: Fix cleanup after failed trace setup Gabriele Monaco
2026-04-27 15:11 ` [RFC PATCH 05/12] tools/rv: Add selftests Gabriele Monaco
2026-04-27 15:11 ` [RFC PATCH 06/12] verification/rvgen: Fix options shared among commands Gabriele Monaco
2026-04-27 15:11 ` [RFC PATCH 07/12] verification/rvgen: Add golden and spec folders for tests Gabriele Monaco
2026-05-04  7:48   ` Nam Cao
2026-05-04  8:26     ` Gabriele Monaco
2026-05-04  8:44       ` Nam Cao
2026-05-04  8:49         ` Gabriele Monaco
2026-05-04  9:07           ` Nam Cao
2026-04-27 15:11 ` [RFC PATCH 08/12] verification/rvgen: Add selftests Gabriele Monaco
2026-04-27 15:11 ` [RFC PATCH 09/12] rv: Add KUnit stub to rv_react() and rv_*_task_monitor_slot() Gabriele Monaco
2026-04-27 15:11 ` [RFC PATCH 10/12] rv: Add KUnit tests for some DA/HA monitors Gabriele Monaco
2026-05-04  8:39   ` Nam Cao [this message]
2026-05-04 11:42     ` Gabriele Monaco
2026-05-04 13:33       ` Nam Cao
2026-05-04 14:02         ` Gabriele Monaco
2026-04-27 15:11 ` [RFC PATCH 11/12] rv: Add KUnit stubs for current and smp_processor_id() Gabriele Monaco
2026-04-27 15:11 ` [RFC PATCH 12/12] rv: Add KUnit tests for some LTL monitors Gabriele Monaco
2026-04-28 15:09 ` [RFC PATCH 00/12] rv: Add selftests to tools and KUnit tests Wen Yang
2026-04-28 15:27   ` Gabriele Monaco

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=875x531scg.fsf@yellow.woof \
    --to=namcao@linutronix.de \
    --cc=gmonaco@redhat.com \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglozar@redhat.com \
    --cc=thomas.weissschuh@linutronix.de \
    --cc=wen.yang@linux.dev \
    /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