(self)
| 3601 | |
| 3602 | @needs_dylink |
| 3603 | def test_dlfcn_longjmp(self): |
| 3604 | create_file('libside.c', r''' |
| 3605 | #include <setjmp.h> |
| 3606 | #include <stdio.h> |
| 3607 | |
| 3608 | void jumpy(jmp_buf buf) { |
| 3609 | static int i = 0; |
| 3610 | i++; |
| 3611 | if (i == 10) longjmp(buf, i); |
| 3612 | printf("pre %d\n", i); |
| 3613 | } |
| 3614 | ''') |
| 3615 | self.build_dlfcn_lib('libside.c') |
| 3616 | |
| 3617 | self.prep_dlfcn_main() |
| 3618 | create_file('main.c', r''' |
| 3619 | #include <assert.h> |
| 3620 | #include <stdio.h> |
| 3621 | #include <dlfcn.h> |
| 3622 | #include <setjmp.h> |
| 3623 | |
| 3624 | typedef void (*jumpfunc)(jmp_buf); |
| 3625 | |
| 3626 | int main() { |
| 3627 | printf("go!\n"); |
| 3628 | |
| 3629 | void *lib_handle; |
| 3630 | lib_handle = dlopen("libside.so", RTLD_NOW); |
| 3631 | assert(lib_handle != NULL); |
| 3632 | |
| 3633 | jumpfunc jumpy = (jumpfunc)dlsym(lib_handle, "jumpy"); |
| 3634 | assert(jumpy); |
| 3635 | |
| 3636 | jmp_buf buf; |
| 3637 | int jmpval = setjmp(buf); |
| 3638 | if (jmpval == 0) { |
| 3639 | while (1) jumpy(buf); |
| 3640 | } else { |
| 3641 | printf("out!\n"); |
| 3642 | } |
| 3643 | |
| 3644 | return 0; |
| 3645 | } |
| 3646 | ''') |
| 3647 | self.do_runf('main.c', '''go! |
| 3648 | pre 1 |
| 3649 | pre 2 |
| 3650 | pre 3 |
| 3651 | pre 4 |
| 3652 | pre 5 |
| 3653 | pre 6 |
| 3654 | pre 7 |
| 3655 | pre 8 |
| 3656 | pre 9 |
| 3657 | out! |
| 3658 | ''') |
| 3659 | |
| 3660 | @needs_dylink |
nothing calls this directly
no test coverage detected