@needs_dlfcn
def zzztest_dlfcn_exceptions(self):
    self.set_setting('DISABLE_EXCEPTION_CATCHING', 0)
    self.prep_dlfcn_lib()
    lib_src = '\n      extern "C" {\n      int ok() {\n        return 65;\n      }\n      int fail() {\n        throw 123;\n      }\n      }\n      '
    self.set_setting('EXPORTED_FUNCTIONS', ['_ok', '_fail'])
    dirname = self.get_dir()
    filename = os.path.join(dirname, 'liblib.cpp')
    self.build_dlfcn_lib(lib_src, dirname, filename)
    self.prep_dlfcn_main()
    src = '\n      #include <assert.h>\n      #include <stdio.h>\n      #include <dlfcn.h>\n\n      typedef int (*intfunc)();\n\n      int main() {\n        printf("go!\\n");\n\n        void *lib_handle;\n        lib_handle = dlopen("liblib.so", RTLD_NOW);\n        assert(lib_handle != NULL);\n\n        intfunc okk = (intfunc)dlsym(lib_handle, "ok");\n        intfunc faill = (intfunc)dlsym(lib_handle, "fail");\n        assert(okk && faill);\n\n        try {\n          printf("ok: %d\\n", okk());\n        } catch(...) {\n          printf("wha\\n");\n        }\n\n        try {\n          printf("fail: %d\\n", faill());\n        } catch(int x) {\n          printf("int %d\\n", x);\n        }\n\n        try {\n          printf("fail: %d\\n", faill());\n        } catch(double x) {\n          printf("caught %f\\n", x);\n        }\n\n        return 0;\n      }\n      '
    self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc', '_free'])
    self.do_run(src, 'go!\nok: 65\nint 123\nok\n')
@needs_dlfcn
def zzztest_dlfcn_exceptions(self):
    self.set_setting('DISABLE_EXCEPTION_CATCHING', 0)
    self.prep_dlfcn_lib()
    lib_src = '\n      extern "C" {\n      int ok() {\n        return 65;\n      }\n      int fail() {\n        throw 123;\n      }\n      }\n      '
    self.set_setting('EXPORTED_FUNCTIONS', ['_ok', '_fail'])
    dirname = self.get_dir()
    filename = os.path.join(dirname, 'liblib.cpp')
    self.build_dlfcn_lib(lib_src, dirname, filename)
    self.prep_dlfcn_main()
    src = '\n      #include <assert.h>\n      #include <stdio.h>\n      #include <dlfcn.h>\n\n      typedef int (*intfunc)();\n\n      int main() {\n        printf("go!\\n");\n\n        void *lib_handle;\n        lib_handle = dlopen("liblib.so", RTLD_NOW);\n        assert(lib_handle != NULL);\n\n        intfunc okk = (intfunc)dlsym(lib_handle, "ok");\n        intfunc faill = (intfunc)dlsym(lib_handle, "fail");\n        assert(okk && faill);\n\n        try {\n          printf("ok: %d\\n", okk());\n        } catch(...) {\n          printf("wha\\n");\n        }\n\n        try {\n          printf("fail: %d\\n", faill());\n        } catch(int x) {\n          printf("int %d\\n", x);\n        }\n\n        try {\n          printf("fail: %d\\n", faill());\n        } catch(double x) {\n          printf("caught %f\\n", x);\n        }\n\n        return 0;\n      }\n      '
    self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc', '_free'])
    self.do_run(src, 'go!\nok: 65\nint 123\nok\n')