Skip to content

Test: UT for st41 tailroom and fps parsing fixes#1645

Open
awilczyns wants to merge 5 commits into
mainfrom
st41-unit-tests
Open

Test: UT for st41 tailroom and fps parsing fixes#1645
awilczyns wants to merge 5 commits into
mainfrom
st41-unit-tests

Conversation

@awilczyns

Copy link
Copy Markdown
Collaborator

Adds negative unit test coverage for the two production fixes in
fix-st41-pytest (st_tx_fastmetadata_session.c tailroom checks and
parse_json.c fps parsing), so both can't silently regress. No
production code is touched.

Changes
New harness tests/unit/session/st41_tx_harness.{c,h} — includes
st_tx_fastmetadata_session.c directly (same pattern as the existing
st20/st40 harnesses) to reach the static
tx_fastmetadata_session_build_packet(), plus an mbuf allocator that
forces an exact tailroom via data_off, and a variant
(ut41tx_alloc_mbuf_stale_data_len) that pre-seeds data_len to a
stale value while keeping real tailroom small.

New test build_packet_capacity_test.cpp
(St41TxBuildPacketCapacityTest, 4 cases):

RejectsTooSmallForHeader / RejectsTooSmallForPayload — buffer
too small for the header, and header-sized-but-payload-too-small,
both correctly rejected without partial mutation.
RejectsTooSmallForHeaderDespiteStaleDataLen — the discriminating
case: data_len is pre-seeded to look "big enough" the way the
pre-fix data_len-based check would have read it, while real
tailroom is still too small. Confirms the code checks tailroom, not
data_len, by asserting data_len is never touched by the
function (i.e. it must equal the still-unclobbered seeded value) —
checking pkt_len alone can't tell "rejected immediately" from
"rejected one check later after partially mutating the packet".
BuildsPacketWhenBufferSufficient — ample buffer, packet actually
built, both checks pass.
New harness tests/unit/app/parse_json_harness.{c,h} — includes
parse_json.c directly, stubs app_get_log_level/app_set_log_level,
to reach the static st_json_parse_tx_fmd().

New test fastmetadata_fps_test.cpp
(ParseJsonTxFmdFpsTest, 3 cases): rejects a genuinely unsupported fps
string (p999) and a near-valid typo (p12) — guarding against a
broken/prefix-matching strcmp across the now 11 back-to-back pNN
branches — and accepts a newly-added value (p120).

meson.build — wires the new sources in, adds
include_directories('../tools/RxTxApp/src') and libpcap_dep
(transitively required since parse_json.c includes <pcap.h> via
app_base.h).

awilczyns added 4 commits July 2, 2026 13:19
Signed-off-by: Wilczynski, Andrzej <andrzej.wilczynski@intel.com>
Signed-off-by: Wilczynski, Andrzej <andrzej.wilczynski@intel.com>
need_build only checked ldconfig SONAME presence, not version, so a
stale SvtJpegxs install (surviving git clean as a system-wide install)
was treated as up-to-date after versions.env bumped SVT_JPEG_XS_VER to
a commit requiring SvtJpegxs >= 0.10.0. FFmpeg configure then failed
with "SvtJpegxs >= 0.10.0 not found using pkg-config" on mtl-runner-7.

Add a pkg-config version check alongside the SONAME check so an
outdated install triggers a rebuild instead of being skipped. The
minimum version is now a versions.env variable instead of a hardcoded
literal, matching the convention used by the other pinned versions.

Fixes: 46b13a9 ("Ci: skip copying missing jpeg-xs helper files on v0.9.0")
Signed-off-by: Wilczynski, Andrzej <andrzej.wilczynski@intel.com>
Pin two already-fixed regressions with gtest coverage that fails
against the pre-fix code and passes against the current fix (verified
by reverting each production hunk locally, rebuilding, and confirming
the new tests fail, then restoring):

- st_tx_fastmetadata_session.c (08d4b27): tx_fastmetadata_session_build_packet()
  must reject buffers with insufficient tailroom without partially
  mutating data_len/pkt_len, even when data_len is stale/nonzero.
- parse_json.c (825e213): st_json_parse_tx_fmd() must still reject
  unsupported fps strings and must accept the newly added ones, with
  no accidental prefix/strcmp match across the now 11 fps branches.

Adds #include-the-.c harnesses (session/st41_tx_harness, app/parse_json_harness)
following the existing st20/st40 harness pattern to reach the static
functions under test.

Signed-off-by: Wilczynski, Andrzej <andrzej.wilczynski@intel.com>
Comment thread tests/unit/meson.build
link_args : unit_link_args,
include_directories : unit_include_dirs,
dependencies : [mtl_internal_dep, dpdk_dep, libm_dep, gtest_dep, libpthread_dep,
usdt_provider_header_dep],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it really needed?

@DawidWesierski4 DawidWesierski4 changed the title Test: Test: Add negative UT for st41 tailroom and fps parsing fixes Test: UT for st41 tailroom and fps parsing fixes Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants