diff options
author | David Gow <davidgow@google.com> | 2023-05-10 08:38:30 +0300 |
---|---|---|
committer | Shuah Khan <skhan@linuxfoundation.org> | 2023-05-12 03:17:29 +0300 |
commit | 410f07492eaef600fe817eef9fd272f6692a451a (patch) | |
tree | 8a73fa665ae423cfdfcde07611d32c539baf52ae /Documentation/dev-tools | |
parent | 55e8c1b49ac5a7f5567430cc83f2d270d8b7ce46 (diff) | |
download | linux-410f07492eaef600fe817eef9fd272f6692a451a.tar.xz |
Documentation: kunit: Note that assertions should not be used in cleanup
As assertions abort the test cleanup process, they should be avoided
from within a suite's exit function, or from within resource 'free'
functions. Unlike with initialisation or main test execution, no further
cleanup will be performed after a failed assertion, potentially causing
a leak of resources.
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 'Documentation/dev-tools')
-rw-r--r-- | Documentation/dev-tools/kunit/usage.rst | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Documentation/dev-tools/kunit/usage.rst b/Documentation/dev-tools/kunit/usage.rst index 9faf2b4153fc..9f720f1317d3 100644 --- a/Documentation/dev-tools/kunit/usage.rst +++ b/Documentation/dev-tools/kunit/usage.rst @@ -121,6 +121,12 @@ there's an allocation error. ``return`` so they only work from the test function. In KUnit, we stop the current kthread on failure, so you can call them from anywhere. +.. note:: + Warning: There is an exception to the above rule. You shouldn't use assertions + in the suite's exit() function, or in the free function for a resource. These + run when a test is shutting down, and an assertion here prevents further + cleanup code from running, potentially leading to a memory leak. + Customizing error messages -------------------------- |