feat(ttl): Gate Script A on bcmcmd port-up count, not thermal sensors
wait_init.ttl V2.0.0 now polls
bcmcmd -n 0 -c ps | grep -w up | wc -l
bcmcmd -n 1 -c ps | grep -w up | wc -l
and proceeds only when BOTH exceed 216, so the baseline is taken with
the data plane actually up rather than merely with pmon answering.
V1.0.0 could use `wait "Thermal Not detected" prompt` because that was a
string-presence test. Comparing a count needs the value captured, so the
count is wrapped in an echo marker and read with waitregex +
groupmatchstr1 + str2int. The command echo cannot false-match: it reads
"PORTS0=$(bcmcmd ..." and the pattern requires a digit immediately after
the "=". The optional-space allowance covers a wc that pads its output.
The two thresholds are compared in nested ifs rather than with `and`,
which is bitwise in TTL.
WT_MIN and WT_INTERVAL are at the top of the file. The enter/exit prompt
contract is unchanged, so Script A's surrounding waits still line up.
Script A -> V1.0.4.
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.3
|
; Version : V1.0.4
|
||||||
; Date : 2026-08-21
|
; Date : 2026-08-21
|
||||||
; Author : ETWen
|
; Author : ETWen
|
||||||
; =============================================================================
|
; =============================================================================
|
||||||
@@ -16,6 +16,8 @@
|
|||||||
; 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
|
||||||
|
; count (both units > 216)
|
||||||
; =============================================================================
|
; =============================================================================
|
||||||
include "config.ttl"
|
include "config.ttl"
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,68 @@
|
|||||||
; =============================================================================
|
; =============================================================================
|
||||||
; File : utils/wait_init.ttl
|
; File : utils/wait_init.ttl
|
||||||
; Version : V1.0.0
|
; Version : V2.0.0
|
||||||
; Date : 2026-08-21
|
; Date : 2026-08-21
|
||||||
; Author : ETWen
|
; Author : ETWen
|
||||||
; =============================================================================
|
; =============================================================================
|
||||||
; Wait until "show platform temperature" is not "Thermal Not detected".
|
; Wait until BOTH switch units report more than WT_MIN ports up:
|
||||||
; Enter : prompt of the previous command is NOT consumed.
|
; bcmcmd -n 0 -c ps | grep -w up | wc -l
|
||||||
; Exit : "show platform temperature" is sent, prompt NOT consumed.
|
; bcmcmd -n 1 -c ps | grep -w up | wc -l
|
||||||
;
|
;
|
||||||
; Version History:
|
; Enter : prompt of the previous command is NOT consumed.
|
||||||
; V1.0.0 2026-08-21 Initial Version
|
; Exit : a command has been sent, prompt NOT consumed (caller does the wait).
|
||||||
; =============================================================================
|
;
|
||||||
wt_interval = 10
|
; Why the "PORTS0=" marker instead of reading the number straight off the
|
||||||
timeout = 30
|
; screen: TTL can only test for a string, so counting requires capturing the
|
||||||
wait prompt_sonic_root
|
; output. Wrapping the count in an echo gives waitregex a unique anchor, and
|
||||||
|
; the ECHO of the command itself cannot false-match -- it reads
|
||||||
:WAIT_THERMAL
|
; "PORTS0=$(bcmcmd ..." and the regex demands a digit right after the "=".
|
||||||
sendln "show platform temperature"
|
;
|
||||||
wait "Thermal Not detected" prompt_sonic_root
|
; Version History:
|
||||||
if result = 2 then
|
; V1.0.0 2026-08-21 Initial Version (waited on "show platform temperature"
|
||||||
goto THERMAL_OK
|
; until it stopped reporting "Thermal Not detected")
|
||||||
endif
|
; V2.0.0 2026-08-21 Wait on the bcmcmd port-up count of BOTH switch units
|
||||||
wait prompt_sonic_root
|
; instead of the thermal sensors; proceed only when both
|
||||||
pause wt_interval
|
; are greater than WT_MIN (216).
|
||||||
goto WAIT_THERMAL
|
; =============================================================================
|
||||||
|
WT_MIN = 216 ; both units must report MORE than this many ports up
|
||||||
:THERMAL_OK
|
WT_INTERVAL = 10 ; seconds between polls
|
||||||
timeout = 0
|
|
||||||
sendln "show platform temperature"
|
timeout = 60 ; per-wait cap; bcmcmd ps is not instant
|
||||||
|
wait prompt_sonic_root
|
||||||
|
|
||||||
|
: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
|
||||||
|
|
||||||
|
; --- 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
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
pause WT_INTERVAL
|
||||||
|
goto WAIT_PORTS
|
||||||
|
|
||||||
|
: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 ""
|
||||||
|
|||||||
Reference in New Issue
Block a user