Re: [PATCH] Documentation: kunit: add tips for using current->kunit_test

From: Shuah Khan
Date: Wed Apr 07 2021 - 18:46:16 EST


On 4/7/21 2:07 PM, Brendan Higgins wrote:
On Tue, Apr 6, 2021 at 3:51 PM Daniel Latypov <dlatypov@xxxxxxxxxx> wrote:

As of commit 359a376081d4 ("kunit: support failure from dynamic analysis
tools"), we can use current->kunit_test to find the current kunit test.

Mention this in tips.rst and give an example of how this can be used in
conjunction with `test->priv` to pass around state and specifically
implement something like mocking.
There's a lot more we could go into on that topic, but given that
example is already longer than every other "tip" on this page, we just
point to the API docs and leave filling in the blanks as an exercise to
the reader.

Also give an example of kunit_fail_current_test().

Signed-off-by: Daniel Latypov <dlatypov@xxxxxxxxxx>

Reviewed-by: Brendan Higgins <brendanhiggins@xxxxxxxxxx>


Thank you. Applied to linux-kseftest kunit branch for 5.13-rc1

thanks,
-- Shuah