From 9e3b450218582e721b102683de9786e7be5ef0b2 Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Mon, 12 Oct 2020 23:21:48 +0800 Subject: [PATCH] [expect] refactor common functions (#5634) * unify node creating and destroying * simplify switching between nodes --- tests/scripts/expect/_common.exp | 60 +++++++++++++------ tests/scripts/expect/_multinode.exp | 25 ++------ tests/scripts/expect/cli-big-table.exp | 14 +---- tests/scripts/expect/cli-channel.exp | 4 +- .../scripts/expect/cli-child-supervision.exp | 8 +-- tests/scripts/expect/cli-child.exp | 8 +-- tests/scripts/expect/cli-childip.exp | 8 +-- tests/scripts/expect/cli-coap.exp | 10 ++-- tests/scripts/expect/cli-coaps.exp | 14 ++--- tests/scripts/expect/cli-coex.exp | 4 +- tests/scripts/expect/cli-commissioner.exp | 8 +-- tests/scripts/expect/cli-counters.exp | 4 +- tests/scripts/expect/cli-dataset.exp | 14 ++--- tests/scripts/expect/cli-discerner.exp | 8 +-- tests/scripts/expect/cli-extaddr.exp | 4 +- tests/scripts/expect/cli-ipmaddr.exp | 10 ++-- tests/scripts/expect/cli-log-level.exp | 6 +- tests/scripts/expect/cli-mac.exp | 4 +- tests/scripts/expect/cli-macfilter.exp | 4 +- tests/scripts/expect/cli-misc.exp | 7 ++- tests/scripts/expect/cli-neighbor.exp | 8 +-- tests/scripts/expect/cli-netdata.exp | 7 ++- tests/scripts/expect/cli-ping.exp | 12 ++-- tests/scripts/expect/cli-promiscuous.exp | 22 +++---- tests/scripts/expect/cli-pskc.exp | 4 +- tests/scripts/expect/cli-reset.exp | 4 +- tests/scripts/expect/cli-router.exp | 8 +-- tests/scripts/expect/cli-routereligible.exp | 4 +- tests/scripts/expect/cli-scan-discover.exp | 20 +++---- tests/scripts/expect/cli-udp.exp | 12 ++-- tests/scripts/expect/cli-unsecure-port.exp | 4 +- tests/scripts/expect/posix-diag-rcp.exp | 4 +- tests/scripts/expect/posix-rcp.exp | 4 +- .../scripts/expect/posix-scan-tx-to-sleep.exp | 5 +- .../scripts/expect/simulation-networktime.exp | 4 +- tests/scripts/expect/tun-dns-client.exp | 4 +- tests/scripts/expect/tun-netif.exp | 4 +- tests/scripts/expect/tun-netstat.exp | 4 +- tests/scripts/expect/tun-sntp.exp | 10 +++- tests/scripts/expect/tun-udp.exp | 9 ++- tests/scripts/expect/v1_2-rcp.exp | 14 +---- tests/scripts/expect/v1_2-sed_mac_send.exp | 6 +- 42 files changed, 196 insertions(+), 201 deletions(-) diff --git a/tests/scripts/expect/_common.exp b/tests/scripts/expect/_common.exp index bc44ee841..e4bce890c 100644 --- a/tests/scripts/expect/_common.exp +++ b/tests/scripts/expect/_common.exp @@ -55,7 +55,29 @@ proc wait_for {command success {failure {[\r\n]FAILURE_NOT_EXPECTED[\r\n]}}} { } } +proc spawn_node_mtd {id} { + global spawn_id + global spawn_ids + + send_user "\n# ${id}\n" + + spawn $::env(MTD_COMMAND) $id + + expect_after { + timeout { exit 1 } + } + + set spawn_ids($id) $spawn_id + + return $spawn_id +} + proc spawn_node {id} { + global spawn_id + global spawn_ids + + send_user "\n# ${id}\n" + if {[info exists ::env(RCP_COMMAND)] && $::env(RCP_COMMAND) != ""} { spawn $::env(OT_COMMAND) "spinel+hdlc+uart://$::env(RCP_COMMAND)?forkpty-arg=$id" } else { @@ -64,18 +86,27 @@ proc spawn_node {id} { expect_after { timeout { exit 1 } } + + set spawn_ids($id) $spawn_id + return $spawn_id } -proc setup_leader {} { - # Sets up a Thread network spawn_1 as the leader. - global spawn_1 +proc switch_node {id} { + global spawn_ids global spawn_id - global env - set spawn_1 [spawn_node 1] + send_user "\n# ${id}\n" + set spawn_id $spawn_ids($id) +} - set spawn_id $spawn_1 +proc dispose_node {id} { + switch_node $id + send "\x04" + expect eof +} + +proc setup_leader {} { send "dataset init new\n" expect "Done" send "dataset commit active\n" @@ -88,17 +119,12 @@ proc setup_leader {} { expect "Done" } -proc dispose {} { - send "\x04" - expect eof -} - -proc dispose_leader {} { - global spawn_1 - global spawn_id - - set spawn_id $spawn_1 - dispose +proc dispose_all {} { + global spawn_ids + set max_node [array size spawn_ids] + for {set i 1} {$i <= $max_node} {incr i} { + dispose_node $i + } } set timeout 10 diff --git a/tests/scripts/expect/_multinode.exp b/tests/scripts/expect/_multinode.exp index 371cdb9fd..4b7d84235 100644 --- a/tests/scripts/expect/_multinode.exp +++ b/tests/scripts/expect/_multinode.exp @@ -29,27 +29,21 @@ source "tests/scripts/expect/_common.exp" -proc setup_nodes {{childmode {r}}} { +proc setup_two_nodes {{childmode {r}}} { # Sets up a Thread network with 2 nodes, spawn_1 as the leader and spawn_2 # as a child. - - global spawn_1 - global spawn_2 - global spawn_id - global env - - set spawn_2 [spawn_node 2] set psk "J01NME" - set spawn_id $spawn_2 + spawn_node 2 send "eui64\n" expect -re {([0-9a-f]{16})} set eui64 $expect_out(1,string) expect "Done" + # Sets up a Thread network with node 1 as the leader. + spawn_node 1 setup_leader - set spawn_id $spawn_1 send "commissioner start\n" expect "Done" expect "Commissioner: active" @@ -61,7 +55,7 @@ proc setup_nodes {{childmode {r}}} { set channel $expect_out(1,string) expect "Done" - set spawn_id $spawn_2 + switch_node 2 send "mode $childmode\n" expect "Done" send "ifconfig up\n" @@ -74,12 +68,3 @@ proc setup_nodes {{childmode {r}}} { wait_for "state" "child" expect "Done" } - -proc dispose_nodes {} { - global spawn_2 - global spawn_id - - dispose_leader - set spawn_id $spawn_2 - dispose -} diff --git a/tests/scripts/expect/cli-big-table.exp b/tests/scripts/expect/cli-big-table.exp index 27659e6f2..b7d03077e 100755 --- a/tests/scripts/expect/cli-big-table.exp +++ b/tests/scripts/expect/cli-big-table.exp @@ -30,8 +30,7 @@ source "tests/scripts/expect/_common.exp" set max_node 15 -set spawn_ids(1) [spawn_node 1] -set spawn_id $spawn_ids(1) +spawn_node 1 expect_after { timeout { exit 1 } } @@ -45,8 +44,7 @@ wait_for "state" "leader" expect "Done" for {set i 2} {$i <= $max_node} {incr i} { - set spawn_ids($i) [spawn_node $i] - set spawn_id $spawn_ids($i) + spawn_node $i expect_after { timeout { exit 1 } } @@ -69,10 +67,4 @@ expect_after { send "child table\n" expect "Done" -for {set i 1} {$i <= $max_node} {incr i} { - set spawn_id $spawn_ids($i) - expect_after { - timeout { exit 1 } - } - dispose -} +dispose_all diff --git a/tests/scripts/expect/cli-channel.exp b/tests/scripts/expect/cli-channel.exp index 007f537fa..e6ef4efbb 100755 --- a/tests/scripts/expect/cli-channel.exp +++ b/tests/scripts/expect/cli-channel.exp @@ -29,7 +29,7 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "ifconfig up\n" expect "Done" @@ -86,4 +86,4 @@ expect "Done" send "channel manager something_invalid\n" expect "Error 7: InvalidArgs" -dispose +dispose_all diff --git a/tests/scripts/expect/cli-child-supervision.exp b/tests/scripts/expect/cli-child-supervision.exp index 84f426b37..1c8bf7f3c 100755 --- a/tests/scripts/expect/cli-child-supervision.exp +++ b/tests/scripts/expect/cli-child-supervision.exp @@ -30,18 +30,18 @@ source "tests/scripts/expect/_common.exp" source "tests/scripts/expect/_multinode.exp" -setup_nodes "-" +setup_two_nodes "-" -set spawn_id $spawn_1 +switch_node 1 send "childsupervision interval 30\n" expect "Done" send "childsupervision interval\n" expect "Done" -set spawn_id $spawn_2 +switch_node 2 send "childsupervision checktimeout 30\n" expect "Done" send "childsupervision checktimeout\n" expect "Done" -dispose_nodes +dispose_all diff --git a/tests/scripts/expect/cli-child.exp b/tests/scripts/expect/cli-child.exp index f54e8b0f9..6d4512163 100755 --- a/tests/scripts/expect/cli-child.exp +++ b/tests/scripts/expect/cli-child.exp @@ -30,9 +30,9 @@ source "tests/scripts/expect/_common.exp" source "tests/scripts/expect/_multinode.exp" -setup_nodes +setup_two_nodes -set spawn_id $spawn_2 +switch_node 2 send "extaddr\n" expect "extaddr" expect -re {([0-9a-f]{16})} @@ -44,7 +44,7 @@ expect -re {([0-9a-f]{4})} set rloc $expect_out(1,string) expect "Done" -set spawn_id $spawn_1 +switch_node 1 send "child table\n" expect "| ID | RLOC16 | Timeout | Age | LQ In | C_VN |R|D|N| Extended MAC |" expect "+-----+--------+------------+------------+-------+------+-+-+-+------------------+" @@ -59,4 +59,4 @@ send "child $child_id\n" expect "Ext Addr: $extaddr" expect "Done" -dispose_nodes +dispose_all diff --git a/tests/scripts/expect/cli-childip.exp b/tests/scripts/expect/cli-childip.exp index 1d8581b87..9a6d06af8 100755 --- a/tests/scripts/expect/cli-childip.exp +++ b/tests/scripts/expect/cli-childip.exp @@ -30,9 +30,9 @@ source "tests/scripts/expect/_common.exp" source "tests/scripts/expect/_multinode.exp" -setup_nodes +setup_two_nodes -set spawn_id $spawn_2 +switch_node 2 send "ipaddr mleid\n" expect "ipaddr mleid" expect -re {(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4})} @@ -44,7 +44,7 @@ expect -re {([0-9a-f]{4})} set rloc $expect_out(1,string) expect "Done" -set spawn_id $spawn_1 +switch_node 1 send "childip\n" expect "$rloc: $addr" expect "Done" @@ -58,4 +58,4 @@ expect "Error 7: InvalidArgs" send "childip something_invalid\n" expect "Error 35: InvalidCommand" -dispose_nodes +dispose_all diff --git a/tests/scripts/expect/cli-coap.exp b/tests/scripts/expect/cli-coap.exp index 829d43be4..871da396f 100755 --- a/tests/scripts/expect/cli-coap.exp +++ b/tests/scripts/expect/cli-coap.exp @@ -30,9 +30,9 @@ source "tests/scripts/expect/_common.exp" source "tests/scripts/expect/_multinode.exp" -setup_nodes +setup_two_nodes -set spawn_id $spawn_1 +switch_node 1 send "coap start\n" expect "Done" send "coap resource test/resource\n" @@ -45,7 +45,7 @@ expect -re {(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4})} set addr_1 $expect_out(1,string) expect "Done" -set spawn_id $spawn_2 +switch_node 2 send "coap start\n" expect "Done" send "coap parameters request 3000 4 3 5\n" @@ -76,7 +76,7 @@ expect -re {(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4})} set addr_2 $expect_out(1,string) expect "Done" -set spawn_id $spawn_1 +switch_node 1 expect "coap request from $addr_2 GET" expect "coap response sent" expect "coap request from $addr_2 POST with payload: 54657374696e67313233" @@ -111,4 +111,4 @@ expect "Error 7: InvalidArgs" send "coap\n" expect "Error 7: InvalidArgs" -dispose_nodes +dispose_all diff --git a/tests/scripts/expect/cli-coaps.exp b/tests/scripts/expect/cli-coaps.exp index 5502d8f88..e2ee895b5 100755 --- a/tests/scripts/expect/cli-coaps.exp +++ b/tests/scripts/expect/cli-coaps.exp @@ -30,9 +30,9 @@ source "tests/scripts/expect/_common.exp" source "tests/scripts/expect/_multinode.exp" -setup_nodes +setup_two_nodes -set spawn_id $spawn_1 +switch_node 1 send "coaps x509\n" expect "Done" send "coaps start\n" @@ -47,7 +47,7 @@ expect -re {(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4})} set addr_1 $expect_out(1,string) expect "Done" -set spawn_id $spawn_2 +switch_node 2 send "coaps x509\n" expect "Done" send "coaps start\n" @@ -78,7 +78,7 @@ expect -re {(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4})} set addr_2 $expect_out(1,string) expect "Done" -set spawn_id $spawn_1 +switch_node 1 expect "coaps request from $addr_2 GET" expect "coaps response sent" expect "coaps request from $addr_2 POST with payload: 54657374696e67313233" @@ -105,12 +105,12 @@ expect "Error 24: Already" send "coaps start something_invalid\n" expect "Error 7: InvalidArgs" -set spawn_id $spawn_2 +switch_node 2 send "coaps stop\n" expect "Done" -set spawn_id $spawn_1 +switch_node 1 send "coaps stop\n" expect "Done" -dispose_nodes +dispose_all diff --git a/tests/scripts/expect/cli-coex.exp b/tests/scripts/expect/cli-coex.exp index 635550924..ca26b3793 100755 --- a/tests/scripts/expect/cli-coex.exp +++ b/tests/scripts/expect/cli-coex.exp @@ -29,7 +29,7 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "coex disable\n" expect "Done" @@ -67,4 +67,4 @@ expect "Done" send "coex something_invalid\n" expect "Error 7: InvalidArgs" -dispose +dispose_all diff --git a/tests/scripts/expect/cli-commissioner.exp b/tests/scripts/expect/cli-commissioner.exp index 14513d272..f4b4e1606 100755 --- a/tests/scripts/expect/cli-commissioner.exp +++ b/tests/scripts/expect/cli-commissioner.exp @@ -30,10 +30,10 @@ source "tests/scripts/expect/_common.exp" source "tests/scripts/expect/_multinode.exp" -setup_nodes +setup_two_nodes set eui64 "d45e64fa83f81cf7" -set spawn_id $spawn_1 +switch_node 1 send "commissioner joiner add $eui64 J01NME\n" expect "Done" wait_for "netdata steeringdata check $eui64" "Done" @@ -41,7 +41,7 @@ send "commissioner joiner remove $eui64\n" expect "Done" wait_for "netdata steeringdata check $eui64" "NotFound" -set spawn_id $spawn_2 +switch_node 2 send "commissioner state\n" expect "disabled" expect "Done" @@ -84,4 +84,4 @@ expect "Error 7: InvalidArgs" send "commissioner\n" expect "Error 35: InvalidCommand" -dispose_nodes +dispose_all diff --git a/tests/scripts/expect/cli-counters.exp b/tests/scripts/expect/cli-counters.exp index 06b4105ca..eda2de1f0 100755 --- a/tests/scripts/expect/cli-counters.exp +++ b/tests/scripts/expect/cli-counters.exp @@ -29,7 +29,7 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "counters\n" expect "mac" @@ -50,4 +50,4 @@ expect "Error 7: InvalidArgs" send "counters other\n" expect "Error 7: InvalidArgs" -dispose +dispose_all diff --git a/tests/scripts/expect/cli-dataset.exp b/tests/scripts/expect/cli-dataset.exp index 6ce313689..e5c5dde1b 100755 --- a/tests/scripts/expect/cli-dataset.exp +++ b/tests/scripts/expect/cli-dataset.exp @@ -30,9 +30,9 @@ source "tests/scripts/expect/_common.exp" source "tests/scripts/expect/_multinode.exp" -setup_nodes +setup_two_nodes -set spawn_id $spawn_1 +switch_node 1 send "dataset active\n" expect -re {Active Timestamp: \d+} expect -re {Channel: (\d+)} @@ -140,7 +140,7 @@ expect "Done" sleep 30 -set spawn_id $spawn_2 +switch_node 2 wait_for "dataset active" "Active Timestamp: 100" expect "Done" send "dataset active\n" @@ -182,14 +182,14 @@ expect "Done" send "dataset init pending\n" expect "Error 23: NotFound" -set spawn_id $spawn_1 +switch_node 1 send "ipaddr mleid\n" expect "ipaddr mleid" expect -re {(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4})} set addr $expect_out(1,string) expect "Done" -set spawn_id $spawn_2 +switch_node 2 send "dataset mgmtgetcommand active \ activetimestamp pendingtimestamp masterkey networkname extpanid \ localprefix delaytimer panid channel \ @@ -203,7 +203,7 @@ localprefix delaytimer panid channel \ address $addr\n" expect "Done" -set spawn_id $spawn_1 +switch_node 1 send "dataset active -x\n" expect "dataset active -x" expect -re {([0-9a-f]+)} @@ -243,4 +243,4 @@ expect "Error 7: InvalidArgs" send "dataset set something_invalid 00\n" expect "Error 7: InvalidArgs" -dispose_nodes +dispose_all diff --git a/tests/scripts/expect/cli-discerner.exp b/tests/scripts/expect/cli-discerner.exp index ad67375a6..64f422ba7 100755 --- a/tests/scripts/expect/cli-discerner.exp +++ b/tests/scripts/expect/cli-discerner.exp @@ -29,6 +29,7 @@ source "tests/scripts/expect/_common.exp" +spawn_node 1 setup_leader set pskd "J01NME" @@ -58,9 +59,8 @@ wait_for "netdata steeringdata check $discerner" "NotFound" send "commissioner joiner add $discerner $pskd\n" expect "Done" -set spawn_2 [spawn_node 2] +spawn_node 2 -set spawn_id $spawn_2 send "mode r\n" expect "Done" send "ifconfig up\n" @@ -96,6 +96,4 @@ expect "Done" wait_for "state" "child" expect "Done" -dispose - -dispose_leader +dispose_all diff --git a/tests/scripts/expect/cli-extaddr.exp b/tests/scripts/expect/cli-extaddr.exp index c98cd7777..a4fc42de6 100755 --- a/tests/scripts/expect/cli-extaddr.exp +++ b/tests/scripts/expect/cli-extaddr.exp @@ -29,7 +29,7 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "extaddr 99aabbccddeeff00\n" expect "Done" @@ -46,4 +46,4 @@ expect "Error 7: InvalidArgs" send "extaddr\n" expect "99aabbccddeeff00" -dispose +dispose_all diff --git a/tests/scripts/expect/cli-ipmaddr.exp b/tests/scripts/expect/cli-ipmaddr.exp index 4f741194e..5084ca2ba 100755 --- a/tests/scripts/expect/cli-ipmaddr.exp +++ b/tests/scripts/expect/cli-ipmaddr.exp @@ -30,9 +30,9 @@ source "tests/scripts/expect/_common.exp" source "tests/scripts/expect/_multinode.exp" -setup_nodes +setup_two_nodes -set spawn_id $spawn_1 +switch_node 1 send "ipmaddr add ff0e::1\n" expect "Done" send "ipmaddr\n" @@ -43,12 +43,12 @@ expect "ipaddr mleid" expect -re {(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4})} set addr $expect_out(1,string) -set spawn_id $spawn_2 +switch_node 2 send "ping ff0e::1\n" expect "Done" expect "16 bytes from $addr: icmp_seq=1" -set spawn_id $spawn_1 +switch_node 1 send "ipmaddr del ff0e::1\n" expect "Done" send "ipmaddr del ff0e::1\n" @@ -66,4 +66,4 @@ expect "Done" send "ipmaddr something_invalid\n" expect "Error 35: InvalidCommand" -dispose_nodes +dispose_all diff --git a/tests/scripts/expect/cli-log-level.exp b/tests/scripts/expect/cli-log-level.exp index 739118572..c7685fcac 100755 --- a/tests/scripts/expect/cli-log-level.exp +++ b/tests/scripts/expect/cli-log-level.exp @@ -29,10 +29,10 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "log level\n" -expect "1" +expect -re {\d} expect "Done" send "log level 5\n" expect "Done" @@ -48,4 +48,4 @@ expect "Error 7: InvalidArgs" send "log level 1 2\n" expect "Error 7: InvalidArgs" -dispose +dispose_all diff --git a/tests/scripts/expect/cli-mac.exp b/tests/scripts/expect/cli-mac.exp index ae1df9828..0d6865dd5 100755 --- a/tests/scripts/expect/cli-mac.exp +++ b/tests/scripts/expect/cli-mac.exp @@ -29,7 +29,7 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "mac retries direct 5\n" expect "Done" @@ -56,4 +56,4 @@ expect "Error 7: InvalidArgs" send "mac retries indirect 256\n" expect "Error 7: InvalidArgs" -dispose +dispose_all diff --git a/tests/scripts/expect/cli-macfilter.exp b/tests/scripts/expect/cli-macfilter.exp index bd8c76b5a..5892b831c 100755 --- a/tests/scripts/expect/cli-macfilter.exp +++ b/tests/scripts/expect/cli-macfilter.exp @@ -29,7 +29,7 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "macfilter\n" expect "Address Mode: Disabled" @@ -140,4 +140,4 @@ expect "Done" send "macfilter rss something_invalid\n" expect "Error 35: InvalidCommand" -dispose +dispose_all diff --git a/tests/scripts/expect/cli-misc.exp b/tests/scripts/expect/cli-misc.exp index a8467ce1f..ccdb9f3e7 100755 --- a/tests/scripts/expect/cli-misc.exp +++ b/tests/scripts/expect/cli-misc.exp @@ -30,8 +30,9 @@ source "tests/scripts/expect/_common.exp" source "tests/scripts/expect/_multinode.exp" -setup_nodes -set spawn_id $spawn_1 +setup_two_nodes + +switch_node 1 send "leaderdata\n" expect -re {Partition ID: \d+} @@ -154,4 +155,4 @@ expect "0:0:0:0::/64 s low" send "route remove ::/64\n" expect "Done" -dispose_nodes +dispose_all diff --git a/tests/scripts/expect/cli-neighbor.exp b/tests/scripts/expect/cli-neighbor.exp index 77f4b4da8..4af05a272 100755 --- a/tests/scripts/expect/cli-neighbor.exp +++ b/tests/scripts/expect/cli-neighbor.exp @@ -30,9 +30,9 @@ source "tests/scripts/expect/_common.exp" source "tests/scripts/expect/_multinode.exp" -setup_nodes +setup_two_nodes -set spawn_id $spawn_2 +switch_node 2 send "rloc16\n" expect "rloc16" expect -re {([0-9a-f]{4})} @@ -44,7 +44,7 @@ expect -re {([0-9a-f]{16})} set extaddr $expect_out(1,string) expect "Done" -set spawn_id $spawn_1 +switch_node 1 send "neighbor table\n" expect "| Role | RLOC16 | Age | Avg RSSI | Last RSSI |R|D|N| Extended MAC |" expect "+------+--------+-----+----------+-----------+-+-+-+------------------+" @@ -56,4 +56,4 @@ expect "Done" send "neighbor something_invalid\n" expect "Error 7: InvalidArgs" -dispose_nodes +dispose_all diff --git a/tests/scripts/expect/cli-netdata.exp b/tests/scripts/expect/cli-netdata.exp index 4f867a5fc..faf65377c 100755 --- a/tests/scripts/expect/cli-netdata.exp +++ b/tests/scripts/expect/cli-netdata.exp @@ -30,8 +30,9 @@ source "tests/scripts/expect/_common.exp" source "tests/scripts/expect/_multinode.exp" -setup_nodes -set spawn_id $spawn_1 +setup_two_nodes + +switch_node 1 send "netdata help\n" expect "Done" @@ -45,4 +46,4 @@ expect "Done" send "netdata show -x\n" expect "Done" -dispose_nodes +dispose_all diff --git a/tests/scripts/expect/cli-ping.exp b/tests/scripts/expect/cli-ping.exp index 9f07a92fd..1e615ff57 100755 --- a/tests/scripts/expect/cli-ping.exp +++ b/tests/scripts/expect/cli-ping.exp @@ -31,7 +31,7 @@ source "tests/scripts/expect/_common.exp" source "tests/scripts/expect/_multinode.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "ping ::1 1 2 1 1\n" expect "Done" @@ -44,19 +44,19 @@ expect "Done" send "ping ::1 1 2 1 1 1\n" expect "Error 7: InvalidArgs" -dispose +dispose_all -setup_nodes +setup_two_nodes -set spawn_id $spawn_2 +switch_node 2 send "ipaddr mleid\n" expect "ipaddr mleid" expect -re {(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4})} set addr $expect_out(1,string) expect "Done" -set spawn_id $spawn_1 +switch_node 1 send "ping $addr\n" expect "16 bytes from $addr: icmp_seq=1" send "ping $addr 20 10 0.00123456 255\n" @@ -64,4 +64,4 @@ for {set i 2} {$i <= 11} {incr i} { expect "28 bytes from $addr: icmp_seq=$i" } -dispose_nodes +dispose_all diff --git a/tests/scripts/expect/cli-promiscuous.exp b/tests/scripts/expect/cli-promiscuous.exp index dc56a5ef5..c2fcf78ce 100755 --- a/tests/scripts/expect/cli-promiscuous.exp +++ b/tests/scripts/expect/cli-promiscuous.exp @@ -31,7 +31,7 @@ source "tests/scripts/expect/_common.exp" source "tests/scripts/expect/_multinode.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "promiscuous\n" expect "Disabled" @@ -46,43 +46,39 @@ expect "Done" send "promiscuous a\n" expect "Error 7: InvalidArgs" -dispose +dispose_all -setup_nodes +setup_two_nodes -set spawn_id $spawn_1 +switch_node 1 send "channel\n" expect "channel" expect -re {(\d+)} set channel $expect_out(1,string) expect "Done" -set spawn_id [spawn_node 3] -set spawn_3 $spawn_id +spawn_node 3 send "channel $channel\n" expect "Done" send "promiscuous enable\n" expect "Done" -set spawn_id $spawn_2 +switch_node 2 send "ipaddr\n" expect -re {(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4})} set addr $expect_out(1,string) expect "Done" -set spawn_id $spawn_1 +switch_node 1 send "ping $addr\n" expect "16 bytes from $addr: icmp_seq=1" -set spawn_id $spawn_3 +switch_node 3 expect -re {============================================\[len = +\d+]============================} expect -re {\|( ([0-9A-Z]{2}|\.\.)){16}\|( .){16}\|} expect -- "-----------------------------------------------------------------------------------" send "promiscuous disable\n" expect "Done" -set spawn_id $spawn_3 -dispose - -dispose_nodes +dispose_all diff --git a/tests/scripts/expect/cli-pskc.exp b/tests/scripts/expect/cli-pskc.exp index d7518247e..1d211fd98 100755 --- a/tests/scripts/expect/cli-pskc.exp +++ b/tests/scripts/expect/cli-pskc.exp @@ -29,7 +29,7 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "pskc 00112233445566778899aabbccddeeff\n" expect "Done" @@ -52,4 +52,4 @@ sleep 0.1 send "pskc -x\n" expect "Error 7: InvalidArgs" -dispose +dispose_all diff --git a/tests/scripts/expect/cli-reset.exp b/tests/scripts/expect/cli-reset.exp index 48fa8f602..d432d3320 100755 --- a/tests/scripts/expect/cli-reset.exp +++ b/tests/scripts/expect/cli-reset.exp @@ -29,7 +29,7 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "ifconfig up\n" expect "Done" @@ -65,4 +65,4 @@ send "panid\n" expect "0xffff" expect "Done" -dispose +dispose_all diff --git a/tests/scripts/expect/cli-router.exp b/tests/scripts/expect/cli-router.exp index bb7e6a005..d5906dc09 100755 --- a/tests/scripts/expect/cli-router.exp +++ b/tests/scripts/expect/cli-router.exp @@ -30,9 +30,9 @@ source "tests/scripts/expect/_common.exp" source "tests/scripts/expect/_multinode.exp" -setup_nodes +setup_two_nodes -set spawn_id $spawn_1 +switch_node 1 send "extaddr\n" expect "extaddr" expect -re {([0-9a-f]{16})} @@ -53,7 +53,7 @@ expect "+----+--------+----------+-----------+-------+--------+-----+----------- expect -re "\\| +$router_id \\| 0x$rloc \\| +\\d+ \\| +\\d+ \\| +\\d+ \\| +\\d+ \\| +\\d+ \\| $extaddr \\|" expect "Done" -set spawn_id $spawn_2 +switch_node 2 send "mode rdn\n" expect "Done" send "state router\n" @@ -66,4 +66,4 @@ expect "Next Hop: fc00" expect -re {Link: [01]} expect "Done" -dispose_nodes +dispose_all diff --git a/tests/scripts/expect/cli-routereligible.exp b/tests/scripts/expect/cli-routereligible.exp index 0e2b2df8f..f18a3d115 100755 --- a/tests/scripts/expect/cli-routereligible.exp +++ b/tests/scripts/expect/cli-routereligible.exp @@ -29,7 +29,7 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "routereligible disable\n" expect "Done" @@ -51,4 +51,4 @@ expect "Done" send "routereligible enable\n" expect "Error 27: NotCapable" -dispose +dispose_all diff --git a/tests/scripts/expect/cli-scan-discover.exp b/tests/scripts/expect/cli-scan-discover.exp index 04fe2b451..b157ed19b 100755 --- a/tests/scripts/expect/cli-scan-discover.exp +++ b/tests/scripts/expect/cli-scan-discover.exp @@ -30,12 +30,11 @@ source "tests/scripts/expect/_common.exp" source "tests/scripts/expect/_multinode.exp" -setup_nodes +setup_two_nodes -set spawn_id [spawn_node 3] -set spawn_3 $spawn_id +spawn_node 3 -set spawn_id $spawn_1 +switch_node 1 send "extaddr\n" expect "extaddr" expect -re {([0-9a-f]{16})} @@ -63,7 +62,7 @@ expect -re {(\d+)} set channel $expect_out(1,string) expect "Done" -set spawn_id $spawn_3 +switch_node 3 send "scan $channel\n" expect "| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |" expect "+---+------------------+------------------+------+------------------+----+-----+-----+" @@ -77,7 +76,7 @@ for {set i 11} {$i <= 26} {incr i} { } expect "Done" -set spawn_id $spawn_3 +switch_node 3 send "ifconfig up\n" expect "Done" send "discover $channel\n" @@ -88,16 +87,15 @@ wait_for "" "Done" send "discover something_invalid\n" expect "Error 7: InvalidArgs" -set spawn_id $spawn_1 +switch_node 1 expect "version=2,joiner=0" -set spawn_id $spawn_3 +switch_node 3 send "joiner start 123456\n" set timeout 10 expect "NotFound" -dispose -set spawn_id $spawn_1 +switch_node 1 expect "version=2,joiner=1" -dispose_nodes +dispose_all diff --git a/tests/scripts/expect/cli-udp.exp b/tests/scripts/expect/cli-udp.exp index fa5dac2d0..e55b45838 100755 --- a/tests/scripts/expect/cli-udp.exp +++ b/tests/scripts/expect/cli-udp.exp @@ -30,9 +30,9 @@ source "tests/scripts/expect/_common.exp" source "tests/scripts/expect/_multinode.exp" -setup_nodes +setup_two_nodes -set spawn_id $spawn_2 +switch_node 2 send "udp open\n" expect "Done" send "udp bind :: 11001\n" @@ -42,7 +42,7 @@ expect "ipaddr mleid" expect -re {(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4})} set addr_2 $expect_out(1,string) -set spawn_id $spawn_1 +switch_node 1 send "ipaddr mleid\n" expect "ipaddr mleid" expect -re {(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4})} @@ -60,13 +60,13 @@ expect "Done" send "udp send -t there\n" expect "Done" -set spawn_id $spawn_2 +switch_node 2 expect "10 bytes from $addr_1 11002 0123456789" expect "6 bytes from $addr_1 11002" expect "hello" expect "5 bytes from $addr_1 11002 there" -set spawn_id $spawn_1 +switch_node 1 send "udp help\n" expect "Done" send "udp connect something_invalid\n" @@ -93,4 +93,4 @@ expect "Done" send "udp linksecurity something_invalid\n" expect "Error 35: InvalidCommand" -dispose_nodes +dispose_all diff --git a/tests/scripts/expect/cli-unsecure-port.exp b/tests/scripts/expect/cli-unsecure-port.exp index b43cc9240..bf99d9783 100755 --- a/tests/scripts/expect/cli-unsecure-port.exp +++ b/tests/scripts/expect/cli-unsecure-port.exp @@ -29,7 +29,7 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "unsecureport remove all\n" expect "Done" @@ -63,4 +63,4 @@ expect "Done" send "unsecureport invalid_command\n" expect "Error 35: InvalidCommand" -dispose +dispose_all diff --git a/tests/scripts/expect/posix-diag-rcp.exp b/tests/scripts/expect/posix-diag-rcp.exp index 8e0be138c..e933922f2 100755 --- a/tests/scripts/expect/posix-diag-rcp.exp +++ b/tests/scripts/expect/posix-diag-rcp.exp @@ -29,7 +29,7 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "diag rcp\n" expect "diagnostics mode is disabled" @@ -54,4 +54,4 @@ expect "Done" send "diag rcp power 10\n" expect "Done" -dispose +dispose_all diff --git a/tests/scripts/expect/posix-rcp.exp b/tests/scripts/expect/posix-rcp.exp index 4e9b3e8fd..c6dd51d27 100755 --- a/tests/scripts/expect/posix-rcp.exp +++ b/tests/scripts/expect/posix-rcp.exp @@ -29,11 +29,11 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "rcp version\n" expect "Done" send "rcp something_invalid\n" expect "Error 7: InvalidArgs" -dispose +dispose_all diff --git a/tests/scripts/expect/posix-scan-tx-to-sleep.exp b/tests/scripts/expect/posix-scan-tx-to-sleep.exp index 33e7958b6..61956e6d4 100755 --- a/tests/scripts/expect/posix-scan-tx-to-sleep.exp +++ b/tests/scripts/expect/posix-scan-tx-to-sleep.exp @@ -87,7 +87,4 @@ expect "+---+------------------+------------------+------+------------------+--- wait_for "" "\\| \\d \\| $network +\\| $extpan \\| $pan \\| $extaddr \\| +$channel \\| +-?\\d+ \\| +\\d \\|" wait_for "" "Done" -dispose - -set spawn_id $node_1 -dispose +dispose_all diff --git a/tests/scripts/expect/simulation-networktime.exp b/tests/scripts/expect/simulation-networktime.exp index 99af19d87..df98db2e1 100755 --- a/tests/scripts/expect/simulation-networktime.exp +++ b/tests/scripts/expect/simulation-networktime.exp @@ -29,7 +29,7 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "networktime 20 200\n" expect "Done" @@ -41,4 +41,4 @@ expect "Done" send "networktime something_invalid\n" expect "Error 7: InvalidArgs" -dispose +dispose_all diff --git a/tests/scripts/expect/tun-dns-client.exp b/tests/scripts/expect/tun-dns-client.exp index 8e4c71ac3..ef9c504ef 100755 --- a/tests/scripts/expect/tun-dns-client.exp +++ b/tests/scripts/expect/tun-dns-client.exp @@ -29,7 +29,7 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "panid 0xface\n" expect "Done" @@ -44,4 +44,4 @@ send "dns resolve ipv6.google.com ::1 53\n" expect "DNS response for ipv6.google.com" expect "Done" -dispose +dispose_all diff --git a/tests/scripts/expect/tun-netif.exp b/tests/scripts/expect/tun-netif.exp index 0c96b0b5d..d9635c7be 100755 --- a/tests/scripts/expect/tun-netif.exp +++ b/tests/scripts/expect/tun-netif.exp @@ -29,10 +29,10 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "netif\n" expect -re {[\r\n][^\r\n:]+?:\d+} expect "Done" -dispose +dispose_all diff --git a/tests/scripts/expect/tun-netstat.exp b/tests/scripts/expect/tun-netstat.exp index ba5476381..1e5ed9266 100755 --- a/tests/scripts/expect/tun-netstat.exp +++ b/tests/scripts/expect/tun-netstat.exp @@ -29,7 +29,7 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "ifconfig up\n" expect "Done" @@ -59,4 +59,4 @@ expect "+-----------------------------------------------+----------------------- expect -re "\\| 0:0:0:0:0:0:0:0:10001 +\\| $addr:10001 +\\|" expect "Done" -dispose +dispose_all diff --git a/tests/scripts/expect/tun-sntp.exp b/tests/scripts/expect/tun-sntp.exp index 23f7f8956..aa920d7f8 100755 --- a/tests/scripts/expect/tun-sntp.exp +++ b/tests/scripts/expect/tun-sntp.exp @@ -27,9 +27,15 @@ # POSSIBILITY OF SUCH DAMAGE. # +set OSTYPE [lindex $tcl_platform(os) 0] + +if { $OSTYPE == "Darwin" } { + exit 77 +} + source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 send "panid 0xface\n" expect "Done" @@ -44,4 +50,4 @@ send "sntp query ::1 123\n" expect -re {SNTP response - Unix time: \d+ \(era: \d+\)} expect "Done" -dispose +dispose_all diff --git a/tests/scripts/expect/tun-udp.exp b/tests/scripts/expect/tun-udp.exp index 981121329..2eb4f6e60 100755 --- a/tests/scripts/expect/tun-udp.exp +++ b/tests/scripts/expect/tun-udp.exp @@ -31,7 +31,9 @@ source "tests/scripts/expect/_common.exp" -set spawn_id [spawn_node 1] +spawn_node 1 + +set timeout 1 send "panid 0xface\n" expect "Done" @@ -43,6 +45,7 @@ send "thread start\n" expect "Done" wait_for "state" "leader" +expect "Done" send "udp open\n" expect "Done" @@ -53,10 +56,10 @@ expect "Done" send "udp connect fdde:ad00:beef:0:bb1:ebd6:ad10:f33 1234\n" expect "Done" -send "udp connect :: 0\n" +send "udp connect :: 1\n" expect "Done" send "udp close\n" expect "Done" -dispose +dispose_all diff --git a/tests/scripts/expect/v1_2-rcp.exp b/tests/scripts/expect/v1_2-rcp.exp index 16ae0207f..abbf2c986 100755 --- a/tests/scripts/expect/v1_2-rcp.exp +++ b/tests/scripts/expect/v1_2-rcp.exp @@ -29,8 +29,7 @@ source "tests/scripts/expect/_common.exp" -set node_1 [spawn_node 1] -set spawn_id $node_1 +spawn_node 1 send "panid 0xface\n" expect "Done" @@ -46,11 +45,7 @@ expect -re {(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4})} set addr $expect_out(1,string) expect "Done" -spawn $env(MTD_COMMAND) "2" -set node_2 $spawn_id -expect_after { - timeout { exit 1 } -} +spawn_node_mtd 2 send "panid 0xface\n" expect "Done" @@ -67,7 +62,4 @@ expect "Done" send "ping $addr\n" expect "16 bytes from $addr: icmp_seq=1" -dispose - -set spawn_id $node_1 -dispose +dispose_all diff --git a/tests/scripts/expect/v1_2-sed_mac_send.exp b/tests/scripts/expect/v1_2-sed_mac_send.exp index f099023be..4a2e15dc4 100755 --- a/tests/scripts/expect/v1_2-sed_mac_send.exp +++ b/tests/scripts/expect/v1_2-sed_mac_send.exp @@ -30,12 +30,12 @@ source "tests/scripts/expect/_common.exp" source "tests/scripts/expect/_multinode.exp" -setup_nodes "-" +setup_two_nodes "-" -set spawn_id $spawn_2 +switch_node 2 send "mac send emptydata\n" expect "Done" send "mac send datarequest\n" expect "Done" -dispose_nodes +dispose_all