feat(ttl): Drive traffic and port wait from SWB_UNIT0/SWB_UNIT1

The bench is not always fully populated. config.ttl now declares which
switch units exist:

    SWB_UNIT0 = 1   ; this DUT has switch unit 0
    SWB_UNIT1 = 1   ; this DUT has switch unit 1

Two values are derived there rather than repeating the same test in
three scripts: swb_any (0 = no unit at all) and swb_opt, the suffix
appended to each blanton_traffic_linespeed call -- "" for both units so
the tool's own TL_UNITS="0 1" applies, " -u 0" or " -u 1" for a single
one.

Script A, B and C build their traffic commands with sprintf2 and the
suffix, wrapped in `if swb_any = 1`. A half-populated DUT no longer
issues bcmcmd against an absent unit, and a DUT with no switch board
skips the traffic stage outright instead of filling the log with
failures.

wait_init.ttl reads the same two flags instead of its own copies, so the
wait and the traffic blocks cannot disagree about what is installed.

Script A -> V1.0.5.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014RetWKFZFG1ZHcitQAyhwM
This commit is contained in:
2026-08-21 12:06:28 +08:00
co-authored by Claude Opus 5
parent da39122c43
commit d8bf1f7a41
5 changed files with 104 additions and 44 deletions
+14 -12
View File
@@ -7,11 +7,12 @@
; Wait until every switch unit ENABLED below reports more than WT_MIN ports up:
; bcmcmd -n <u> -c ps | grep -w up | wc -l
;
; The DUT is not always fully populated, so declare what this bench has:
; both units -> WT_UNIT0 = 1 , WT_UNIT1 = 1
; unit 0 only -> WT_UNIT0 = 1 , WT_UNIT1 = 0
; unit 1 only -> WT_UNIT0 = 0 , WT_UNIT1 = 1
; no unit -> WT_UNIT0 = 0 , WT_UNIT1 = 0 (bypass, returns immediately)
; The DUT is not always fully populated. Which units exist is declared ONCE in
; config.ttl, so the traffic blocks in Script A/B/C and this wait agree:
; both units -> SWB_UNIT0 = 1 , SWB_UNIT1 = 1
; unit 0 only -> SWB_UNIT0 = 1 , SWB_UNIT1 = 0
; unit 1 only -> SWB_UNIT0 = 0 , SWB_UNIT1 = 1
; no unit -> SWB_UNIT0 = 0 , SWB_UNIT1 = 0 (bypass, returns immediately)
;
; Enter : prompt of the previous command is NOT consumed.
; Exit : a command has been sent, prompt NOT consumed (caller does the wait).
@@ -30,10 +31,11 @@
; V3.0.0 2026-08-21 Add WT_UNIT0 / WT_UNIT1 so a partly populated DUT can
; be declared: wait on the enabled units only, and bypass
; entirely when neither is set.
; V3.1.0 2026-08-21 Take the population from SWB_UNIT0 / SWB_UNIT1 in
; config.ttl instead of local copies, so this wait and the
; traffic blocks cannot drift apart.
; =============================================================================
; ---- edit these for the bench ----------------------------------------------
WT_UNIT0 = 1 ; 1 = this DUT has switch unit 0, wait for it ; 0 = skip
WT_UNIT1 = 1 ; 1 = this DUT has switch unit 1, wait for it ; 0 = skip
; ---- which units to wait for: SWB_UNIT0 / SWB_UNIT1, set in config.ttl ------
WT_MIN = 216 ; an enabled unit must report MORE than this many ports up
WT_INTERVAL = 10 ; seconds between polls
; -----------------------------------------------------------------------------
@@ -42,8 +44,8 @@ timeout = 60 ; per-wait cap; bcmcmd ps is not instant
wait prompt_sonic_root
; nothing declared -> bypass
if WT_UNIT0 = 0 then
if WT_UNIT1 = 0 then
if SWB_UNIT0 = 0 then
if SWB_UNIT1 = 0 then
goto NO_UNITS
endif
endif
@@ -51,7 +53,7 @@ endif
:WAIT_PORTS
wt_ok = 1
if WT_UNIT0 = 1 then
if SWB_UNIT0 = 1 then
wt_up0 = 0
sendln "echo PORTS0=$(bcmcmd -n 0 -c ps | grep -w up | wc -l)"
waitregex "PORTS0=[ ]*([0-9]+)"
@@ -64,7 +66,7 @@ if WT_UNIT0 = 1 then
endif
endif
if WT_UNIT1 = 1 then
if SWB_UNIT1 = 1 then
wt_up1 = 0
sendln "echo PORTS1=$(bcmcmd -n 1 -c ps | grep -w up | wc -l)"
waitregex "PORTS1=[ ]*([0-9]+)"