mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 01:17:46 +00:00
[test] verify realm-local multicast on POSIX (#5738)
This commit is contained in:
@@ -65,7 +65,7 @@ jobs:
|
||||
sudo apt-get --no-install-recommends install -y ninja-build libreadline-dev libncurses-dev
|
||||
- name: Build
|
||||
run: |
|
||||
NODE_MODE=rcp ./script/test build
|
||||
OT_NODE_TYPE=rcp ./script/test build
|
||||
|
||||
package:
|
||||
name: package-${{ matrix.compiler }}
|
||||
|
||||
@@ -223,7 +223,7 @@ jobs:
|
||||
sudo apt-get --no-install-recommends install -y expect ninja-build lcov
|
||||
- name: Run RCP Mode
|
||||
run: |
|
||||
OT_OPTIONS=-DOT_READLINE=OFF NODE_MODE=rcp ./script/test build expect
|
||||
OT_OPTIONS=-DOT_READLINE=OFF OT_NODE_TYPE=rcp ./script/test build expect
|
||||
- name: Keep-1-2-only
|
||||
run: |
|
||||
./script/test tar posix 1.2-bbr
|
||||
|
||||
@@ -288,7 +288,7 @@ jobs:
|
||||
path: tmp/coverage.info
|
||||
- name: Run RCP Mode
|
||||
run: |
|
||||
OT_OPTIONS=-DOT_READLINE=OFF VIRTUAL_TIME=0 NODE_MODE=rcp ./script/test clean build expect
|
||||
OT_OPTIONS=-DOT_READLINE=OFF VIRTUAL_TIME=0 OT_NODE_TYPE=rcp ./script/test clean build expect
|
||||
- name: Keep POSIX Only
|
||||
run: |
|
||||
./script/test tar simulation 1.1
|
||||
@@ -320,7 +320,7 @@ jobs:
|
||||
echo 0 | sudo tee /proc/sys/net/ipv6/conf/all/disable_ipv6
|
||||
sudo systemctl restart dnsmasq
|
||||
host ipv6.google.com ::1
|
||||
OT_OPTIONS=-DOT_READLINE=OFF OT_NATIVE_IP=1 VIRTUAL_TIME=0 NODE_MODE=rcp ./script/test clean build expect
|
||||
OT_OPTIONS=-DOT_READLINE=OFF OT_NATIVE_IP=1 VIRTUAL_TIME=0 OT_NODE_TYPE=rcp ./script/test clean build expect
|
||||
- name: Keep POSIX Only
|
||||
run: |
|
||||
./script/test tar simulation 1.1
|
||||
|
||||
+26
-24
@@ -39,8 +39,7 @@ readonly COLOR_PASS='\033[0;32m'
|
||||
readonly COLOR_FAIL='\033[0;31m'
|
||||
readonly COLOR_NONE='\033[0m'
|
||||
|
||||
readonly NODE_MODE="${NODE_MODE:-standalone}"
|
||||
readonly NODE_TYPE="${NODE_TYPE:-sim}"
|
||||
readonly OT_NODE_TYPE="${OT_NODE_TYPE:-cli}"
|
||||
readonly OT_NATIVE_IP="${OT_NATIVE_IP:-0}"
|
||||
readonly THREAD_VERSION="${THREAD_VERSION:-1.1}"
|
||||
readonly INTER_OP="${INTER_OP:-0}"
|
||||
@@ -59,7 +58,7 @@ build_simulation()
|
||||
if [[ ${VIRTUAL_TIME} == 1 ]]; then
|
||||
options+=("-DOT_SIMULATION_VIRTUAL_TIME=ON")
|
||||
|
||||
if [[ ${NODE_MODE} == "rcp" ]]; then
|
||||
if [[ ${OT_NODE_TYPE} == "rcp" ]]; then
|
||||
options+=("-DOT_SIMULATION_VIRTUAL_TIME_UART=ON")
|
||||
fi
|
||||
|
||||
@@ -123,7 +122,7 @@ build_for_one_version()
|
||||
|
||||
build_simulation "${version}"
|
||||
|
||||
if [[ ${NODE_MODE} == "rcp" ]]; then
|
||||
if [[ ${OT_NODE_TYPE} == "rcp" ]]; then
|
||||
build_posix "${version}"
|
||||
fi
|
||||
}
|
||||
@@ -171,6 +170,15 @@ do_cert()
|
||||
{
|
||||
export top_builddir="${OT_BUILDDIR}/cmake/openthread-simulation-${THREAD_VERSION}"
|
||||
|
||||
case "${OT_NODE_TYPE}" in
|
||||
rcp | cli)
|
||||
export NODE_TYPE=sim
|
||||
;;
|
||||
ncp)
|
||||
export NODE_TYPE=ncp-sim
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ ${THREAD_VERSION} == "1.2" ]]; then
|
||||
export top_builddir_1_2_bbr="${OT_BUILDDIR}/cmake/openthread-simulation-1.2-bbr"
|
||||
if [[ ${INTER_OP} == "1" ]]; then
|
||||
@@ -306,16 +314,10 @@ do_pktverify()
|
||||
|
||||
do_expect()
|
||||
{
|
||||
local ot_command
|
||||
local rcp_command=
|
||||
local mtd_command=
|
||||
local test_patterns
|
||||
|
||||
if [[ ${NODE_MODE} == rcp ]]; then
|
||||
ot_command="${OT_CLI_PATH}"
|
||||
rcp_command="${RADIO_DEVICE}"
|
||||
if [[ ${OT_NODE_TYPE} == rcp ]]; then
|
||||
if [[ ${THREAD_VERSION} == "1.2" ]]; then
|
||||
mtd_command="${OT_BUILDDIR}/cmake/openthread-simulation-${THREAD_VERSION}/examples/apps/cli/ot-cli-mtd"
|
||||
test_patterns=(-name 'v1_2-*.exp')
|
||||
elif [[ ${OT_NATIVE_IP} == 1 ]]; then
|
||||
test_patterns=(-name 'tun-*.exp')
|
||||
@@ -323,7 +325,6 @@ do_expect()
|
||||
test_patterns=(-name 'posix-*.exp' -o -name 'cli-*.exp')
|
||||
fi
|
||||
else
|
||||
ot_command="${OT_BUILDDIR}/cmake/openthread-simulation-${THREAD_VERSION}/examples/apps/cli/ot-cli-ftd"
|
||||
test_patterns=(-name 'cli-*.exp' -o -name 'simulation-*.exp')
|
||||
fi
|
||||
|
||||
@@ -333,9 +334,9 @@ do_expect()
|
||||
mkdir tmp
|
||||
{
|
||||
if [[ ${OT_NATIVE_IP} == 1 ]]; then
|
||||
OT_COMMAND="${ot_command}" RCP_COMMAND="${rcp_command}" MTD_COMMAND="${mtd_command}" sudo -E expect -df "${script}" 2>"${log_file}"
|
||||
sudo -E expect -df "${script}" 2>"${log_file}"
|
||||
else
|
||||
OT_COMMAND="${ot_command}" RCP_COMMAND="${rcp_command}" MTD_COMMAND="${mtd_command}" expect -df "${script}" 2>"${log_file}"
|
||||
expect -df "${script}" 2>"${log_file}"
|
||||
fi
|
||||
} || {
|
||||
local exit_code=$?
|
||||
@@ -363,8 +364,8 @@ print_usage()
|
||||
echo "USAGE: [ENVIRONMENTS] $0 COMMANDS
|
||||
|
||||
ENVIRONMENTS:
|
||||
NODE_TYPE 'sim' for CLI, 'ncp-sim' for NCP. The default is 'sim'.
|
||||
NODE_MODE 'rcp' for RCP mode, otherwise for standalone mode. The default is standalone mode.
|
||||
OT_NODE_TYPE 'rcp' for POSIX/RCP, 'cli' for CLI simulation, 'ncp' for NCP simulation, The default is 'cli'.
|
||||
OT_NATIVE_IP 1 to enable platform UDP and netif on POSIX platform. The default is 0.
|
||||
VERBOSE 1 to build or test verbosely. The default is 0.
|
||||
VIRTUAL_TIME 1 for virtual time, otherwise real time. The default is 1.
|
||||
THREAD_VERSION 1.1 for Thread 1.1 stack, 1.2 for Thread 1.2 stack. The default is 1.1.
|
||||
@@ -385,12 +386,12 @@ EXAMPLES:
|
||||
$0 cert tests/scripts/thread-cert/Cert_5_1_02_ChildAddressTimeout.py
|
||||
|
||||
# Test NCP with default settings
|
||||
NODE_TYPE=ncp-sim $0 clean build cert tests/scripts/thread-cert/Cert_5_1_01_RouterAttach.py
|
||||
NODE_TYPE=ncp-sim $0 cert tests/scripts/thread-cert/Cert_5_1_02_ChildAddressTimeout.py
|
||||
$0 clean build cert tests/scripts/thread-cert/Cert_5_1_01_RouterAttach.py
|
||||
$0 cert tests/scripts/thread-cert/Cert_5_1_02_ChildAddressTimeout.py
|
||||
|
||||
# Test CLI with radio only
|
||||
NODE_MODE=rcp $0 clean build cert tests/scripts/thread-cert/Cert_5_1_01_RouterAttach.py
|
||||
NODE_MODE=rcp $0 cert tests/scripts/thread-cert/Cert_5_1_02_ChildAddressTimeout.py
|
||||
$0 clean build cert tests/scripts/thread-cert/Cert_5_1_01_RouterAttach.py
|
||||
$0 cert tests/scripts/thread-cert/Cert_5_1_02_ChildAddressTimeout.py
|
||||
|
||||
# Test CLI with real time
|
||||
VIRTUAL_TIME=0 $0 clean build cert tests/scripts/thread-cert/Cert_5_1_01_RouterAttach.py
|
||||
@@ -483,7 +484,7 @@ do_upload_codecov()
|
||||
|
||||
envsetup()
|
||||
{
|
||||
if [[ ${NODE_MODE} == 'rcp' ]]; then
|
||||
if [[ ${OT_NODE_TYPE} == 'rcp' ]]; then
|
||||
export RADIO_DEVICE="${OT_BUILDDIR}/cmake/openthread-simulation-${THREAD_VERSION}/examples/apps/ncp/ot-rcp"
|
||||
export OT_CLI_PATH="${OT_BUILDDIR}/cmake/openthread-posix-${THREAD_VERSION}/src/posix/ot-cli"
|
||||
export OT_NCP_PATH="${OT_BUILDDIR}/cmake/openthread-posix-${THREAD_VERSION}/src/posix/ot-ncp"
|
||||
@@ -497,6 +498,9 @@ envsetup()
|
||||
fi
|
||||
fi
|
||||
|
||||
export OT_SIMULATION_APPS="${OT_BUILDDIR}/cmake/openthread-simulation-${THREAD_VERSION}/examples/apps"
|
||||
export OT_POSIX_APPS="${OT_BUILDDIR}/cmake/openthread-posix-${THREAD_VERSION}/src/posix"
|
||||
|
||||
if [[ ! ${VIRTUAL_TIME+x} ]]; then
|
||||
# All expect tests only works in real time mode.
|
||||
VIRTUAL_TIME=1
|
||||
@@ -509,7 +513,7 @@ envsetup()
|
||||
fi
|
||||
|
||||
readonly VIRTUAL_TIME
|
||||
export NODE_TYPE VIRTUAL_TIME
|
||||
export OT_NODE_TYPE VIRTUAL_TIME
|
||||
|
||||
# CMake always works in verbose mode if VERBOSE exists in environments.
|
||||
if [[ ${VERBOSE} == 1 ]]; then
|
||||
@@ -533,8 +537,6 @@ main()
|
||||
print_usage 1
|
||||
fi
|
||||
|
||||
[[ ${NODE_MODE} == "rcp" ]] && echo "Using rcp mode" || echo "Using standalone mode"
|
||||
[[ ${NODE_TYPE} == "ncp-sim" ]] && echo "Using NCP node" || echo "Using CLI node"
|
||||
[[ ${VIRTUAL_TIME} == 1 ]] && echo "Using virtual time" || echo "Using real time"
|
||||
[[ ${THREAD_VERSION} == "1.2" ]] && echo "Using Thread 1.2 stack" || echo "Using Thread 1.1 stack"
|
||||
|
||||
|
||||
@@ -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
@@ -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
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user