Skip to content

Commit 73b6b13

Browse files
authored
[tests] add startup delay to prevent expect desync (openthread#13174)
This commit adds a brief 0.1-second sleep delay immediately after spawning node processes (rcp, cli, and mtd types) in the expect test harness. Under high CPU load on GitHub Actions runner VMs, the PTY file descriptors can take a fraction of a second to fully initialize. If commands are sent immediately after spawn without delay, the initial expect match can fail with an instant timeout. This triggers duplicate retransmissions in wait_for, leaving extra "Done" strings in expect's PTY read buffer. The leftover "Done" strings desynchronize subsequent assertions, causing tests to match cached output instead of waiting for actual command execution (e.g., sending "diag stats" during an active "diag send" command, which fails). Adding a 100ms delay gives the PTY and child process enough time to fully initialize and stabilize, avoiding instant timeouts and subsequent test harness desynchronization.
1 parent 5bc5324 commit 73b6b13

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

tests/scripts/expect/_common.exp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ proc spawn_node {id {type ""} {args ""}} {
118118
# avoid the error: "bind(sTxFd): Address already in use"
119119
sleep 0.2
120120
spawn /usr/bin/env GCOV_PREFIX=$gcov_prefix $ot_posix_apps/ot-cli $radio_url
121+
sleep 0.1
121122
send "factoryreset\n"
122123
wait_for "state" "disabled"
123124
expect_line "Done"
@@ -127,6 +128,7 @@ proc spawn_node {id {type ""} {args ""}} {
127128
cli {
128129
spawn /usr/bin/env GCOV_PREFIX=$gcov_prefix $ot_simulation_apps/cli/ot-cli-ftd \
129130
-L$ot_simulation_local_host $id
131+
sleep 0.1
130132
send "factoryreset\n"
131133
wait_for "state" "disabled"
132134
expect_line "Done"
@@ -136,6 +138,7 @@ proc spawn_node {id {type ""} {args ""}} {
136138
mtd {
137139
spawn /usr/bin/env GCOV_PREFIX=$gcov_prefix $ot_simulation_apps/cli/ot-cli-mtd \
138140
-L$ot_simulation_local_host $id
141+
sleep 0.1
139142
send "factoryreset\n"
140143
wait_for "state" "disabled"
141144
expect_line "Done"

0 commit comments

Comments
 (0)