| 49 | class JITCoreTest : public testing::TestWithParam<std::string> {}; |
| 50 | |
| 51 | TEST_P(NativeCoreTest, TestSuites) { |
| 52 | auto [Proposal, Conf, UnitName] = T.resolve(GetParam()); |
| 53 | // Native AOT spec test: explicitly opt into RunMode::AOT so the runtime |
| 54 | // load step uses the produced .so as AOT, instead of falling back to |
| 55 | // interpreter under the new default mode. |
| 56 | Conf.getRuntimeConfigure().setRunMode(WasmEdge::RunMode::AOT); |
| 57 | const auto &ConfRef = Conf; |
| 58 | |
| 59 | // Define context structure |
| 60 | struct TestContext { |
| 61 | WasmEdge::VM::VM VM; |
| 62 | WasmEdge::SpecTestModule SpecTestMod; |
| 63 | WasmEdge::Configure Conf; |
| 64 | TestContext(const WasmEdge::Configure &C) : VM(C), Conf(C) { |
| 65 | VM.registerModule(SpecTestMod); |
| 66 | } |
| 67 | Expect<std::string> compile(const std::string &FileName) { |
| 68 | WasmEdge::Configure CopyConf = Conf; |
| 69 | WasmEdge::Loader::Loader Loader(Conf); |
| 70 | WasmEdge::Validator::Validator ValidatorEngine(Conf); |
| 71 | CopyConf.getCompilerConfigure().setOutputFormat( |
| 72 | CompilerConfigure::OutputFormat::Native); |
| 73 | CopyConf.getCompilerConfigure().setOptimizationLevel( |
| 74 | WasmEdge::CompilerConfigure::OptimizationLevel::O0); |
| 75 | CopyConf.getCompilerConfigure().setDumpIR(true); |
| 76 | WasmEdge::LLVM::Compiler Compiler(CopyConf); |
| 77 | WasmEdge::LLVM::CodeGen CodeGen(CopyConf); |
| 78 | auto Path = std::filesystem::u8path(FileName); |
| 79 | Path.replace_extension(std::filesystem::u8path(WASMEDGE_LIB_EXTENSION)); |
| 80 | const auto SOPath = Path.u8string(); |
| 81 | std::vector<WasmEdge::Byte> Data; |
| 82 | std::unique_ptr<WasmEdge::AST::Module> Module; |
| 83 | return Loader.loadFile(FileName) |
| 84 | .and_then([&](auto Result) noexcept { |
| 85 | Data = std::move(Result); |
| 86 | return Loader.parseModule(Data); |
| 87 | }) |
| 88 | .and_then([&](auto Result) noexcept { |
| 89 | Module = std::move(Result); |
| 90 | return ValidatorEngine.validate(*Module); |
| 91 | }) |
| 92 | .and_then([&]() noexcept { return Compiler.compile(*Module); }) |
| 93 | .and_then([&](auto Result) noexcept { |
| 94 | return CodeGen.codegen(Data, std::move(Result), SOPath); |
| 95 | }) |
| 96 | .and_then([&]() noexcept { return Expect<std::string>{SOPath}; }); |
| 97 | } |
| 98 | }; |
| 99 | |
| 100 | T.onInit = [&ConfRef](SpecTest::ContextHandle Parent, |
| 101 | const std::vector<std::pair<std::string, std::string>> |
| 102 | &SharedModules) -> SpecTest::ContextHandle { |
| 103 | auto *Ctx = new TestContext(ConfRef); |
| 104 | if (Parent != nullptr && !SharedModules.empty()) { |
| 105 | auto *P = static_cast<TestContext *>(Parent); |
| 106 | for (const auto &[ParentName, AliasName] : SharedModules) { |
| 107 | const auto *ModInst = P->VM.getStoreManager().findModule(ParentName); |
| 108 | if (ModInst != nullptr) { |
nothing calls this directly
no test coverage detected