diff --git a/src/Script_ABC_Blanton/1_Blanton_Script_A.ttl b/src/Script_ABC_Blanton/1_Blanton_Script_A.ttl index 3b3470e..f7afb01 100644 --- a/src/Script_ABC_Blanton/1_Blanton_Script_A.ttl +++ b/src/Script_ABC_Blanton/1_Blanton_Script_A.ttl @@ -1,6 +1,6 @@ ; ============================================================================= ; Script A for Blanton -; Version : V1.0.5 +; Version : V1.0.4 ; Date : 2026-08-21 ; Author : ETWen ; ============================================================================= @@ -16,9 +16,9 @@ ; ScriptB/C Add Traffic Test ; V1.0.3 2026-08-21 utils/wait_init.ttl Created ; ScriptA Add Wait DUT Ready -; V1.0.4 2026-08-21 utils/wait_init.ttl Wait on bcmcmd port-up -; count (both units > 216) -; V1.0.5 2026-08-21 ScriptA Add EEPROM info (hpe-eeprom-tlv --bus 4 --addr 0x50) +; V1.0.4 2026-08-21 utils/wait_init.ttl Wait on bcmcmd port-up, count (both units > 216) +; utils/wait_init.ttl Add WT_UNIT0/WT_UNIT1, skip absent units +; ScriptA Add EEPROM info (hpe-eeprom-tlv --bus 4 --addr 0x50) ; ScriptA Remove empty Check History block ; ScriptA/B Disable lldp + config save before traffic (silent MAC) ; ScriptB Add sfputil lpmode off Ethernet513/514 diff --git a/src/Script_ABC_Blanton/utils/wait_init.ttl b/src/Script_ABC_Blanton/utils/wait_init.ttl index df53470..108a1c8 100644 --- a/src/Script_ABC_Blanton/utils/wait_init.ttl +++ b/src/Script_ABC_Blanton/utils/wait_init.ttl @@ -1,21 +1,25 @@ ; ============================================================================= ; File : utils/wait_init.ttl -; Version : V2.0.0 +; Version : V3.0.0 ; Date : 2026-08-21 ; Author : ETWen ; ============================================================================= -; Wait until BOTH switch units report more than WT_MIN ports up: -; bcmcmd -n 0 -c ps | grep -w up | wc -l -; bcmcmd -n 1 -c ps | grep -w up | wc -l +; Wait until every switch unit ENABLED below reports more than WT_MIN ports up: +; bcmcmd -n -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. ; 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 -; screen: TTL can only test for a string, so counting requires capturing the -; output. Wrapping the count in an echo gives waitregex a unique anchor, and -; the ECHO of the command itself cannot false-match -- it reads -; "PORTS0=$(bcmcmd ..." and the regex demands a digit right after the "=". +; Why the "PORTS0=" marker: TTL can only test for a string, so reading a count +; means capturing it. Wrapping the number in an echo gives waitregex a unique +; anchor, and the ECHO of the command cannot false-match -- it reads +; "PORTS0=$(bcmcmd ..." and the pattern requires a digit right after the "=". ; ; Version History: ; V1.0.0 2026-08-21 Initial Version (waited on "show platform temperature" @@ -23,46 +27,72 @@ ; 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 ; 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 -WT_INTERVAL = 10 ; seconds between polls +; ---- 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 +; ----------------------------------------------------------------------------- -timeout = 60 ; per-wait cap; bcmcmd ps is not instant +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 + goto NO_UNITS + endif +endif + :WAIT_PORTS -; --- unit 0 ----------------------------------------------------------------- -wt_up0 = 0 -sendln "echo PORTS0=$(bcmcmd -n 0 -c ps | grep -w up | wc -l)" -waitregex "PORTS0=[ ]*([0-9]+)" -if result = 1 then - str2int wt_up0 groupmatchstr1 -endif -wait prompt_sonic_root +wt_ok = 1 -; --- unit 1 ----------------------------------------------------------------- -wt_up1 = 0 -sendln "echo PORTS1=$(bcmcmd -n 1 -c ps | grep -w up | wc -l)" -waitregex "PORTS1=[ ]*([0-9]+)" -if result = 1 then - str2int wt_up1 groupmatchstr1 -endif -wait prompt_sonic_root - -; --- both above the threshold? ---------------------------------------------- -; 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 +if WT_UNIT0 = 1 then + wt_up0 = 0 + sendln "echo PORTS0=$(bcmcmd -n 0 -c ps | grep -w up | wc -l)" + waitregex "PORTS0=[ ]*([0-9]+)" + if result = 1 then + str2int wt_up0 groupmatchstr1 endif + wait prompt_sonic_root + if wt_up0 <= WT_MIN then + wt_ok = 0 + endif +endif + +if WT_UNIT1 = 1 then + wt_up1 = 0 + sendln "echo PORTS1=$(bcmcmd -n 1 -c ps | grep -w up | wc -l)" + waitregex "PORTS1=[ ]*([0-9]+)" + if result = 1 then + str2int wt_up1 groupmatchstr1 + endif + wait prompt_sonic_root + if wt_up1 <= WT_MIN then + wt_ok = 0 + endif +endif + +if wt_ok = 1 then + goto PORTS_OK endif pause WT_INTERVAL 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 -timeout = 0 -; Exit contract: send something without waiting, so the caller's next -; "wait prompt_sonic_root" has a prompt to match. sendln "" + +:DONE +timeout = 0