test_gen: reorder import names in wasm_linking test

This commit is contained in:
Brian Carroll 2022-12-11 11:56:26 +00:00
parent 3d5edf57fc
commit adc213b364
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0

View file

@ -234,6 +234,12 @@ fn execute_wasm_module<'a>(arena: &'a Bump, orig_module: WasmModule<'a>) -> Resu
// But I want to use main so that I can test that _start is created for it! // But I want to use main so that I can test that _start is created for it!
// So return void from main, and call another function to get the result. // So return void from main, and call another function to get the result.
inst.call_export(&module, "_start", [])?; inst.call_export(&module, "_start", [])?;
// FIXME: read_host_result does not actually appear as an export!
// The interpreter has to look it up in debug info! (Apparently Wasm3 did this!)
// If we change gen_wasm to export it, then it does the same for js_unused,
// so we can't test import elimination and function reordering.
// We should to come back to this and fix it.
inst.call_export(&module, "read_host_result", [])? inst.call_export(&module, "read_host_result", [])?
.ok_or(String::from("expected a return value"))? .ok_or(String::from("expected a return value"))?
.expect_i32() .expect_i32()
@ -344,17 +350,17 @@ fn test_linking_without_dce() {
fn test_linking_with_dce() { fn test_linking_with_dce() {
let expected_final_import_names = &[ let expected_final_import_names = &[
"js_called_indirectly_from_roc", "js_called_indirectly_from_roc",
"js_called_indirectly_from_main", // "js_unused", // eliminated
// js_unused removed from imports
"js_called_directly_from_roc", "js_called_directly_from_roc",
"js_called_directly_from_main", "js_called_directly_from_main",
"js_called_indirectly_from_main",
]; ];
let expected_name_section_start = &[ let expected_name_section_start = &[
(0, "js_called_indirectly_from_roc"), (0, "js_called_indirectly_from_roc"),
(1, "js_called_indirectly_from_main"), (1, "js_called_directly_from_roc"), // index changed
(2, "js_called_directly_from_roc"), // index changed (2, "js_called_directly_from_main"), // index changed
(3, "js_called_directly_from_main"), // index changed (3, "js_called_indirectly_from_main"), // index changed
(4, "js_unused"), // still exists, but now an internal dummy, with index changed (4, "js_unused"), // still exists, but now an internal dummy, with index changed
]; ];