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

Function TEST_F

test/plugins/wasmedge_ffmpeg/avcodec/avcodec_func.cpp:17–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15// TODO: Commented functions need tests.
16
17TEST_F(FFmpegTest, AVCodecFunc) {
18 ASSERT_TRUE(AVCodecMod != nullptr);
19
20 uint32_t CodecCtxPtr = UINT32_C(4);
21 uint32_t CodecParamPtr = UINT32_C(8);
22 uint32_t CodecParamPtr2 = UINT32_C(20);
23 uint32_t CodecDecoderPtr = UINT32_C(12);
24 uint32_t CodecEncoderPtr = UINT32_C(16);
25 uint32_t StrPtr = UINT32_C(32);
26
27 uint32_t CodecNamePtr = UINT32_C(150);
28 std::string CodecName = "mpeg1video";
29 spdlog::info("Filling memory CodecName into CodecNamePtr"sv);
30 fillMemContent(MemInst, CodecNamePtr, CodecName);
31
32 uint32_t ID = 1;
33
34 auto *FuncInst = AVCodecMod->findFuncExports(
35 "wasmedge_ffmpeg_avcodec_avcodec_alloc_context3");
36 EXPECT_NE(FuncInst, nullptr);
37 EXPECT_TRUE(FuncInst->isHostFunction());
38
39 auto &HostFuncAVCodecAllocContext3 = dynamic_cast<
40 WasmEdge::Host::WasmEdgeFFmpeg::AVcodec::AVCodecAllocContext3 &>(
41 FuncInst->getHostFunc());
42
43 spdlog::info("Testing AvCodecAllocContext3"sv);
44 {
45 EXPECT_TRUE(HostFuncAVCodecAllocContext3.run(
46 CallFrame, std::initializer_list<WasmEdge::ValVariant>{0, CodecCtxPtr},
47 Result));
48 EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
49 }
50
51 uint32_t AVCodecCtxId = readUInt32(MemInst, CodecCtxPtr);
52 ASSERT_TRUE(AVCodecCtxId > 0);
53
54 FuncInst = AVCodecMod->findFuncExports(
55 "wasmedge_ffmpeg_avcodec_avcodec_parameters_alloc");
56 EXPECT_NE(FuncInst, nullptr);
57 EXPECT_TRUE(FuncInst->isHostFunction());
58
59 auto &HostFuncAVCodecParametersAlloc = dynamic_cast<
60 WasmEdge::Host::WasmEdgeFFmpeg::AVcodec::AVCodecParametersAlloc &>(
61 FuncInst->getHostFunc());
62
63 spdlog::info("Testing AVCodecParametersAlloc"sv);
64 {
65 EXPECT_TRUE(HostFuncAVCodecParametersAlloc.run(
66 CallFrame, std::initializer_list<WasmEdge::ValVariant>{CodecParamPtr},
67 Result));
68 EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
69
70 EXPECT_TRUE(HostFuncAVCodecParametersAlloc.run(
71 CallFrame, std::initializer_list<WasmEdge::ValVariant>{CodecParamPtr2},
72 Result));
73 EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
74 }

Callers

nothing calls this directly

Calls 5

readUInt32Function · 0.85
findFuncExportsMethod · 0.80
isHostFunctionMethod · 0.80
fillMemContentFunction · 0.50
runMethod · 0.45

Tested by

no test coverage detected