[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAFd5g45CaCFdQCxQqxgYfoQSGAF8RAV2YrOMs0oR4R-iCTZrig@mail.gmail.com>
Date: Thu, 25 Apr 2019 14:39:15 -0700
From: Brendan Higgins <brendanhiggins@...gle.com>
To: Masayoshi Mizuma <msys.mizuma@...il.com>
Cc: Jonathan Corbet <corbet@....net>,
Frank Rowand <frowand.list@...il.com>,
Kees Cook <keescook@...gle.com>,
Kieran Bingham <kieran.bingham@...asonboard.com>,
Luis Chamberlain <mcgrof@...nel.org>,
Rob Herring <robh@...nel.org>, shuah@...nel.org,
yamada.masahiro@...ionext.com, Petr Mladek <pmladek@...e.com>,
linux-doc@...r.kernel.org, Amir Goldstein <amir73il@...il.com>,
dri-devel <dri-devel@...ts.freedesktop.org>,
Sasha Levin <Alexander.Levin@...rosoft.com>,
linux-kselftest@...r.kernel.org,
linux-nvdimm <linux-nvdimm@...ts.01.org>,
Kevin Hilman <khilman@...libre.com>,
Knut Omang <knut.omang@...cle.com>, wfg@...ux.intel.com,
Joel Stanley <joel@....id.au>, Jeff Dike <jdike@...toit.com>,
Dan Carpenter <dan.carpenter@...cle.com>,
devicetree <devicetree@...r.kernel.org>,
linux-kbuild@...r.kernel.org, "Bird, Timothy" <Tim.Bird@...y.com>,
Avinash Kondareddy <akndr41@...il.com>,
linux-um@...ts.infradead.org, Steven Rostedt <rostedt@...dmis.org>,
Julia Lawall <julia.lawall@...6.fr>,
kunit-dev@...glegroups.com, Richard Weinberger <richard@....at>,
Greg KH <gregkh@...uxfoundation.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Daniel Vetter <daniel@...ll.ch>,
Michael Ellerman <mpe@...erman.id.au>,
linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH v1 11/17] kunit: test: add test managed resource tests
On Wed, Apr 24, 2019 at 12:00 PM Masayoshi Mizuma <msys.mizuma@...il.com> wrote:
>
> On Thu, Apr 04, 2019 at 03:06:46PM -0700, Brendan Higgins wrote:
> > From: Avinash Kondareddy <akndr41@...il.com>
> >
> > Tests how tests interact with test managed resources in their lifetime.
> >
> > Signed-off-by: Avinash Kondareddy <akndr41@...il.com>
> > Signed-off-by: Brendan Higgins <brendanhiggins@...gle.com>
> > ---
> > kunit/test-test.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 122 insertions(+)
> >
> > diff --git a/kunit/test-test.c b/kunit/test-test.c
> > index 4bd7a34d0a6cb..54add8ca418a0 100644
> > --- a/kunit/test-test.c
> > +++ b/kunit/test-test.c
> > @@ -135,3 +135,125 @@ static struct kunit_module kunit_try_catch_test_module = {
> > .test_cases = kunit_try_catch_test_cases,
> > };
> > module_test(kunit_try_catch_test_module);
> > +
> > +/*
> > + * Context for testing test managed resources
> > + * is_resource_initialized is used to test arbitrary resources
> > + */
> > +struct kunit_test_resource_context {
> > + struct kunit test;
> > + bool is_resource_initialized;
> > +};
> > +
> > +static int fake_resource_init(struct kunit_resource *res, void *context)
> > +{
> > + struct kunit_test_resource_context *ctx = context;
> > +
> > + res->allocation = &ctx->is_resource_initialized;
> > + ctx->is_resource_initialized = true;
> > + return 0;
> > +}
> > +
> > +static void fake_resource_free(struct kunit_resource *res)
> > +{
> > + bool *is_resource_initialized = res->allocation;
> > +
> > + *is_resource_initialized = false;
> > +}
> > +
> > +static void kunit_resource_test_init_resources(struct kunit *test)
> > +{
> > + struct kunit_test_resource_context *ctx = test->priv;
> > +
> > + kunit_init_test(&ctx->test, "testing_test_init_test");
> > +
> > + KUNIT_EXPECT_TRUE(test, list_empty(&ctx->test.resources));
> > +}
> > +
> > +static void kunit_resource_test_alloc_resource(struct kunit *test)
> > +{
> > + struct kunit_test_resource_context *ctx = test->priv;
> > + struct kunit_resource *res;
> > + kunit_resource_free_t free = fake_resource_free;
> > +
> > + res = kunit_alloc_resource(&ctx->test,
> > + fake_resource_init,
> > + fake_resource_free,
> > + ctx);
> > +
>
> > + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, res);
>
> KUNIT_EXPECT_NOT_ERR_OR_NULL(test, res);
See my reply to your email on the 14/17 patch.
Powered by blists - more mailing lists