Commit 1a9f2c77 authored by Arthur Grillo's avatar Arthur Grillo Committed by Shuah Khan

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: default avatarArthur Grillo <arthurgrillo@riseup.net>
Reviewed-by: default avatarDavid Gow <davidgow@google.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent a1af6a2b
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment