mirror of
https://github.com/espressif/openthread.git
synced 2026-10-01 21:37:39 +00:00
[test] include CLI tests in RCP mode (#5159)
This makes expect run all cli-*.exp and posix-*.exp tests in RCP mode. New scripts should use the function spawn_node in _common.exp to spawn new processes. This is compatible with both simulation mode and RCP mode.
This commit is contained in:
+5
-5
@@ -204,19 +204,19 @@ do_expect()
|
||||
{
|
||||
local ot_command
|
||||
local rcp_command=
|
||||
local test_pattern
|
||||
local test_patterns
|
||||
|
||||
if [[ ${NODE_MODE} == rcp ]]; then
|
||||
ot_command="${OT_CLI_PATH}"
|
||||
rcp_command="${RADIO_DEVICE}"
|
||||
if [[ ${OT_NATIVE_IP} == 1 ]]; then
|
||||
test_pattern='tun-*.exp'
|
||||
test_patterns=(-name 'tun-*.exp')
|
||||
else
|
||||
test_pattern='posix-*.exp'
|
||||
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_pattern='cli-*.exp'
|
||||
test_patterns=(-name 'cli-*.exp' -o -name 'simulation-*.exp')
|
||||
fi
|
||||
|
||||
while read -r script; do
|
||||
@@ -237,7 +237,7 @@ do_expect()
|
||||
if [[ $# != 0 ]]; then
|
||||
for script in "$@"; do echo ${script}; done
|
||||
else
|
||||
find tests/scripts/expect -type f -executable -name "${test_pattern}"
|
||||
find tests/scripts/expect -type f -executable \( "${test_patterns[@]}" \)
|
||||
fi
|
||||
)
|
||||
|
||||
|
||||
@@ -48,6 +48,18 @@ proc wait_for {command expected} {
|
||||
}
|
||||
}
|
||||
|
||||
proc spawn_node {id} {
|
||||
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
|
||||
}
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
return $spawn_id
|
||||
}
|
||||
|
||||
proc dispose {} {
|
||||
send "\x04"
|
||||
expect eof
|
||||
|
||||
@@ -38,13 +38,8 @@ proc setup_nodes {} {
|
||||
global spawn_id
|
||||
global env
|
||||
|
||||
spawn $env(OT_COMMAND) 1
|
||||
set spawn_1 $spawn_id
|
||||
spawn $env(OT_COMMAND) 2
|
||||
set spawn_2 $spawn_id
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
set spawn_1 [spawn_node 1]
|
||||
set spawn_2 [spawn_node 2]
|
||||
set psk "J01NME"
|
||||
|
||||
set spawn_id $spawn_2
|
||||
|
||||
@@ -29,11 +29,8 @@
|
||||
|
||||
source "tests/scripts/expect/_common.exp"
|
||||
|
||||
spawn $env(OT_COMMAND) 1
|
||||
set spawn_id [spawn_node 1]
|
||||
set timeout 1
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "ifconfig up\n"
|
||||
expect "Done"
|
||||
|
||||
@@ -29,11 +29,8 @@
|
||||
|
||||
source "tests/scripts/expect/_common.exp"
|
||||
|
||||
spawn $env(OT_COMMAND) 1
|
||||
set spawn_id [spawn_node 1]
|
||||
set timeout 1
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "coex disable\n"
|
||||
expect "Done"
|
||||
|
||||
@@ -27,11 +27,10 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
spawn $env(OT_COMMAND) 1
|
||||
source "tests/scripts/expect/_common.exp"
|
||||
|
||||
set spawn_id [spawn_node 1]
|
||||
set timeout 1
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "counters\n"
|
||||
expect "mac"
|
||||
@@ -51,3 +50,5 @@ send "counters mle 1\n"
|
||||
expect "Error 7: InvalidArgs"
|
||||
send "counters other\n"
|
||||
expect "Error 7: InvalidArgs"
|
||||
|
||||
dispose
|
||||
|
||||
@@ -27,24 +27,24 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
spawn $env(OT_COMMAND) 1
|
||||
source "tests/scripts/expect/_common.exp"
|
||||
|
||||
set spawn_id [spawn_node 1]
|
||||
set timeout 1
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "extaddr 99aabbccddeeff00\n"
|
||||
expect "Done\r\n"
|
||||
expect "Done"
|
||||
send "extaddr 99AABBCCDDEEFF00\n"
|
||||
expect "Done\r\n"
|
||||
expect "Done"
|
||||
send "extaddr\n"
|
||||
expect "99aabbccddeeff00\r\n"
|
||||
expect "99aabbccddeeff00"
|
||||
send "extaddr 1\n"
|
||||
expect "Error 7: InvalidArgs\r\n"
|
||||
expect "Error 7: InvalidArgs"
|
||||
send "extaddr 0123456789abcdef0\n"
|
||||
expect "Error 7: InvalidArgs\r\n"
|
||||
expect "Error 7: InvalidArgs"
|
||||
send "extaddr invalid\n"
|
||||
expect "Error 7: InvalidArgs\r\n"
|
||||
expect "Error 7: InvalidArgs"
|
||||
send "extaddr\n"
|
||||
expect "99aabbccddeeff00\r\n"
|
||||
send "\x04"
|
||||
expect eof
|
||||
expect "99aabbccddeeff00"
|
||||
|
||||
dispose
|
||||
|
||||
@@ -27,24 +27,26 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
spawn $env(OT_COMMAND) 1
|
||||
source "tests/scripts/expect/_common.exp"
|
||||
|
||||
set spawn_id [spawn_node 1]
|
||||
set timeout 1
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "log level\n"
|
||||
expect "1\r\nDone\r\n"
|
||||
expect "1"
|
||||
expect "Done"
|
||||
send "log level 5\n"
|
||||
expect "Done"
|
||||
send "log level\n"
|
||||
expect "5\r\nDone\r\n"
|
||||
expect "5"
|
||||
expect "Done"
|
||||
send "log level -1\n"
|
||||
expect "Error 7: InvalidArgs\r\n"
|
||||
expect "Error 7: InvalidArgs"
|
||||
send "log level 6\n"
|
||||
expect "Error 7: InvalidArgs\r\n"
|
||||
expect "Error 7: InvalidArgs"
|
||||
send "log a\n"
|
||||
expect "Error 7: InvalidArgs\r\n"
|
||||
expect "Error 7: InvalidArgs"
|
||||
send "log level 1 2\n"
|
||||
expect "Error 7: InvalidArgs\r\n"
|
||||
send "\x04"
|
||||
expect eof
|
||||
expect "Error 7: InvalidArgs"
|
||||
|
||||
dispose
|
||||
|
||||
@@ -29,11 +29,8 @@
|
||||
|
||||
source "tests/scripts/expect/_common.exp"
|
||||
|
||||
spawn $env(OT_COMMAND) 1
|
||||
set spawn_id [spawn_node 1]
|
||||
set timeout 1
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "mac retries direct 5\n"
|
||||
expect "Done"
|
||||
|
||||
@@ -29,11 +29,8 @@
|
||||
|
||||
source "tests/scripts/expect/_common.exp"
|
||||
|
||||
spawn $env(OT_COMMAND) 1
|
||||
set spawn_id [spawn_node 1]
|
||||
set timeout 1
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "macfilter\n"
|
||||
expect "Address Mode: Disabled"
|
||||
|
||||
@@ -146,14 +146,4 @@ expect "0:0:0:0::/64 s low"
|
||||
send "route remove ::/64\n"
|
||||
expect "Done"
|
||||
|
||||
send "networktime 20 200\n"
|
||||
expect "Done"
|
||||
send "networktime\n"
|
||||
expect -re {Network Time: \d+us \((unsynchronized|resync needed|synchronized)\)}
|
||||
expect "Time Sync Period: 20s"
|
||||
expect "XTAL Threshold: 200ppm"
|
||||
expect "Done"
|
||||
send "networktime something_invalid\n"
|
||||
expect "Error 7: InvalidArgs"
|
||||
|
||||
dispose_nodes
|
||||
|
||||
@@ -34,10 +34,8 @@ source "tests/scripts/expect/_multinode.exp"
|
||||
set timeout 1
|
||||
|
||||
|
||||
spawn $env(OT_COMMAND) 1
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
set spawn_id [spawn_node 1]
|
||||
|
||||
send "ping ::1 1 2 1 1\n"
|
||||
expect "Done"
|
||||
send "ping stop\n"
|
||||
@@ -48,6 +46,7 @@ send "ping stop\n"
|
||||
expect "Done"
|
||||
send "ping ::1 1 2 1 1 1\n"
|
||||
expect "Error 7: InvalidArgs"
|
||||
|
||||
dispose
|
||||
|
||||
|
||||
|
||||
@@ -34,10 +34,8 @@ source "tests/scripts/expect/_multinode.exp"
|
||||
set timeout 1
|
||||
|
||||
|
||||
spawn $env(OT_COMMAND) 1
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
set spawn_id [spawn_node 1]
|
||||
|
||||
send "promiscuous\n"
|
||||
expect "Disabled"
|
||||
expect "Done"
|
||||
@@ -50,6 +48,7 @@ send "promiscuous disable\n"
|
||||
expect "Done"
|
||||
send "promiscuous a\n"
|
||||
expect "Error 7: InvalidArgs"
|
||||
|
||||
dispose
|
||||
|
||||
|
||||
@@ -62,7 +61,7 @@ expect -re {(\d+)}
|
||||
set channel $expect_out(1,string)
|
||||
expect "Done"
|
||||
|
||||
spawn $env(OT_COMMAND) 3
|
||||
set spawn_id [spawn_node 3]
|
||||
set spawn_3 $spawn_id
|
||||
send "channel $channel\n"
|
||||
expect "Done"
|
||||
|
||||
@@ -27,27 +27,30 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
spawn $env(OT_COMMAND) 1
|
||||
source "tests/scripts/expect/_common.exp"
|
||||
|
||||
set spawn_id [spawn_node 1]
|
||||
set timeout 1
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "pskc 00112233445566778899aabbccddeeff\n"
|
||||
expect "Done\r\n"
|
||||
expect "Done"
|
||||
send "pskc\n"
|
||||
expect "00112233445566778899aabbccddeeff\r\nDone\r\n"
|
||||
expect "00112233445566778899aabbccddeeff"
|
||||
expect "Done"
|
||||
send "factoryreset\n"
|
||||
sleep 0.1
|
||||
send "networkname Test\\ Network\n"
|
||||
expect "Done\r\n"
|
||||
expect "Done"
|
||||
send "extpanid 0001020304050607\n"
|
||||
expect "Done\r\n"
|
||||
expect "Done"
|
||||
send "pskc -p 12SECRETPASSWORD34\n"
|
||||
expect "Done\r\n"
|
||||
expect "Done"
|
||||
send "pskc\n"
|
||||
expect "c3f59368445a1b6106be420a706d4cc9\r\nDone\r\n"
|
||||
expect "c3f59368445a1b6106be420a706d4cc9"
|
||||
expect "Done"
|
||||
send "factoryreset\n"
|
||||
sleep 0.1
|
||||
send "pskc -x\n"
|
||||
expect "Error 7: InvalidArgs\r\n"
|
||||
send_user "\r\n"
|
||||
expect "Error 7: InvalidArgs"
|
||||
|
||||
dispose
|
||||
|
||||
@@ -27,11 +27,10 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
spawn $env(OT_COMMAND) 1
|
||||
source "tests/scripts/expect/_common.exp"
|
||||
|
||||
set spawn_id [spawn_node 1]
|
||||
set timeout 1
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "routereligible disable\n"
|
||||
expect "Done"
|
||||
@@ -52,3 +51,5 @@ expect "Disabled"
|
||||
expect "Done"
|
||||
send "routereligible enable\n"
|
||||
expect "Error 27: NotCapable"
|
||||
|
||||
dispose
|
||||
|
||||
@@ -33,7 +33,7 @@ source "tests/scripts/expect/_multinode.exp"
|
||||
set timeout 1
|
||||
setup_nodes
|
||||
|
||||
spawn $env(OT_COMMAND) 3
|
||||
set spawn_id [spawn_node 3]
|
||||
set spawn_3 $spawn_id
|
||||
|
||||
set spawn_id $spawn_1
|
||||
@@ -54,7 +54,7 @@ set extpan $expect_out(1,string)
|
||||
expect "Done"
|
||||
send "networkname\n"
|
||||
expect "networkname"
|
||||
expect -re {\r\n(.*?)\r\n}
|
||||
expect -re {[\r\n]([^\r\n]+?)[\r\n]}
|
||||
set network $expect_out(1,string)
|
||||
expect "Done"
|
||||
send "channel\n"
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
#!/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.
|
||||
#
|
||||
|
||||
source "tests/scripts/expect/_common.exp"
|
||||
|
||||
set spawn_id [spawn_node 1]
|
||||
|
||||
send "networktime 20 200\n"
|
||||
expect "Done"
|
||||
send "networktime\n"
|
||||
expect -re {Network Time: \d+us \((unsynchronized|resync needed|synchronized)\)}
|
||||
expect "Time Sync Period: 20s"
|
||||
expect "XTAL Threshold: 200ppm"
|
||||
expect "Done"
|
||||
send "networktime something_invalid\n"
|
||||
expect "Error 7: InvalidArgs"
|
||||
|
||||
dispose
|
||||
Reference in New Issue
Block a user