@needs_dlfcn
def test_dlfcn_info(self):
    self.prep_dlfcn_lib()
    lib_src = '\n      #include <stdio.h>\n\n      int myfunc(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m) {\n        return 13;\n      }\n      '
    self.set_setting('EXPORTED_FUNCTIONS', ['_myfunc'])
    dirname = self.get_dir()
    filename = os.path.join(dirname, 'liblib.c')
    self.build_dlfcn_lib(lib_src, dirname, filename)
    self.prep_dlfcn_main()
    src = '\n      #include <assert.h>\n      #include <stdio.h>\n      #include <string.h>\n      #include <dlfcn.h>\n\n      typedef int (*FUNCTYPE)(int, int, int, int, int, int, int, int, int, int, int, int, int);\n\n      int main() {\n        void *lib_handle;\n        FUNCTYPE func_ptr;\n\n        lib_handle = dlopen("liblib.so", RTLD_NOW);\n        assert(lib_handle != NULL);\n\n        func_ptr = (FUNCTYPE)dlsym(lib_handle, "myfunc");\n        assert(func_ptr != NULL);\n        assert(func_ptr(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) == 13);\n\n        /* Verify that we don\'t corrupt func_ptr when calling dladdr.  */\n        Dl_info info;\n        memset(&info, 0, sizeof(info));\n        dladdr(func_ptr, &info);\n\n        assert(func_ptr != NULL);\n        assert(func_ptr(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) == 13);\n\n        /* Verify something useful lives in info.  */\n        assert(info.dli_fname != NULL);\n        assert(info.dli_fbase == NULL);\n        assert(info.dli_sname == NULL);\n        assert(info.dli_saddr == NULL);\n\n        puts("success");\n\n        return 0;\n      }\n      '
    self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc'])
    self.do_run(src, 'success', force_c=True)
@needs_dlfcn
def test_dlfcn_info(self):
    self.prep_dlfcn_lib()
    lib_src = '\n      #include <stdio.h>\n\n      int myfunc(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m) {\n        return 13;\n      }\n      '
    self.set_setting('EXPORTED_FUNCTIONS', ['_myfunc'])
    dirname = self.get_dir()
    filename = os.path.join(dirname, 'liblib.c')
    self.build_dlfcn_lib(lib_src, dirname, filename)
    self.prep_dlfcn_main()
    src = '\n      #include <assert.h>\n      #include <stdio.h>\n      #include <string.h>\n      #include <dlfcn.h>\n\n      typedef int (*FUNCTYPE)(int, int, int, int, int, int, int, int, int, int, int, int, int);\n\n      int main() {\n        void *lib_handle;\n        FUNCTYPE func_ptr;\n\n        lib_handle = dlopen("liblib.so", RTLD_NOW);\n        assert(lib_handle != NULL);\n\n        func_ptr = (FUNCTYPE)dlsym(lib_handle, "myfunc");\n        assert(func_ptr != NULL);\n        assert(func_ptr(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) == 13);\n\n        /* Verify that we don\'t corrupt func_ptr when calling dladdr.  */\n        Dl_info info;\n        memset(&info, 0, sizeof(info));\n        dladdr(func_ptr, &info);\n\n        assert(func_ptr != NULL);\n        assert(func_ptr(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) == 13);\n\n        /* Verify something useful lives in info.  */\n        assert(info.dli_fname != NULL);\n        assert(info.dli_fbase == NULL);\n        assert(info.dli_sname == NULL);\n        assert(info.dli_saddr == NULL);\n\n        puts("success");\n\n        return 0;\n      }\n      '
    self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc'])
    self.do_run(src, 'success', force_c=True)