diff options
| author | Angus Gratton <angus@redyak.com.au> | 2024-08-13 16:12:25 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-08-14 12:57:27 +1000 |
| commit | a6fa85d8f96897863546423b2bbfc2c24237040f (patch) | |
| tree | 9be6b5d4f9076e02b5fd64678298f0c9a6c68e0e /ports/unix/coverage.c | |
| parent | fbc19596f052016dee10a6af56441f4fb532243c (diff) | |
unix: Switch stack limit check to new cstack API.
Necessary to pass CI when testing the V2 preview APIs.
Also adds an extra coverage test for the legacy stackctrl API, to maintain
coverage and check for any regression.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Diffstat (limited to 'ports/unix/coverage.c')
| -rw-r--r-- | ports/unix/coverage.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c index 99a6d8c8c..67052ea70 100644 --- a/ports/unix/coverage.c +++ b/ports/unix/coverage.c @@ -7,6 +7,7 @@ #include "py/objint.h" #include "py/objstr.h" #include "py/runtime.h" +#include "py/stackctrl.h" #include "py/gc.h" #include "py/repl.h" #include "py/mpz.h" @@ -739,6 +740,32 @@ static mp_obj_t extra_coverage(void) { mp_printf(&mp_plat_print, "%d %d\n", mp_obj_is_int(MP_OBJ_NEW_SMALL_INT(1)), mp_obj_is_int(mp_obj_new_int_from_ll(1))); } + // Legacy stackctrl.h API, this has been replaced by cstack.h + { + mp_printf(&mp_plat_print, "# stackctrl\n"); + char *old_stack_top = MP_STATE_THREAD(stack_top); + size_t old_stack_limit = 0; + size_t new_stack_limit = SIZE_MAX; + #if MICROPY_STACK_CHECK + old_stack_limit = MP_STATE_THREAD(stack_limit); + MP_STACK_CHECK(); + #endif + + mp_stack_ctrl_init(); // Will set stack top incorrectly + mp_stack_set_top(old_stack_top); // ... and restore it + + #if MICROPY_STACK_CHECK + mp_stack_set_limit(MP_STATE_THREAD(stack_limit)); + MP_STACK_CHECK(); + new_stack_limit = MP_STATE_THREAD(stack_limit); + #endif + + // Nothing should have changed + mp_printf(&mp_plat_print, "%d %d\n", + old_stack_top == MP_STATE_THREAD(stack_top), + MICROPY_STACK_CHECK == 0 || old_stack_limit == new_stack_limit); + } + mp_printf(&mp_plat_print, "# end coverage.c\n"); mp_obj_streamtest_t *s = mp_obj_malloc(mp_obj_streamtest_t, &mp_type_stest_fileio); |
