message: test: add wasm_engine_test case for host functions
diff: @@ -264,3 +264,36 @@ TEST(wasm_engine, memory)
  EXPECT_FALSE(engine->init_memory(bytes(PageSize + 4, 0)));
  }
  }
  +
  +TEST(wasm_engine, host_function)
  +{
  + /* wat2wasm
  + (func $adler32 (import "env" "adler32") (param i32 i32) (result i32))
  + (memory (export "memory") 1)
  + (func $test (export "test") (param $a i32) (param $b i32) (result i32)
  + local.get $a
  + local.get $b
  + call $adler32
  + )
  + */
  + const auto wasm = from_hex(
  + "0061736d0100000001070160027f7f017f020f0103656e760761646c6572333200000302010005030100010711"
  + "02066d656d6f72790200047465737400010a0a0108002000200110000b");
  +
  + for (auto engine_create_fn : all_engines)
  + {
  + auto engine = engine_create_fn();
  + ASSERT_TRUE(engine->parse(wasm));
  + ASSERT_TRUE(engine->instantiate(wasm));
  + const auto func = engine->find_function("test");
  + ASSERT_TRUE(func.has_value());
  +
  + const auto mem_init = bytes{0x12, 0, 0, 0x34};
  + EXPECT_TRUE(engine->init_memory(mem_init));
  +
  + const auto result = engine->execute(*func, {0, 4});
  + ASSERT_FALSE(result.trapped);
  + ASSERT_TRUE(result.value.has_value());
  + ASSERT_EQ(*result.value, 8388679);
  + }
  +}
  