@@ -2216,14 +2216,17 @@ def test_dylink_pthread_static_data(self):
22162216      int* get_address();
22172217
22182218      void* thread_main(void* arg) {
2219-         assert(*get_address() == 123);
2220-         printf("%d\n", *get_address());
2219+         int* addr = get_address();
2220+         printf("thread_main: %p, %d\n", addr, *addr);
2221+         assert(*addr == 123);
22212222        return NULL;
22222223      }
22232224
22242225      int main() {
2225-         assert(*get_address() == 42);
2226-         *get_address() = 123;
2226+         int* addr = get_address();
2227+         printf("in main: %p, %d\n", addr, *addr);
2228+         assert(*addr == 42);
2229+         *addr = 123;
22272230        pthread_t t;
22282231        pthread_create(&t, NULL, thread_main, NULL);
22292232        pthread_join(t, NULL);
@@ -2232,10 +2235,10 @@ def test_dylink_pthread_static_data(self):
22322235      ''')
22332236
22342237    self.do_runf('main.c', '123', cflags=['-pthread', '-Wno-experimental',
2235-                                               '-sPROXY_TO_PTHREAD',
2236-                                               '-sEXIT_RUNTIME',
2237-                                               '-sMAIN_MODULE=2',
2238-                                               'side.wasm'])
2238+                                           '-sPROXY_TO_PTHREAD',
2239+                                           '-sEXIT_RUNTIME',
2240+                                           '-sMAIN_MODULE=2',
2241+                                           'side.wasm'])
22392242
22402243  def test_dylink_pthread_warning(self):
22412244    err = self.expect_fail([EMCC, '-Werror', '-sMAIN_MODULE', '-pthread', test_file('hello_world.c')])
@@ -5102,7 +5105,15 @@ def test_bitcode_linking(self):
51025105    'wasm2js': (False, False),
51035106    'wasm2js_safe_heap': (False, True),
51045107  })
5105-   def test_bad_function_pointer_cast(self, opts, wasm, safe):
5108+   @parameterized({
5109+     '': (False,),
5110+     'emulate_casts': (True,),
5111+   })
5112+   @parameterized({
5113+     '': (False,),
5114+     'dylink': (True,),
5115+   })
5116+   def test_bad_function_pointer_cast(self, opts, wasm, safe, emulate_casts, dylink):
51065117    create_file('src.cpp', r'''
51075118#include <stdio.h>
51085119
@@ -5120,31 +5131,28 @@ def test_bad_function_pointer_cast(self, opts, wasm, safe):
51205131}
51215132''')
51225133
5123-     for emulate_casts in (0, 1):
5124-       for dylink in (0, 1):
5125-         # wasm2js is not compatible with dynamic linking
5126-         if dylink and not wasm:
5127-           continue
5128-         cmd = [EMXX, 'src.cpp'] + opts
5129-         if not wasm:
5130-           cmd += ['-sWASM=0']
5131-         if safe:
5132-           cmd += ['-sSAFE_HEAP']
5133-         if emulate_casts:
5134-           cmd += ['-sEMULATE_FUNCTION_POINTER_CASTS']
5135-         if dylink:
5136-           cmd += ['-sMAIN_MODULE=2'] # disables asm-optimized safe heap
5137-         print(cmd)
5138-         self.run_process(cmd)
5139-         returncode = 0 if emulate_casts or not wasm else NON_ZERO
5140-         output = self.run_js('a.out.js', assert_returncode=returncode)
5141-         if emulate_casts or wasm == 0:
5142-           # success!
5143-           self.assertContained('Hello, world.', output)
5144-         else:
5145-           # otherwise, the error depends on the mode we are in
5146-           # wasm trap raised by the vm
5147-           self.assertContained('function signature mismatch', output)
5134+     # wasm2js is not compatible with dylink mode
5135+     if not wasm and dylink:
5136+       self.skipTest("wasm2js + dylink")
5137+     cmd = [EMXX, 'src.cpp'] + opts
5138+     if not wasm:
5139+       cmd += ['-sWASM=0']
5140+     if safe:
5141+       cmd += ['-sSAFE_HEAP']
5142+     if emulate_casts:
5143+       cmd += ['-sEMULATE_FUNCTION_POINTER_CASTS']
5144+     if dylink:
5145+       cmd += ['-sMAIN_MODULE=2'] # disables asm-optimized safe heap
5146+     self.run_process(cmd)
5147+     returncode = 0 if emulate_casts or not wasm else NON_ZERO
5148+     output = self.run_js('a.out.js', assert_returncode=returncode)
5149+     if emulate_casts or wasm == 0:
5150+       # success!
5151+       self.assertContained('Hello, world.', output)
5152+     else:
5153+       # otherwise, the error depends on the mode we are in
5154+       # wasm trap raised by the vm
5155+       self.assertContained('function signature mismatch', output)
51485156
51495157  def test_bad_export(self):
51505158    for exports in ('_main', '_main,foo'):
0 commit comments