Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6b32b0c
feat(wasi_crypto): implement ECDSA public key verification (#4932)
parthdagia05 Jun 11, 2026
d0c2922
fix(plugin/zlib): rename shadowed z_stream locals in zlib plugin
hydai Jun 12, 2026
efb882d
fix(plugin/wasm_bpf): rename shadowed loop variables in wasm_bpf test
hydai Jun 12, 2026
ea67fef
fix(test/opencvmini): suppress shadow warnings on the opencvmini test…
hydai Jun 12, 2026
cceb933
chore(plugin/llmc): deprecate wasmedge-llmc plugin (#4964)
hydai Jun 16, 2026
4424d2f
fix(test/plugins/wasi_nn): remove concrete types to fix devirtualizat…
pranjalkole Jun 17, 2026
59da64f
fix(test/plugins/wasm_bpf): remove concrete types to fix devirtualiza…
hydai Jun 17, 2026
034adc0
fix(test/plugins/wasmedge_process): remove concrete types to fix devi…
hydai Jun 17, 2026
84da82d
fix(test/plugins/wasmedge_stablediffusion): remove concrete types to …
hydai Jun 17, 2026
df6a8d9
fix(test/plugins/wasi_logging): remove concrete types to fix devirtua…
hydai Jun 17, 2026
2142e62
fix(plugin/wasi-logging): validate full string extent in Log::body (#…
Yashika0724 Jun 17, 2026
59f6362
fix(test/plugins/wasmedge_ffmpeg): remove concrete types to fix devir…
hydai Jun 17, 2026
df3bfd9
test(plugins): use ASSERT for host-function guards before getHostFunc()
hydai Jun 17, 2026
f8e7223
docs(test/plugins/wasm_bpf): correct copied comment to wasm_bpf_map_o…
hydai Jun 17, 2026
cf526fa
test(plugins): assert host-call outputs to preserve devirtualized bin…
hydai Jun 18, 2026
2d3f51f
fix(test/plugins/wasmedge_ffmpeg): expect AV_NOPTS_VALUE for unprobed…
hydai Jun 18, 2026
38d7801
test(plugins/wasmedge_ffmpeg): assert exact getter values to keep bin…
hydai Jun 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(plugins): assert host-call outputs to preserve devirtualized bin…
…dings

Replacing the concrete dynamic_cast host-function lookups with getHostFunc()
dropped the only check that each export was wired to the correct, same-signature
host function: a call that copies bytes into memory or returns a scalar still
reports ErrNo::Success when mis-bound. Read the written output back or pin a
distinguishing value so every export binding stays observable.

wasmedge_ffmpeg name and scalar readbacks:
- avPixfmt: av_color_range_name (pc), av_color_transfer_name (smpte170m),
  av_color_space_name / av_color_primaries_name (bt709), av_pix_format_name
  (yuv420p).
- avCodec: avcodec_get_name (h264) and avcodec_get_long_name.
- avSampleFmt: av_get_sample_fmt_name (u8).
- avInputFormat: name (mov,mp4,...) and long_name (QuickTime / MOV).
- avfilter: avfilter_name (abuffer), description, pad_get_name.
- avDictionary: av_dict_get_key_value copies KEY/VALUE; read both back.
- avError: av_strerror ran with no arguments; pass the real buffer and assert.
- av_log_get_flags ran with a stray argument; call the setter with an empty
  result span and the getter with none, then assert the flag.
- utils: initEmptyFrame asserts the av_frame_alloc run() result.

wasmedge_ffmpeg version, configuration/license, and codec-kind sweep:
- version exports (avutil, avcodec, avformat, avfilter, swresample, swscale):
  assert the major-version byte (>> 16) is nonzero, so a swap with a
  configuration/license length getter no longer passes.
- configuration/license copiers (all six modules): read back the buffer and
  require the configure-flag marker "--" to be present for configuration and
  absent for license, distinguishing the pair on both sides.
- avformatContext duration: replace the tautological check with the sample
  asset's exact duration.
- avcodec find_decoder_by_name / find_encoder_by_name: confirm the returned
  codec kind via av_codec_is_decoder / av_codec_is_encoder.

wasmedge_process:
- GetStdErr compares the StdErr buffer instead of the empty StdOut.
- GetExitCode seeds a nonzero Env.ExitCode and asserts it.

Assisted-by: Claude (Anthropic)
Signed-off-by: hydai <z54981220@gmail.com>
  • Loading branch information
hydai authored and 0yi0 committed Jun 18, 2026
commit cf526fa01383ec51f09b9ca3b92b2131638cee87
6 changes: 6 additions & 0 deletions test/plugins/wasmedge_ffmpeg/avcodec/avCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ TEST_F(FFmpegTest, AVCodec) {
AVCodecId, StringPtr, Length},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
EXPECT_EQ(std::string_view(MemInst->getPointer<char *>(StringPtr),
static_cast<size_t>(Length)),
"h264"sv);
}

FuncInst = AVCodecMod->findFuncExports(
Expand Down Expand Up @@ -154,6 +157,9 @@ TEST_F(FFmpegTest, AVCodec) {
Length},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
EXPECT_EQ(std::string_view(MemInst->getPointer<char *>(StringPtr),
static_cast<size_t>(Length)),
"H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"sv);
}

FuncInst =
Expand Down
2 changes: 1 addition & 1 deletion test/plugins/wasmedge_ffmpeg/avcodec/avCodecCtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ TEST_F(FFmpegTest, AVCodecCtx) {
EXPECT_TRUE(HostFuncAVCodecCtxColorTrc.run(
CallFrame, std::initializer_list<WasmEdge::ValVariant>{AVCodecCtxId},
Result));
ASSERT_TRUE(Result[0].get<int32_t>() > 0);
EXPECT_EQ(Result[0].get<int32_t>(), 2);
}

FuncInst = AVCodecMod->findFuncExports(
Expand Down
35 changes: 19 additions & 16 deletions test/plugins/wasmedge_ffmpeg/avcodec/avPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ TEST_F(FFmpegTest, AVPacketTest) {
ASSERT_TRUE(PacketId > 0);
ASSERT_TRUE(PacketId2 > 0);

uint32_t PacketDataSize = 0;
FuncInst =
AVCodecMod->findFuncExports("wasmedge_ffmpeg_avcodec_av_packet_size");
ASSERT_NE(FuncInst, nullptr);
ASSERT_TRUE(FuncInst->isHostFunction());
auto &HostFuncAVPacketSize = FuncInst->getHostFunc();
auto ExpectPacketSize = [&](uint32_t ExpectedSize) {
EXPECT_TRUE(HostFuncAVPacketSize.run(
CallFrame, std::initializer_list<WasmEdge::ValVariant>{PacketId},
Result));
PacketDataSize = static_cast<uint32_t>(Result[0].get<int32_t>());
EXPECT_EQ(PacketDataSize, ExpectedSize);
};

FuncInst =
AVCodecMod->findFuncExports("wasmedge_ffmpeg_avcodec_av_new_packet");
ASSERT_NE(FuncInst, nullptr);
Expand All @@ -58,6 +72,7 @@ TEST_F(FFmpegTest, AVPacketTest) {
CallFrame, std::initializer_list<WasmEdge::ValVariant>{PacketId, Size},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), 0);
ExpectPacketSize(Size);
}

FuncInst =
Expand All @@ -72,6 +87,7 @@ TEST_F(FFmpegTest, AVPacketTest) {
CallFrame, std::initializer_list<WasmEdge::ValVariant>{PacketId, Size},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), 0);
ExpectPacketSize(80);
}

FuncInst =
Expand All @@ -86,6 +102,7 @@ TEST_F(FFmpegTest, AVPacketTest) {
CallFrame, std::initializer_list<WasmEdge::ValVariant>{PacketId, Size},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), 0);
ExpectPacketSize(Size);
}

uint32_t StreamIdx = 3;
Expand Down Expand Up @@ -116,21 +133,6 @@ TEST_F(FFmpegTest, AVPacketTest) {
EXPECT_EQ(Result[0].get<int32_t>(), StreamIdx);
}

uint32_t Size = 0;
FuncInst =
AVCodecMod->findFuncExports("wasmedge_ffmpeg_avcodec_av_packet_size");
ASSERT_NE(FuncInst, nullptr);
ASSERT_TRUE(FuncInst->isHostFunction());
auto &HostFuncAVPacketSize = FuncInst->getHostFunc();

{
EXPECT_TRUE(HostFuncAVPacketSize.run(
CallFrame, std::initializer_list<WasmEdge::ValVariant>{PacketId},
Result));
Size = Result[0].get<int32_t>();
EXPECT_TRUE(Size > 0);
}

uint32_t Flags = 5;

FuncInst = AVCodecMod->findFuncExports(
Expand Down Expand Up @@ -290,7 +292,8 @@ TEST_F(FFmpegTest, AVPacketTest) {
{
EXPECT_TRUE(HostFuncAVPacketData.run(
CallFrame,
std::initializer_list<WasmEdge::ValVariant>{PacketId, DataPtr, Size},
std::initializer_list<WasmEdge::ValVariant>{PacketId, DataPtr,
PacketDataSize},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
}
Expand Down
22 changes: 21 additions & 1 deletion test/plugins/wasmedge_ffmpeg/avcodec/avcodec_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ TEST_F(FFmpegTest, AVCodecFunc) {
CodecNamePtr, Length},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));

uint32_t DecoderByNameId = readUInt32(MemInst, CodecDecoderPtr);
EXPECT_TRUE(HostFuncAVCodecIsDecoder.run(
CallFrame, std::initializer_list<WasmEdge::ValVariant>{DecoderByNameId},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), 1);
}

FuncInst = AVCodecMod->findFuncExports(
Expand All @@ -227,6 +233,12 @@ TEST_F(FFmpegTest, AVCodecFunc) {
CodecNamePtr, Length},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));

uint32_t EncoderByNameId = readUInt32(MemInst, CodecEncoderPtr);
EXPECT_TRUE(HostFuncAVCodecIsEncoder.run(
CallFrame, std::initializer_list<WasmEdge::ValVariant>{EncoderByNameId},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), 1);
}

FuncInst = AVCodecMod->findFuncExports(
Expand Down Expand Up @@ -273,7 +285,7 @@ TEST_F(FFmpegTest, AVCodecFunc) {
{
EXPECT_TRUE(HostFuncAVCodecVersion.run(
CallFrame, std::initializer_list<WasmEdge::ValVariant>{}, Result));
EXPECT_TRUE(Result[0].get<int32_t>() > 0);
EXPECT_TRUE((Result[0].get<int32_t>() >> 16) > 0);
}

FuncInst = AVCodecMod->findFuncExports(
Expand Down Expand Up @@ -305,6 +317,10 @@ TEST_F(FFmpegTest, AVCodecFunc) {
CallFrame, std::initializer_list<WasmEdge::ValVariant>{StrPtr, Length},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
EXPECT_NE(std::string_view(MemInst->getPointer<char *>(StrPtr),
static_cast<size_t>(Length))
.find("--"),
std::string_view::npos);
}

FuncInst = AVCodecMod->findFuncExports(
Expand Down Expand Up @@ -336,6 +352,10 @@ TEST_F(FFmpegTest, AVCodecFunc) {
CallFrame, std::initializer_list<WasmEdge::ValVariant>{StrPtr, Length},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
EXPECT_EQ(std::string_view(MemInst->getPointer<char *>(StrPtr),
static_cast<size_t>(Length))
.find("--"),
std::string_view::npos);
}

FuncInst = AVCodecMod->findFuncExports(
Expand Down
13 changes: 13 additions & 0 deletions test/plugins/wasmedge_ffmpeg/avfilter/avfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Host {
namespace WasmEdgeFFmpeg {

TEST_F(FFmpegTest, AVFilterStructs) {
using namespace std::literals::string_view_literals;
ASSERT_TRUE(AVFilterMod != nullptr);

uint32_t FilterPtr = UINT32_C(8);
Expand Down Expand Up @@ -82,6 +83,9 @@ TEST_F(FFmpegTest, AVFilterStructs) {
std::initializer_list<WasmEdge::ValVariant>{FilterId, StrPtr, Length},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
EXPECT_EQ(std::string_view(MemInst->getPointer<char *>(StrPtr),
static_cast<size_t>(Length)),
"abuffer"sv);
}

FuncInst = AVFilterMod->findFuncExports(
Expand Down Expand Up @@ -114,6 +118,10 @@ TEST_F(FFmpegTest, AVFilterStructs) {
std::initializer_list<WasmEdge::ValVariant>{FilterId, StrPtr, Length},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
EXPECT_EQ(std::string_view(MemInst->getPointer<char *>(StrPtr),
static_cast<size_t>(Length)),
"Buffer audio frames, and make them accessible to the "
"filterchain."sv);
}

FuncInst = AVFilterMod->findFuncExports(
Expand Down Expand Up @@ -166,12 +174,14 @@ TEST_F(FFmpegTest, AVFilterStructs) {
auto &HostFuncAVFilterGetInputsFilterPad = FuncInst->getHostFunc();

{
writeUInt32(MemInst, UINT32_C(0), InputFilterPadPtr);
EXPECT_TRUE(HostFuncAVFilterGetInputsFilterPad.run(
CallFrame,
std::initializer_list<WasmEdge::ValVariant>{FilterId,
InputFilterPadPtr},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
EXPECT_EQ(readUInt32(MemInst, InputFilterPadPtr), UINT32_C(0));
}

FuncInst = AVFilterMod->findFuncExports(
Expand Down Expand Up @@ -224,6 +234,9 @@ TEST_F(FFmpegTest, AVFilterStructs) {
StrPtr, Length},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
EXPECT_EQ(std::string_view(MemInst->getPointer<char *>(StrPtr),
static_cast<size_t>(Length)),
"default"sv);
}

FuncInst = AVFilterMod->findFuncExports(
Expand Down
10 changes: 9 additions & 1 deletion test/plugins/wasmedge_ffmpeg/avfilter/avfilter_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ TEST_F(FFmpegTest, AVFilterFunc) {
{
EXPECT_TRUE(HostFuncAVFilterVersion.run(
CallFrame, std::initializer_list<WasmEdge::ValVariant>{}, Result));
ASSERT_TRUE(Result[0].get<int32_t>() > 0);
ASSERT_TRUE((Result[0].get<int32_t>() >> 16) > 0);
}

FuncInst = AVFilterMod->findFuncExports(
Expand Down Expand Up @@ -414,6 +414,10 @@ TEST_F(FFmpegTest, AVFilterFunc) {
CallFrame, std::initializer_list<WasmEdge::ValVariant>{StrPtr, Length},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
EXPECT_NE(std::string_view(MemInst->getPointer<char *>(StrPtr),
static_cast<size_t>(Length))
.find("--"),
std::string_view::npos);
}

FuncInst = AVFilterMod->findFuncExports(
Expand Down Expand Up @@ -442,6 +446,10 @@ TEST_F(FFmpegTest, AVFilterFunc) {
CallFrame, std::initializer_list<WasmEdge::ValVariant>{StrPtr, Length},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
EXPECT_EQ(std::string_view(MemInst->getPointer<char *>(StrPtr),
static_cast<size_t>(Length))
.find("--"),
std::string_view::npos);
}

// ==================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Host {
namespace WasmEdgeFFmpeg {

TEST_F(FFmpegTest, AVInputFormat) {
using namespace std::literals::string_view_literals;
std::string FileName = "ffmpeg-assets/sample_video.mp4"; // 32 chars
uint32_t FormatCtxPtr = UINT32_C(24);
uint32_t InputFormatPtr = UINT32_C(28);
Expand Down Expand Up @@ -78,6 +79,9 @@ TEST_F(FFmpegTest, AVInputFormat) {
Length},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
EXPECT_EQ(std::string_view(MemInst->getPointer<char *>(StrBuf),
static_cast<size_t>(Length)),
"mov,mp4,m4a,3gp,3g2,mj2"sv);
}

FuncInst = AVFormatMod->findFuncExports(
Expand Down Expand Up @@ -109,6 +113,9 @@ TEST_F(FFmpegTest, AVInputFormat) {
Result));

EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
EXPECT_EQ(std::string_view(MemInst->getPointer<char *>(StrBuf),
static_cast<size_t>(Length)),
"QuickTime / MOV"sv);
}

FuncInst = AVFormatMod->findFuncExports(
Expand Down
2 changes: 1 addition & 1 deletion test/plugins/wasmedge_ffmpeg/avformat/avformatContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ TEST_F(FFmpegTest, AVFormatContextStruct) {
EXPECT_TRUE(HostFuncAVFormatCtxDuration.run(
CallFrame, std::initializer_list<WasmEdge::ValVariant>{FormatCtxId},
Result));
EXPECT_TRUE(Result[0].get<int64_t>() >= 0 || Result[0].get<int64_t>() < 0);
EXPECT_EQ(Result[0].get<int64_t>(), INT64_C(2000000));
}

FuncInst = AVFormatMod->findFuncExports(
Expand Down
10 changes: 9 additions & 1 deletion test/plugins/wasmedge_ffmpeg/avformat/avformat_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ TEST_F(FFmpegTest, AVInputFormatFunc) {
EXPECT_TRUE(HostFuncAVFormatVersion.run(
CallFrame, std::initializer_list<WasmEdge::ValVariant>{}, Result));

EXPECT_TRUE(Result[0].get<int32_t>() >= 0);
EXPECT_TRUE((Result[0].get<int32_t>() >> 16) > 0);
}

FuncInst = AVFormatMod->findFuncExports(
Expand Down Expand Up @@ -274,6 +274,10 @@ TEST_F(FFmpegTest, AVInputFormatFunc) {
Result));

EXPECT_TRUE(Result[0].get<int32_t>() >= 0);
EXPECT_NE(std::string_view(MemInst->getPointer<char *>(StrPtr),
static_cast<size_t>(Length))
.find("--"),
std::string_view::npos);
}

FuncInst = AVFormatMod->findFuncExports(
Expand Down Expand Up @@ -304,6 +308,10 @@ TEST_F(FFmpegTest, AVInputFormatFunc) {
Result));

EXPECT_TRUE(Result[0].get<int32_t>() >= 0);
EXPECT_EQ(std::string_view(MemInst->getPointer<char *>(StrPtr),
static_cast<size_t>(Length))
.find("--"),
std::string_view::npos);
}
}

Expand Down
7 changes: 6 additions & 1 deletion test/plugins/wasmedge_ffmpeg/avutil/avDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ TEST_F(FFmpegTest, AVDictionary) {
UINT32_C(3), PrevDictEntryIdx, Flags},
Result));
EXPECT_EQ(Result[0].get<int32_t>(), 1);
// Verify String. Read String from MemInst
EXPECT_EQ(std::string_view(MemInst->getPointer<char *>(KeyBufPtr),
static_cast<size_t>(KeyLen)),
"KEY"sv);
EXPECT_EQ(std::string_view(MemInst->getPointer<char *>(ValueBufPtr),
static_cast<size_t>(ValueLen)),
"VALUE"sv);

// Pass a Null Dict and testing.
EXPECT_TRUE(HostFuncAVDictGetKeyValue.run(
Expand Down
9 changes: 5 additions & 4 deletions test/plugins/wasmedge_ffmpeg/avutil/avError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ TEST_F(FFmpegTest, AVError) {
auto &HostFuncAVUtilAVStrError = FuncInst->getHostFunc();

{
HostFuncAVUtilAVStrError.run(
CallFrame, std::initializer_list<WasmEdge::ValVariant>{}, Result);

EXPECT_EQ(Result[0].get<int32_t>(), 0);
EXPECT_TRUE(HostFuncAVUtilAVStrError.run(
CallFrame,
std::initializer_list<WasmEdge::ValVariant>{ErrNum, ErrStartPtr,
ErrSize},
Result));
}

FuncInst = AVUtilMod->findFuncExports("wasmedge_ffmpeg_avutil_AVERROR");
Expand Down
7 changes: 4 additions & 3 deletions test/plugins/wasmedge_ffmpeg/avutil/avFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ TEST_F(FFmpegTest, AVFrame) {
ASSERT_TRUE(FuncInst->isHostFunction());
auto &HostFuncAVFrameAlloc = FuncInst->getHostFunc();

uint32_t EmptyFramePtr = UINT32_C(64);
uint32_t EmptyFramePtr = UINT32_C(88);

{
HostFuncAVFrameAlloc.run(
writeUInt32(MemInst, UINT32_C(0), EmptyFramePtr);
EXPECT_TRUE(HostFuncAVFrameAlloc.run(
CallFrame, std::initializer_list<WasmEdge::ValVariant>{EmptyFramePtr},
Result);
Result));

EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
EXPECT_TRUE(readUInt32(MemInst, EmptyFramePtr) > 0);
Expand Down
Loading