@needs_dlfcn
def test_dylink_global_inits(self):

    def test():
        self.dylink_test(header='\n        #include <stdio.h>\n        struct Class {\n          Class(const char *name) { printf("new %s\\n", name); }\n        };\n      ', main='\n        #include "header.h"\n        static Class c("main");\n        int main() {\n          return 0;\n        }\n      ', side='\n        #include "header.h"\n        static Class c("side");\n      ', expected=['new main\nnew side\n', 'new side\nnew main\n'])
    test()
    if ((self.get_setting('ASSERTIONS') == 1) and (not self.is_wasm())):
        print('check warnings')
        self.set_setting('ASSERTIONS', 2)
        test()
        full = run_js('src.cpp.o.js', engine=JS_ENGINES[0], full_output=True, stderr=STDOUT)
        self.assertNotContained("trying to dynamically load symbol '__ZN5ClassC2EPKc' (from 'liblib.so') that already exists", full)
@needs_dlfcn
def test_dylink_global_inits(self):

    def test():
        self.dylink_test(header='\n        #include <stdio.h>\n        struct Class {\n          Class(const char *name) { printf("new %s\\n", name); }\n        };\n      ', main='\n        #include "header.h"\n        static Class c("main");\n        int main() {\n          return 0;\n        }\n      ', side='\n        #include "header.h"\n        static Class c("side");\n      ', expected=['new main\nnew side\n', 'new side\nnew main\n'])
    test()
    if ((self.get_setting('ASSERTIONS') == 1) and (not self.is_wasm())):
        print('check warnings')
        self.set_setting('ASSERTIONS', 2)
        test()
        full = run_js('src.cpp.o.js', engine=JS_ENGINES[0], full_output=True, stderr=STDOUT)
        self.assertNotContained("trying to dynamically load symbol '__ZN5ClassC2EPKc' (from 'liblib.so') that already exists", full)