MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / test_dlfcn_longjmp

Method test_dlfcn_longjmp

test/test_core.py:3603–3658  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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 ''&#x27;)
3615 self.build_dlfcn_lib('libside.c')
3616
3617 self.prep_dlfcn_main()
3618 create_file('main.c', r''&#x27;
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 ''&#x27;)
3647 self.do_runf('main.c', ''&#x27;go!
3648pre 1
3649pre 2
3650pre 3
3651pre 4
3652pre 5
3653pre 6
3654pre 7
3655pre 8
3656pre 9
3657out!
3658''&#x27;)
3659
3660 @needs_dylink

Callers

nothing calls this directly

Calls 4

build_dlfcn_libMethod · 0.95
prep_dlfcn_mainMethod · 0.95
create_fileFunction · 0.90
do_runfMethod · 0.80

Tested by

no test coverage detected