@@ -33,13 +33,13 @@ void test_error_count_and_reset()
33
33
MBED_WARNING (MBED_ERROR_OUT_OF_MEMORY, " Out of memory" , i);
34
34
}
35
35
36
- TEST_ASSERT_EQUAL_INT (count, get_error_count ());
36
+ TEST_ASSERT_EQUAL_INT (count, mbed_get_error_count ());
37
37
38
38
// clear the errors and error count to 0
39
39
mbed_clear_all_errors ();
40
40
41
41
// Now the error count should be 0
42
- TEST_ASSERT_EQUAL_INT (0 , get_error_count ());
42
+ TEST_ASSERT_EQUAL_INT (0 , mbed_get_error_count ());
43
43
44
44
}
45
45
@@ -54,61 +54,61 @@ void test_error_capturing()
54
54
// first clear all errors and start afresh
55
55
56
56
MBED_WARNING (MBED_ERROR_OUT_OF_RESOURCES, " System type error" , 0x1100 );
57
- mbed_error_status_t lastError = get_last_error ();
57
+ mbed_error_status_t lastError = mbed_get_last_error ();
58
58
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_TYPE_SYSTEM, MBED_GET_ERROR_TYPE (lastError));
59
59
TEST_ASSERT_EQUAL_UINT (MBED_MODULE_UNKNOWN, MBED_GET_ERROR_MODULE (lastError));
60
60
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_CODE_OUT_OF_RESOURCES, MBED_GET_ERROR_CODE (lastError));
61
61
62
62
mbed_error_status_t error = MBED_MAKE_ERROR (MBED_MODULE_DRIVER_SERIAL, MBED_ERROR_CODE_OUT_OF_RESOURCES);
63
63
MBED_WARNING (error, " Error Serial" , 0xAA );
64
- lastError = get_last_error ();
64
+ lastError = mbed_get_last_error ();
65
65
TEST_ASSERT_EQUAL_UINT (error, lastError);
66
66
67
67
error = MBED_MAKE_CUSTOM_ERROR (MBED_MODULE_APPLICATION, MBED_ERROR_CODE_UNKNOWN);
68
68
MBED_WARNING (error, " Custom Error Unknown" , 0x1234 );
69
- lastError = get_last_error ();
69
+ lastError = mbed_get_last_error ();
70
70
TEST_ASSERT_EQUAL_UINT (error, lastError);
71
71
72
72
MBED_WARNING (MBED_ERROR_EPERM, " Posix Error Eperm" , 0x1234 );
73
- lastError = get_last_error ();
73
+ lastError = mbed_get_last_error ();
74
74
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_EPERM, lastError);
75
75
76
76
error = MBED_MAKE_CUSTOM_ERROR (MBED_MODULE_PLATFORM, MBED_ERROR_CODE_CREATE_FAILED);
77
77
MBED_WARNING (error, " Custom Error Type" , error_value);
78
- lastError = get_last_error ();
78
+ lastError = mbed_get_last_error ();
79
79
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_TYPE_CUSTOM, MBED_GET_ERROR_TYPE (lastError));
80
80
TEST_ASSERT_EQUAL_UINT (MBED_MODULE_PLATFORM, MBED_GET_ERROR_MODULE (lastError));
81
81
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_CODE_CREATE_FAILED, MBED_GET_ERROR_CODE (lastError));
82
- mbed_error_status_t status = mbed_get_last_error_log_info ( &error_ctx );
82
+ mbed_error_status_t status = mbed_get_last_error_info ( &error_ctx );
83
83
TEST_ASSERT (status == MBED_SUCCESS);
84
84
TEST_ASSERT_EQUAL_UINT (error_value, error_ctx.error_value );
85
85
86
86
error_value = 0xAABBCC ;
87
87
MBED_WARNING (MBED_ERROR_EACCES, " Posix Error" , error_value );
88
- lastError = get_last_error ();
88
+ lastError = mbed_get_last_error ();
89
89
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_TYPE_POSIX, MBED_GET_ERROR_TYPE (lastError));
90
90
TEST_ASSERT_EQUAL_UINT (MBED_MODULE_UNKNOWN, MBED_GET_ERROR_MODULE (lastError));
91
91
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_CODE_EACCES, MBED_GET_ERROR_CODE (lastError));
92
- status = mbed_get_last_error_log_info ( &error_ctx );
92
+ status = mbed_get_last_error_info ( &error_ctx );
93
93
TEST_ASSERT (status == MBED_SUCCESS);
94
94
TEST_ASSERT_EQUAL_UINT (error_value, error_ctx.error_value );
95
95
96
96
error_value = 0 ;
97
97
error = MBED_MAKE_ERROR (MBED_MODULE_HAL, MBED_ERROR_CODE_UNKNOWN);
98
98
MBED_WARNING (error, " HAL Entity error" , error_value );
99
- lastError = get_last_error ();
99
+ lastError = mbed_get_last_error ();
100
100
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_TYPE_SYSTEM, MBED_GET_ERROR_TYPE (lastError));
101
101
TEST_ASSERT_EQUAL_UINT (MBED_MODULE_HAL, MBED_GET_ERROR_MODULE (lastError));
102
102
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_CODE_UNKNOWN, MBED_GET_ERROR_CODE (lastError));
103
- status = mbed_get_last_error_log_info ( &error_ctx );
103
+ status = mbed_get_last_error_info ( &error_ctx );
104
104
TEST_ASSERT (status == MBED_SUCCESS);
105
105
TEST_ASSERT_EQUAL_UINT (error_value, error_ctx.error_value );
106
106
107
107
MBED_WARNING (MBED_ERROR_MUTEX_LOCK_FAILED, " Mutex lock failed" , 0x4455 );
108
- error = get_last_error ();
108
+ error = mbed_get_last_error ();
109
109
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_MUTEX_LOCK_FAILED, error);
110
110
111
- error = get_first_error ();
111
+ error = mbed_get_first_error ();
112
112
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_OUT_OF_RESOURCES, error);
113
113
114
114
}
@@ -121,7 +121,7 @@ void test_error_context_capture()
121
121
mbed_error_ctx error_ctx = {0 };
122
122
123
123
MBED_WARNING (MBED_ERROR_INVALID_ARGUMENT, " System type error" , error_value );
124
- mbed_error_status_t status = mbed_get_last_error_log_info ( &error_ctx );
124
+ mbed_error_status_t status = mbed_get_last_error_info ( &error_ctx );
125
125
TEST_ASSERT (status == MBED_SUCCESS);
126
126
TEST_ASSERT_EQUAL_UINT (error_value, error_ctx.error_value );
127
127
TEST_ASSERT_EQUAL_UINT (osThreadGetId (), error_ctx.thread_id );
@@ -136,7 +136,7 @@ void test_error_context_capture()
136
136
#endif
137
137
}
138
138
139
- #ifndef MBED_CONF_ERROR_LOG_DISABLED
139
+ #ifndef MBED_CONF_ERROR_HIST_DISABLED
140
140
/* * Test error logging functionality
141
141
*/
142
142
void test_error_logging ()
@@ -151,15 +151,15 @@ void test_error_logging()
151
151
MBED_WARNING (MBED_ERROR_INVALID_SIZE, " Invalid size" , 2 );
152
152
MBED_WARNING (MBED_ERROR_INVALID_FORMAT, " Invalid format" , 3 );
153
153
154
- mbed_error_status_t status = mbed_get_error_log_info ( 0 , &error_ctx );
154
+ mbed_error_status_t status = mbed_get_error_hist_info ( 0 , &error_ctx );
155
155
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_INVALID_ARGUMENT, error_ctx.error_status );
156
156
TEST_ASSERT_EQUAL_UINT (1 , error_ctx.error_value );
157
157
158
- status = mbed_get_error_log_info ( 1 , &error_ctx );
158
+ status = mbed_get_error_hist_info ( 1 , &error_ctx );
159
159
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_INVALID_SIZE, error_ctx.error_status );
160
160
TEST_ASSERT_EQUAL_UINT (2 , error_ctx.error_value );
161
161
162
- status = mbed_get_error_log_info ( 2 , &error_ctx );
162
+ status = mbed_get_error_hist_info ( 2 , &error_ctx );
163
163
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_INVALID_FORMAT, error_ctx.error_status );
164
164
TEST_ASSERT_EQUAL_UINT (3 , error_ctx.error_value );
165
165
@@ -175,24 +175,24 @@ void test_error_logging()
175
175
MBED_WARNING (MBED_ERROR_UNSUPPORTED, " Not supported" , 12 );
176
176
MBED_WARNING (MBED_ERROR_ACCESS_DENIED, " Access denied" , 13 );
177
177
178
- status = mbed_get_error_log_info ( 0 , &error_ctx );
178
+ status = mbed_get_error_hist_info ( 0 , &error_ctx );
179
179
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_TIME_OUT, error_ctx.error_status );
180
180
TEST_ASSERT_EQUAL_UINT (10 , error_ctx.error_value );
181
181
182
- status = mbed_get_error_log_info ( 1 , &error_ctx );
182
+ status = mbed_get_error_hist_info ( 1 , &error_ctx );
183
183
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_ALREADY_IN_USE, error_ctx.error_status );
184
184
TEST_ASSERT_EQUAL_UINT (11 , error_ctx.error_value );
185
185
186
- status = mbed_get_error_log_info ( 2 , &error_ctx );
186
+ status = mbed_get_error_hist_info ( 2 , &error_ctx );
187
187
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_UNSUPPORTED, error_ctx.error_status );
188
188
TEST_ASSERT_EQUAL_UINT (12 , error_ctx.error_value );
189
189
190
- status = mbed_get_error_log_info ( 3 , &error_ctx );
190
+ status = mbed_get_error_hist_info ( 3 , &error_ctx );
191
191
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_ACCESS_DENIED, error_ctx.error_status );
192
192
TEST_ASSERT_EQUAL_UINT (13 , error_ctx.error_value );
193
193
194
194
// Try an index which is invalid, we should get ERROR_INVALID_ARGUMENT back
195
- status = mbed_get_error_log_info ( 99 , &error_ctx );
195
+ status = mbed_get_error_hist_info ( 99 , &error_ctx );
196
196
TEST_ASSERT_EQUAL_UINT (MBED_ERROR_INVALID_ARGUMENT, status);
197
197
198
198
}
@@ -202,7 +202,6 @@ void test_error_logging()
202
202
// Error logger threads
203
203
void err_thread_func (mbed_error_status_t *error_status)
204
204
{
205
- // printf("\nError Status = 0x%08X\n",*error_status);
206
205
MBED_WARNING (*error_status, " Error from Multi-Threaded error logging test" , *error_status );
207
206
}
208
207
@@ -228,15 +227,14 @@ void test_error_logging_multithread()
228
227
errThread[i]->join ();
229
228
}
230
229
231
- i = mbed_get_error_log_count ()-1 ;
232
- // printf("\nError log count = %d\n", i+1);
230
+ i = mbed_get_error_hist_count ()-1 ;
231
+
233
232
for (;i>=0 ;--i) {
234
- mbed_error_status_t status = mbed_get_error_log_info ( i, &error_ctx );
233
+ mbed_error_status_t status = mbed_get_error_hist_info ( i, &error_ctx );
235
234
if (status != MBED_SUCCESS) {
236
235
TEST_FAIL ();
237
236
}
238
237
239
- // printf("\nError Status[%d] = 0x%08X Value = 0x%08X\n", i, (unsigned int)error_ctx.error_status, (unsigned int)error_ctx.error_value);
240
238
TEST_ASSERT_EQUAL_UINT ((unsigned int )error_ctx.error_value , (unsigned int )error_ctx.error_status );
241
239
}
242
240
}
@@ -307,47 +305,41 @@ void test_save_error_log()
307
305
308
306
error = MBED_TEST_FILESYSTEM::format (&fd);
309
307
if (error < 0 ) {
310
- printf (" Failed formatting" );
311
- TEST_FAIL ();
308
+ TEST_FAIL_MESSAGE (" Failed formatting" );
312
309
}
313
310
314
311
error = fs.mount (&fd);
315
312
if (error < 0 ) {
316
- printf (" Failed mounting fs" );
317
- TEST_FAIL ();
313
+ TEST_FAIL_MESSAGE (" Failed mounting fs" );
318
314
}
319
315
320
- if (MBED_SUCCESS != mbed_save_error_log (" /fs/errors.log" )) {
321
- printf (" Failed saving error log" );
322
- TEST_FAIL ();
316
+ if (MBED_SUCCESS != mbed_save_error_hist (" /fs/errors.log" )) {
317
+ TEST_FAIL_MESSAGE (" Failed saving error log" );
323
318
}
324
319
325
320
FILE *error_file = fopen (" /fs/errors.log" , " r" );
326
321
if (error_file == NULL ) {
327
- printf (" Unable to find error log in fs" );
328
- TEST_FAIL ();
322
+ TEST_FAIL_MESSAGE (" Unable to find error log in fs" );
329
323
}
330
324
331
325
char buff[64 ] = {0 };
332
326
while (!feof (error_file)){
333
327
int size = fread (&buff[0 ], 1 , 15 , error_file);
334
328
fwrite (&buff[0 ], 1 , size, stdout);
335
329
}
336
- printf (" \r\n " );
337
330
fclose (error_file);
338
331
339
332
error = fs.unmount ();
340
333
if (error < 0 ) {
341
- printf (" Failed unmounting fs" );
342
- TEST_FAIL ();
334
+ TEST_FAIL_MESSAGE (" Failed unmounting fs" );
343
335
}
344
336
}
345
337
346
338
#endif
347
339
348
340
utest::v1::status_t test_setup (const size_t number_of_cases)
349
341
{
350
- GREENTEA_SETUP (300 , " default_auto" );
342
+ GREENTEA_SETUP (120 , " default_auto" );
351
343
return utest::v1::verbose_test_setup_handler (number_of_cases);
352
344
}
353
345
@@ -356,7 +348,7 @@ Case cases[] = {
356
348
Case (" Test error encoding, value capture, first and last errors" , test_error_capturing),
357
349
Case (" Test error context capture" , test_error_context_capture),
358
350
Case (" Test error hook" , test_error_hook),
359
- #ifndef MBED_CONF_ERROR_LOG_DISABLED
351
+ #ifndef MBED_CONF_ERROR_HIST_DISABLED
360
352
Case (" Test error logging" , test_error_logging),
361
353
Case (" Test error handling multi-threaded" , test_error_logging_multithread),
362
354
#ifdef MBED_TEST_SIM_BLOCKDEVICE
0 commit comments