| 40 | class CoreTest : public testing::TestWithParam<std::string> {}; |
| 41 | |
| 42 | TEST_P(CoreTest, TestSuites) { |
| 43 | const auto [Proposal, Conf, UnitName] = T.resolve(GetParam()); |
| 44 | const auto &ConfRef = Conf; |
| 45 | |
| 46 | // Define context structure for C API steps |
| 47 | struct TestContext { |
| 48 | WasmEdge_StoreContext *StoreCxt; |
| 49 | WasmEdge_StatisticsContext *StatCxt; |
| 50 | WasmEdge_LoaderContext *LoadCxt; |
| 51 | WasmEdge_ValidatorContext *ValidCxt; |
| 52 | WasmEdge_ExecutorContext *ExecCxt; |
| 53 | WasmEdge_ModuleInstanceContext *TestModCxt; |
| 54 | WasmEdge_ModuleInstanceContext *ActiveModCxt; |
| 55 | std::vector<WasmEdge_ModuleInstanceContext *> InstantiatedMod; |
| 56 | |
| 57 | TestContext(const WasmEdge::Configure &C) : ActiveModCxt(nullptr) { |
| 58 | WasmEdge_ConfigureContext *ConfCxt = createConf(C); |
| 59 | StoreCxt = WasmEdge_StoreCreate(); |
| 60 | StatCxt = WasmEdge_StatisticsCreate(); |
| 61 | LoadCxt = WasmEdge_LoaderCreate(ConfCxt); |
| 62 | ValidCxt = WasmEdge_ValidatorCreate(ConfCxt); |
| 63 | ExecCxt = WasmEdge_ExecutorCreate(ConfCxt, StatCxt); |
| 64 | WasmEdge_ConfigureDelete(ConfCxt); |
| 65 | TestModCxt = createSpecTestModule(); |
| 66 | WasmEdge_ExecutorRegisterImport(ExecCxt, StoreCxt, TestModCxt); |
| 67 | } |
| 68 | ~TestContext() { |
| 69 | WasmEdge_LoaderDelete(LoadCxt); |
| 70 | WasmEdge_ValidatorDelete(ValidCxt); |
| 71 | WasmEdge_ExecutorDelete(ExecCxt); |
| 72 | WasmEdge_StoreDelete(StoreCxt); |
| 73 | WasmEdge_StatisticsDelete(StatCxt); |
| 74 | WasmEdge_ModuleInstanceDelete(TestModCxt); |
| 75 | for (auto &&ModCxt : InstantiatedMod) { |
| 76 | WasmEdge_ModuleInstanceDelete(ModCxt); |
| 77 | } |
| 78 | InstantiatedMod.clear(); |
| 79 | } |
| 80 | }; |
| 81 | |
| 82 | T.onInit = [&ConfRef](SpecTest::ContextHandle Parent, |
| 83 | const std::vector<std::pair<std::string, std::string>> |
| 84 | &SharedModules) -> SpecTest::ContextHandle { |
| 85 | auto *Ctx = new TestContext(ConfRef); |
| 86 | if (Parent != nullptr && !SharedModules.empty()) { |
| 87 | auto *P = static_cast<TestContext *>(Parent); |
| 88 | for (const auto &[ParentName, AliasName] : SharedModules) { |
| 89 | WasmEdge_String ParentNameStr = |
| 90 | WasmEdge_StringCreateByCString(ParentName.c_str()); |
| 91 | const WasmEdge_ModuleInstanceContext *ModInst = |
| 92 | WasmEdge_StoreFindModule(P->StoreCxt, ParentNameStr); |
| 93 | WasmEdge_StringDelete(ParentNameStr); |
| 94 | if (ModInst != nullptr) { |
| 95 | WasmEdge_String AliasNameStr = |
| 96 | WasmEdge_StringCreateByCString(AliasName.c_str()); |
| 97 | WasmEdge_ExecutorRegisterImportWithAlias(Ctx->ExecCxt, Ctx->StoreCxt, |
| 98 | ModInst, AliasNameStr); |
| 99 | WasmEdge_StringDelete(AliasNameStr); |
nothing calls this directly
no test coverage detected