| 315 | 0x09, 0x01, 0x07, 0x00, 0x03, 0x40, 0x0c, 0x00, 0x0b, 0x0b}; |
| 316 | |
| 317 | TEST(AsyncInvoke, InterruptTest) { |
| 318 | WasmEdge_LoaderContext *Loader = WasmEdge_LoaderCreate(nullptr); |
| 319 | WasmEdge_ValidatorContext *Validator = WasmEdge_ValidatorCreate(nullptr); |
| 320 | WasmEdge_ExecutorContext *Executor = |
| 321 | WasmEdge_ExecutorCreate(nullptr, nullptr); |
| 322 | WasmEdge_StoreContext *Store = WasmEdge_StoreCreate(); |
| 323 | |
| 324 | ASSERT_NE(Loader, nullptr); |
| 325 | ASSERT_NE(Validator, nullptr); |
| 326 | ASSERT_NE(Executor, nullptr); |
| 327 | ASSERT_NE(Store, nullptr); |
| 328 | |
| 329 | WasmEdge_ASTModuleContext *AST = nullptr; |
| 330 | ASSERT_TRUE(WasmEdge_ResultOK( |
| 331 | WasmEdge_LoaderParseFromBuffer(Loader, &AST, AsyncWasm.data(), |
| 332 | static_cast<uint32_t>(AsyncWasm.size())))); |
| 333 | ASSERT_NE(AST, nullptr); |
| 334 | ASSERT_TRUE(WasmEdge_ResultOK(WasmEdge_ValidatorValidate(Validator, AST))); |
| 335 | WasmEdge_ModuleInstanceContext *Module = nullptr; |
| 336 | ASSERT_TRUE(WasmEdge_ResultOK( |
| 337 | WasmEdge_ExecutorInstantiate(Executor, &Module, Store, AST))); |
| 338 | WasmEdge_ASTModuleDelete(AST); |
| 339 | ASSERT_NE(Module, nullptr); |
| 340 | WasmEdge_FunctionInstanceContext *FuncInst = |
| 341 | WasmEdge_ModuleInstanceFindFunction(Module, |
| 342 | WasmEdge_StringWrap("_start", 6)); |
| 343 | ASSERT_NE(FuncInst, nullptr); |
| 344 | { |
| 345 | WasmEdge_Async *AsyncCxt = |
| 346 | WasmEdge_ExecutorAsyncInvoke(Executor, FuncInst, nullptr, 0); |
| 347 | EXPECT_NE(AsyncCxt, nullptr); |
| 348 | EXPECT_FALSE(WasmEdge_AsyncWaitFor(AsyncCxt, 1)); |
| 349 | WasmEdge_AsyncCancel(AsyncCxt); |
| 350 | WasmEdge_Result Res = WasmEdge_AsyncGet(AsyncCxt, nullptr, 0); |
| 351 | EXPECT_FALSE(WasmEdge_ResultOK(Res)); |
| 352 | EXPECT_EQ(WasmEdge_ResultGetCode(Res), WasmEdge_ErrCode_Interrupted); |
| 353 | WasmEdge_AsyncDelete(AsyncCxt); |
| 354 | } |
| 355 | WasmEdge_LoaderDelete(Loader); |
| 356 | WasmEdge_ValidatorDelete(Validator); |
| 357 | WasmEdge_ExecutorDelete(Executor); |
| 358 | WasmEdge_StoreDelete(Store); |
| 359 | WasmEdge_ModuleInstanceDelete(Module); |
| 360 | } |
| 361 | |
| 362 | } // namespace |
| 363 |
nothing calls this directly
no test coverage detected