Skip to content

Commit f130663

Browse files
authored
Cleanup test_offset_converter. NFC (#23098)
- Using zero return code for success. - Run test both with and without pthreads.
1 parent 44dc320 commit f130663

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

test/browser/test_offset_converter.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1+
#include <assert.h>
12
#include <stdio.h>
23
#include <emscripten.h>
34

4-
void *get_pc(void) { return __builtin_return_address(0); }
5+
void *get_pc(void) {
6+
return __builtin_return_address(0);
7+
}
58

6-
int magic_test_function(void) {
9+
void magic_test_function(void) {
710
int result = EM_ASM_INT({
811
function report(x) {
9-
fetch(encodeURI('http://localhost:8888?stdout=' + x));
12+
out(x);
13+
fetch('http://localhost:8888?stdout=' + encodeURIComponent(x));
1014
}
1115
report('magic_test_function: input=' + $0);
1216
var converted = wasmOffsetConverter.getName($0);
1317
report('magic_test_function: converted=' + converted);
1418
return converted == 'magic_test_function';
1519
}, get_pc());
16-
return result;
20+
assert(result);
1721
}
1822

1923
int main(void) {
20-
return magic_test_function();
24+
magic_test_function();
25+
return 0;
2126
}

test/test_browser.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4948,8 +4948,12 @@ def test_minimal_runtime_loader_shell(self, args):
49484948
def test_minimal_runtime_hello_world(self, args):
49494949
self.btest_exit('small_hello_world.c', args=args + ['-sMINIMAL_RUNTIME'])
49504950

4951-
def test_offset_converter(self, *args):
4952-
self.btest_exit('test_offset_converter.c', assert_returncode=1, args=['-sUSE_OFFSET_CONVERTER', '-gsource-map', '-sPROXY_TO_PTHREAD', '-pthread'])
4951+
@parameterized({
4952+
'': ([],),
4953+
'pthread': (['-sPROXY_TO_PTHREAD', '-pthread'],)
4954+
})
4955+
def test_offset_converter(self, args):
4956+
self.btest_exit('test_offset_converter.c', args=['-sUSE_OFFSET_CONVERTER', '-gsource-map'] + args)
49534957

49544958
# Tests emscripten_unwind_to_js_event_loop() behavior
49554959
def test_emscripten_unwind_to_js_event_loop(self, *args):

0 commit comments

Comments
 (0)