|
17 | 17 | #define HEAP_SIZE (128 * 1024) |
18 | 18 | STATIC void *heap; |
19 | 19 |
|
20 | | -void do_str(const char *src); |
21 | | -inline void do_str(const char *src) { |
22 | | - gc_init(heap, (char*)heap + HEAP_SIZE); |
23 | | - mp_init(); |
24 | | - |
25 | | - nlr_buf_t nlr; |
26 | | - if (nlr_push(&nlr) == 0) { |
27 | | - mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0); |
28 | | - qstr source_name = lex->source_name; |
29 | | - mp_parse_tree_t parse_tree = mp_parse(lex, MP_PARSE_FILE_INPUT); |
30 | | - mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, false); |
31 | | - mp_call_function_0(module_fun); |
32 | | - nlr_pop(); |
33 | | - } else { |
34 | | - mp_obj_t exc = (mp_obj_t)nlr.ret_val; |
35 | | - if (mp_obj_is_subclass_fast(mp_obj_get_type(exc), &mp_type_SystemExit)) { |
36 | | - // Assume that sys.exit() is called to skip the test. |
37 | | - // TODO: That can be always true, we should set up convention to |
38 | | - // use specific exit code as skip indicator. |
39 | | - tinytest_set_test_skipped_(); |
40 | | - goto end; |
41 | | - } |
42 | | - mp_obj_print_exception(&mp_plat_print, exc); |
43 | | - tt_abort_msg("Uncaught exception"); |
44 | | - } |
45 | | -end: |
46 | | - mp_deinit(); |
47 | | -} |
48 | | - |
49 | 20 | #include "genhdr/tests.h" |
50 | 21 |
|
51 | 22 | int main() { |
52 | 23 | mp_stack_ctrl_init(); |
53 | 24 | mp_stack_set_limit(10240); |
54 | 25 | heap = malloc(HEAP_SIZE); |
| 26 | + upytest_set_heap(heap, (char*)heap + HEAP_SIZE); |
55 | 27 | int r = tinytest_main(0, NULL, groups); |
56 | 28 | printf("status: %d\n", r); |
57 | 29 | return r; |
|
0 commit comments