Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | #ifndef _JTEST_GROUP_CALL_H_ |
2 | #define _JTEST_GROUP_CALL_H_ |
||
3 | |||
4 | /*--------------------------------------------------------------------------------*/ |
||
5 | /* Includes */ |
||
6 | /*--------------------------------------------------------------------------------*/ |
||
7 | |||
8 | #include "jtest_fw.h" |
||
9 | #include <inttypes.h> |
||
10 | |||
11 | /*--------------------------------------------------------------------------------*/ |
||
12 | /* Macros and Defines */ |
||
13 | /*--------------------------------------------------------------------------------*/ |
||
14 | |||
15 | /** |
||
16 | * Execute the test in the #JTEST_GROUP_t struct associated witht he identifier |
||
17 | * group_fn. |
||
18 | */ |
||
19 | #define JTEST_GROUP_RUN(group_fn) \ |
||
20 | do \ |
||
21 | { \ |
||
22 | JTEST_DUMP_STR("Group Name:\n"); \ |
||
23 | JTEST_DUMP_STR(JTEST_GROUP_STRUCT_NAME(group_fn).name_str); \ |
||
24 | JTEST_GROUP_STRUCT_NAME(group_fn).group_fn_ptr(); \ |
||
25 | } while (0) |
||
26 | |||
27 | |||
28 | /** |
||
29 | * Update the enclosing #JTEST_GROUP_t's pass/fail information using the |
||
30 | * current #JTEST_GROUP_t's. |
||
31 | * |
||
32 | * @param group_ptr Pointer to the current #JTEST_GROUP_t. |
||
33 | * @param parent_ptr Pointer to the enclosing #JTEST_GROUP_t. |
||
34 | * |
||
35 | * @warning Only run this if the current #JTEST_GROUP_t is being called within |
||
36 | * the context of another #JTEST_GROUP_t. |
||
37 | */ |
||
38 | #define JTEST_GROUP_UPDATE_PARENT_GROUP_PF(group_ptr, parent_group_ptr) \ |
||
39 | do \ |
||
40 | { \ |
||
41 | JTEST_GROUP_INC_PASSED(parent_group_ptr, \ |
||
42 | (group_ptr)->passed); \ |
||
43 | JTEST_GROUP_INC_FAILED(parent_group_ptr, \ |
||
44 | (group_ptr)->failed); \ |
||
45 | } while (0) |
||
46 | |||
47 | /** |
||
48 | * Update the #JTEST_FW's pass/fail information using the current |
||
49 | * #JTEST_GROUP_t's. |
||
50 | */ |
||
51 | #define JTEST_GROUP_UPDATE_FW_PF(group_ptr) \ |
||
52 | do \ |
||
53 | { \ |
||
54 | JTEST_FW_INC_PASSED((group_ptr)->passed); \ |
||
55 | JTEST_FW_INC_FAILED((group_ptr)->failed); \ |
||
56 | } while (0) |
||
57 | |||
58 | /** |
||
59 | * Update the enclosing context with the current #JTEST_GROUP_t's pass/fail |
||
60 | * information. If this group isn't in an enclosing group, it updates the |
||
61 | * #JTEST_FW's pass/fail info by default. |
||
62 | */ |
||
63 | #define JTEST_GROUP_UPDATE_PARENT_GROUP_OR_FW_PF(group_ptr, \ |
||
64 | parent_group_ptr) \ |
||
65 | do \ |
||
66 | { \ |
||
67 | /* Update the pass fail counts in the parent group */ \ |
||
68 | if (parent_group_ptr /* Null implies Top*/) \ |
||
69 | { \ |
||
70 | JTEST_GROUP_UPDATE_PARENT_GROUP_PF( \ |
||
71 | group_ptr, \ |
||
72 | parent_group_ptr); \ |
||
73 | } else { \ |
||
74 | JTEST_GROUP_UPDATE_FW_PF( \ |
||
75 | group_ptr); \ |
||
76 | } \ |
||
77 | } while (0) |
||
78 | |||
79 | /** |
||
80 | * Dump the results of running the #JTEST_GROUP_t to the Keil Debugger. |
||
81 | */ |
||
82 | #define JTEST_GROUP_DUMP_RESULTS(group_ptr) \ |
||
83 | do \ |
||
84 | { \ |
||
85 | JTEST_DUMP_STRF( \ |
||
86 | "Tests Run: %" PRIu32 "\n" \ |
||
87 | "----------\n" \ |
||
88 | " Passed: %" PRIu32 "\n" \ |
||
89 | " Failed: %" PRIu32 "\n", \ |
||
90 | (group_ptr)->passed + (group_ptr)->failed, \ |
||
91 | (group_ptr)->passed, \ |
||
92 | (group_ptr)->failed); \ |
||
93 | } while (0) |
||
94 | |||
95 | /** |
||
96 | * Call the #JTEST_GROUP_t associated with the identifier group_fn. |
||
97 | */ |
||
98 | #define JTEST_GROUP_CALL(group_fn) \ |
||
99 | do \ |
||
100 | { /* Save the current group from JTEST_FW_t before swapping */ \ |
||
101 | /* it to this group (in order to restore it later )*/ \ |
||
102 | JTEST_GROUP_t * __jtest_temp_group_ptr = \ |
||
103 | JTEST_CURRENT_GROUP_PTR(); \ |
||
104 | JTEST_SET_CURRENT_GROUP(&JTEST_GROUP_STRUCT_NAME(group_fn)); \ |
||
105 | \ |
||
106 | /* Reset this group's pass/fail count. Each group */ \ |
||
107 | /* should only remember counts for its last execution. */ \ |
||
108 | JTEST_GROUP_RESET_PF(JTEST_CURRENT_GROUP_PTR()); \ |
||
109 | \ |
||
110 | /* Run the current group */ \ |
||
111 | JTEST_ACT_GROUP_START(); \ |
||
112 | JTEST_GROUP_RUN(group_fn); \ |
||
113 | JTEST_ACT_GROUP_END(); \ |
||
114 | \ |
||
115 | /* Update the pass fail counts in the parent group (or FW) */ \ |
||
116 | JTEST_GROUP_UPDATE_PARENT_GROUP_OR_FW_PF( \ |
||
117 | JTEST_CURRENT_GROUP_PTR(), \ |
||
118 | __jtest_temp_group_ptr); \ |
||
119 | \ |
||
120 | JTEST_GROUP_DUMP_RESULTS(JTEST_CURRENT_GROUP_PTR()); \ |
||
121 | \ |
||
122 | /* Restore the previously current group */ \ |
||
123 | JTEST_SET_CURRENT_GROUP(__jtest_temp_group_ptr); \ |
||
124 | } while (0) |
||
125 | |||
126 | #endif /* _JTEST_GROUP_CALL_H_ */ |