Re: [PATCH 2/3] kunit: add ability to specify suite-level init and exit functions

From: Daniel Latypov
Date: Tue Apr 26 2022 - 23:07:23 EST


On Tue, Apr 26, 2022 at 8:56 PM David Gow <davidgow@xxxxxxxxxx> wrote:
> >
> > static size_t kunit_suite_counter = 1;
> >
> > -static void kunit_print_suite_end(struct kunit_suite *suite)
> > +static void kunit_print_suite_end(struct kunit_suite *suite, int init_err)
>
> A part of me feels that it'd be nicer to have the init_err be part of
> struct kunit_suite, and have kunit_suite_has_succeeded() take it into
> account. It could go either way, though -- WDYT?

Yeah, passing it around as a parameter felt a bit icky.
But I think adding it in as a field feels worse.

Another thought: perhaps have this function take a `kunit_status`
parameter instead?
Moving the ?: expression below out into the caller isn't that bad, imo.

>
>
> > {
> > + enum kunit_status status =
> > + init_err ? KUNIT_FAILURE : kunit_suite_has_succeeded(suite);
> > +