Re: [PATCH v1] kunit: add tests for using current KUnit test field

From: Daniel Latypov
Date: Mon Apr 03 2023 - 19:09:35 EST


On Mon, Apr 3, 2023 at 12:31 PM Rae Moar <rmoar@xxxxxxxxxx> wrote:
>
> On Thu, Mar 30, 2023 at 6:21 PM 'Daniel Latypov' via KUnit Development
> <kunit-dev@xxxxxxxxxxxxxxxx> wrote:
> >
> > I've got a few minor comments below, but this otherwise looks good.
> > I like the idea of testing knuit_fail_current_test().
> >
> >
> > On Thu, Mar 30, 2023 at 3:05 PM Rae Moar <rmoar@xxxxxxxxxx> wrote:
> > >
> > > +static void kunit_current_kunit_test_field(struct kunit *test)
> > > +{
> > > + struct kunit *current_test;
> > > +
> > > + /* Check to ensure the result of current->kunit_test
> > > + * is equivalent to current test.
> > > + */
> > > + current_test = current->kunit_test;
> > > + KUNIT_EXPECT_PTR_EQ(test, test, current_test);
> >
> > Perhaps we can combine this and the next test case down to
> > static void kunit_current_test(struct kunit *test) {
> > /* There are two different ways of getting the current test */
> > KUNIT_EXPECT_PTR_EQ(test, test, current->kunit_test);
> > KUNIT_EXPECT_PTR_EQ(test, test, kunit_get_current_test());
> > }
> > ?
>
> Hi Daniel!
>
> Yes, I would be happy to combine these for v2. I might want to alter
> that proposed comment slightly. "Two different ways" seems a bit
> unclear to me. Maybe: Check results of both current->kunit_test and
> kunit_get_current_test() are equivalent to current test. What do you
> think? I might send out a v2 with a proposed comment.

What you went with in v2 works for me.
I'll take a look at the other changes in v2.

Thanks!
Daniel