8000 tests/unix: Add coverage tests for kbd-intr and scheduler. · jeremyherbert/micropython@eaf30c5 · GitHub
[go: up one dir, main page]

Skip to content

Commit eaf30c5

Browse files
committed
tests/unix: Add coverage tests for kbd-intr and scheduler.
1 parent 9efb36b commit eaf30c5

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

ports/unix/coverage.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,32 @@ STATIC mp_obj_t extra_coverage(void) {
476476
while (mp_sched_num_pending()) {
477477
mp_handle_pending(true);
478478
}
479+
480+
// setting the keyboard interrupt and raising it during mp_handle_pending
481+
mp_keyboard_interrupt();
482+
nlr_buf_t nlr;
483+
if (nlr_push(&nlr) == 0) {
484+
mp_handle_pending(true);
485+
nlr_pop();
486+
} else {
487+
mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val));
488+
}
489+
490+
// setting the keyboard interrupt (twice) and cancelling it during mp_handle_pending
491+
mp_keyboard_interrupt();
492+
mp_keyboard_interrupt();
493+
mp_handle_pending(false);
494+
495+
// setting keyboard interrupt and a pending event (intr should be handled first)
496+
mp_sched_schedule(MP_OBJ_FROM_PTR(&mp_builtin_print_obj), MP_OBJ_NEW_SMALL_INT(10));
497+
mp_keyboard_interrupt();
498+
if (nlr_push(&nlr) == 0) {
499+
mp_handle_pending(true);
500+
nlr_pop();
501+
} else {
502+
mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val));
503+
}
504+
mp_handle_pending(true);
479505
}
480506

481507
// ringbuf

tests/unix/extra_coverage.py.exp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ unlocked
8080
1
8181
2
8282
3
83+
KeyboardInterrupt:
84+
KeyboardInterrupt:
85+
10
8386
# ringbuf
8487
99 0
8588
98 1

0 commit comments

Comments
 (0)
0