diff options
author | Arthur Grillo <arthurgrillo@riseup.net> | 2024-01-10 14:39:28 -0300 |
---|---|---|
committer | Shuah Khan <skhan@linuxfoundation.org> | 2024-01-22 07:59:03 -0700 |
commit | 1a9f2c776d1416c4ea6cb0d0b9917778c41a1a7d (patch) | |
tree | 2c237b377dc50c19cdabc5c753d0e8cb508ffe67 /Documentation | |
parent | a1af6a2bfa0cb46d70b7df5352993e750da6c79b (diff) |
Documentation: KUnit: Update the instructions on how to test static functions
Now that we have the VISIBLE_IF_KUNIT and EXPORT_SYMBOL_IF_KUNIT macros,
update the instructions to recommend this way of testing static
functions.
Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/dev-tools/kunit/usage.rst | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/Documentation/dev-tools/kunit/usage.rst b/Documentation/dev-tools/kunit/usage.rst index a9efab50eed8..22955d56b379 100644 --- a/Documentation/dev-tools/kunit/usage.rst +++ b/Documentation/dev-tools/kunit/usage.rst @@ -671,8 +671,23 @@ Testing Static Functions ------------------------ If we do not want to expose functions or variables for testing, one option is to -conditionally ``#include`` the test file at the end of your .c file. For -example: +conditionally export the used symbol. For example: + +.. code-block:: c + + /* In my_file.c */ + + VISIBLE_IF_KUNIT int do_interesting_thing(); + EXPORT_SYMBOL_IF_KUNIT(do_interesting_thing); + + /* In my_file.h */ + + #if IS_ENABLED(CONFIG_KUNIT) + int do_interesting_thing(void); + #endif + +Alternatively, you could conditionally ``#include`` the test file at the end of +your .c file. For example: .. code-block:: c |