mirror of
https://github.com/espressif/openthread.git
synced 2026-08-22 10:29:52 +00:00
[expect] split and extend tests for discovery (#8832)
Signed-off-by: Lukasz Duda <[email protected]>
This commit is contained in:
committed by
Jonathan Hui
parent
7ec184d68e
commit
1c190a4f6d
@@ -126,6 +126,15 @@ proc switch_node {id} {
|
||||
set spawn_id $spawn_ids($id)
|
||||
}
|
||||
|
||||
proc attach {{role "leader"}} {
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
wait_for "state" $role
|
||||
expect_line "Done"
|
||||
}
|
||||
|
||||
proc setup_leader {} {
|
||||
send "dataset init new\n"
|
||||
expect_line "Done"
|
||||
@@ -133,12 +142,7 @@ proc setup_leader {} {
|
||||
expect_line "Done"
|
||||
send "dataset commit active\n"
|
||||
expect_line "Done"
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
wait_for "state" "leader"
|
||||
expect_line "Done"
|
||||
attach
|
||||
}
|
||||
|
||||
proc dispose_node {id} {
|
||||
@@ -173,6 +177,23 @@ proc get_extaddr {} {
|
||||
return $rval
|
||||
}
|
||||
|
||||
proc get_extpanid {} {
|
||||
send "extpanid\n"
|
||||
set rval [expect_line {[0-9a-fA-F]{16}}]
|
||||
expect_line "Done"
|
||||
|
||||
return $rval
|
||||
}
|
||||
|
||||
proc get_panid {} {
|
||||
send "panid\n"
|
||||
expect -re {0x([0-9a-fA-F]{4})}
|
||||
set rval $expect_out(1,string)
|
||||
expect_line "Done"
|
||||
|
||||
return $rval
|
||||
}
|
||||
|
||||
proc get_meshlocal_prefix {} {
|
||||
send "prefix meshlocal\n"
|
||||
expect -re {[\r\n ](([0-9a-fA-F]{1,4}:){3}[0-9a-fA-f]{1,4})::/64(?=[\r\n>])}
|
||||
|
||||
Executable
+146
@@ -0,0 +1,146 @@
|
||||
#!/usr/bin/expect -f
|
||||
#
|
||||
# Copyright (c) 2023, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
source "tests/scripts/expect/_common.exp"
|
||||
source "tests/scripts/expect/_multinode.exp"
|
||||
|
||||
for {set i 1} {$i <= 5} {incr i} {
|
||||
spawn_node $i
|
||||
}
|
||||
|
||||
switch_node 1
|
||||
|
||||
send "dataset init new\n"
|
||||
expect_line "Done"
|
||||
send "dataset networkkey 00112233445566778899aabbccddeeff\n"
|
||||
expect_line "Done"
|
||||
send "dataset channel 12\n"
|
||||
expect_line "Done"
|
||||
send "dataset networkname OpenThread-ch12\n"
|
||||
expect_line "Done"
|
||||
send "dataset commit active\n"
|
||||
expect_line "Done"
|
||||
send "dataset active -x\n"
|
||||
expect -re {([0-9a-f]+)[\r\n]+Done}
|
||||
set dataset $expect_out(1,string)
|
||||
attach
|
||||
|
||||
set extaddr_1 [get_extaddr]
|
||||
set extpan_1 [get_extpanid]
|
||||
set pan_1 [get_panid]
|
||||
|
||||
switch_node 2
|
||||
|
||||
send "dataset init new\n"
|
||||
expect_line "Done"
|
||||
send "dataset channel 23\n"
|
||||
expect_line "Done"
|
||||
send "dataset networkname OpenThread-ch23\n"
|
||||
expect_line "Done"
|
||||
send "dataset commit active\n"
|
||||
expect_line "Done"
|
||||
attach
|
||||
|
||||
set extaddr_2 [get_extaddr]
|
||||
set extpan_2 [get_extpanid]
|
||||
set pan_2 [get_panid]
|
||||
|
||||
switch_node 3
|
||||
|
||||
send "dataset set active $dataset\n"
|
||||
expect_line "Done"
|
||||
send "mode r\n"
|
||||
expect_line "Done"
|
||||
attach "child"
|
||||
|
||||
switch_node 4
|
||||
|
||||
send "dataset set active $dataset\n"
|
||||
expect_line "Done"
|
||||
send "mode -\n"
|
||||
expect_line "Done"
|
||||
attach "child"
|
||||
|
||||
for {set i 3} {$i <= 4} {incr i} {
|
||||
switch_node $i
|
||||
|
||||
send "discover\n"
|
||||
expect "| Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |"
|
||||
expect "+------------------+------------------+------+------------------+----+-----+-----+"
|
||||
wait_for "" "\\| OpenThread-ch12 +\\| $extpan_1 \\| $pan_1 \\| $extaddr_1 \\| 12 \\| +-?\\d+ \\| +\\d \\|"
|
||||
wait_for "" "\\| OpenThread-ch23 +\\| $extpan_2 \\| $pan_2 \\| $extaddr_2 \\| 23 \\| +-?\\d+ \\| +\\d \\|"
|
||||
wait_for "" "Done"
|
||||
}
|
||||
|
||||
if {$::env(THREAD_VERSION) != "1.1" && $::env(OT_NODE_TYPE) == "cli"} {
|
||||
send "csl channel 12\n"
|
||||
expect_line "Done"
|
||||
send "csl period 3125\n"
|
||||
expect_line "Done"
|
||||
|
||||
sleep 1
|
||||
|
||||
send "discover\n"
|
||||
expect "| Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |"
|
||||
expect "+------------------+------------------+------+------------------+----+-----+-----+"
|
||||
wait_for "" "\\| OpenThread-ch12 +\\| $extpan_1 \\| $pan_1 \\| $extaddr_1 \\| 12 \\| +-?\\d+ \\| +\\d \\|"
|
||||
wait_for "" "\\| OpenThread-ch23 +\\| $extpan_2 \\| $pan_2 \\| $extaddr_2 \\| 23 \\| +-?\\d+ \\| +\\d \\|"
|
||||
wait_for "" "Done"
|
||||
}
|
||||
|
||||
switch_node 1
|
||||
send "discover reqcallback enable\n"
|
||||
expect_line "Done"
|
||||
|
||||
switch_node 5
|
||||
send "discover\n"
|
||||
expect "Error 13: InvalidState"
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
send "discover 12\n"
|
||||
|
||||
expect "| Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |"
|
||||
expect "+------------------+------------------+------+------------------+----+-----+-----+"
|
||||
wait_for "" "\\| OpenThread-ch12 +\\| $extpan_1 \\| $pan_1 \\| $extaddr_1 \\| 12 \\| +-?\\d+ \\| +\\d \\|"
|
||||
wait_for "" "Done"
|
||||
|
||||
switch_node 1
|
||||
expect -re {version=\d,joiner=0}
|
||||
|
||||
switch_node 5
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
send "joiner start 123456\n"
|
||||
set timeout 10
|
||||
expect "NotFound"
|
||||
|
||||
switch_node 1
|
||||
expect -re {version=\d,joiner=1}
|
||||
|
||||
dispose_all
|
||||
@@ -44,14 +44,7 @@ set timeout 1
|
||||
send "panid 0xface\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
|
||||
wait_for "state" "leader"
|
||||
expect_line "Done"
|
||||
attach
|
||||
|
||||
set extaddr1 [get_extaddr]
|
||||
|
||||
@@ -63,14 +56,8 @@ setup_default_network
|
||||
send "panid 0xface\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
attach "router"
|
||||
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
|
||||
wait_for "state" "router"
|
||||
expect_line "Done"
|
||||
sleep 3
|
||||
|
||||
get_rloc16
|
||||
@@ -87,14 +74,8 @@ expect_line "Done"
|
||||
send "macfilter addr denylist\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
attach "router"
|
||||
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
|
||||
wait_for "state" "router"
|
||||
expect_line "Done"
|
||||
sleep 4
|
||||
|
||||
set extaddr3 [get_extaddr]
|
||||
@@ -116,14 +97,7 @@ expect_line "Done"
|
||||
send "macfilter addr allowlist\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
|
||||
wait_for "state" "child"
|
||||
expect_line "Done"
|
||||
attach "child"
|
||||
|
||||
get_rloc16
|
||||
|
||||
|
||||
@@ -41,24 +41,12 @@ expect "panid"
|
||||
expect -re {([0-9a-f]{4})}
|
||||
set pan $expect_out(1,string)
|
||||
expect_line "Done"
|
||||
send "extpanid\n"
|
||||
expect "extpanid"
|
||||
expect -re {([0-9a-f]{16})}
|
||||
set extpan $expect_out(1,string)
|
||||
expect_line "Done"
|
||||
expect "> "
|
||||
send "networkname\n"
|
||||
expect "networkname"
|
||||
expect -re {[\r\n]([^\r\n]+?)[\r\n]}
|
||||
set network $expect_out(1,string)
|
||||
expect_line "Done"
|
||||
send "channel\n"
|
||||
expect "channel"
|
||||
expect -re {(\d+)}
|
||||
set channel $expect_out(1,string)
|
||||
expect_line "Done"
|
||||
send "discover reqcallback enable\n"
|
||||
expect_line "Done"
|
||||
|
||||
switch_node 3
|
||||
send "scan $channel\n"
|
||||
@@ -79,28 +67,4 @@ expect "+----+------+"
|
||||
expect -re "\\| +$channel \\| +-?\\d+ \\|"
|
||||
expect_line "Done"
|
||||
|
||||
switch_node 3
|
||||
send "discover\n"
|
||||
expect "Error 13: InvalidState"
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
send "discover $channel\n"
|
||||
expect "| Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |"
|
||||
expect "+------------------+------------------+------+------------------+----+-----+-----+"
|
||||
wait_for "" "\\| $network +\\| $extpan \\| $pan \\| $extaddr \\| +$channel \\| +-?\\d+ \\| +\\d \\|"
|
||||
wait_for "" "Done"
|
||||
send "discover something_invalid\n"
|
||||
expect "Error 7: InvalidArgs"
|
||||
|
||||
switch_node 1
|
||||
expect -re {version=\d,joiner=0}
|
||||
|
||||
switch_node 3
|
||||
send "joiner start 123456\n"
|
||||
set timeout 10
|
||||
expect "NotFound"
|
||||
|
||||
switch_node 1
|
||||
expect -re {version=\d,joiner=1}
|
||||
|
||||
dispose_all
|
||||
@@ -251,12 +251,7 @@ try {
|
||||
puts "While energy scanning"
|
||||
|
||||
spawn_node 1 "rcp" "spinel+hdlc_uart://$host_pty"
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
wait_for "state" "leader"
|
||||
expect_line "Done"
|
||||
attach
|
||||
|
||||
send "scan energy 100\n"
|
||||
expect "| Ch | RSSI |"
|
||||
|
||||
@@ -36,12 +36,7 @@ send "dataset panid 0xface\n"
|
||||
expect_line "Done"
|
||||
send "dataset commit active\n"
|
||||
expect_line "Done"
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
wait_for "state" "leader"
|
||||
expect_line "Done"
|
||||
attach
|
||||
|
||||
set extaddr [get_extaddr]
|
||||
send "panid\n"
|
||||
|
||||
@@ -39,27 +39,15 @@ source "tests/scripts/expect/_common.exp"
|
||||
spawn_node 1
|
||||
setup_default_network
|
||||
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
|
||||
wait_for "state" "leader"
|
||||
expect_line "Done"
|
||||
attach
|
||||
|
||||
set extaddr1 [get_extaddr]
|
||||
|
||||
spawn_node 2 cli
|
||||
setup_default_network
|
||||
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
attach "router"
|
||||
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
|
||||
wait_for "state" "router"
|
||||
sleep 3
|
||||
|
||||
spawn_node 3 cli
|
||||
@@ -71,13 +59,8 @@ expect_line "Done"
|
||||
send "macfilter addr denylist\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
attach "router"
|
||||
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
|
||||
wait_for "state" "router"
|
||||
sleep 4
|
||||
|
||||
set extaddr3 [get_extaddr]
|
||||
@@ -94,13 +77,7 @@ expect_line "Done"
|
||||
send "macfilter addr allowlist\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
|
||||
wait_for "state" "child"
|
||||
attach "child"
|
||||
|
||||
set mleid4 [get_ipaddr "mleid"]
|
||||
|
||||
|
||||
@@ -35,12 +35,7 @@ spawn_node 1
|
||||
|
||||
send "panid 0xface\n"
|
||||
expect_line "Done"
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
wait_for "state" "leader"
|
||||
expect_line "Done"
|
||||
attach
|
||||
|
||||
send "sntp query ::1 123\n"
|
||||
expect -re {SNTP response - Unix time: \d+ \(era: \d+\)}
|
||||
|
||||
@@ -38,14 +38,7 @@ set timeout 1
|
||||
send "panid 0xface\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
|
||||
wait_for "state" "leader"
|
||||
expect_line "Done"
|
||||
attach
|
||||
|
||||
send "udp open\n"
|
||||
expect_line "Done"
|
||||
|
||||
Reference in New Issue
Block a user