Skip to content

Commit df1d9f5

Browse files
niklarm0xc0170
authored andcommitted
Extend scheduler with init and run callbacks.
1 parent 6e85376 commit df1d9f5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

frameworks\utest/utest/scheduler.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ extern "C" {
3333
*/
3434
typedef void (*utest_v1_harness_callback_t)(void);
3535

36+
/**
37+
* utest calls this function before running the test specification.
38+
* Use this function to initialize your scheduler before the first callback is requested.
39+
*
40+
* @retval `0` if success
41+
* @retval non-zero if failure
42+
*/
43+
typedef int32_t (*utest_v1_scheduler_init_callback_t)(void);
44+
3645
/**
3746
* utest calls this function when it needs to schedule a callback with a delay in milliseconds.
3847
* `delay_ms` will only be non-zero if an asynchronous test case exists in the test specification.
@@ -66,13 +75,25 @@ typedef void *(*utest_v1_scheduler_post_callback_t)(const utest_v1_harness_callb
6675
*/
6776
typedef int32_t (*utest_v1_scheduler_cancel_callback_t)(void *handle);
6877

78+
/**
79+
* utest calls this function at the end of the `Harness::run()` function, after (!) the first callback has been requested.
80+
* This function is meant to implement an optional event loop, which may very well be blocking (if your scheduler works with that).
81+
* This assumes that `Harness::run()` will be called on the main stack (ie. not in an interrupt!).
82+
*
83+
* @retval `0` if success
84+
* @retval non-zero if failure
85+
*/
86+
typedef int32_t (*utest_v1_scheduler_run_callback_t)(void);
87+
6988
/**
7089
* The scheduler interface consists out of the `post` and `cancel` functions,
7190
* which you must implement to use `utest`.
7291
*/
7392
typedef struct {
93+
utest_v1_scheduler_init_callback_t init;
7494
utest_v1_scheduler_post_callback_t post;
7595
utest_v1_scheduler_cancel_callback_t cancel;
96+
utest_v1_scheduler_run_callback_t run;
7697
} utest_v1_scheduler_t;
7798

7899
#ifdef __cplusplus

0 commit comments

Comments
 (0)