Skip to content

Commit

Permalink
Add test_dylink_function_pointer_equality test (emscripten-core#8330)
Browse files Browse the repository at this point in the history
This test currently is currently expected to fail, until we fix
this issue;

See emscripten-core#8268.
  • Loading branch information
sbc100 authored and VirtualTim committed May 21, 2019
1 parent c184ae3 commit 3715670
Showing 1 changed file with 51 additions and 17 deletions.
68 changes: 51 additions & 17 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3206,7 +3206,6 @@ def dylink_test(self, main, side, expected, header=None, main_emcc_args=[], forc
# side settings
self.clear_setting('MAIN_MODULE')
self.set_setting('SIDE_MODULE')
print(self.is_wasm())
side_suffix = 'wasm' if self.is_wasm() else 'js'
if isinstance(side, list):
# side is just a library
Expand Down Expand Up @@ -3246,25 +3245,60 @@ def dylink_test(self, main, side, expected, header=None, main_emcc_args=[], forc
print('flip')
self.dylink_test(side, main, expected, header, main_emcc_args, force_c, need_reverse=False)

def do_basic_dylink_test(self):
self.dylink_test(r'''
#include <stdio.h>
#include "header.h"
int main() {
printf("other says %d.\n", sidey());
return 0;
}
''', '''
#include "header.h"
int sidey() {
return 11;
}
''', 'other says 11.', 'extern "C" int sidey();')

@needs_dlfcn
def test_dylink_basics(self):
def test():
self.dylink_test('''
#include <stdio.h>
extern "C" int sidey();
int main() {
printf("other says %d.\\n", sidey());
return 0;
}
''', '''
extern "C" int sidey() { return 11; }
''', 'other says 11.')
test()
self.do_basic_dylink_test()

if self.is_wasm():
print('test memory growth with dynamic linking, which works in wasm')
self.set_setting('ALLOW_MEMORY_GROWTH', 1)
test()
@needs_dlfcn
def test_dylink_memory_growth(self):
if not self.is_wasm():
self.skipTest('wasm only')
self.set_setting('ALLOW_MEMORY_GROWTH', 1)
self.do_basic_dylink_test()

@needs_dlfcn
def test_dylink_function_pointer_equality(self):
# TODO(sbc): This is currently a known failure.
# See https://github.com/emscripten-core/emscripten/issues/8268
self.dylink_test(r'''
#include <stdio.h>
#include "header.h"
int main() {
void* puts_side = get_address();
printf("main module address %p.\n", &puts);
printf("side module address address %p.\n", puts_side);
if (&puts == puts_side)
printf("success\n");
else
printf("failure\n");
return 0;
}
''', '''
#include <stdio.h>
#include "header.h"
void* get_address() {
return (void*)&puts;
}
''', 'failure', header='extern "C" void* get_address();')

@needs_dlfcn
def test_dylink_floats(self):
Expand Down

0 comments on commit 3715670

Please sign in to comment.