Skip to content

Commit 8ddbac2

Browse files
authored
Support multiple extensions in lld test generation (WebAssembly#1417)
1 parent 1f8fd30 commit 8ddbac2

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

auto_update_tests.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,35 @@
7676

7777
print '\n[ checking wasm-link-metadata testcases... ]\n'
7878

79+
link_metadata_extension_arg_map = {
80+
'.json': [],
81+
'.jscall.json': ['--emscripten-reserved-function-pointers=3'],
82+
}
7983
for obj_path in files_with_pattern('test', 'lld', '*.o'):
8084
print '..', obj_path
81-
json_path = obj_path.replace('.o', '.json')
82-
83-
cmd = WASM_LINK_METADATA + [obj_path]
84-
actual = run_command(cmd)
85-
with open(json_path, 'w') as o: o.write(actual)
85+
for ext, ext_args in link_metadata_extension_arg_map.items():
86+
json_path = obj_path.replace('.o', ext)
87+
if ext != 'json' and not os.path.exists(json_path):
88+
continue
89+
cmd = WASM_LINK_METADATA + [obj_path] + ext_args
90+
actual = run_command(cmd)
91+
with open(json_path, 'w') as o: o.write(actual)
8692

8793
print '\n[ checking wasm-emscripten-finalize testcases... ]\n'
8894

95+
emscripten_finalize_extension_arg_map = {
96+
'.out': [],
97+
'.jscall.out': ['--emscripten-reserved-function-pointers=3'],
98+
}
8999
for wast_path in files_with_pattern('test', 'lld', '*.wast'):
90100
print '..', wast_path
91-
out_path = wast_path + '.out'
92-
cmd = WASM_EMSCRIPTEN_FINALIZE + [wast_path, '-S']
93-
actual = run_command(cmd)
94-
with open(out_path, 'w') as o: o.write(actual)
101+
for ext, ext_args in emscripten_finalize_extension_arg_map.items():
102+
out_path = wast_path + ext
103+
if ext != '.out' and not os.path.exists(out_path):
104+
continue
105+
cmd = WASM_EMSCRIPTEN_FINALIZE + [wast_path, '-S'] + ext_args
106+
actual = run_command(cmd)
107+
with open(out_path, 'w') as o: o.write(actual)
95108

96109
for t in sorted(os.listdir(os.path.join('test', 'print'))):
97110
if t.endswith('.wast'):

0 commit comments

Comments
 (0)