File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ ut_luos_assert_t ut_assert = {.state = 0, .enable = 1};
19
19
uint16_t test_case_number ;
20
20
uint16_t step_number ;
21
21
22
+ // external error context
23
+ jmp_buf err_ctx ;
24
+ bool try_state = false;
25
+
22
26
/*******************************************************************************
23
27
* Function
24
28
******************************************************************************/
@@ -192,6 +196,12 @@ void UNIT_TEST_ASSERT(char *file, uint32_t line)
192
196
memcpy (msg .data , & line , sizeof (line ));
193
197
memcpy (& msg .data [sizeof (line )], file , strlen (file ));
194
198
ut_assert .msg = msg ;
199
+ // This is the THROW of the TRY CATCH
200
+ if (try_state )
201
+ {
202
+ _LONGJMP (err_ctx , 1 );
203
+ try_state = false;
204
+ }
195
205
}
196
206
197
207
void setUp (void )
Original file line number Diff line number Diff line change 13
13
#include " luos_engine.h"
14
14
#include " luos_utils.h"
15
15
#include " robus_struct.h"
16
+ #include < setjmp.h>
16
17
17
18
/* ******************************************************************************
18
19
* Definitions
19
20
******************************************************************************/
21
+ #ifdef _WIN32
22
+ #define _SETJMP __builtin_setjmp
23
+ #define _LONGJMP __builtin_longjmp
24
+ #else
25
+ #define _SETJMP setjmp
26
+ #define _LONGJMP longjmp
27
+ #endif
28
+
29
+ extern jmp_buf err_ctx;
30
+ extern bool try_state;
31
+
20
32
#ifndef UNIT_TEST_RUN
21
33
#define UNIT_TEST_RUN (f ) RUN(#f, f)
22
34
#endif
@@ -32,6 +44,12 @@ typedef struct
32
44
msg_t msg;
33
45
} ut_luos_assert_t ;
34
46
47
+ #define TRY \
48
+ try_state = true ; \
49
+ if (!_SETJMP(err_ctx))
50
+
51
+ #define CATCH else
52
+
35
53
/* ******************************************************************************
36
54
* Function
37
55
******************************************************************************/
You can’t perform that action at this time.
0 commit comments