8000 unix/coverage: Add coverage test for mp_sched_schedule_node. · micropython/micropython@2a6bb79 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2a6bb79

Browse files
committed
unix/coverage: Add coverage test for mp_sched_schedule_node.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
1 parent bee1fd5 commit 2a6bb79

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

ports/unix/coverage.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,17 @@ static void pairheap_test(size_t nops, int *ops) {
184184
mp_printf(&mp_plat_print, "\n");
185185
}
186186

187+
static mp_sched_node_t mp_coverage_sched_node;
188+
189+
static void coverage_sched_function(mp_sched_node_t *node) {
190+
(void)node;
191+
static mp_uint_t loop = 3;
192+
mp_printf(&mp_plat_print, "scheduled function\n");
193+
if (--loop) {
194+
mp_sched_schedule_node(&mp_coverage_sched_node, coverage_sched_function);
195+
}
196+
}
197+
187198
// function to run extra tests for things that can't be checked by scripts
188199
static mp_obj_t extra_coverage(void) {
189200
// mp_printf (used by ports that don't have a native printf)
@@ -621,6 +632,12 @@ static mp_obj_t extra_coverage(void) {
621632
mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val));
622633
}
623634
mp_handle_pending(true);
635+
636+
mp_sched_schedule_node(&mp_coverage_sched_node, coverage_sched_function);
637+
for (int i = 0; i <= 3; ++i) {
638+
mp_printf(&mp_plat_print, "loop\n");
639+
mp_handle_pending(true);
640+
}
624641
}
625642

626643
// ringbuf

ports/unix/variants/coverage/mpconfigvariant.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#undef MICROPY_VFS_ROM_IOCTL
4545
#define MICROPY_VFS_ROM_IOCTL (1)
4646
#define MICROPY_PY_CRYPTOLIB_CTR (1)
47+
#define MICROPY_SCHEDULER_STATIC_NODES (1)
4748

4849
// Enable os.uname for attrtuple coverage test
4950
#define MICROPY_PY_OS_UNAME (1)

tests/ports/unix/extra_coverage.py.exp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ unlocked
122122
KeyboardInterrupt:
123123
KeyboardInterrupt:
124124
10
125+
loop
126+
scheduled function
127+
loop
128+
scheduled function
129+
loop
130+
scheduled function
131+
loop
125132
# ringbuf
126133
99 0
127134
98 1

0 commit comments

Comments
 (0)
0