| 42 | class CoreCompileArrayTest : public testing::TestWithParam<std::string> {}; |
| 43 | |
| 44 | TEST_P(CoreCompileTest, TestSuites) { |
| 45 | auto [Proposal, Conf, UnitName] = T.resolve(GetParam()); |
| 46 | // C API AOT spec test: opt into RunMode::AOT so the runtime load |
| 47 | // step uses the produced .so as AOT under the new default mode. |
| 48 | Conf.getRuntimeConfigure().setRunMode(WasmEdge::RunMode::AOT); |
| 49 | const auto &ConfRef = Conf; |
| 50 | |
| 51 | // Define context structure for C API AOT |
| 52 | struct TestContext { |
| 53 | WasmEdge_VMContext *VM; |
| 54 | WasmEdge_ModuleInstanceContext *TestModCxt; |
| 55 | WasmEdge_CompilerContext *CompilerCxt; |
| 56 | TestContext(const WasmEdge::Configure &C) { |
| 57 | WasmEdge_ConfigureContext *ConfCxt = createConf(C); |
| 58 | VM = WasmEdge_VMCreate(ConfCxt, nullptr); |
| 59 | WasmEdge_ConfigureCompilerSetOptimizationLevel( |
| 60 | ConfCxt, WasmEdge_CompilerOptimizationLevel_O0); |
| 61 | WasmEdge_ConfigureCompilerSetOutputFormat( |
| 62 | ConfCxt, WasmEdge_CompilerOutputFormat_Native); |
| 63 | CompilerCxt = WasmEdge_CompilerCreate(ConfCxt); |
| 64 | WasmEdge_ConfigureDelete(ConfCxt); |
| 65 | TestModCxt = createSpecTestModule(); |
| 66 | WasmEdge_VMRegisterModuleFromImport(VM, TestModCxt); |
| 67 | } |
| 68 | ~TestContext() { |
| 69 | WasmEdge_VMDelete(VM); |
| 70 | WasmEdge_ModuleInstanceDelete(TestModCxt); |
| 71 | WasmEdge_CompilerDelete(CompilerCxt); |
| 72 | } |
| 73 | Expect<std::string> compile(const std::string &FileName) { |
| 74 | auto Path = std::filesystem::u8path(FileName); |
| 75 | Path.replace_extension(std::filesystem::u8path(WASMEDGE_LIB_EXTENSION)); |
| 76 | const auto SOPath = Path.u8string(); |
| 77 | WasmEdge_Result Res = WasmEdge_CompilerCompile( |
| 78 | CompilerCxt, FileName.c_str(), SOPath.c_str()); |
| 79 | if (!WasmEdge_ResultOK(Res)) { |
| 80 | return Unexpect(convResult(Res)); |
| 81 | } |
| 82 | return SOPath; |
| 83 | } |
| 84 | }; |
| 85 | |
| 86 | T.onInit = [&ConfRef](SpecTest::ContextHandle Parent, |
| 87 | const std::vector<std::pair<std::string, std::string>> |
| 88 | &SharedModules) -> SpecTest::ContextHandle { |
| 89 | auto *Ctx = new TestContext(ConfRef); |
| 90 | if (Parent != nullptr && !SharedModules.empty()) { |
| 91 | auto *P = static_cast<TestContext *>(Parent); |
| 92 | WasmEdge_StoreContext *ParentStore = WasmEdge_VMGetStoreContext(P->VM); |
| 93 | for (const auto &[ParentName, AliasName] : SharedModules) { |
| 94 | WasmEdge_String ParentNameStr = |
| 95 | WasmEdge_StringCreateByCString(ParentName.c_str()); |
| 96 | const WasmEdge_ModuleInstanceContext *ModInst = |
| 97 | WasmEdge_StoreFindModule(ParentStore, ParentNameStr); |
| 98 | WasmEdge_StringDelete(ParentNameStr); |
| 99 | if (ModInst != nullptr) { |
| 100 | WasmEdge_String AliasNameStr = |
| 101 | WasmEdge_StringCreateByCString(AliasName.c_str()); |
nothing calls this directly
no test coverage detected