]> git.baikalelectronics.ru Git - kernel.git/commit
kunit: add support for named resources
authorAlan Maguire <alan.maguire@oracle.com>
Fri, 29 May 2020 21:46:21 +0000 (22:46 +0100)
committerShuah Khan <skhan@linuxfoundation.org>
Fri, 26 Jun 2020 20:12:00 +0000 (14:12 -0600)
commit5fe1ece172af11deaede09c5da5ac4b4424a4416
treed12f4d1586c07f91dec8596e07b17f22c30dad14
parent47396270f741e93d58c2b704efa6bb187185c711
kunit: add support for named resources

The kunit resources API allows for custom initialization and
cleanup code (init/fini); here a new resource add function sets
the "struct kunit_resource" "name" field, and calls the standard
add function.  Having a simple way to name resources is
useful in cases such as multithreaded tests where a set of
resources are shared among threads; a pointer to the
"struct kunit *" test state then is all that is needed to
retrieve and use named resources.  Support is provided to add,
find and destroy named resources; the latter two are simply
wrappers that use a "match-by-name" callback.

If an attempt to add a resource with a name that already exists
is made kunit_add_named_resource() will return -EEXIST.

Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
include/kunit/test.h
lib/kunit/kunit-test.c
lib/kunit/test.c