[posix] enable expect tests on macOS (#5384)

This commit enables expect tests on macOS, also includes the following
required changes:

* Fixed bound to interface issue on macOS.
* Added ability to configure scan period, because macOS environment on
  GitHub Actions is much slower.
This commit is contained in:
Yakun Xu
2021-02-02 21:50:18 -08:00
committed by GitHub
parent 4755eea1d1
commit ad91ac3b9c
9 changed files with 112 additions and 54 deletions
+23 -16
View File
@@ -27,8 +27,15 @@
# POSSIBILITY OF SUCH DAMAGE.
#
proc skip_on_macos {} {
set OSTYPE [lindex $::tcl_platform(os) 0]
if { $OSTYPE == "Darwin" } {
exit 77
}
}
proc wait_for {command success {failure {[\r\n]FAILURE_NOT_EXPECTED[\r\n]}}} {
set result 0
set timeout 1
for {set i 0} {$i < 20} {incr i} {
if {$command != ""} {
@@ -37,22 +44,17 @@ proc wait_for {command success {failure {[\r\n]FAILURE_NOT_EXPECTED[\r\n]}}} {
expect {
-re $success {
set result 1
return 0
}
-re $failure {
error "Got failure in wait_for"
fail "Failed due to '$failure' found"
}
timeout {
# Do nothing
}
}
if {$result == 1} {
break
}
}
if {$result == 0} {
error "Timed out in wait_for"
}
fail "Failed due to '$success' not found"
}
proc expect_line {line} {
@@ -107,7 +109,7 @@ proc spawn_node {id {type ""} {radio_url ""}} {
}
expect_after {
timeout { error "Timed out" }
timeout { fail "Timed out" }
}
set spawn_ids($id) $spawn_id
@@ -123,12 +125,6 @@ proc switch_node {id} {
set spawn_id $spawn_ids($id)
}
proc dispose_node {id} {
switch_node $id
send "\x04"
expect eof
}
proc setup_leader {} {
send "dataset init new\n"
expect_line "Done"
@@ -144,6 +140,12 @@ proc setup_leader {} {
expect_line "Done"
}
proc dispose_node {id} {
switch_node $id
send "\x04"
expect eof
}
proc dispose_all {} {
global spawn_ids
set max_node [array size spawn_ids]
@@ -188,4 +190,9 @@ proc setup_default_network {} {
expect_line "Done"
}
proc fail {message} {
dispose_all
error $message
}
set timeout 10
+1 -1
View File
@@ -77,7 +77,7 @@ proc setup_node {node {mode "r"} {role "child"}} {
expect_line "Done"
send "joiner start $::JOINER_PSK\n"
expect_line "Done"
wait_for "" "Join success"
wait_for "" "Join success" "Join failed"
send "thread start\n"
expect_line "Done"
wait_for "state" $role
@@ -31,6 +31,9 @@ source "tests/scripts/expect/_common.exp"
source "tests/scripts/expect/_multinode.exp"
# 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 &]
while {true} {
+2 -6
View File
@@ -27,14 +27,10 @@
# POSSIBILITY OF SUCH DAMAGE.
#
set OSTYPE [lindex $tcl_platform(os) 0]
if { $OSTYPE == "Darwin" } {
exit 77
}
source "tests/scripts/expect/_common.exp"
skip_on_macos
spawn_node 1
send "panid 0xface\n"