| 543 | 0x09, 0x01, 0x07, 0x00, 0x03, 0x40, 0x0c, 0x00, 0x0b, 0x0b}; |
| 544 | |
| 545 | TEST(AsyncRunWsmFile, NativeInterruptTest) { |
| 546 | WasmEdge::Configure Conf; |
| 547 | Conf.getCompilerConfigure().setInterruptible(true); |
| 548 | Conf.getCompilerConfigure().setOutputFormat( |
| 549 | CompilerConfigure::OutputFormat::Native); |
| 550 | Conf.getRuntimeConfigure().setRunMode(WasmEdge::RunMode::AOT); |
| 551 | |
| 552 | WasmEdge::VM::VM VM(Conf); |
| 553 | WasmEdge::Loader::Loader Loader(Conf); |
| 554 | WasmEdge::Validator::Validator ValidatorEngine(Conf); |
| 555 | WasmEdge::LLVM::Compiler Compiler(Conf); |
| 556 | WasmEdge::LLVM::CodeGen CodeGen(Conf); |
| 557 | auto Path = std::filesystem::temp_directory_path() / |
| 558 | std::filesystem::u8path("AOTcoreTest" WASMEDGE_LIB_EXTENSION); |
| 559 | auto Module = *Loader.parseModule(AsyncWasm); |
| 560 | ASSERT_TRUE(ValidatorEngine.validate(*Module)); |
| 561 | auto Data = Compiler.compile(*Module); |
| 562 | ASSERT_TRUE(Data); |
| 563 | ASSERT_TRUE(CodeGen.codegen(AsyncWasm, std::move(*Data), Path)); |
| 564 | { |
| 565 | auto Timeout = |
| 566 | std::chrono::system_clock::now() + std::chrono::milliseconds(1); |
| 567 | auto AsyncResult = VM.asyncRunWasmFile(Path, "_start"); |
| 568 | EXPECT_FALSE(AsyncResult.waitUntil(Timeout)); |
| 569 | AsyncResult.cancel(); |
| 570 | auto Result = AsyncResult.get(); |
| 571 | EXPECT_FALSE(Result); |
| 572 | EXPECT_EQ(Result.error(), WasmEdge::ErrCode::Value::Interrupted); |
| 573 | } |
| 574 | { |
| 575 | auto Timeout = std::chrono::milliseconds(1); |
| 576 | auto AsyncResult = VM.asyncRunWasmFile(Path, "_start"); |
| 577 | EXPECT_FALSE(AsyncResult.waitFor(Timeout)); |
| 578 | AsyncResult.cancel(); |
| 579 | auto Result = AsyncResult.get(); |
| 580 | EXPECT_FALSE(Result); |
| 581 | EXPECT_EQ(Result.error(), WasmEdge::ErrCode::Value::Interrupted); |
| 582 | } |
| 583 | VM.cleanup(); |
| 584 | EXPECT_NO_THROW(std::filesystem::remove(Path)); |
| 585 | } |
| 586 | |
| 587 | TEST(AsyncExecute, NativeInterruptTest) { |
| 588 | WasmEdge::Configure Conf; |
nothing calls this directly
no test coverage detected