Re: [PATCH v5 13/17] rv: Add KUnit mock for current
From: Nam Cao
Date: Fri Jul 31 2026 - 06:59:45 EST
Gabriele Monaco <gmonaco@xxxxxxxxxx> writes:
> Some monitors do not only rely on tracepoint arguments but also on the
> currently executing task.
> This makes it more challenging to mock events in KUnit.
>
> Define wrapper functions around current, the functionality is mocked
> only during KUnit, an additional function call is avoided using a static
> branch unless any (even unrelated) KUnit test is running.
>
> Rely on a global mock_current variable that is set only by the RV KUnit
> tests and cleared on teardown. Unrelated KUnit tests that happen to
> trigger RV handlers would see it null and use current.
>
> Signed-off-by: Gabriele Monaco <gmonaco@xxxxxxxxxx>
Reviewed-by: Nam Cao <namcao@xxxxxxxxxxxxx>