amiro-os / core / inc / aos_unittest.h @ 908b6fb4
History | View | Annotate | Download (4.866 KB)
1 | e545e620 | Thomas Schöpping | /*
|
---|---|---|---|
2 | AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
||
3 | 84f0ce9e | Thomas Schöpping | Copyright (C) 2016..2019 Thomas Schöpping et al.
|
4 | e545e620 | Thomas Schöpping | |
5 | This program is free software: you can redistribute it and/or modify
|
||
6 | it under the terms of the GNU General Public License as published by
|
||
7 | the Free Software Foundation, either version 3 of the License, or
|
||
8 | (at your option) any later version.
|
||
9 | |||
10 | This program is distributed in the hope that it will be useful,
|
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | GNU General Public License for more details.
|
||
14 | |||
15 | You should have received a copy of the GNU General Public License
|
||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
17 | */
|
||
18 | |||
19 | 53710ca3 | Marc Rothmann | /**
|
20 | * @file aos_unittest.h
|
||
21 | * @brief Unittest structures.
|
||
22 | *
|
||
23 | * @addtogroup aos_unittests
|
||
24 | * @{
|
||
25 | */
|
||
26 | |||
27 | 6ff06bbf | Thomas Schöpping | #ifndef AMIROOS_UNITTEST_H
|
28 | #define AMIROOS_UNITTEST_H
|
||
29 | e545e620 | Thomas Schöpping | |
30 | 3940ba8a | Thomas Schöpping | #include <amiroos.h> |
31 | |||
32 | bc5cdb79 | Thomas Schöpping | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
33 | 3940ba8a | Thomas Schöpping | |
34 | f3ac1c96 | Thomas Schöpping | /******************************************************************************/
|
35 | /* CONSTANTS */
|
||
36 | /******************************************************************************/
|
||
37 | |||
38 | /******************************************************************************/
|
||
39 | /* SETTINGS */
|
||
40 | /******************************************************************************/
|
||
41 | |||
42 | /******************************************************************************/
|
||
43 | /* CHECKS */
|
||
44 | /******************************************************************************/
|
||
45 | |||
46 | /******************************************************************************/
|
||
47 | /* DATA STRUCTURES AND TYPES */
|
||
48 | /******************************************************************************/
|
||
49 | e545e620 | Thomas Schöpping | |
50 | /*
|
||
51 | f3ac1c96 | Thomas Schöpping | * forward declarations
|
52 | e545e620 | Thomas Schöpping | */
|
53 | typedef struct aos_utresult aos_utresult_t; |
||
54 | f3ac1c96 | Thomas Schöpping | typedef struct aos_unittest aos_unittest_t; |
55 | e545e620 | Thomas Schöpping | |
56 | /**
|
||
57 | * @brief Unit test interface function definition.
|
||
58 | *
|
||
59 | * @param[in] stream The stream to use for printing messages.
|
||
60 | * @param[in] ut The object to run the test on.
|
||
61 | *
|
||
62 | * @return A result containing the number of passed and failed tests.
|
||
63 | */
|
||
64 | f3ac1c96 | Thomas Schöpping | typedef aos_utresult_t (*aos_utfunction_t)(BaseSequentialStream*, aos_unittest_t*);
|
65 | e545e620 | Thomas Schöpping | |
66 | /**
|
||
67 | * @brief Unit test result struct.
|
||
68 | */
|
||
69 | struct aos_utresult {
|
||
70 | /**
|
||
71 | * @brief Number of passed tests.
|
||
72 | */
|
||
73 | uint32_t passed; |
||
74 | |||
75 | /**
|
||
76 | * @brief Number of failed tests.
|
||
77 | */
|
||
78 | uint32_t failed; |
||
79 | }; |
||
80 | |||
81 | /**
|
||
82 | * @brief Unit test definition struct.
|
||
83 | */
|
||
84 | struct aos_unittest {
|
||
85 | /**
|
||
86 | * @brief Name of the unit test.
|
||
87 | */
|
||
88 | const char* name; |
||
89 | |||
90 | /**
|
||
91 | * @brief Further information about the test.
|
||
92 | */
|
||
93 | const char* info; |
||
94 | |||
95 | /**
|
||
96 | * @brief Callback function to run that executes the unit test.
|
||
97 | */
|
||
98 | aos_utfunction_t testfunc; |
||
99 | |||
100 | /**
|
||
101 | * @brief Shell command to add to an shell command list.
|
||
102 | */
|
||
103 | aos_shellcommand_t shellcmd; |
||
104 | |||
105 | /**
|
||
106 | * @brief Further test specific data.
|
||
107 | */
|
||
108 | void* data;
|
||
109 | }; |
||
110 | |||
111 | f3ac1c96 | Thomas Schöpping | |
112 | /******************************************************************************/
|
||
113 | /* MACROS */
|
||
114 | /******************************************************************************/
|
||
115 | |||
116 | /******************************************************************************/
|
||
117 | /* EXTERN DECLARATIONS */
|
||
118 | /******************************************************************************/
|
||
119 | |||
120 | 7de0cc90 | Thomas Schöpping | #if defined(__cplusplus)
|
121 | e545e620 | Thomas Schöpping | extern "C" { |
122 | 7de0cc90 | Thomas Schöpping | #endif /* defined(__cplusplus) */ |
123 | e545e620 | Thomas Schöpping | uint32_t aosUtResultTotal(aos_utresult_t* result); |
124 | float aosUtResultRatio(aos_utresult_t* result);
|
||
125 | void aosUtResultPrintSummary(BaseSequentialStream* stream, aos_utresult_t* result, char* heading); |
||
126 | void aosUtObjectInit(aos_unittest_t* ut, char* name, char* info, aos_utfunction_t func, void* data, char* shellname, aos_shellcmdcb_t shellcb); |
||
127 | aos_utresult_t aosUtRun(BaseSequentialStream* stream, aos_unittest_t* ut, char* note);
|
||
128 | void aosUtPassed(BaseSequentialStream* stream, aos_utresult_t* result);
|
||
129 | void aosUtPassedMsg(BaseSequentialStream* stream, aos_utresult_t* result, const char* fmt, ...); |
||
130 | void aosUtFailed(BaseSequentialStream* stream, aos_utresult_t* result);
|
||
131 | void aosUtFailedMsg(BaseSequentialStream* stream, aos_utresult_t* result, const char* fmt, ...); |
||
132 | void aosUtInfoMsg(BaseSequentialStream* stream, const char* fmt, ...); |
||
133 | 7de0cc90 | Thomas Schöpping | #if defined(__cplusplus)
|
134 | e545e620 | Thomas Schöpping | } |
135 | 7de0cc90 | Thomas Schöpping | #endif /* defined(__cplusplus) */ |
136 | e545e620 | Thomas Schöpping | |
137 | f3ac1c96 | Thomas Schöpping | /******************************************************************************/
|
138 | /* INLINE FUNCTIONS */
|
||
139 | /******************************************************************************/
|
||
140 | |||
141 | 7de0cc90 | Thomas Schöpping | #endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
142 | e545e620 | Thomas Schöpping | |
143 | 6ff06bbf | Thomas Schöpping | #endif /* AMIROOS_UNITTEST_H */ |
144 | 53710ca3 | Marc Rothmann | |
145 | /** @} */ |