From mboxrd@z Thu Jan 1 00:00:00 1970 From: brendanhiggins@google.com (Brendan Higgins) Date: Tue, 19 Feb 2019 15:24:01 -0800 Subject: [RFC v4 02/17] kunit: test: add test resource management API In-Reply-To: <155026451067.115909.17082794837098610153@swboyd.mtv.corp.google.com> References: <20190214213729.21702-1-brendanhiggins@google.com> <20190214213729.21702-3-brendanhiggins@google.com> <155026451067.115909.17082794837098610153@swboyd.mtv.corp.google.com> Message-ID: Content-Type: text/plain; charset="UTF-8" Message-ID: <20190219232401.2xV7frGarWaaDQOob7Imgso3COM4YE8XaCZS-HP5zOc@z> On Fri, Feb 15, 2019@1:01 PM Stephen Boyd wrote: > > Quoting Brendan Higgins (2019-02-14 13:37:14) > > @@ -104,6 +167,7 @@ struct kunit { > > const char *name; /* Read only after initialization! */ > > spinlock_t lock; /* Gaurds all mutable test state. */ > > bool success; /* Protected by lock. */ > > + struct list_head resources; /* Protected by lock. */ > > void (*vprintk)(const struct kunit *test, > > const char *level, > > struct va_format *vaf); > > @@ -127,6 +191,51 @@ int kunit_run_tests(struct kunit_module *module); > > } \ > > late_initcall(module_kunit_init##module) > > > > +/** > > + * kunit_alloc_resource() - Allocates a *test managed resource*. > > + * @test: The test context object. > > + * @init: a user supplied function to initialize the resource. > > + * @free: a user supplied function to free the resource. > > + * @context: for the user to pass in arbitrary data. > > Nitpick: "pass in arbitrary data to the init function"? Maybe that > provides some more clarity. I think that makes sense. Will fix in next revision.