mirror-linux/Documentation/dev-tools/kunit
Daniel Latypov 1cdba21db2 kunit: add ability to specify suite-level init and exit functions
KUnit has support for setup/cleanup logic for each test case in a suite.
But it lacks the ability to specify setup/cleanup for the entire suite
itself.

This can be used to do setup that is too expensive or cumbersome to do
for each test.
Or it can be used to do simpler things like log debug information after
the suite completes.
It's a fairly common feature, so the lack of it is noticeable.

Some examples in other frameworks and languages:
* https://docs.python.org/3/library/unittest.html#setupclass-and-teardownclass
* https://google.github.io/googletest/reference/testing.html#Test::SetUpTestSuite

Meta:
This is very similar to this patch here: https://lore.kernel.org/linux-kselftest/20210805043503.20252-3-bvanassche@acm.org/
The changes from that patch:
* pass in `struct kunit *` so users can do stuff like
  `kunit_info(suite, "debug message")`
* makes sure the init failure is bubbled up as a failure
* updates kunit-example-test.c to use a suite init
* Updates kunit/usage.rst to mention the new support
* some minor cosmetic things
  * use `suite_{init,exit}` instead of `{init/exit}_suite`
  * make suite init error message more consistent w/ test init
  * etc.

Signed-off-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2022-05-02 12:35:51 -06:00
..
api kunit: split resource API from test.h into new resource.h 2022-04-04 16:23:08 -06:00
architecture.rst Documentation: kunit: Fix cross-referencing warnings 2022-03-28 15:36:41 -06:00
faq.rst Documentation: KUnit: Restyled Frequently Asked Questions 2021-12-23 12:49:43 -07:00
index.rst Documentation: KUnit: Rework writing page to focus on writing tests 2021-12-23 12:49:43 -07:00
kunit-tool.rst kunit: tool: make --raw_output support only showing kunit output 2021-08-13 13:32:01 -06:00
kunit_suitememorydiagram.svg Documentation: KUnit: Added KUnit Architecture 2021-12-23 12:49:06 -07:00
run_manual.rst Documentation: kunit: Reorganize documentation related to running tests 2021-12-23 12:49:43 -07:00
run_wrapper.rst Documentation: kunit: Reorganize documentation related to running tests 2021-12-23 12:49:43 -07:00
running_tips.rst Documentation: kunit: update kconfig options needed for UML coverage 2022-04-04 16:42:38 -06:00
start.rst This isn't a hugely busy cycle for documentation, but a few significant 2022-01-11 10:00:04 -08:00
style.rst Documentation: KUnit: Restyle Test Style and Nomenclature page 2021-12-23 12:49:43 -07:00
tips.rst docs: dev-tools: kunit: avoid using ReST :doc:`foo` markup 2021-06-17 13:24:37 -06:00
usage.rst kunit: add ability to specify suite-level init and exit functions 2022-05-02 12:35:51 -06:00