diff options
author | David Gow <davidgow@google.com> | 2023-05-10 13:38:31 +0800 |
---|---|---|
committer | Shuah Khan <skhan@linuxfoundation.org> | 2023-05-11 18:17:35 -0600 |
commit | cdc87bda607518e70b6a6745cd593458d725b5a7 (patch) | |
tree | 790528bb739eeb915f028c997818c2fdb8c7cb2d /include | |
parent | 410f07492eaef600fe817eef9fd272f6692a451a (diff) |
Documentation: kunit: Warn that exit functions run even if init fails
KUnit's exit functions will run even if the corresponding init function
fails. It's easy, when writing an exit function, to assume the init
function succeeded, and (for example) access uninitialised memory or
dereference NULL pointers.
Note that this case exists and should be handled in the documentation.
Suggested-by: Benjamin Berg <benjamin@sipsolutions.net>
Link: https://lore.kernel.org/linux-kselftest/a39af0400abedb2e9b31d84c37551cecc3eed0e1.camel@sipsolutions.net/
Reviewed-by: Sadiya Kazi <sadiyakazi@google.com>
Signed-off-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/kunit/test.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/kunit/test.h b/include/kunit/test.h index 57b309c6ca27..3028a1a3fcad 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -168,6 +168,9 @@ static inline char *kunit_status_to_ok_not_ok(enum kunit_status status) * test case, similar to the notion of a *test fixture* or a *test class* * in other unit testing frameworks like JUnit or Googletest. * + * Note that @exit and @suite_exit will run even if @init or @suite_init + * fail: make sure they can handle any inconsistent state which may result. + * * Every &struct kunit_case must be associated with a kunit_suite for KUnit * to run it. */ |