efi_selftest: add unit test functions to HTML documentation
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Sat, 9 May 2020 05:33:43 +0000 (07:33 +0200)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Sat, 9 May 2020 07:30:28 +0000 (09:30 +0200)
Add the UEFI unit test helper functions to the generated HTML
documentation.

Correct some documentation texts in include/efi_selftest.h.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
doc/api/efi.rst
include/efi_selftest.h

index 0667c3aef7824673c1efe9b3b4f7363113c5f3d0..d5114f05b3bd2df2de5368b636bed411ace7d752 100644 (file)
@@ -163,3 +163,12 @@ Unicode Collation protocol
 
 .. kernel-doc:: lib/efi_loader/efi_unicode_collation.c
    :internal:
 
 .. kernel-doc:: lib/efi_loader/efi_unicode_collation.c
    :internal:
+
+Unit testing
+------------
+
+The following library functions are provided to support writing UEFI unit tests.
+The should not be used elsewhere.
+
+.. kernel-doc:: include/efi_selftest.h
+   :internal:
index eaee188de7ef60db32784f3f3d7a9fbe26fac95d..1515fdaa02b05fcc6015dff3e33ec9176ea9795f 100644 (file)
 #define EFI_ST_SUCCESS 0
 #define EFI_ST_FAILURE 1
 #define EFI_ST_SUCCESS_STR L"SUCCESS"
 #define EFI_ST_SUCCESS 0
 #define EFI_ST_FAILURE 1
 #define EFI_ST_SUCCESS_STR L"SUCCESS"
-/*
- * Prints a message.
+
+/**
+ * efi_st_printf() - print a message
+ *
+ * @...:       format string followed by fields to print
  */
 #define efi_st_printf(...) \
        (efi_st_printc(-1, __VA_ARGS__))
 
  */
 #define efi_st_printf(...) \
        (efi_st_printc(-1, __VA_ARGS__))
 
-/*
- * Prints an error message.
+/**
+ * efi_st_error() - prints an error message
  *
  *
- * @...        format string followed by fields to print
+ * @...:       format string followed by fields to print
  */
 #define efi_st_error(...) \
        (efi_st_printc(EFI_LIGHTRED, "%s(%u):\nERROR: ", __FILE__, __LINE__), \
        efi_st_printc(EFI_LIGHTRED, __VA_ARGS__))
 
  */
 #define efi_st_error(...) \
        (efi_st_printc(EFI_LIGHTRED, "%s(%u):\nERROR: ", __FILE__, __LINE__), \
        efi_st_printc(EFI_LIGHTRED, __VA_ARGS__))
 
-/*
- * Prints a TODO message.
+/**
+ * efi_st_todo() - prints a TODO message
  *
  *
- * @...        format string followed by fields to print
+ * @...:       format string followed by fields to print
  */
 #define efi_st_todo(...) \
        (efi_st_printc(EFI_YELLOW, "%s(%u):\nTODO: ", __FILE__, __LINE__), \
        efi_st_printc(EFI_YELLOW, __VA_ARGS__)) \
 
  */
 #define efi_st_todo(...) \
        (efi_st_printc(EFI_YELLOW, "%s(%u):\nTODO: ", __FILE__, __LINE__), \
        efi_st_printc(EFI_YELLOW, __VA_ARGS__)) \
 
-/*
+/**
+ * enum efi_test_phase - phase when test will be executed
+ *
  * A test may be setup and executed at boottime,
  * it may be setup at boottime and executed at runtime,
  * or it may be setup and executed at runtime.
  */
 enum efi_test_phase {
  * A test may be setup and executed at boottime,
  * it may be setup at boottime and executed at runtime,
  * or it may be setup and executed at runtime.
  */
 enum efi_test_phase {
+       /**
+        * @EFI_EXECUTE_BEFORE_BOOTTIME_EXIT: - execute before ExitBootServices
+        *
+        * Setup, execute, and teardown are executed before ExitBootServices().
+        */
        EFI_EXECUTE_BEFORE_BOOTTIME_EXIT = 1,
        EFI_EXECUTE_BEFORE_BOOTTIME_EXIT = 1,
+       /**
+        * @EFI_SETUP_BEFORE_BOOTTIME_EXIT: - setup before ExitBootServices
+        *
+        * Setup is executed before ExitBootServices() while execute, and
+        * teardown are executed after ExitBootServices().
+        */
        EFI_SETUP_BEFORE_BOOTTIME_EXIT,
        EFI_SETUP_BEFORE_BOOTTIME_EXIT,
+       /**
+        * @EFI_SETUP_AFTER_BOOTTIME_EXIT: - setup after ExitBootServices
+        *
+        * Setup, execute, and teardown are executed after ExitBootServices().
+        */
        EFI_SETUP_AFTER_BOOTTIME_EXIT,
 };
 
 extern struct efi_simple_text_output_protocol *con_out;
 extern struct efi_simple_text_input_protocol *con_in;
 
        EFI_SETUP_AFTER_BOOTTIME_EXIT,
 };
 
 extern struct efi_simple_text_output_protocol *con_out;
 extern struct efi_simple_text_input_protocol *con_in;
 
-/*
- * Exit the boot services.
+/**
+ * efi_st_exit_boot_services() - exit the boot services
  *
  *
- * The size of the memory map is determined.
- * Pool memory is allocated to copy the memory map.
- * The memory amp is copied and the map key is obtained.
- * The map key is used to exit the boot services.
+ * The size of the memory map is determined.
+ * Pool memory is allocated to copy the memory map.
+ * * The memory map is copied and the map key is obtained.
+ * The map key is used to exit the boot services.
  */
 void efi_st_exit_boot_services(void);
 
  */
 void efi_st_exit_boot_services(void);
 
-/*
- * Print a colored message
+/**
+ * efi_st_printc() - print a colored message
  *
  *
- * @color      color, see constants in efi_api.h, use -1 for no color
- * @fmt                printf format
- * @...                arguments to be printed
- *             on return position of terminating zero word
+ * @color:     color, see constants in efi_api.h, use -1 for no color
+ * @fmt:       printf style format string
+ * @...:       arguments to be printed
  */
 void efi_st_printc(int color, const char *fmt, ...)
                 __attribute__ ((format (__printf__, 2, 3)));
 
 /**
  */
 void efi_st_printc(int color, const char *fmt, ...)
                 __attribute__ ((format (__printf__, 2, 3)));
 
 /**
- * efi_st_translate_char() - translate a unicode character to a string
+ * efi_st_translate_char() - translate a Unicode character to a string
  *
  *
- * @code:      unicode character
+ * @code:      Unicode character
  * Return:     string
  */
 u16 *efi_st_translate_char(u16 code);
  * Return:     string
  */
 u16 *efi_st_translate_char(u16 code);
@@ -87,38 +107,44 @@ u16 *efi_st_translate_char(u16 code);
 /**
  * efi_st_translate_code() - translate a scan code to a human readable string
  *
 /**
  * efi_st_translate_code() - translate a scan code to a human readable string
  *
- * @code:      unicode character
- * Return:     string
+ * This function translates the scan code returned by the simple text input
+ * protocol to a human readable string, e.g. 0x04 is translated to L"Left".
+ *
+ * @code:      scan code
+ * Return:     Unicode string
  */
 u16 *efi_st_translate_code(u16 code);
 
  */
 u16 *efi_st_translate_code(u16 code);
 
-/*
- * Compare an u16 string to a char string.
+/**
+ * efi_st_strcmp_16_8() - compare an u16 string to a char string
+ *
+ * This function compares each u16 value to the char value at the same
+ * position. This function is only useful for ANSI strings.
  *
  * @buf1:      u16 string
  * @buf2:      char string
  *
  * @buf1:      u16 string
  * @buf2:      char string
- * @return:    0 if both buffers contain the same bytes
+ * Return:     0 if both buffers contain equivalent strings
  */
 int efi_st_strcmp_16_8(const u16 *buf1, const char *buf2);
 
  */
 int efi_st_strcmp_16_8(const u16 *buf1, const char *buf2);
 
-/*
- * Reads an Unicode character from the input device.
+/**
+ * efi_st_get_key() - reads an Unicode character from the input device
  *
  *
- * @return: Unicode character
+ * Return:     Unicode character
  */
 u16 efi_st_get_key(void);
 
 /**
  * struct efi_unit_test - EFI unit test
  *
  */
 u16 efi_st_get_key(void);
 
 /**
  * struct efi_unit_test - EFI unit test
  *
- * An efi_unit_test provides a interface to an EFI unit test.
+ * The &struct efi_unit_test structure provides a interface to an EFI unit test.
  *
  *
- * @name:      name of unit test
+ * @name:      name of the unit test used in the user interface
  * @phase:     specifies when setup and execute are executed
  * @phase:     specifies when setup and execute are executed
- * @setup:     set up the unit test
- * @teardown:  tear down the unit test
- * @execute:   execute the unit test
- * @on_request:        test is only executed on request
+ * @setup:     set up function of the unit test
+ * @execute:   execute function of the unit test
+ * @teardown:  tear down function of the unit test
+ * @on_request:        flag indicating that the test shall only be executed on request
  */
 struct efi_unit_test {
        const char *name;
  */
 struct efi_unit_test {
        const char *name;
@@ -130,7 +156,15 @@ struct efi_unit_test {
        bool on_request;
 };
 
        bool on_request;
 };
 
-/* Declare a new EFI unit test */
+/**
+ * EFI_UNIT_TEST() - macro to declare a new EFI unit test
+ *
+ * The macro EFI_UNIT_TEST() declares an EFI unit test using the &struct
+ * efi_unit_test structure. The test is added to a linker generated list which
+ * is evaluated by the 'bootefi selftest' command.
+ *
+ * @__name:    string identifying the unit test in the linker generated list
+ */
 #define EFI_UNIT_TEST(__name)                                          \
        ll_entry_declare(struct efi_unit_test, __name, efi_unit_test)
 
 #define EFI_UNIT_TEST(__name)                                          \
        ll_entry_declare(struct efi_unit_test, __name, efi_unit_test)