[test] stabilize rcp restoration test (#12140)

This commit is contained in:
Yakun Xu
2025-11-12 15:58:19 +01:00
committed by GitHub
parent beeef5f8a6
commit 01aba923ad
+50 -38
View File
@@ -31,11 +31,24 @@ source "tests/scripts/expect/_common.exp"
source "tests/scripts/expect/_multinode.exp"
if {[info exists ::env(THREAD_VERSION)]} {
set ot_thread_version $::env(THREAD_VERSION)
} else {
set ot_thread_version ""
}
if {[info exists ::env(OT_SIMULATION_APPS)]} {
set ot_simulation_apps $::env(OT_SIMULATION_APPS)
} else {
set ot_simulation_apps "build/simulation/examples/apps"
}
# The expect on macOS doesn't support `try` or `file tempfile`.
skip_on_macos
file tempfile socat_out
set socat_pid [exec socat -d -d pty,raw,echo=0 pty,raw,echo=0 >/dev/null 2>$socat_out &]
spawn bash -c "exec socat -d -d pty,raw,echo=0 pty,raw,echo=0 >/dev/null 2>$socat_out"
set socat_id $spawn_id
while {true} {
if {[exec head -n2 $socat_out | wc -l] == 2} {
set radio_pty [exec head -n1 $socat_out | grep -o {/dev/.\+}]
@@ -48,8 +61,9 @@ while {true} {
puts "Radio PTY: $radio_pty"
puts "Host PTY: $host_pty"
set rcp_pid [exec $::env(OT_SIMULATION_APPS)/ncp/ot-rcp 1 < $radio_pty > $radio_pty &]
puts "RCP PID: $rcp_pid"
spawn bash -c "exec $ot_simulation_apps/ncp/ot-rcp 1 < $radio_pty > $radio_pty"
set rcp_id $spawn_id
puts "RCP PID: $rcp_id"
try {
puts "Before enabling"
@@ -87,11 +101,12 @@ try {
sleep 1
exec kill $rcp_pid
puts "Killed $rcp_pid"
close -i $rcp_id
puts "Killed $rcp_id"
sleep 1
set rcp_pid [exec $::env(OT_SIMULATION_APPS)/ncp/ot-rcp 1 < $radio_pty > $radio_pty &]
puts "RCP PID: $rcp_pid"
spawn bash -c "exec $ot_simulation_apps/ncp/ot-rcp 1 < $radio_pty > $radio_pty"
set rcp_id $spawn_id
puts "RCP PID: $rcp_id"
sleep 1
@@ -106,11 +121,12 @@ try {
puts "Queued parent-to-child packets, as child"
exec kill $rcp_pid
puts "Killed $rcp_pid"
close -i $rcp_id
puts "Killed $rcp_id"
sleep 1
set rcp_pid [exec $::env(OT_SIMULATION_APPS)/ncp/ot-rcp 2 < $radio_pty > $radio_pty &]
puts "RCP PID: $rcp_pid"
spawn bash -c "exec $ot_simulation_apps/ncp/ot-rcp 2 < $radio_pty > $radio_pty"
set rcp_id $spawn_id
puts "RCP PID: $rcp_id"
spawn_node 1
spawn_node 2 "rcp" "spinel+hdlc_uart://$host_pty"
@@ -141,11 +157,12 @@ try {
sleep 1
exec kill $rcp_pid
puts "Killed $rcp_pid"
close -i $rcp_id
puts "Killed $rcp_id"
sleep 1
set rcp_pid [exec $::env(OT_SIMULATION_APPS)/ncp/ot-rcp 2 < $radio_pty > $radio_pty &]
puts "RCP PID: $rcp_pid"
spawn bash -c "exec $ot_simulation_apps/ncp/ot-rcp 2 < $radio_pty > $radio_pty"
set rcp_id $spawn_id
puts "RCP PID: $rcp_id"
sleep 1
@@ -156,11 +173,12 @@ try {
dispose_all
exec kill $rcp_pid
puts "Killed $rcp_pid"
close -i $rcp_id
puts "Killed $rcp_id"
sleep 1
set rcp_pid [exec $::env(OT_SIMULATION_APPS)/ncp/ot-rcp 1 < $radio_pty > $radio_pty &]
puts "RCP PID: $rcp_pid"
spawn bash -c "exec $ot_simulation_apps/ncp/ot-rcp 1 < $radio_pty > $radio_pty"
set rcp_id $spawn_id
puts "RCP PID: $rcp_id"
puts "Many children, queued child-to-child packets"
@@ -197,11 +215,12 @@ try {
sleep 1
exec kill $rcp_pid
puts "Killed $rcp_pid"
close -i $rcp_id
puts "Killed $rcp_id"
sleep 1
set rcp_pid [exec $::env(OT_SIMULATION_APPS)/ncp/ot-rcp 1 < $radio_pty > $radio_pty &]
puts "RCP PID: $rcp_pid"
spawn bash -c "exec $ot_simulation_apps/ncp/ot-rcp 1 < $radio_pty > $radio_pty"
set rcp_id $spawn_id
puts "RCP PID: $rcp_id"
sleep 1
@@ -215,17 +234,18 @@ try {
switch_node 4
send "udp send $addr(5) 11003 hello_from_node_4\n"
expect_line "Done"
if {$::env(THREAD_VERSION) != "1.1"} {
if {$ot_thread_version != "1.1"} {
expect "5 bytes from $addr(1) 11004 hello"
}
sleep 1
exec kill $rcp_pid
puts "Killed $rcp_pid"
close -i $rcp_id
puts "Killed $rcp_id"
sleep 1
set rcp_pid [exec $::env(OT_SIMULATION_APPS)/ncp/ot-rcp 1 < $radio_pty > $radio_pty &]
puts "RCP PID: $rcp_pid"
spawn bash -c "exec $ot_simulation_apps/ncp/ot-rcp 1 < $radio_pty > $radio_pty"
set rcp_id $spawn_id
puts "RCP PID: $rcp_id"
sleep 1
@@ -249,14 +269,6 @@ try {
sleep 1
exec kill $rcp_pid
puts "Killed $rcp_pid"
sleep 1
set rcp_pid [exec $::env(OT_SIMULATION_APPS)/ncp/ot-rcp 1 < $radio_pty > $radio_pty &]
puts "RCP PID: $rcp_pid"
sleep 1
for {set i 11} {$i <= 26} {incr i} {
expect -re "\\| +$i \\| +-?\\d+ \\|"
}
@@ -264,6 +276,6 @@ try {
dispose_all
} finally {
exec kill $rcp_pid
exec kill $socat_pid
close -i $rcp_id
close -i $socat_id
}