feat(ttl): Let wait_init skip switch units the DUT does not have
wait_init.ttl V3.0.0 adds WT_UNIT0 and WT_UNIT1 at the top of the file.
Benches are not always fully populated, and V2.0.0 waited on both units
unconditionally, so a DUT with one switch board sat in the poll loop
forever -- silently, since the loop neither advances nor reports.
both units -> 1 , 1
unit 0 only -> 1 , 0
unit 1 only -> 0 , 1
no unit -> 0 , 0 (bypass, returns immediately)
A disabled unit is skipped rather than polled and ignored: its whole
block sits inside the if, so no bcmcmd is issued for it and no
misleading error reaches the log.
Two independent integer flags rather than a "0 1" string, because
parsing a string in TTL needs strscan and this is meant to be edited by
hand at the bench.
All three exit paths still leave exactly one prompt unconsumed, so
Script A's surrounding waits are unaffected.
Script A history: recorded under the existing V1.0.4 block rather than a
new version, matching the consolidation done there.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014RetWKFZFG1ZHcitQAyhwM
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
; =============================================================================
|
; =============================================================================
|
||||||
; Script A for Blanton
|
; Script A for Blanton
|
||||||
; Version : V1.0.5
|
; Version : V1.0.4
|
||||||
; Date : 2026-08-21
|
; Date : 2026-08-21
|
||||||
; Author : ETWen
|
; Author : ETWen
|
||||||
; =============================================================================
|
; =============================================================================
|
||||||
@@ -16,9 +16,9 @@
|
|||||||
; ScriptB/C Add Traffic Test
|
; ScriptB/C Add Traffic Test
|
||||||
; V1.0.3 2026-08-21 utils/wait_init.ttl Created
|
; V1.0.3 2026-08-21 utils/wait_init.ttl Created
|
||||||
; ScriptA Add Wait DUT Ready
|
; ScriptA Add Wait DUT Ready
|
||||||
; V1.0.4 2026-08-21 utils/wait_init.ttl Wait on bcmcmd port-up
|
; V1.0.4 2026-08-21 utils/wait_init.ttl Wait on bcmcmd port-up, count (both units > 216)
|
||||||
; count (both units > 216)
|
; utils/wait_init.ttl Add WT_UNIT0/WT_UNIT1, skip absent units
|
||||||
; V1.0.5 2026-08-21 ScriptA Add EEPROM info (hpe-eeprom-tlv --bus 4 --addr 0x50)
|
; ScriptA Add EEPROM info (hpe-eeprom-tlv --bus 4 --addr 0x50)
|
||||||
; ScriptA Remove empty Check History block
|
; ScriptA Remove empty Check History block
|
||||||
; ScriptA/B Disable lldp + config save before traffic (silent MAC)
|
; ScriptA/B Disable lldp + config save before traffic (silent MAC)
|
||||||
; ScriptB Add sfputil lpmode off Ethernet513/514
|
; ScriptB Add sfputil lpmode off Ethernet513/514
|
||||||
|
|||||||
@@ -1,21 +1,25 @@
|
|||||||
; =============================================================================
|
; =============================================================================
|
||||||
; File : utils/wait_init.ttl
|
; File : utils/wait_init.ttl
|
||||||
; Version : V2.0.0
|
; Version : V3.0.0
|
||||||
; Date : 2026-08-21
|
; Date : 2026-08-21
|
||||||
; Author : ETWen
|
; Author : ETWen
|
||||||
; =============================================================================
|
; =============================================================================
|
||||||
; Wait until BOTH switch units report more than WT_MIN ports up:
|
; Wait until every switch unit ENABLED below reports more than WT_MIN ports up:
|
||||||
; bcmcmd -n 0 -c ps | grep -w up | wc -l
|
; bcmcmd -n <u> -c ps | grep -w up | wc -l
|
||||||
; bcmcmd -n 1 -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)
|
||||||
;
|
;
|
||||||
; Enter : prompt of the previous command is NOT consumed.
|
; Enter : prompt of the previous command is NOT consumed.
|
||||||
; Exit : a command has been sent, prompt NOT consumed (caller does the wait).
|
; Exit : a command has been sent, prompt NOT consumed (caller does the wait).
|
||||||
;
|
;
|
||||||
; Why the "PORTS0=" marker instead of reading the number straight off the
|
; Why the "PORTS0=" marker: TTL can only test for a string, so reading a count
|
||||||
; screen: TTL can only test for a string, so counting requires capturing the
|
; means capturing it. Wrapping the number in an echo gives waitregex a unique
|
||||||
; output. Wrapping the count in an echo gives waitregex a unique anchor, and
|
; anchor, and the ECHO of the command cannot false-match -- it reads
|
||||||
; the ECHO of the command itself cannot false-match -- it reads
|
; "PORTS0=$(bcmcmd ..." and the pattern requires a digit right after the "=".
|
||||||
; "PORTS0=$(bcmcmd ..." and the regex demands a digit right after the "=".
|
|
||||||
;
|
;
|
||||||
; Version History:
|
; Version History:
|
||||||
; V1.0.0 2026-08-21 Initial Version (waited on "show platform temperature"
|
; V1.0.0 2026-08-21 Initial Version (waited on "show platform temperature"
|
||||||
@@ -23,15 +27,31 @@
|
|||||||
; V2.0.0 2026-08-21 Wait on the bcmcmd port-up count of BOTH switch units
|
; V2.0.0 2026-08-21 Wait on the bcmcmd port-up count of BOTH switch units
|
||||||
; instead of the thermal sensors; proceed only when both
|
; instead of the thermal sensors; proceed only when both
|
||||||
; are greater than WT_MIN (216).
|
; are greater than WT_MIN (216).
|
||||||
|
; 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.
|
||||||
; =============================================================================
|
; =============================================================================
|
||||||
WT_MIN = 216 ; both units must report MORE than this many ports up
|
; ---- 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
|
||||||
|
WT_MIN = 216 ; an enabled unit must report MORE than this many ports up
|
||||||
WT_INTERVAL = 10 ; seconds between polls
|
WT_INTERVAL = 10 ; seconds between polls
|
||||||
|
; -----------------------------------------------------------------------------
|
||||||
|
|
||||||
timeout = 60 ; per-wait cap; bcmcmd ps is not instant
|
timeout = 60 ; per-wait cap; bcmcmd ps is not instant
|
||||||
wait prompt_sonic_root
|
wait prompt_sonic_root
|
||||||
|
|
||||||
|
; nothing declared -> bypass
|
||||||
|
if WT_UNIT0 = 0 then
|
||||||
|
if WT_UNIT1 = 0 then
|
||||||
|
goto NO_UNITS
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
:WAIT_PORTS
|
:WAIT_PORTS
|
||||||
; --- unit 0 -----------------------------------------------------------------
|
wt_ok = 1
|
||||||
|
|
||||||
|
if WT_UNIT0 = 1 then
|
||||||
wt_up0 = 0
|
wt_up0 = 0
|
||||||
sendln "echo PORTS0=$(bcmcmd -n 0 -c ps | grep -w up | wc -l)"
|
sendln "echo PORTS0=$(bcmcmd -n 0 -c ps | grep -w up | wc -l)"
|
||||||
waitregex "PORTS0=[ ]*([0-9]+)"
|
waitregex "PORTS0=[ ]*([0-9]+)"
|
||||||
@@ -39,8 +59,12 @@ if result = 1 then
|
|||||||
str2int wt_up0 groupmatchstr1
|
str2int wt_up0 groupmatchstr1
|
||||||
endif
|
endif
|
||||||
wait prompt_sonic_root
|
wait prompt_sonic_root
|
||||||
|
if wt_up0 <= WT_MIN then
|
||||||
|
wt_ok = 0
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
; --- unit 1 -----------------------------------------------------------------
|
if WT_UNIT1 = 1 then
|
||||||
wt_up1 = 0
|
wt_up1 = 0
|
||||||
sendln "echo PORTS1=$(bcmcmd -n 1 -c ps | grep -w up | wc -l)"
|
sendln "echo PORTS1=$(bcmcmd -n 1 -c ps | grep -w up | wc -l)"
|
||||||
waitregex "PORTS1=[ ]*([0-9]+)"
|
waitregex "PORTS1=[ ]*([0-9]+)"
|
||||||
@@ -48,21 +72,27 @@ if result = 1 then
|
|||||||
str2int wt_up1 groupmatchstr1
|
str2int wt_up1 groupmatchstr1
|
||||||
endif
|
endif
|
||||||
wait prompt_sonic_root
|
wait prompt_sonic_root
|
||||||
|
if wt_up1 <= WT_MIN then
|
||||||
; --- both above the threshold? ----------------------------------------------
|
wt_ok = 0
|
||||||
; Nested ifs rather than "and": in TTL "and" is bitwise, so keeping the two
|
|
||||||
; comparisons separate leaves no room for precedence surprises.
|
|
||||||
if wt_up0 > WT_MIN then
|
|
||||||
if wt_up1 > WT_MIN then
|
|
||||||
goto PORTS_OK
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if wt_ok = 1 then
|
||||||
|
goto PORTS_OK
|
||||||
|
endif
|
||||||
|
|
||||||
pause WT_INTERVAL
|
pause WT_INTERVAL
|
||||||
goto WAIT_PORTS
|
goto WAIT_PORTS
|
||||||
|
|
||||||
|
; ---- exits ------------------------------------------------------------------
|
||||||
|
; Both leave exactly one prompt unconsumed, so the caller's next
|
||||||
|
; "wait prompt_sonic_root" has something to match.
|
||||||
|
:NO_UNITS
|
||||||
|
sendln "echo wait_init:no-switch-unit-declared,bypassing-port-wait"
|
||||||
|
goto DONE
|
||||||
|
|
||||||
:PORTS_OK
|
:PORTS_OK
|
||||||
timeout = 0
|
|
||||||
; Exit contract: send something without waiting, so the caller's next
|
|
||||||
; "wait prompt_sonic_root" has a prompt to match.
|
|
||||||
sendln ""
|
sendln ""
|
||||||
|
|
||||||
|
:DONE
|
||||||
|
timeout = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user