[test] verify realm-local multicast on POSIX (#5738)

This commit is contained in:
Yakun Xu
2020-10-29 10:37:51 -07:00
committed by GitHub
parent 4ac6e5509c
commit 0603ed1c14
9 changed files with 194 additions and 54 deletions
+38 -21
View File
@@ -55,34 +55,32 @@ proc wait_for {command success {failure {[\r\n]FAILURE_NOT_EXPECTED[\r\n]}}} {
}
}
proc spawn_node_mtd {id} {
proc spawn_node {id {type ""}} {
global spawn_id
global spawn_ids
send_user "\n# ${id}\n"
spawn $::env(MTD_COMMAND) $id
expect_after {
timeout { exit 1 }
if {${type} == ""} {
set type $::env(OT_NODE_TYPE)
}
set spawn_ids($id) $spawn_id
send_user "\n# ${id} ${type}\n"
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 {
spawn $::env(OT_COMMAND) $id
switch ${type} {
rcp {
spawn $::env(OT_POSIX_APPS)/ot-cli "spinel+hdlc+uart://$::env(OT_SIMULATION_APPS)/ncp/ot-rcp?forkpty-arg=$id"
send "routerselectionjitter 1\n"
expect "Done"
}
cli {
spawn $::env(OT_SIMULATION_APPS)/cli/ot-cli-ftd $id
send "routerselectionjitter 1\n"
expect "Done"
}
mtd {
spawn $::env(OT_SIMULATION_APPS)/cli/ot-cli-mtd $id
}
}
expect_after {
timeout { exit 1 }
}
@@ -127,4 +125,23 @@ proc dispose_all {} {
}
}
proc get_mleid {} {
send "ipaddr mleid\n"
expect "ipaddr mleid"
expect -re {(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4})}
set rval $expect_out(1,string)
expect "Done"
return $rval
}
proc get_extaddr {} {
send "extaddr\n"
expect -re {([0-9a-fA-F]{16})}
set rval $expect_out(1,string)
expect "Done"
return $rval
}
set timeout 10
@@ -30,7 +30,7 @@
source "tests/scripts/expect/_common.exp"
# allows 11-25 and forbidden 26
spawn $env(OT_COMMAND) "spinel+hdlc+uart://$env(RCP_COMMAND)?max-power-table=11,12,13,14,15,16,17,18,19,20,21,22,23,24,-1,0x7f&forkpty-arg=1"
spawn $env(OT_POSIX_APPS)/ot-cli "spinel+hdlc+uart://$env(OT_SIMULATION_APPS)/ncp/ot-rcp?max-power-table=11,12,13,14,15,16,17,18,19,20,21,22,23,24,-1,0x7f&forkpty-arg=1"
expect_after {
timeout { exit 1 }
}
@@ -43,7 +43,7 @@ expect "Done"
send "\x04"
expect eof
# allows all channels by default
spawn $env(OT_COMMAND) "spinel+hdlc+uart://$env(RCP_COMMAND)?forkpty-arg=1"
spawn $env(OT_POSIX_APPS)/ot-cli "spinel+hdlc+uart://$env(OT_SIMULATION_APPS)/ncp/ot-rcp?forkpty-arg=1"
expect_after {
timeout { exit 1 }
}
@@ -29,7 +29,7 @@
source "tests/scripts/expect/_common.exp"
spawn $env(OT_COMMAND) "spinel+hdlc+uart://$env(RCP_COMMAND)?forkpty-arg=--sleep-to-tx 1"
spawn $env(OT_POSIX_APPS)/ot-cli "spinel+hdlc+uart://$env(OT_SIMULATION_APPS)/ncp/ot-rcp?forkpty-arg=--sleep-to-tx 1"
set node_1 $spawn_id
expect_after {
timeout { exit 1 }
@@ -75,7 +75,7 @@ expect -re {(\d+)}
set channel $expect_out(1,string)
expect "Done"
spawn $env(OT_COMMAND) "spinel+hdlc+uart://$env(RCP_COMMAND)?forkpty-arg=--sleep-to-tx 2"
spawn $env(OT_POSIX_APPS)/ot-cli "spinel+hdlc+uart://$env(OT_SIMULATION_APPS)/ncp/ot-rcp?forkpty-arg=--sleep-to-tx 2"
set node_2 $spawn_id
expect_after {
timeout { exit 1 }
+121
View File
@@ -0,0 +1,121 @@
#!/usr/bin/expect -f
#
# Copyright (c) 2020, 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.
#
# This script verifies realm-local multicast on POSIX platform.
#
#
# R1(Leader,POSIX) -- R2 -- R3 -- E4
#
source "tests/scripts/expect/_common.exp"
spawn_node 1
set timeout 1
send "panid 0xface\n"
expect "Done"
send "ifconfig up\n"
expect "Done"
send "thread start\n"
expect "Done"
wait_for "state" "leader"
expect "Done"
set extaddr1 [get_extaddr]
spawn_node 2 cli
send "panid 0xface\n"
expect "Done"
send "ifconfig up\n"
expect "Done"
send "thread start\n"
expect "Done"
wait_for "state" "router"
spawn_node 3 cli
send "panid 0xface\n"
expect "Done"
send "macfilter addr add ${extaddr1}\n"
expect "Done"
send "macfilter addr denylist\n"
expect "Done"
send "ifconfig up\n"
expect "Done"
send "thread start\n"
expect "Done"
wait_for "state" "router"
set extaddr3 [get_extaddr]
spawn_node 4 cli
send "panid 0xface\n"
expect "Done"
send "mode rn\n"
expect "Done"
send "macfilter addr add ${extaddr3}\n"
expect "Done"
send "macfilter addr allowlist\n"
expect "Done"
send "ifconfig up\n"
expect "Done"
send "thread start\n"
expect "Done"
wait_for "state" "child"
set mleid4 [get_mleid]
switch_node 1
send "ping ${mleid4}\n"
expect "Done"
expect "16 bytes from $mleid4: icmp_seq=1"
dispose_all
+1 -1
View File
@@ -45,7 +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_node_mtd 2
spawn_node 2 mtd
send "panid 0xface\n"
expect "Done"