14
14
* See the License for the specific language governing permissions and
15
15
* limitations under the License.
16
16
*/
17
- #include " mbed.h"
18
- #include " test_env.h"
19
- #include " utest.h"
20
- #include " unity.h"
21
- #include " stack_trace.h"
17
+ #include " mbed-drivers/mbed .h"
18
+ #include " greentea-client/ test_env.h"
19
+ #include " utest/utest .h"
20
+ #include " unity/unity .h"
21
+ #include " utest/ stack_trace.h"
22
22
23
23
using namespace utest ::v1;
24
24
25
- #ifdef UTEST_STACK_TRACE
26
- std::string utest_trace[UTEST_MAX_BACKTRACE];
27
- #endif // UTEST_STACK_TRACE
28
25
29
- int call_counter (0 );
30
- Timeout to ;
26
+ static int call_counter (0 );
27
+ static Timeout utest_to ;
31
28
32
29
class Utest_func_bind {
33
30
@@ -48,29 +45,29 @@ class Utest_func_bind {
48
45
49
46
void await_case_validate (int expected_call_count)
50
47
{
51
- UTEST_LOG_FUNCTION
48
+ UTEST_LOG_FUNCTION ();
52
49
printf (" await_case_validate called with expected call count of %d\n " , expected_call_count);
53
50
TEST_ASSERT_EQUAL (expected_call_count, call_counter++);
54
51
Harness::validate_callback ();
55
52
}
56
53
57
- Utest_func_bind validate1 (await_case_validate, 7 );
58
- Utest_func_bind validate2 (await_case_validate, 37 );
59
- Utest_func_bind validate3 (await_case_validate, 50 );
54
+ static Utest_func_bind validate1 (await_case_validate, 7 );
55
+ static Utest_func_bind validate2 (await_case_validate, 37 );
56
+ static Utest_func_bind validate3 (await_case_validate, 50 );
60
57
61
58
62
59
63
60
// Control: Timeout (Failure) -----------------------------------------------------------------------------------------
64
61
control_t timeout_failure_case (const size_t call_count)
65
62
{
66
- UTEST_LOG_FUNCTION
63
+ UTEST_LOG_FUNCTION ();
67
64
TEST_ASSERT_EQUAL (1 , call_count);
68
65
TEST_ASSERT_EQUAL (0 , call_counter++);
69
66
return CaseTimeout (100 );
70
67
}
71
68
status_t timeout_failure_case_failure_handler (const Case *const source, const failure_t failure)
72
69
{
73
- UTEST_LOG_FUNCTION
70
+ UTEST_LOG_FUNCTION ();
74
71
TEST_ASSERT_EQUAL (1 , call_counter++);
75
72
TEST_ASSERT_EQUAL (REASON_TIMEOUT, failure.reason );
76
73
TEST_ASSERT_EQUAL (LOCATION_CASE_HANDLER, failure.location );
@@ -79,7 +76,7 @@ status_t timeout_failure_case_failure_handler(const Case *const source, const fa
79
76
}
80
77
status_t timeout_failure_case_teardown (const Case *const source, const size_t passed, const size_t failed, const failure_t failure)
81
78
{
82
- UTEST_LOG_FUNCTION
79
+ UTEST_LOG_FUNCTION ();
83
80
TEST_ASSERT_EQUAL (2 , call_counter++);
84
81
TEST_ASSERT_EQUAL (0 , passed);
85
82
TEST_ASSERT_EQUAL (1 , failed);
@@ -90,23 +87,23 @@ status_t timeout_failure_case_teardown(const Case *const source, const size_t pa
90
87
91
88
// Control: Timeout (Success) -----------------------------------------------------------------------------------------
92
89
void timeout_success_case_validate () {
93
- UTEST_LOG_FUNCTION
90
+ UTEST_LOG_FUNCTION ();
94
91
TEST_ASSERT_EQUAL (4 , call_counter++);
95
92
Harness::validate_callback ();
96
93
}
97
94
98
95
control_t timeout_success_case (const size_t call_count)
99
96
{
100
- UTEST_LOG_FUNCTION
97
+ UTEST_LOG_FUNCTION ();
101
98
TEST_ASSERT_EQUAL (1 , call_count);
102
99
TEST_ASSERT_EQUAL (3 , call_counter++);
103
- to .attach_us (timeout_success_case_validate, 100000 ); // Fire after 100 ms
100
+ utest_to .attach_us (timeout_success_case_validate, 100000 ); // Fire after 100 ms
104
101
105
102
return CaseTimeout (200 );
106
103
}
107
104
status_t timeout_success_case_failure_handler (const Case *const source, const size_t passed, const size_t failed, const failure_t failure)
108
105
{
109
- UTEST_LOG_FUNCTION
106
+ UTEST_LOG_FUNCTION ();
110
107
TEST_ASSERT_EQUAL (5 , call_counter++);
111
108
TEST_ASSERT_EQUAL (1 , passed);
112
109
TEST_ASSERT_EQUAL (0 , failed);
@@ -118,11 +115,11 @@ status_t timeout_success_case_failure_handler(const Case *const source, const si
118
115
// Control: Await -----------------------------------------------------------------------------------------------------
119
116
control_t await_case (const size_t call_count)
120
117
{
121
- UTEST_LOG_FUNCTION
118
+ UTEST_LOG_FUNCTION ();
122
119
TEST_ASSERT_EQUAL (1 , call_count);
123
120
TEST_ASSERT_EQUAL (6 , call_counter++);
124
121
125
- to .attach_us (&validate1, &Utest_func_bind::callback, (1372 *1000 )); // Fire after 1372 ms
122
+ utest_to .attach_us (&validate1, &Utest_func_bind::callback, (1372 *1000 )); // Fire after 1372 ms
126
123
127
124
return CaseAwait;
128
125
}
@@ -135,7 +132,7 @@ status_t repeat_all_on_timeout_case_setup(const Case *const source, const size_t
135
132
UTEST_TRACE_START
136
133
repeat_all_start_flag = false ;
137
134
}
138
- UTEST_LOG_FUNCTION
135
+ UTEST_LOG_FUNCTION ();
139
136
static int repeat_counter (0 );
140
137
TEST_ASSERT_EQUAL (3 , index_of_case);
141
138
TEST_ASSERT_EQUAL (repeat_counter*3 + 8 , call_counter++);
@@ -144,21 +141,21 @@ status_t repeat_all_on_timeout_case_setup(const Case *const source, const size_t
144
141
}
145
142
control_t repeat_all_on_timeout_case (const size_t call_count)
146
143
{
147
- UTEST_LOG_FUNCTION
144
+ UTEST_LOG_FUNCTION ();
148
145
printf (" Running case handler for %u. time\n " , call_count);
149
146
static int repeat_counter (1 );
150
147
TEST_ASSERT_EQUAL (repeat_counter++, call_count);
151
148
TEST_ASSERT (call_count <= 10 );
152
149
TEST_ASSERT_EQUAL ((call_count-1 )*3 + 9 , call_counter++);
153
150
if (call_count == 10 ) {
154
151
printf (" Scheduling await_case_validate with value 37" );
155
- to .attach_us (&validate2, &Utest_func_bind::callback, (50 *1000 )); // Fire after 50ms
152
+ utest_to .attach_us (&validate2, &Utest_func_bind::callback, (50 *1000 )); // Fire after 50ms
156
153
}
157
154
return CaseRepeatAllOnTimeout (100 );
158
155
}
159
156
status_t repeat_all_on_timeout_case_teardown (const Case *const source, const size_t passed, const size_t failed, const failure_t failure)
160
157
{
161
- UTEST_LOG_FUNCTION
158
+ UTEST_LOG_FUNCTION ();
162
159
static int repeat_counter (0 );
163
160
printf (" Call counter = %d, passed =%u, failed = %u\n " , call_counter, passed, failed);
164
161
@@ -174,29 +171,29 @@ status_t repeat_all_on_timeout_case_teardown(const Case *const source, const siz
174
171
// Control: RepeatAllOnTimeout ----------------------------------------------------------------------------------------
175
172
status_t repeat_handler_on_timeout_case_setup (const Case *const source, const size_t index_of_case)
176
173
{
177
- UTEST_LOG_FUNCTION
174
+ UTEST_LOG_FUNCTION ();
178
175
TEST_ASSERT_EQUAL (4 , index_of_case);
179
176
TEST_ASSERT_EQUAL (39 , call_counter++);
180
177
return greentea_case_setup_handler (source, index_of_case);
181
178
}
182
179
183
180
control_t repeat_handler_on_timeout_case (const size_t call_count)
184
181
{
185
- UTEST_LOG_FUNCTION
182
+ UTEST_LOG_FUNCTION ();
186
183
printf (" Running case handler for %u. time\n " , call_count);
187
184
static int repeat_counter (1 );
188
185
TEST_ASSERT_EQUAL (repeat_counter++, call_count);
189
186
TEST_ASSERT (call_count <= 10 );
190
187
TEST_ASSERT_EQUAL (call_count-1 + 40 , call_counter++);
191
188
if (call_count == 10 ) {
192
189
printf (" Scheduling await_case_validate with value 50" );
193
- to .attach_us (&validate3, &Utest_func_bind::callback, (50 *1000 )); // Fire after 50ms
190
+ utest_to .attach_us (&validate3, &Utest_func_bind::callback, (50 *1000 )); // Fire after 50ms
194
191
}
195
192
return CaseRepeatHandlerOnTimeout (100 );
196
193
}
197
194
status_t repeat_handler_on_timeout_case_teardown (const Case *const source, const size_t passed, const size_t failed, const failure_t failure)
198
195
{
199
- UTEST_LOG_FUNCTION
196
+ UTEST_LOG_FUNCTION ();
200
197
TEST_ASSERT_EQUAL (1 , passed);
201
198
TEST_ASSERT_EQUAL (0 , failed);
202
199
TEST_ASSERT_EQUAL (REASON_NONE, failure.reason );
@@ -208,7 +205,7 @@ status_t repeat_handler_on_timeout_case_teardown(const Case *const source, const
208
205
// Control: NoTimeout -------------------------------------------------------------------------------------------------
209
206
control_t no_timeout_case (const size_t call_count)
210
207
{
211
- UTEST_LOG_FUNCTION
208
+ UTEST_LOG_FUNCTION ();
212
209
TEST_ASSERT_EQUAL (1 , call_count);
213
210
TEST_ASSERT_EQUAL (52 , call_counter++);
214
211
return CaseNoTimeout;
@@ -217,7 +214,7 @@ control_t no_timeout_case(const size_t call_count)
217
214
// Control: NoTimeout -------------------------------------------------------------------------------------------------
218
215
control_t next_case (const size_t call_count)
219
216
{
220
- UTEST_LOG_FUNCTION
217
+ UTEST_LOG_FUNCTION ();
221
218
TEST_ASSERT_EQUAL (1 , call_count);
222
219
TEST_ASSERT_EQUAL (53 , call_counter++);
223
220
return CaseNoTimeout;
0 commit comments