1 /* 2 * 3 * (C) COPYRIGHT 2014, 2017 ARM Limited. All rights reserved. 4 * 5 * This program is free software and is provided to you under the terms of the 6 * GNU General Public License version 2 as published by the Free Software 7 * Foundation, and any use by you of this program is subject to the terms 8 * of such GNU licence. 9 * 10 * A copy of the licence is included with the program, and can also be obtained 11 * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 12 * Boston, MA 02110-1301, USA. 13 * 14 */ 15 16 17 18 #ifndef _KERNEL_UTF_RESULTSET_H_ 19 #define _KERNEL_UTF_RESULTSET_H_ 20 21 /* kutf_resultset.h 22 * Functions and structures for handling test results and result sets. 23 * 24 * This section of the kernel UTF contains structures and functions used for the 25 * management of Results and Result Sets. 26 */ 27 28 /** 29 * enum kutf_result_status - Status values for a single Test error. 30 * @KUTF_RESULT_BENCHMARK: Result is a meta-result containing benchmark 31 * results. 32 * @KUTF_RESULT_SKIP: The test was skipped. 33 * @KUTF_RESULT_UNKNOWN: The test has an unknown result. 34 * @KUTF_RESULT_PASS: The test result passed. 35 * @KUTF_RESULT_DEBUG: The test result passed, but raised a debug 36 * message. 37 * @KUTF_RESULT_INFO: The test result passed, but raised 38 * an informative message. 39 * @KUTF_RESULT_WARN: The test result passed, but raised a warning 40 * message. 41 * @KUTF_RESULT_FAIL: The test result failed with a non-fatal error. 42 * @KUTF_RESULT_FATAL: The test result failed with a fatal error. 43 * @KUTF_RESULT_ABORT: The test result failed due to a non-UTF 44 * assertion failure. 45 * @KUTF_RESULT_COUNT: The current number of possible status messages. 46 */ 47 enum kutf_result_status { 48 KUTF_RESULT_BENCHMARK = -3, 49 KUTF_RESULT_SKIP = -2, 50 KUTF_RESULT_UNKNOWN = -1, 51 52 KUTF_RESULT_PASS = 0, 53 KUTF_RESULT_DEBUG = 1, 54 KUTF_RESULT_INFO = 2, 55 KUTF_RESULT_WARN = 3, 56 KUTF_RESULT_FAIL = 4, 57 KUTF_RESULT_FATAL = 5, 58 KUTF_RESULT_ABORT = 6, 59 60 KUTF_RESULT_COUNT 61 }; 62 63 /* The maximum size of a kutf_result_status result when 64 * converted to a string 65 */ 66 #define KUTF_ERROR_MAX_NAME_SIZE 21 67 68 #ifdef __KERNEL__ 69 70 #include <kutf/kutf_mem.h> 71 72 /** 73 * struct kutf_result - Represents a single test result. 74 * @node: Next result in the list of results. 75 * @status: The status summary (pass / warn / fail / etc). 76 * @message: A more verbose status message. 77 */ 78 struct kutf_result { 79 struct list_head node; 80 enum kutf_result_status status; 81 const char *message; 82 }; 83 84 /** 85 * kutf_create_result_set() - Create a new result set 86 * to which results can be added. 87 * 88 * Return: The created resultset. 89 */ 90 struct kutf_result_set *kutf_create_result_set(void); 91 92 /** 93 * kutf_add_result() - Add a result to the end of an existing resultset. 94 * 95 * @mempool: The memory pool to allocate the result storage from. 96 * @set: The resultset to add the result to. 97 * @status: The result status to add. 98 * @message: The result message to add. 99 */ 100 void kutf_add_result(struct kutf_mempool *mempool, struct kutf_result_set *set, 101 enum kutf_result_status status, const char *message); 102 103 /** 104 * kutf_remove_result() - Remove a result from the head of a resultset. 105 * @set: The resultset. 106 * 107 * Return: result or NULL if there are no further results in the resultset. 108 */ 109 struct kutf_result *kutf_remove_result( 110 struct kutf_result_set *set); 111 112 /** 113 * kutf_destroy_result_set() - Free a previously created resultset. 114 * 115 * @results: The result set whose resources to free. 116 */ 117 void kutf_destroy_result_set(struct kutf_result_set *results); 118 119 #endif /* __KERNEL__ */ 120 121 #endif /* _KERNEL_UTF_RESULTSET_H_ */ 122