Messages in this thread | | | From | Daniel Latypov <> | Date | Fri, 13 Jan 2023 17:38:17 -0800 | Subject | Re: [PATCH] kunit: memcpy: Split slow memcpy tests into MEMCPY_SLOW_KUNIT_TEST |
| |
On Fri, Jan 13, 2023 at 4:54 PM Kees Cook <keescook@chromium.org> wrote: > diff --git a/lib/memcpy_kunit.c b/lib/memcpy_kunit.c > index 89128551448d..5a545e1b5dbb 100644 > --- a/lib/memcpy_kunit.c > +++ b/lib/memcpy_kunit.c > @@ -307,8 +307,12 @@ static void set_random_nonzero(struct kunit *test, u8 *byte) > } > } > > -static void init_large(struct kunit *test) > +static int init_large(struct kunit *test) > { > + if (!IS_ENABLED(CONFIG_MEMCPY_SLOW_KUNIT_TEST)) { > + kunit_skip(test, "Slow test skipped. Enable with CONFIG_MEMCPY_SLOW_KUNIT_TEST=y"); > + return -EBUSY;
Note: kunit_skip() here means you don't need explicit returns in the test cases. kunit_skip() is basically kunit_mark_skipped(test, "reason"); kthread_complete_and_exit(...);
So the diff in this file could be reduced down to just these 2 lines if (!IS_ENABLED(...)) kunit_skip(test, "...")
But I can see the appeal of being more explicit about the control flow. In that case, you could switch kunit_mark_skipped(), which just sets the status and doesn't affect control flow at all.
Daniel
| |