MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / TEST

Function TEST

test/llvm/LLVMcoreTest.cpp:545–585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

543 0x09, 0x01, 0x07, 0x00, 0x03, 0x40, 0x0c, 0x00, 0x0b, 0x0b};
544
545TEST(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
587TEST(AsyncExecute, NativeInterruptTest) {
588 WasmEdge::Configure Conf;

Callers

nothing calls this directly

Calls 15

nowClass · 0.85
setInterruptibleMethod · 0.80
setOutputFormatMethod · 0.80
setRunModeMethod · 0.80
parseModuleMethod · 0.80
codegenMethod · 0.80
waitUntilMethod · 0.80
cancelMethod · 0.80
waitForMethod · 0.80
cleanupMethod · 0.80
loadWasmMethod · 0.80
checkConfigureMethod · 0.80

Tested by

no test coverage detected