fix(traffic): Stop report saturating counters at INT32_MAX
Every value in the report printed as 2147483647 because grp() rendered
counters with sprintf("%d", v). The DUT's awk casts to a 32-bit int for
%d, so any counter above 2^31-1 saturates -- and a real line-speed run
is around 7e11, three orders of magnitude past that. Formatting with
%.0f keeps the value in awk's double domain, which is exact to 2^53.
The FAIL delta line had the same defect (%+d): a dead port makes the
delta as large as the counter itself, so the one number needed to
diagnose the failure would have been the one that saturated.
Verdicts were never affected. The cross-check compares the TX[]/RX[]
doubles directly and only the display path goes through grp(), so past
PASS results stand; only the printed numbers were wrong.
Verified against a captured run (secret/Counter.log, 108 pairs): values
now match the raw MIB_TPOK/MIB_RPOK lines exactly, and the loopback
identity holds (cd0.TX == cd32.RX, cd0.RX == cd32.TX).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014RetWKFZFG1ZHcitQAyhwM
This commit is contained in:
@@ -61,6 +61,19 @@
|
|||||||
# intentional difference from
|
# intentional difference from
|
||||||
# tools/bcm_mibpair_report_V1.1.0.py, which hides NA pairs
|
# tools/bcm_mibpair_report_V1.1.0.py, which hides NA pairs
|
||||||
# unless -a is given.
|
# unless -a is given.
|
||||||
|
# V0.4.1 2026-08-19 Fix: report printed every counter as 2147483647 (INT32_MAX).
|
||||||
|
# grp() rendered values with sprintf("%d", v); the DUT's awk
|
||||||
|
# casts to a 32-bit int for %d, so any counter above 2^31-1
|
||||||
|
# -- i.e. every real line-speed run -- saturated. Values are
|
||||||
|
# now formatted with %.0f, which stays in awk's double domain
|
||||||
|
# (exact to 2^53, far above any MIB counter).
|
||||||
|
# NOTE: the PASS/FAIL verdicts were NEVER affected -- the
|
||||||
|
# cross-check compares TX[]/RX[] doubles directly and only
|
||||||
|
# the display path went through grp(). Past reports that said
|
||||||
|
# PASS were right; only the numbers shown were wrong.
|
||||||
|
# Same fix applied to the "# FAIL ..." delta line (%+d ->
|
||||||
|
# %+.0f), which would otherwise saturate when a dead port
|
||||||
|
# makes the delta the size of the whole counter.
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
#
|
#
|
||||||
# The VLAN/port table below is copied verbatim from
|
# The VLAN/port table below is copied verbatim from
|
||||||
@@ -486,7 +499,7 @@ _tl_pair_report() {
|
|||||||
-v TSV="$TL_REPORT_TSV" \
|
-v TSV="$TL_REPORT_TSV" \
|
||||||
-v COLOR="$color" '
|
-v COLOR="$color" '
|
||||||
function grp(v, s,out,l,i) {
|
function grp(v, s,out,l,i) {
|
||||||
s = sprintf("%d", v)
|
s = sprintf("%.0f", v)
|
||||||
if (!GROUPED) return s
|
if (!GROUPED) return s
|
||||||
out = ""; l = length(s)
|
out = ""; l = length(s)
|
||||||
for (i = 1; i <= l; i++) {
|
for (i = 1; i <= l; i++) {
|
||||||
@@ -557,7 +570,7 @@ _tl_pair_report() {
|
|||||||
if (d <= TOL + 0) { v = "PASS"; npass++ }
|
if (d <= TOL + 0) { v = "PASS"; npass++ }
|
||||||
else {
|
else {
|
||||||
v = "FAIL"; nfail++
|
v = "FAIL"; nfail++
|
||||||
FL[++nf] = sprintf("# FAIL %s/%s: %s.TX-%s.RX=%+d %s.RX-%s.TX=%+d", \
|
FL[++nf] = sprintf("# FAIL %s/%s: %s.TX-%s.RX=%+.0f %s.RX-%s.TX=%+.0f", \
|
||||||
a, b, a, b, dtx, a, b, drx)
|
a, b, a, b, dtx, a, b, drx)
|
||||||
}
|
}
|
||||||
ta = grp(TX[a]); ra = grp(RX[a]); tb = grp(TX[b]); rb = grp(RX[b])
|
ta = grp(TX[a]); ra = grp(RX[a]); tb = grp(TX[b]); rb = grp(RX[b])
|
||||||
|
|||||||
Reference in New Issue
Block a user