Re: [RFC PATCH 2/2] kunit: expose ftrace-based API for stubbing out functions during tests

From: Daniel Latypov
Date: Mon Apr 04 2022 - 18:09:42 EST


On Thu, Mar 17, 2022 at 9:13 PM David Gow <davidgow@xxxxxxxxxx> wrote:
> +
> +/** KUNIT_STUBBABLE - marks a function as stubbable when stubbing support is
> + * enabled.
> + *
> + * Stubbing uses ftrace internally, so we can only stub out functions when they
> + * are not inlined. This macro eavlautes to noinline when stubbing support is

Just noting a couple typos lest they be forgotten:
*evaluates

> + * enabled to thus make it safe.
> + *

<snip>

> + *
> + * void replacement_func(int n)
> + * {
> + * pr_info("replacement_func() called with %d", n);
> + * return 42;
> + * }
> + *
> + * void example_test(struct kunit *test)
> + * {
> + * kunit_active_ftrace_stub(test, real_func, replacement_func);

*activate