diff --git a/src/posix/platform/ip6_utils.hpp b/src/posix/platform/ip6_utils.hpp new file mode 100644 index 000000000..15d4ef634 --- /dev/null +++ b/src/posix/platform/ip6_utils.hpp @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021, 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. + */ + +#include "openthread-posix-config.h" +#include "platform-posix.h" + +#include + +namespace ot { +namespace Posix { +namespace Ip6Utils { + +/** + * This utility class converts binary IPv6 address to text format. + * + */ +class Ip6AddressString +{ +public: + /** + * The constructor of this converter. + * + * @param[in] aAddress A pointer to a buffer holding an IPv6 address. + * + */ + Ip6AddressString(const void *aAddress) + { + VerifyOrDie(inet_ntop(AF_INET6, aAddress, mBuffer, sizeof(mBuffer)) != nullptr, OT_EXIT_ERROR_ERRNO); + } + + /** + * This method returns the string as a null-terminated C string. + * + * @returns The null-terminated C string. + * + */ + const char *AsCString(void) const { return mBuffer; } + +private: + char mBuffer[INET6_ADDRSTRLEN]; +}; + +} // namespace Ip6Utils +} // namespace Posix +} // namespace ot diff --git a/src/posix/platform/netif.cpp b/src/posix/platform/netif.cpp index c84c21cb6..63c7c720b 100644 --- a/src/posix/platform/netif.cpp +++ b/src/posix/platform/netif.cpp @@ -151,40 +151,9 @@ unsigned int gNetifIndex = 0; char gNetifName[IFNAMSIZ]; #if OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE +#include "posix/platform/ip6_utils.hpp" -namespace { - -/** - * This utility class converts binary IPv6 address to text format. - * - */ -class Ip6AddressString -{ -public: - /** - * The constructor of this converter. - * - * @param[in] aAddress A pointer to a buffer holding an IPv6 address. - * - */ - Ip6AddressString(const void *aAddress) - { - VerifyOrDie(inet_ntop(AF_INET6, aAddress, mBuffer, sizeof(mBuffer)) != nullptr, OT_EXIT_ERROR_ERRNO); - } - - /** - * This method returns the string as a null-terminated C string. - * - * @returns The null-terminated C string. - * - */ - const char *AsCString(void) const { return mBuffer; } - -private: - char mBuffer[INET6_ADDRSTRLEN]; -}; - -} // namespace +using namespace ot::Posix::Ip6Utils; #ifndef OPENTHREAD_POSIX_TUN_DEVICE diff --git a/src/posix/platform/udp.cpp b/src/posix/platform/udp.cpp index 1d0307c57..027990afd 100644 --- a/src/posix/platform/udp.cpp +++ b/src/posix/platform/udp.cpp @@ -55,6 +55,10 @@ #if OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE +#include "posix/platform/ip6_utils.hpp" + +using namespace ot::Posix::Ip6Utils; + static const size_t kMaxUdpSize = 1280; static void *FdToHandle(int aFd) @@ -392,26 +396,24 @@ otError otPlatUdpConnect(otUdpSocket *aUdpSocket) if (len > 0 && netifName[0] != '\0') { fd = FdFromHandle(aUdpSocket->mHandle); - VerifyOrExit(setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &netifName, len) == 0, error = OT_ERROR_FAILED); + VerifyOrExit(setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &netifName, len) == 0, { + otLogWarnPlat("Failed to bind to device: %s", strerror(errno)); + error = OT_ERROR_FAILED; + }); } ExitNow(); #endif } - switch (connect(fd, reinterpret_cast(&sin6), sizeof(sin6))) + if (connect(fd, reinterpret_cast(&sin6), sizeof(sin6)) != 0) { - case 0: - break; #ifdef __APPLE__ - case EAFNOSUPPORT: - VerifyOrExit(isDisconnect, error = OT_ERROR_FAILED); - break; + VerifyOrExit(errno == EAFNOSUPPORT && isDisconnect); #endif - - default: + otLogWarnPlat("Failed to connect to [%s]:%u: %s", Ip6AddressString(&aUdpSocket->mPeerName.mAddress).AsCString(), + aUdpSocket->mPeerName.mPort, strerror(errno)); error = OT_ERROR_FAILED; - break; } exit: diff --git a/tests/scripts/expect/_common.exp b/tests/scripts/expect/_common.exp index 653ac7be8..f68380b82 100644 --- a/tests/scripts/expect/_common.exp +++ b/tests/scripts/expect/_common.exp @@ -55,6 +55,11 @@ proc wait_for {command success {failure {[\r\n]FAILURE_NOT_EXPECTED[\r\n]}}} { } } +proc expect_line {line} { + expect -re "\[\r\n \]($line)(?=\[\r\n>\])" + return $expect_out(1,string) +} + proc spawn_node {id {type ""} {radio_url ""}} { global spawn_id global spawn_ids @@ -81,23 +86,23 @@ proc spawn_node {id {type ""} {radio_url ""}} { spawn /usr/bin/env GCOV_PREFIX=$gcov_prefix $::env(OT_POSIX_APPS)/ot-cli $radio_url send "factoryreset\n" wait_for "state" "disabled" - expect "Done" + expect_line "Done" send "routerselectionjitter 1\n" - expect "Done" + expect_line "Done" } cli { spawn /usr/bin/env GCOV_PREFIX=$gcov_prefix $::env(OT_SIMULATION_APPS)/cli/ot-cli-ftd $id send "factoryreset\n" wait_for "state" "disabled" - expect "Done" + expect_line "Done" send "routerselectionjitter 1\n" - expect "Done" + expect_line "Done" } mtd { spawn /usr/bin/env GCOV_PREFIX=$gcov_prefix $::env(OT_SIMULATION_APPS)/cli/ot-cli-mtd $id send "factoryreset\n" wait_for "state" "disabled" - expect "Done" + expect_line "Done" } } @@ -126,15 +131,17 @@ proc dispose_node {id} { proc setup_leader {} { send "dataset init new\n" - expect "Done" + expect_line "Done" + send "dataset masterkey 00112233445566778899aabbccddeeff\n" + expect_line "Done" send "dataset commit active\n" - expect "Done" + expect_line "Done" send "ifconfig up\n" - expect "Done" + expect_line "Done" send "thread start\n" - expect "Done" + expect_line "Done" wait_for "state" "leader" - expect "Done" + expect_line "Done" } proc dispose_all {} { @@ -149,18 +156,16 @@ proc dispose_all {} { proc get_ipaddr {type} { send "ipaddr $type\n" expect "ipaddr $type" - expect -re {(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4})} - set rval $expect_out(1,string) - expect "Done" + set rval [expect_line {([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}}] + expect_line "Done" return $rval } proc get_extaddr {} { send "extaddr\n" - expect -re {([0-9a-fA-F]{16})} - set rval $expect_out(1,string) - expect "Done" + set rval [expect_line {[0-9a-fA-F]{16}}] + expect_line "Done" return $rval } @@ -168,20 +173,19 @@ proc get_extaddr {} { proc get_rloc16 {} { send "rloc16\n" expect "rloc16" - expect -re {([0-9a-fA-F]{4})} - set rval $expect_out(1,string) - expect "Done" + set rval [expect_line {[0-9a-fA-F]{4}}] + expect_line "Done" return $rval } proc setup_default_network {} { send "channel 11\n" - expect "Done" + expect_line "Done" send "panid 0xface\n" - expect "Done" + expect_line "Done" send "masterkey 00112233445566778899aabbccddeeff\n" - expect "Done" + expect_line "Done" } set timeout 10 diff --git a/tests/scripts/expect/_multinode.exp b/tests/scripts/expect/_multinode.exp index dc24c8fa0..ee568e387 100644 --- a/tests/scripts/expect/_multinode.exp +++ b/tests/scripts/expect/_multinode.exp @@ -51,39 +51,39 @@ proc setup_node {node {mode "r"} {role "child"}} { expect "eui64" expect -re {([0-9a-f]{16})} set eui64 $expect_out(1,string) - expect "Done" + expect_line "Done" switch_node 1 send "commissioner state\n" expect { "disabled" { - expect "Done" + expect_line "Done" send "commissioner start\n" - expect "Done" + expect_line "Done" expect "Commissioner: active" } "active" { - expect "Done" + expect_line "Done" } } send "commissioner joiner add $eui64 $::JOINER_PSK\n" - expect "Done" + expect_line "Done" wait_for "netdata steeringdata check $eui64" "Done" switch_node $node send "mode $mode\n" - expect "Done" + expect_line "Done" send "ifconfig up\n" - expect "Done" + expect_line "Done" send "joiner start $::JOINER_PSK\n" - expect "Done" + expect_line "Done" wait_for "" "Join success" send "thread start\n" - expect "Done" + expect_line "Done" wait_for "state" $role - expect "Done" + expect_line "Done" switch_node 1 send "commissioner joiner remove $eui64\n" - expect "Done" + expect_line "Done" } diff --git a/tests/scripts/expect/cli-anycast.exp b/tests/scripts/expect/cli-anycast.exp deleted file mode 100644 index 3081a6bea..000000000 --- a/tests/scripts/expect/cli-anycast.exp +++ /dev/null @@ -1,56 +0,0 @@ -#!/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 "panid 0xface\n" -expect "Done" -send "ifconfig up\n" -expect "Done" -send "thread start\n" -expect "Done" - -wait_for "state" "leader" -expect "Done" - -send "ping fdde:ad00:beef:0:0:ff:fe00:fc00\n" -expect "Done" -expect "16 bytes from " -expect { - "fdde:ad00:beef:0:0:ff:fe00:fc00" abort - - -re {(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4})} {} - - timeout abort -} - -dispose diff --git a/tests/scripts/expect/cli-big-table.exp b/tests/scripts/expect/cli-big-table.exp index f0aaa8c4f..a1fd28e3e 100755 --- a/tests/scripts/expect/cli-big-table.exp +++ b/tests/scripts/expect/cli-big-table.exp @@ -41,6 +41,6 @@ for {set i 2} {$i <= $max_node} {incr i} { set spawn_id $spawn_ids(1) send "child table\n" -expect "Done" +expect_line "Done" dispose_all diff --git a/tests/scripts/expect/cli-channel.exp b/tests/scripts/expect/cli-channel.exp index e6ef4efbb..238bac98d 100755 --- a/tests/scripts/expect/cli-channel.exp +++ b/tests/scripts/expect/cli-channel.exp @@ -32,17 +32,17 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 send "ifconfig up\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" send "channel monitor stop\n" -expect "Done" +expect_line "Done" send "channel monitor\n" expect "enabled: 0" -expect "Done" +expect_line "Done" send "channel monitor start\n" -expect "Done" +expect_line "Done" send "channel monitor\n" expect "enabled: 1" expect -re {interval: \d+} @@ -53,28 +53,28 @@ expect "occupancies:" for {set i 11} {$i <= 26} {incr i} { expect -re "ch $i \\(0x\[0-9a-f\]{4}\\) +\\d+\\.\\d+% busy" } -expect "Done" +expect_line "Done" send "channel monitor something_invalid\n" expect "Error 7: InvalidArgs" send "channel manager change 15\n" -expect "Done" +expect_line "Done" send "channel manager\n" expect "channel: 15" expect "auto: 0" -expect "Done" +expect_line "Done" send "channel manager select 1\n" expect "Error 13: InvalidState" # Because of insufficient channel monitor samples send "channel manager delay 200\n" -expect "Done" +expect_line "Done" send "channel manager interval 20000\n" -expect "Done" +expect_line "Done" send "channel manager supported 0x7fff800\n" -expect "Done" +expect_line "Done" send "channel manager favored 0x7fff800\n" -expect "Done" +expect_line "Done" send "channel manager auto 1\n" -expect "Done" +expect_line "Done" send "channel manager\n" expect "channel: 15" expect "auto: 1" @@ -82,7 +82,7 @@ expect "delay: 200" expect "interval: 20000" expect "supported: { 11-26}" expect "favored: { 11-26}" -expect "Done" +expect_line "Done" send "channel manager something_invalid\n" expect "Error 7: InvalidArgs" diff --git a/tests/scripts/expect/cli-child-supervision.exp b/tests/scripts/expect/cli-child-supervision.exp index 1c8bf7f3c..6c8f1c1df 100755 --- a/tests/scripts/expect/cli-child-supervision.exp +++ b/tests/scripts/expect/cli-child-supervision.exp @@ -34,14 +34,14 @@ setup_two_nodes "-" switch_node 1 send "childsupervision interval 30\n" -expect "Done" +expect_line "Done" send "childsupervision interval\n" -expect "Done" +expect_line "Done" switch_node 2 send "childsupervision checktimeout 30\n" -expect "Done" +expect_line "Done" send "childsupervision checktimeout\n" -expect "Done" +expect_line "Done" dispose_all diff --git a/tests/scripts/expect/cli-child.exp b/tests/scripts/expect/cli-child.exp index 9ac2a5ca4..1e7309966 100755 --- a/tests/scripts/expect/cli-child.exp +++ b/tests/scripts/expect/cli-child.exp @@ -33,16 +33,8 @@ source "tests/scripts/expect/_multinode.exp" setup_two_nodes switch_node 2 -send "extaddr\n" -expect "extaddr" -expect -re {([0-9a-f]{16})} -set extaddr $expect_out(1,string) -expect "Done" -send "rloc16\n" -expect "rloc16" -expect -re {([0-9a-f]{4})} -set rloc $expect_out(1,string) -expect "Done" +set extaddr [get_extaddr] +set rloc [get_rloc16] switch_node 1 send "child table\n" @@ -50,13 +42,13 @@ expect "| ID | RLOC16 | Timeout | Age | LQ In | C_VN |R|D|N|Ver|CSL|Q expect "+-----+--------+------------+------------+-------+------+-+-+-+---+---+-------+------------------+" expect -re "\\| +(\\d+) \\| 0x$rloc \\| +\\d+ \\| +\\d+ \\| +\\d+ \\| +\\d+ \\|\\d\\|\\d\\|\\d\\| *\\d+\\| \\d \\| +\\d+ \\| $extaddr \\|" set child_id $expect_out(1,string) -expect "Done" +expect_line "Done" send "child list\n" expect "child list" expect $child_id -expect "Done" +expect_line "Done" send "child $child_id\n" expect "Ext Addr: $extaddr" -expect "Done" +expect_line "Done" dispose_all diff --git a/tests/scripts/expect/cli-childip.exp b/tests/scripts/expect/cli-childip.exp index 9a6d06af8..294324df0 100755 --- a/tests/scripts/expect/cli-childip.exp +++ b/tests/scripts/expect/cli-childip.exp @@ -33,26 +33,18 @@ source "tests/scripts/expect/_multinode.exp" setup_two_nodes 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" -send "rloc16\n" -expect "rloc16" -expect -re {([0-9a-f]{4})} -set rloc $expect_out(1,string) -expect "Done" +set addr [get_ipaddr mleid] +set rloc [get_rloc16] switch_node 1 send "childip\n" expect "$rloc: $addr" -expect "Done" +expect_line "Done" send "childip max 2\n" -expect "Done" +expect_line "Done" send "childip max\n" expect "2" -expect "Done" +expect_line "Done" send "childip max something_invalid\n" expect "Error 7: InvalidArgs" send "childip something_invalid\n" diff --git a/tests/scripts/expect/cli-coap.exp b/tests/scripts/expect/cli-coap.exp index 871da396f..f7bb65402 100755 --- a/tests/scripts/expect/cli-coap.exp +++ b/tests/scripts/expect/cli-coap.exp @@ -34,47 +34,39 @@ setup_two_nodes switch_node 1 send "coap start\n" -expect "Done" +expect_line "Done" send "coap resource test/resource\n" -expect "Done" +expect_line "Done" send "coap set Testing123\n" -expect "Done" -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_1 $expect_out(1,string) -expect "Done" +expect_line "Done" +set addr_1 [get_ipaddr mleid] switch_node 2 send "coap start\n" -expect "Done" +expect_line "Done" send "coap parameters request 3000 4 3 5\n" expect "Transmission parameters for request:" expect "ACK_TIMEOUT=3000 ms, ACK_RANDOM_FACTOR=4/3, MAX_RETRANSMIT=5" -expect "Done" +expect_line "Done" send "coap parameters response 2500 4 3 3\n" expect "Transmission parameters for response:" expect "ACK_TIMEOUT=2500 ms, ACK_RANDOM_FACTOR=4/3, MAX_RETRANSMIT=3" -expect "Done" +expect_line "Done" send "coap get $addr_1 test/resource\n" -expect "Done" +expect_line "Done" expect "coap response from $addr_1 with payload: 54657374696e67313233" # ASCII of "Testing123" send "coap post $addr_1 test/resource con Testing123\n" -expect "Done" +expect_line "Done" expect "coap response from $addr_1" send "coap put $addr_1 test/resource con Testing123\n" -expect "Done" +expect_line "Done" expect "coap response from $addr_1" send "coap delete $addr_1 test/resource con\n" -expect "Done" +expect_line "Done" expect "coap response from $addr_1" send "coap post $addr_1 test/resource none Testing123\n" -expect "Done" -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_2 $expect_out(1,string) -expect "Done" +expect_line "Done" +set addr_2 [get_ipaddr mleid] switch_node 1 expect "coap request from $addr_2 GET" @@ -88,20 +80,20 @@ expect "coap response sent" expect "coap request from $addr_2 POST with payload: 54657374696e67313233" send "coap resource\n" expect "test/resource" -expect "Done" +expect_line "Done" send "coap set\n" expect "Testing123" -expect "Done" +expect_line "Done" send "coap parameters request default\n" expect "Transmission parameters for request:" expect "default" -expect "Done" +expect_line "Done" send "coap parameters response default\n" expect "Transmission parameters for response:" expect "default" -expect "Done" +expect_line "Done" send "coap help\n" -expect "Done" +expect_line "Done" send "coap parameters something_invalid\n" expect "Error 7: InvalidArgs" send "coap get\n" diff --git a/tests/scripts/expect/cli-coaps.exp b/tests/scripts/expect/cli-coaps.exp index e2ee895b5..6a9521294 100755 --- a/tests/scripts/expect/cli-coaps.exp +++ b/tests/scripts/expect/cli-coaps.exp @@ -34,49 +34,42 @@ setup_two_nodes switch_node 1 send "coaps x509\n" -expect "Done" +expect_line "Done" send "coaps start\n" -expect "Done" +expect_line "Done" send "coaps resource test/resource\n" -expect "Done" +expect_line "Done" send "coaps set Testing123\n" -expect "Done" -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_1 $expect_out(1,string) -expect "Done" +expect_line "Done" + +set addr_1 [get_ipaddr mleid] switch_node 2 send "coaps x509\n" -expect "Done" +expect_line "Done" send "coaps start\n" -expect "Done" +expect_line "Done" send "coaps connect $addr_1 5684\n" -expect "Done" +expect_line "Done" expect "coaps connected" send "coaps get $addr_1 test/resource\n" -expect "Done" +expect_line "Done" expect "coaps response from $addr_1 with payload: 54657374696e67313233" # ASCII of "Testing123" send "coaps post $addr_1 test/resource con Testing123\n" -expect "Done" +expect_line "Done" expect "coaps response from $addr_1" send "coaps put $addr_1 test/resource con Testing123\n" -expect "Done" +expect_line "Done" expect "coaps response from $addr_1" send "coaps delete $addr_1 test/resource con\n" -expect "Done" +expect_line "Done" expect "coaps response from $addr_1" send "coaps post $addr_1 test/resource none Testing123\n" -expect "Done" +expect_line "Done" send "coaps get $addr_1 default\n" -expect "Done" +expect_line "Done" expect "coaps response from $addr_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_2 $expect_out(1,string) -expect "Done" +set addr_2 [get_ipaddr mleid] switch_node 1 expect "coaps request from $addr_2 GET" @@ -90,12 +83,12 @@ expect "coaps response sent" expect "coaps request from $addr_2 POST with payload: 54657374696e67313233" send "coaps resource\n" expect "test/resource" -expect "Done" +expect_line "Done" send "coaps set\n" expect "Testing123" -expect "Done" +expect_line "Done" send "coaps help\n" -expect "Done" +expect_line "Done" send "coaps get\n" expect "Error 7: InvalidArgs" send "coaps\n" @@ -107,10 +100,10 @@ expect "Error 7: InvalidArgs" switch_node 2 send "coaps stop\n" -expect "Done" +expect_line "Done" switch_node 1 send "coaps stop\n" -expect "Done" +expect_line "Done" dispose_all diff --git a/tests/scripts/expect/cli-coex.exp b/tests/scripts/expect/cli-coex.exp index ca26b3793..9bfbfb6d4 100755 --- a/tests/scripts/expect/cli-coex.exp +++ b/tests/scripts/expect/cli-coex.exp @@ -32,15 +32,15 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 send "coex disable\n" -expect "Done" +expect_line "Done" send "coex\n" expect "Disabled" -expect "Done" +expect_line "Done" send "coex enable\n" -expect "Done" +expect_line "Done" send "coex\n" expect "Enabled" -expect "Done" +expect_line "Done" send "coex metrics\n" expect -re {Stopped: (true|false)} expect -re {Grant Glitch: \d+} @@ -63,7 +63,7 @@ expect -re { Grant Deactivated During Request: \d+} expect -re { Delayed Grant: \d+} expect -re { Average Request To Grant Time: \d+} expect -re { Grant None: \d+} -expect "Done" +expect_line "Done" send "coex something_invalid\n" expect "Error 7: InvalidArgs" diff --git a/tests/scripts/expect/cli-commissioner.exp b/tests/scripts/expect/cli-commissioner.exp index f4b4e1606..1474d2f4b 100755 --- a/tests/scripts/expect/cli-commissioner.exp +++ b/tests/scripts/expect/cli-commissioner.exp @@ -35,46 +35,46 @@ setup_two_nodes set eui64 "d45e64fa83f81cf7" switch_node 1 send "commissioner joiner add $eui64 J01NME\n" -expect "Done" +expect_line "Done" wait_for "netdata steeringdata check $eui64" "Done" send "commissioner joiner remove $eui64\n" -expect "Done" +expect_line "Done" wait_for "netdata steeringdata check $eui64" "NotFound" switch_node 2 send "commissioner state\n" expect "disabled" -expect "Done" +expect_line "Done" send "commissioner start\n" -expect "Done" +expect_line "Done" expect "Commissioner: active" send "commissioner state\n" expect "active" -expect "Done" +expect_line "Done" send "commissioner provisioningurl openthread.io\n" -expect "Done" +expect_line "Done" send "commissioner joiner add * J01NME 1\n" -expect "Done" +expect_line "Done" send "commissioner joiner remove *\n" -expect "Done" +expect_line "Done" send "commissioner sessionid\n" expect "commissioner sessionid" expect -re {(\d+)} set sessionid $expect_out(1,string) send "commissioner mgmtset sessionid $sessionid steeringdata ffffffff joinerudpport 10001\n" -expect "Done" +expect_line "Done" send "commissioner mgmtset sessionid $sessionid locator 0x0100\n" -expect "Done" +expect_line "Done" send "commissioner mgmtget sessionid steeringdata joinerudpport locator binary 0b081209\n" -expect "Done" +expect_line "Done" send "commissioner stop\n" expect "Commissioner: disabled" -expect "Done" +expect_line "Done" send "commissioner state\n" expect "disabled" -expect "Done" +expect_line "Done" send "commissioner help\n" -expect "Done" +expect_line "Done" send "commissioner joiner something_invalid\n" expect "Error 7: InvalidArgs" send "commissioner mgmtget something_invalid\n" diff --git a/tests/scripts/expect/cli-counters.exp b/tests/scripts/expect/cli-counters.exp index eda2de1f0..359d3b45f 100755 --- a/tests/scripts/expect/cli-counters.exp +++ b/tests/scripts/expect/cli-counters.exp @@ -34,15 +34,15 @@ spawn_node 1 send "counters\n" expect "mac" expect "mle" -expect "Done" +expect_line "Done" send "counters mac\n" -expect "Done" +expect_line "Done" send "counters mle\n" -expect "Done" +expect_line "Done" send "counters mac reset\n" -expect "Done" +expect_line "Done" send "counters mle reset\n" -expect "Done" +expect_line "Done" send "counters mac 1\n" expect "Error 7: InvalidArgs" send "counters mle 1\n" diff --git a/tests/scripts/expect/cli-dataset.exp b/tests/scripts/expect/cli-dataset.exp index 259f9cfd2..5af33eba2 100755 --- a/tests/scripts/expect/cli-dataset.exp +++ b/tests/scripts/expect/cli-dataset.exp @@ -48,77 +48,77 @@ expect -re {Security Policy: \d+, o?n?r?c?b?} send "dataset pending\n" expect "Error 23: NotFound" send "dataset init active\n" -expect "Done" +expect_line "Done" send "dataset activetimestamp 100\n" -expect "Done" +expect_line "Done" send "dataset activetimestamp\n" expect "100" -expect "Done" +expect_line "Done" if {$channel == 11} { send "dataset channel 18\n" - expect "Done" + expect_line "Done" send "dataset channel\n" expect "18" - expect "Done" + expect_line "Done" } else { send "dataset channel 11\n" - expect "Done" + expect_line "Done" send "dataset channel\n" expect "11" - expect "Done" + expect_line "Done" } send "dataset channelmask 0x03fff800\n" -expect "Done" +expect_line "Done" send "dataset channelmask\n" expect "0x03fff800" -expect "Done" +expect_line "Done" send "dataset extpanid aabbccddeeff0011\n" -expect "Done" +expect_line "Done" send "dataset extpanid\n" expect "aabbccddeeff0011" -expect "Done" +expect_line "Done" send "dataset masterkey aabbccddeeff00112233445566778899\n" -expect "Done" +expect_line "Done" send "dataset masterkey\n" expect "aabbccddeeff00112233445566778899" -expect "Done" +expect_line "Done" send "dataset meshlocalprefix fdde:4860::\n" -expect "Done" +expect_line "Done" send "dataset meshlocalprefix\n" expect "fdde:4860:0:0::/64" -expect "Done" +expect_line "Done" send "dataset networkname OT-network\n" -expect "Done" +expect_line "Done" send "dataset networkname\n" expect "OT-network" -expect "Done" +expect_line "Done" send "dataset panid 0xface\n" -expect "Done" +expect_line "Done" send "dataset panid\n" expect "0xface" -expect "Done" +expect_line "Done" send "dataset pskc 00112233445566778899aabbccddeeff\n" -expect "Done" +expect_line "Done" send "dataset pskc\n" expect "00112233445566778899aabbccddeeff" -expect "Done" +expect_line "Done" send "dataset securitypolicy 678 onrcb\n" -expect "Done" +expect_line "Done" send "dataset securitypolicy\n" expect "678 onrcb" -expect "Done" +expect_line "Done" send "dataset pendingtimestamp 100\n" -expect "Done" +expect_line "Done" send "dataset pendingtimestamp\n" expect "100" -expect "Done" +expect_line "Done" send "dataset delay 30000\n" -expect "Done" +expect_line "Done" send "dataset delay\n" expect "30000" -expect "Done" +expect_line "Done" send "dataset commit pending\n" -expect "Done" +expect_line "Done" send "dataset pending\n" expect "Pending Timestamp: 100" expect "Active Timestamp: 100" @@ -136,13 +136,13 @@ expect "Network Name: OT-network" expect "PAN ID: 0xface" expect "PSKc: 00112233445566778899aabbccddeeff" expect "Security Policy: 678, onrcb" -expect "Done" +expect_line "Done" sleep 30 switch_node 2 wait_for "dataset active" "Active Timestamp: 100" -expect "Done" +expect_line "Done" send "dataset active\n" expect "Active Timestamp: 100" if {$channel == 11} { @@ -158,11 +158,11 @@ expect "Network Name: OT-network" expect "PAN ID: 0xface" expect "PSKc: 00112233445566778899aabbccddeeff" expect "Security Policy: 678, onrcb" -expect "Done" +expect_line "Done" send "dataset clear\n" -expect "Done" +expect_line "Done" send "dataset init active\n" -expect "Done" +expect_line "Done" send "dataset\n" expect "Active Timestamp: 100" if {$channel == 11} { @@ -178,16 +178,12 @@ expect "Network Name: OT-network" expect "PAN ID: 0xface" expect "PSKc: 00112233445566778899aabbccddeeff" expect "Security Policy: 678, onrcb" -expect "Done" +expect_line "Done" send "dataset init pending\n" expect "Error 23: NotFound" 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 addr [get_ipaddr mleid] switch_node 2 send "dataset mgmtgetcommand active \ @@ -195,60 +191,60 @@ activetimestamp pendingtimestamp masterkey networkname extpanid \ localprefix delaytimer panid channel \ -x 000102030405060708090a0b0e0f0c333435 \ address $addr\n" -expect "Done" +expect_line "Done" send "dataset mgmtgetcommand pending \ activetimestamp pendingtimestamp masterkey networkname extpanid \ localprefix delaytimer panid channel \ -x 000102030405060708090a0b0e0f0c333435 \ address $addr\n" -expect "Done" +expect_line "Done" switch_node 1 send "dataset init active\n" -expect "Done" +expect_line "Done" send "dataset networkname Thread\\ 网络\n" -expect "Done" +expect_line "Done" send "dataset commit active\n" -expect "Done" +expect_line "Done" send "dataset active -x\n" expect "54687265616420e7bd91e7bb9c" ;# UTF-8 of "Thread 网络" -expect "Done" +expect_line "Done" send "dataset active -x\n" expect "dataset active -x" expect -re {([0-9a-f]+)[\r\n]+Done} set binary $expect_out(1,string) send "dataset set pending $binary\n" -expect "Done" +expect_line "Done" send "dataset pending -x\n" expect $binary -expect "Done" +expect_line "Done" send "dataset pending\n" expect "Network Name: Thread 网络" -expect "Done" +expect_line "Done" send "dataset set active $binary\n" -expect "Done" +expect_line "Done" send "dataset mgmtsetcommand active activetimestamp 200 -x 030d54687265616420e7bd91e7bb9c\n" -expect "Done" +expect_line "Done" send "dataset active\n" expect "Network Name: Thread 网络" -expect "Done" +expect_line "Done" send "dataset mgmtsetcommand active activetimestamp 210 -x 0301ff\n" -expect "Done" +expect_line "Done" send "dataset active\n" expect "Active Timestamp: 200" expect "Network Name: Thread 网络" -expect "Done" +expect_line "Done" send "dataset set active 03023432\n" -expect "Done" +expect_line "Done" send "dataset active\n" expect "Network Name: 42" -expect "Done" +expect_line "Done" send "dataset set active 0301bf\n" expect "Error 7: InvalidArgs" send "dataset help\n" -expect "Done" +expect_line "Done" send "dataset\n" -expect "Done" +expect_line "Done" send "dataset init something_invalid\n" expect "Error 7: InvalidArgs" send "dataset active something_invalid\n" @@ -266,7 +262,7 @@ expect "Error 7: InvalidArgs" send "dataset mgmtgetcommand active something_invalid\n" expect "Error 7: InvalidArgs" send "dataset pskc -p 123456\n" -expect "Done" +expect_line "Done" send "dataset securitypolicy 678 something_invalid\n" expect "Error 7: InvalidArgs" send "dataset set something_invalid 00\n" diff --git a/tests/scripts/expect/cli-discerner.exp b/tests/scripts/expect/cli-discerner.exp index 64f422ba7..07a9e413a 100755 --- a/tests/scripts/expect/cli-discerner.exp +++ b/tests/scripts/expect/cli-discerner.exp @@ -44,27 +44,27 @@ expect "InvalidArgs" send "netdata steeringdata check $discerner\n" expect "InvalidState" send "commissioner start\n" -expect "Done" +expect_line "Done" expect "Commissioner: active" send "commissioner joiner add 1/0 $pskd\n" expect "InvalidArgs" send "netdata steeringdata check 0xabc/12\n" expect "NotFound" send "commissioner joiner add $discerner $pskd\n" -expect "Done" +expect_line "Done" wait_for "netdata steeringdata check $discerner" "Done" send "commissioner joiner remove $discerner\n" -expect "Done" +expect_line "Done" wait_for "netdata steeringdata check $discerner" "NotFound" send "commissioner joiner add $discerner $pskd\n" -expect "Done" +expect_line "Done" spawn_node 2 send "mode r\n" -expect "Done" +expect_line "Done" send "ifconfig up\n" -expect "Done" +expect_line "Done" send "joiner discerner\n" expect "NotFound" send "joiner discerner 1/1 2\n" @@ -82,18 +82,18 @@ expect "InvalidArgs" send "joiner discerner invalid/20\n" expect "InvalidArgs" send "joiner discerner clear\n" -expect "Done" +expect_line "Done" send "joiner discerner $discerner\n" -expect "Done" +expect_line "Done" send "joiner discerner\n" expect "$discerner" -expect "Done" +expect_line "Done" send "joiner start $pskd\n" -expect "Done" +expect_line "Done" wait_for "" "Join success" "Join failed" send "thread start\n" -expect "Done" +expect_line "Done" wait_for "state" "child" -expect "Done" +expect_line "Done" dispose_all diff --git a/tests/scripts/expect/cli-extaddr.exp b/tests/scripts/expect/cli-extaddr.exp index a4fc42de6..ca48271a8 100755 --- a/tests/scripts/expect/cli-extaddr.exp +++ b/tests/scripts/expect/cli-extaddr.exp @@ -32,9 +32,9 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 send "extaddr 99aabbccddeeff00\n" -expect "Done" +expect_line "Done" send "extaddr 99AABBCCDDEEFF00\n" -expect "Done" +expect_line "Done" send "extaddr\n" expect "99aabbccddeeff00" send "extaddr 1\n" diff --git a/tests/scripts/expect/cli-ipmaddr.exp b/tests/scripts/expect/cli-ipmaddr.exp index 5084ca2ba..a4e324f0c 100755 --- a/tests/scripts/expect/cli-ipmaddr.exp +++ b/tests/scripts/expect/cli-ipmaddr.exp @@ -34,35 +34,32 @@ setup_two_nodes switch_node 1 send "ipmaddr add ff0e::1\n" -expect "Done" +expect_line "Done" send "ipmaddr\n" expect "ff0e:0:0:0:0:0:0:1" -expect "Done" -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_line "Done" +set addr [get_ipaddr mleid] switch_node 2 send "ping ff0e::1\n" -expect "Done" +expect_line "Done" expect "16 bytes from $addr: icmp_seq=1" switch_node 1 send "ipmaddr del ff0e::1\n" -expect "Done" +expect_line "Done" send "ipmaddr del ff0e::1\n" expect "Error 23: NotFound" send "ipmaddr promiscuous enable\n" -expect "Done" +expect_line "Done" send "ipmaddr promiscuous\n" expect "Enabled" -expect "Done" +expect_line "Done" send "ipmaddr promiscuous disable\n" -expect "Done" +expect_line "Done" send "ipmaddr promiscuous\n" expect "Disabled" -expect "Done" +expect_line "Done" send "ipmaddr something_invalid\n" expect "Error 35: InvalidCommand" diff --git a/tests/scripts/expect/cli-log-level.exp b/tests/scripts/expect/cli-log-level.exp index c7685fcac..8544d5a2d 100755 --- a/tests/scripts/expect/cli-log-level.exp +++ b/tests/scripts/expect/cli-log-level.exp @@ -33,12 +33,12 @@ spawn_node 1 send "log level\n" expect -re {\d} -expect "Done" +expect_line "Done" send "log level 5\n" -expect "Done" +expect_line "Done" send "log level\n" expect "5" -expect "Done" +expect_line "Done" send "log level -1\n" expect "Error 7: InvalidArgs" send "log level 6\n" diff --git a/tests/scripts/expect/cli-mac.exp b/tests/scripts/expect/cli-mac.exp index 0d6865dd5..0d3054410 100755 --- a/tests/scripts/expect/cli-mac.exp +++ b/tests/scripts/expect/cli-mac.exp @@ -32,16 +32,16 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 send "mac retries direct 5\n" -expect "Done" +expect_line "Done" send "mac retries direct\n" expect "5" -expect "Done" +expect_line "Done" send "mac retries indirect 2\n" -expect "Done" +expect_line "Done" send "mac retries indirect\n" expect "2" -expect "Done" +expect_line "Done" send "mac\n" expect "Error 7: InvalidArgs" diff --git a/tests/scripts/expect/cli-macfilter.exp b/tests/scripts/expect/cli-macfilter.exp index 5892b831c..21456b35a 100755 --- a/tests/scripts/expect/cli-macfilter.exp +++ b/tests/scripts/expect/cli-macfilter.exp @@ -34,108 +34,108 @@ spawn_node 1 send "macfilter\n" expect "Address Mode: Disabled" expect "RssIn List:" -expect "Done" +expect_line "Done" send "macfilter addr add aabbccddeeff0011\n" -expect "Done" +expect_line "Done" send "macfilter addr\n" expect "Disabled" expect "aabbccddeeff0011" -expect "Done" +expect_line "Done" send "macfilter addr allowlist\n" -expect "Done" +expect_line "Done" send "macfilter addr\n" expect "Allowlist" expect "aabbccddeeff0011" -expect "Done" +expect_line "Done" send "macfilter\n" expect "Address Mode: Allowlist" expect "aabbccddeeff0011" expect "RssIn List:" -expect "Done" +expect_line "Done" send "macfilter addr add 2233445566778899\n" -expect "Done" +expect_line "Done" send "macfilter addr remove aabbccddeeff0011\n" -expect "Done" +expect_line "Done" send "macfilter addr denylist\n" -expect "Done" +expect_line "Done" send "macfilter addr\n" expect "Denylist" expect "2233445566778899" -expect "Done" +expect_line "Done" send "macfilter\n" expect "Address Mode: Denylist" expect "2233445566778899" expect "RssIn List:" -expect "Done" +expect_line "Done" send "macfilter addr clear\n" -expect "Done" +expect_line "Done" send "macfilter addr disable\n" -expect "Done" +expect_line "Done" send "macfilter addr\n" expect "Disabled" -expect "Done" +expect_line "Done" send "macfilter\n" expect "Address Mode: Disabled" expect "RssIn List:" -expect "Done" +expect_line "Done" send "macfilter addr something_invalid\n" expect "Error 35: InvalidCommand" send "macfilter rss\n" -expect "Done" +expect_line "Done" send "macfilter rss add-lqi * 2\n" -expect "Done" +expect_line "Done" send "macfilter rss add-lqi aabbccddeeff0011 3\n" -expect "Done" +expect_line "Done" send "macfilter rss\n" expect -re {aabbccddeeff0011 : rss -?\d+ \(lqi 3\)} expect -re {Default rss: -?\d+ \(lqi 2\)} -expect "Done" +expect_line "Done" send "macfilter\n" expect "Address Mode: Disabled" expect "RssIn List:" expect -re {aabbccddeeff0011 : rss -?\d+ \(lqi 3\)} expect -re {Default rss : -?\d+ \(lqi 2\)} -expect "Done" +expect_line "Done" send "macfilter rss remove *\n" -expect "Done" +expect_line "Done" send "macfilter rss remove aabbccddeeff0011\n" -expect "Done" +expect_line "Done" send "macfilter rss add 2233445566778899 -70\n" -expect "Done" +expect_line "Done" send "macfilter rss add * -80\n" -expect "Done" +expect_line "Done" send "macfilter rss\n" expect -re {2233445566778899 : rss -70 \(lqi \d\)} expect -re {Default rss: -80 \(lqi \d\)} -expect "Done" +expect_line "Done" send "macfilter rss clear\n" -expect "Done" +expect_line "Done" send "macfilter rss something_invalid\n" expect "Error 35: InvalidCommand" diff --git a/tests/scripts/expect/cli-misc.exp b/tests/scripts/expect/cli-misc.exp index 65992bb19..98651e8b5 100755 --- a/tests/scripts/expect/cli-misc.exp +++ b/tests/scripts/expect/cli-misc.exp @@ -40,129 +40,129 @@ expect -re {Weighting: \d+} expect -re {Data Version: \d+} expect -re {Stable Data Version: \d+} expect -re {Leader Router ID: \d+} -expect "Done" +expect_line "Done" send "help\n" -expect "Done" +expect_line "Done" send "bufferinfo\n" -expect "Done" +expect_line "Done" send "ccathreshold -62\n" -expect "Done" +expect_line "Done" send "ccathreshold\n" expect -- "-62 dBm" -expect "Done" +expect_line "Done" send "parent\n" -expect "Done" +expect_line "Done" send "delaytimermin 1\n" -expect "Done" +expect_line "Done" send "delaytimermin\n" expect "1" -expect "Done" +expect_line "Done" send "delaytimermin 1 2\n" send "counters mac 1\n" expect "Error 7: InvalidArgs" send "fem lnagain 11\n" -expect "Done" +expect_line "Done" send "fem lnagain\n" expect -- "11" -expect "Done" +expect_line "Done" send "fem\n" expect -- "LNA gain 11 dBm" -expect "Done" +expect_line "Done" send "ifconfig down\n" -expect "Done" +expect_line "Done" send "ifconfig\n" expect "down" -expect "Done" +expect_line "Done" send "ifconfig up\n" -expect "Done" +expect_line "Done" send "ifconfig\n" expect "up" -expect "Done" +expect_line "Done" send "ipaddr add ::\n" -expect "Done" +expect_line "Done" send "ipaddr del ::\n" -expect "Done" +expect_line "Done" send "leaderweight 1\n" -expect "Done" +expect_line "Done" send "leaderweight\n" expect "1" -expect "Done" +expect_line "Done" send "mode rdn\n" -expect "Done" +expect_line "Done" send "mode\n" expect -re "(?=.*r)(?=.*d)(?=.*n)" send "parent\n" -expect "Done" +expect_line "Done" send "singleton\n" expect -re "true|false" -expect "Done" +expect_line "Done" send "state\n" expect "disabled" -expect "Done" +expect_line "Done" send "txpower -10\n" -expect "Done" +expect_line "Done" send "txpower\n" expect -- "-10 dBm" -expect "Done" +expect_line "Done" send "thread version\n" -expect "Done" +expect_line "Done" send "version\n" -expect "Done" +expect_line "Done" send "version api\n" expect -re {\d+} -expect "Done" +expect_line "Done" send "version something_invalid\n" expect "Error 35: InvalidCommand" send "joinerport 10001\n" -expect "Done" +expect_line "Done" send "joinerport\n" expect "10001" -expect "Done" +expect_line "Done" send "parentpriority 1\n" -expect "Done" +expect_line "Done" send "parentpriority\n" expect "1" -expect "Done" +expect_line "Done" send "pollperiod 100000\n" -expect "Done" +expect_line "Done" send "pollperiod\n" expect "100000" -expect "Done" +expect_line "Done" send "prefix add ::/64 low pdcrosn\n" -expect "Done" +expect_line "Done" send "prefix\n" expect "0:0:0:0::/64 pdcrosn low" -expect "Done" +expect_line "Done" send "preferrouterid 1\n" -expect "Done" +expect_line "Done" send "route add ::/64 s low\n" -expect "Done" +expect_line "Done" send "route\n" expect "0:0:0:0::/64 s low" send "route remove ::/64\n" -expect "Done" +expect_line "Done" send "diag start\n" expect ": InvalidState" diff --git a/tests/scripts/expect/cli-multicast-loop.exp b/tests/scripts/expect/cli-multicast-loop.exp index 4d84adeb1..ef6c8b68b 100755 --- a/tests/scripts/expect/cli-multicast-loop.exp +++ b/tests/scripts/expect/cli-multicast-loop.exp @@ -42,16 +42,16 @@ setup_default_network set timeout 1 send "panid 0xface\n" -expect "Done" +expect_line "Done" send "ifconfig up\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" wait_for "state" "leader" -expect "Done" +expect_line "Done" set extaddr1 [get_extaddr] @@ -61,16 +61,16 @@ spawn_node 2 cli setup_default_network send "panid 0xface\n" -expect "Done" +expect_line "Done" send "ifconfig up\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" wait_for "state" "router" -expect "Done" +expect_line "Done" sleep 3 get_rloc16 @@ -79,22 +79,22 @@ spawn_node 3 cli setup_default_network send "panid 0xface\n" -expect "Done" +expect_line "Done" send "macfilter addr add ${extaddr1}\n" -expect "Done" +expect_line "Done" send "macfilter addr denylist\n" -expect "Done" +expect_line "Done" send "ifconfig up\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" wait_for "state" "router" -expect "Done" +expect_line "Done" sleep 4 set extaddr3 [get_extaddr] @@ -105,25 +105,25 @@ spawn_node 4 cli setup_default_network send "panid 0xface\n" -expect "Done" +expect_line "Done" send "mode rn\n" -expect "Done" +expect_line "Done" send "macfilter addr add ${extaddr3}\n" -expect "Done" +expect_line "Done" send "macfilter addr allowlist\n" -expect "Done" +expect_line "Done" send "ifconfig up\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" wait_for "state" "child" -expect "Done" +expect_line "Done" get_rloc16 @@ -133,7 +133,7 @@ set rloc(1) [get_ipaddr "rloc"] send "networkdiagnostic get ff03::2 5 16\n" expect "DIAG_GET.rsp/ans from $rloc(1)" -expect "Done" +expect_line "Done" sleep 5 diff --git a/tests/scripts/expect/cli-neighbor.exp b/tests/scripts/expect/cli-neighbor.exp index 4af05a272..9f5dd9e5f 100755 --- a/tests/scripts/expect/cli-neighbor.exp +++ b/tests/scripts/expect/cli-neighbor.exp @@ -33,26 +33,18 @@ source "tests/scripts/expect/_multinode.exp" setup_two_nodes switch_node 2 -send "rloc16\n" -expect "rloc16" -expect -re {([0-9a-f]{4})} -set rloc $expect_out(1,string) -expect "Done" -send "extaddr\n" -expect "extaddr" -expect -re {([0-9a-f]{16})} -set extaddr $expect_out(1,string) -expect "Done" +set rloc [get_rloc16] +set extaddr [get_extaddr] switch_node 1 send "neighbor table\n" expect "| Role | RLOC16 | Age | Avg RSSI | Last RSSI |R|D|N| Extended MAC |" expect "+------+--------+-----+----------+-----------+-+-+-+------------------+" expect -re "\\| +C +\\| 0x$rloc \\| +\\d+ \\| +-?\\d+ \\| +-?\\d+ \\|1\\|0\\|0\\| $extaddr \\|" -expect "Done" +expect_line "Done" send "neighbor list\n" expect "0x$rloc" -expect "Done" +expect_line "Done" send "neighbor something_invalid\n" expect "Error 7: InvalidArgs" diff --git a/tests/scripts/expect/cli-netdata.exp b/tests/scripts/expect/cli-netdata.exp index faf65377c..ff2d62cff 100755 --- a/tests/scripts/expect/cli-netdata.exp +++ b/tests/scripts/expect/cli-netdata.exp @@ -35,15 +35,15 @@ setup_two_nodes switch_node 1 send "netdata help\n" -expect "Done" +expect_line "Done" send "netdata register\n" -expect "Done" +expect_line "Done" send "netdata show\n" -expect "Done" +expect_line "Done" send "netdata show -x\n" -expect "Done" +expect_line "Done" dispose_all diff --git a/tests/scripts/expect/cli-networkname.exp b/tests/scripts/expect/cli-networkname.exp index 2b0ce3e70..20c09c668 100755 --- a/tests/scripts/expect/cli-networkname.exp +++ b/tests/scripts/expect/cli-networkname.exp @@ -34,47 +34,47 @@ spawn_node 2 switch_node 1 send "networkname Thread\\ Network\n" -expect "Done" +expect_line "Done" send "ifconfig up\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" wait_for "state" "leader" -expect "Done" +expect_line "Done" switch_node 2 send "scan\n" expect "Thread Network" -expect "Done" +expect_line "Done" switch_node 1 send "thread stop\n" -expect "Done" +expect_line "Done" send "networkname Thread\\ 网络\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" wait_for "state" "leader" -expect "Done" +expect_line "Done" switch_node 2 send "scan\n" expect "Thread 网络" -expect "Done" +expect_line "Done" switch_node 1 send "thread stop\n" -expect "Done" +expect_line "Done" send "networkname スレッド\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" wait_for "state" "leader" -expect "Done" +expect_line "Done" switch_node 2 send "scan\n" expect "スレッド" -expect "Done" +expect_line "Done" dispose_all diff --git a/tests/scripts/expect/cli-partitionid.exp b/tests/scripts/expect/cli-partitionid.exp old mode 100644 new mode 100755 index e2e0b6039..18a5efa00 --- a/tests/scripts/expect/cli-partitionid.exp +++ b/tests/scripts/expect/cli-partitionid.exp @@ -32,14 +32,14 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 send "partitionid preferred 12345678\n" -expect "Done" +expect_line "Done" send "partitionid preferred\n" expect "12345678" -expect "Done" +expect_line "Done" send "partitionid invalid\n" expect "Error 35: InvalidCommand" send "partitionid\n" expect "0" -expect "Done" +expect_line "Done" dispose_all diff --git a/tests/scripts/expect/cli-ping.exp b/tests/scripts/expect/cli-ping.exp index 1e615ff57..db24d4728 100755 --- a/tests/scripts/expect/cli-ping.exp +++ b/tests/scripts/expect/cli-ping.exp @@ -34,13 +34,13 @@ source "tests/scripts/expect/_multinode.exp" spawn_node 1 send "ping ::1 1 2 1 1\n" -expect "Done" +expect_line "Done" send "ping stop\n" -expect "Done" +expect_line "Done" send "ping ::1 1 2 0.12345 1\n" -expect "Done" +expect_line "Done" send "ping stop\n" -expect "Done" +expect_line "Done" send "ping ::1 1 2 1 1 1\n" expect "Error 7: InvalidArgs" @@ -50,11 +50,7 @@ dispose_all setup_two_nodes 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 addr [get_ipaddr mleid] switch_node 1 send "ping $addr\n" diff --git a/tests/scripts/expect/cli-promiscuous.exp b/tests/scripts/expect/cli-promiscuous.exp index c2fcf78ce..61acf4987 100755 --- a/tests/scripts/expect/cli-promiscuous.exp +++ b/tests/scripts/expect/cli-promiscuous.exp @@ -35,14 +35,14 @@ spawn_node 1 send "promiscuous\n" expect "Disabled" -expect "Done" +expect_line "Done" send "promiscuous enable\n" -expect "Done" +expect_line "Done" send "promiscuous\n" expect "Enabled" -expect "Done" +expect_line "Done" send "promiscuous disable\n" -expect "Done" +expect_line "Done" send "promiscuous a\n" expect "Error 7: InvalidArgs" @@ -56,19 +56,19 @@ send "channel\n" expect "channel" expect -re {(\d+)} set channel $expect_out(1,string) -expect "Done" +expect_line "Done" spawn_node 3 send "channel $channel\n" -expect "Done" +expect_line "Done" send "promiscuous enable\n" -expect "Done" +expect_line "Done" 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" +expect_line "Done" switch_node 1 send "ping $addr\n" @@ -79,6 +79,6 @@ expect -re {============================================\[len = +\d+]=========== expect -re {\|( ([0-9A-Z]{2}|\.\.)){16}\|( .){16}\|} expect -- "-----------------------------------------------------------------------------------" send "promiscuous disable\n" -expect "Done" +expect_line "Done" dispose_all diff --git a/tests/scripts/expect/cli-pskc.exp b/tests/scripts/expect/cli-pskc.exp index 1d211fd98..f4de844d1 100755 --- a/tests/scripts/expect/cli-pskc.exp +++ b/tests/scripts/expect/cli-pskc.exp @@ -32,21 +32,21 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 send "pskc 00112233445566778899aabbccddeeff\n" -expect "Done" +expect_line "Done" send "pskc\n" expect "00112233445566778899aabbccddeeff" -expect "Done" +expect_line "Done" send "factoryreset\n" sleep 0.1 send "networkname Test\\ Network\n" -expect "Done" +expect_line "Done" send "extpanid 0001020304050607\n" -expect "Done" +expect_line "Done" send "pskc -p 12SECRETPASSWORD34\n" -expect "Done" +expect_line "Done" send "pskc\n" expect "c3f59368445a1b6106be420a706d4cc9" -expect "Done" +expect_line "Done" send "factoryreset\n" sleep 0.1 send "pskc -x\n" diff --git a/tests/scripts/expect/cli-region.exp b/tests/scripts/expect/cli-region.exp index b1dc44655..3c75c40ab 100755 --- a/tests/scripts/expect/cli-region.exp +++ b/tests/scripts/expect/cli-region.exp @@ -32,9 +32,9 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 send "region\n" -expect "Done" +expect_line "Done" send "region US\n" -expect "Done" +expect_line "Done" send "region\n" expect "US" -expect "Done" +expect_line "Done" diff --git a/tests/scripts/expect/cli-reset.exp b/tests/scripts/expect/cli-reset.exp index d432d3320..dc2944160 100755 --- a/tests/scripts/expect/cli-reset.exp +++ b/tests/scripts/expect/cli-reset.exp @@ -32,11 +32,11 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 send "ifconfig up\n" -expect "Done" +expect_line "Done" send "panid 0xabcd\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" sleep 3 @@ -45,24 +45,24 @@ sleep 3 send "ifconfig\n" expect "down" -expect "Done" +expect_line "Done" send "panid\n" expect "0xabcd" -expect "Done" +expect_line "Done" send "ifconfig up\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" send "factoryreset\n" sleep 3 send "ifconfig\n" expect "down" -expect "Done" +expect_line "Done" send "panid\n" expect "0xffff" -expect "Done" +expect_line "Done" dispose_all diff --git a/tests/scripts/expect/cli-router.exp b/tests/scripts/expect/cli-router.exp index 028476da0..b7f1a56dd 100755 --- a/tests/scripts/expect/cli-router.exp +++ b/tests/scripts/expect/cli-router.exp @@ -33,37 +33,33 @@ source "tests/scripts/expect/_multinode.exp" setup_two_nodes switch_node 1 -send "extaddr\n" -expect "extaddr" -expect -re {([0-9a-f]{16})} -set extaddr $expect_out(1,string) -expect "Done" +set extaddr [get_extaddr] send "router list\n" expect "router list" expect -re {(\d+)} set router_id $expect_out(1,string) -expect "Done" +expect_line "Done" send "router $router_id\n" expect -re {Rloc: ([0-9a-f]{4})} set rloc $expect_out(1,string) -expect "Done" +expect_line "Done" send "router table\n" expect "| ID | RLOC16 | Next Hop | Path Cost | LQ In | LQ Out | Age | Extended MAC |" expect "+----+--------+----------+-----------+-------+--------+-----+------------------+" expect -re "\\| +$router_id \\| 0x$rloc \\| +\\d+ \\| +\\d+ \\| +\\d+ \\| +\\d+ \\| +\\d+ \\| $extaddr \\|" -expect "Done" +expect_line "Done" switch_node 2 send "mode rdn\n" -expect "Done" +expect_line "Done" send "state router\n" -expect "Done" +expect_line "Done" wait_for "router list" $router_id send "router $router_id\n" expect "Router ID: $router_id" expect "Rloc: $rloc" expect -re {Next Hop: [0-9a-f]{4}} expect -re {Link: [01]} -expect "Done" +expect_line "Done" dispose_all diff --git a/tests/scripts/expect/cli-routereligible.exp b/tests/scripts/expect/cli-routereligible.exp index f18a3d115..821b1272b 100755 --- a/tests/scripts/expect/cli-routereligible.exp +++ b/tests/scripts/expect/cli-routereligible.exp @@ -32,22 +32,22 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 send "routereligible disable\n" -expect "Done" +expect_line "Done" send "routereligible\n" expect "Disabled" -expect "Done" +expect_line "Done" send "routereligible enable\n" -expect "Done" +expect_line "Done" send "routereligible\n" expect "Enabled" -expect "Done" +expect_line "Done" send "routereligible something_invalid\n" expect "Error 7: InvalidArgs" send "mode r\n" -expect "Done" +expect_line "Done" send "routereligible\n" expect "Disabled" -expect "Done" +expect_line "Done" send "routereligible enable\n" expect "Error 27: NotCapable" diff --git a/tests/scripts/expect/cli-scan-discover.exp b/tests/scripts/expect/cli-scan-discover.exp index fd9061ee4..812b88298 100755 --- a/tests/scripts/expect/cli-scan-discover.exp +++ b/tests/scripts/expect/cli-scan-discover.exp @@ -35,32 +35,28 @@ setup_two_nodes spawn_node 3 switch_node 1 -send "extaddr\n" -expect "extaddr" -expect -re {([0-9a-f]{16})} -set extaddr $expect_out(1,string) -expect "Done" +set extaddr [get_extaddr] send "panid\n" expect "panid" expect -re {([0-9a-f]{4})} set pan $expect_out(1,string) -expect "Done" +expect_line "Done" send "extpanid\n" expect "extpanid" expect -re {([0-9a-f]{16})} set extpan $expect_out(1,string) -expect "Done" +expect_line "Done" expect "> " send "networkname\n" expect "networkname" expect -re {[\r\n]([^\r\n]+?)[\r\n]} set network $expect_out(1,string) -expect "Done" +expect_line "Done" send "channel\n" expect "channel" expect -re {(\d+)} set channel $expect_out(1,string) -expect "Done" +expect_line "Done" switch_node 3 send "scan $channel\n" @@ -74,16 +70,16 @@ expect "+----+------+" for {set i 11} {$i <= 26} {incr i} { expect -re "\\| +$i \\| +-?\\d+ \\|" } -expect "Done" +expect_line "Done" send "scan energy 100 $channel\n" expect "| Ch | RSSI |" expect "+----+------+" expect -re "\\| +$channel \\| +-?\\d+ \\|" -expect "Done" +expect_line "Done" switch_node 3 send "ifconfig up\n" -expect "Done" +expect_line "Done" send "discover $channel\n" expect "| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |" expect "+---+------------------+------------------+------+------------------+----+-----+-----+" diff --git a/tests/scripts/expect/cli-udp.exp b/tests/scripts/expect/cli-udp.exp index e55b45838..2a78f7ed9 100755 --- a/tests/scripts/expect/cli-udp.exp +++ b/tests/scripts/expect/cli-udp.exp @@ -34,31 +34,25 @@ setup_two_nodes switch_node 2 send "udp open\n" -expect "Done" +expect_line "Done" send "udp bind :: 11001\n" -expect "Done" -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_2 $expect_out(1,string) +expect_line "Done" +set addr_2 [get_ipaddr mleid] 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_1 $expect_out(1,string) +set addr_1 [get_ipaddr mleid] send "udp open\n" -expect "Done" +expect_line "Done" send "udp bind :: 11002\n" -expect "Done" +expect_line "Done" send "udp connect $addr_2 11001\n" -expect "Done" +expect_line "Done" send "udp send -s 10\n" -expect "Done" +expect_line "Done" send "udp send -x a68656c6c6f\n" -expect "Done" +expect_line "Done" send "udp send -t there\n" -expect "Done" +expect_line "Done" switch_node 2 expect "10 bytes from $addr_1 11002 0123456789" @@ -68,7 +62,7 @@ expect "5 bytes from $addr_1 11002 there" switch_node 1 send "udp help\n" -expect "Done" +expect_line "Done" send "udp connect something_invalid\n" expect "Error 7: InvalidArgs" send "udp send -x something_invalid\n" @@ -78,17 +72,17 @@ expect "Error 7: InvalidArgs" send "udp linksecurity\n" expect "Enabled" -expect "Done" +expect_line "Done" send "udp linksecurity disable\n" -expect "Done" +expect_line "Done" send "udp linksecurity\n" expect "Disabled" -expect "Done" +expect_line "Done" send "udp linksecurity enable\n" -expect "Done" +expect_line "Done" send "udp linksecurity\n" expect "Enabled" -expect "Done" +expect_line "Done" send "udp linksecurity something_invalid\n" expect "Error 35: InvalidCommand" diff --git a/tests/scripts/expect/cli-unsecure-port.exp b/tests/scripts/expect/cli-unsecure-port.exp index bf99d9783..51c36d433 100755 --- a/tests/scripts/expect/cli-unsecure-port.exp +++ b/tests/scripts/expect/cli-unsecure-port.exp @@ -32,33 +32,33 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 send "unsecureport remove all\n" -expect "Done" +expect_line "Done" send "unsecureport get\n" -expect "Done" +expect_line "Done" send "unsecureport add 123\n" -expect "Done" +expect_line "Done" send "unsecureport add 456\n" -expect "Done" +expect_line "Done" send "unsecureport get\n" expect "123 456" -expect "Done" +expect_line "Done" send "unsecureport remove 123\n" -expect "Done" +expect_line "Done" send "unsecureport get\n" expect "456" -expect "Done" +expect_line "Done" send "unsecureport remove all\n" -expect "Done" +expect_line "Done" send "unsecureport get\n" -expect "Done" +expect_line "Done" send "unsecureport invalid_command\n" expect "Error 35: InvalidCommand" diff --git a/tests/scripts/expect/posix-ccathreshold.exp b/tests/scripts/expect/posix-ccathreshold.exp index 34e4d966c..0ea5d7cb1 100755 --- a/tests/scripts/expect/posix-ccathreshold.exp +++ b/tests/scripts/expect/posix-ccathreshold.exp @@ -27,13 +27,15 @@ # POSSIBILITY OF SUCH DAMAGE. # +source "tests/scripts/expect/_common.exp" + spawn $env(OT_POSIX_APPS)/ot-cli "spinel+hdlc+uart://$env(OT_SIMULATION_APPS)/ncp/ot-rcp?forkpty-arg=1&cca-threshold=-100" expect_after { timeout { exit 1 } } send "ccathreshold\n" expect -- "-100" -expect "Done" +expect_line "Done" send "\x04" expect eof @@ -43,7 +45,7 @@ expect_after { } send "ccathreshold\n" expect -- "-128" -expect "Done" +expect_line "Done" send "\x04" expect eof @@ -53,7 +55,7 @@ expect_after { } send "ccathreshold\n" expect "127" -expect "Done" +expect_line "Done" send "\x04" expect eof diff --git a/tests/scripts/expect/posix-diag-rcp.exp b/tests/scripts/expect/posix-diag-rcp.exp index e933922f2..2e4732e83 100755 --- a/tests/scripts/expect/posix-diag-rcp.exp +++ b/tests/scripts/expect/posix-diag-rcp.exp @@ -33,25 +33,25 @@ spawn_node 1 send "diag rcp\n" expect "diagnostics mode is disabled" -expect "Done" +expect_line "Done" send "diag start\n" expect "start diagnostics mode" expect "status 0x00" -expect "Done" +expect_line "Done" send "diag rcp\n" expect "diagnostics mode is enabled" -expect "Done" +expect_line "Done" send "diag rcp channel\n" expect "failed" expect "status 0x7" -expect "Done" +expect_line "Done" send "diag rcp channel 11\n" -expect "Done" +expect_line "Done" send "diag rcp power\n" expect "failed" expect "status 0x7" -expect "Done" +expect_line "Done" send "diag rcp power 10\n" -expect "Done" +expect_line "Done" dispose_all diff --git a/tests/scripts/expect/posix-fem-lnagain.exp b/tests/scripts/expect/posix-fem-lnagain.exp index 77adfaa4c..f157c2493 100755 --- a/tests/scripts/expect/posix-fem-lnagain.exp +++ b/tests/scripts/expect/posix-fem-lnagain.exp @@ -27,13 +27,15 @@ # POSSIBILITY OF SUCH DAMAGE. # +source "tests/scripts/expect/_common.exp" + spawn $env(OT_POSIX_APPS)/ot-cli "spinel+hdlc+uart://$env(OT_SIMULATION_APPS)/ncp/ot-rcp?forkpty-arg=1&fem-lnagain=10" expect_after { timeout { exit 1 } } send "fem lnagain\n" expect "10" -expect "Done" +expect_line "Done" send "\x04" expect eof @@ -43,7 +45,7 @@ expect_after { } send "fem lnagain\n" expect -- "-128" -expect "Done" +expect_line "Done" send "\x04" expect eof diff --git a/tests/scripts/expect/posix-max-power-table.exp b/tests/scripts/expect/posix-max-power-table.exp index 733edfb34..86d3a0f14 100755 --- a/tests/scripts/expect/posix-max-power-table.exp +++ b/tests/scripts/expect/posix-max-power-table.exp @@ -33,24 +33,24 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 "rcp" "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" send "channel supported\n" expect "0x3fff800" -expect "Done" +expect_line "Done" send "channel preferred\n" expect "0x3fff800" -expect "Done" +expect_line "Done" send "txpower 20\n" -expect "Done" +expect_line "Done" send "txpower\n" expect "11 dBm" -expect "Done" +expect_line "Done" send "\x04" expect eof # allows all channels by default spawn_node 1 "rcp" "spinel+hdlc+uart://$env(OT_SIMULATION_APPS)/ncp/ot-rcp?forkpty-arg=1" send "channel supported\n" expect "0x7fff800" -expect "Done" +expect_line "Done" send "channel preferred\n" expect "0x7fff800" -expect "Done" +expect_line "Done" send "\x04" expect eof diff --git a/tests/scripts/expect/posix-rcp-restoration.exp b/tests/scripts/expect/posix-rcp-restoration.exp index b163897e5..25c23f4c6 100755 --- a/tests/scripts/expect/posix-rcp-restoration.exp +++ b/tests/scripts/expect/posix-rcp-restoration.exp @@ -70,36 +70,28 @@ try { setup_two_nodes "-" false 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_2 $expect_out(1,string) - expect "Done" + set addr_2 [get_ipaddr mleid] send "udp open\n" - expect "Done" + expect_line "Done" send "udp bind :: 11003\n" - expect "Done" + expect_line "Done" send "pollperiod 100000\n" - expect "Done" + expect_line "Done" sleep 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_1 $expect_out(1,string) - expect "Done" + set addr_1 [get_ipaddr mleid] send "udp open\n" - expect "Done" + expect_line "Done" send "udp bind :: 11004\n" - expect "Done" + expect_line "Done" send "udp connect $addr_2 11003\n" - expect "Done" + expect_line "Done" send "udp send hello\n" - expect "Done" + expect_line "Done" send "udp send there\n" - expect "Done" + expect_line "Done" sleep 1 @@ -113,7 +105,7 @@ try { switch_node 2 send "pollperiod 1000\n" - expect "Done" + expect_line "Done" expect "5 bytes from $addr_1 11004 hello" expect "5 bytes from $addr_1 11004 there" @@ -134,34 +126,26 @@ try { setup_two_nodes "-" false 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_2 $expect_out(1,string) - expect "Done" + set addr_2 [get_ipaddr mleid] send "udp open\n" - expect "Done" + expect_line "Done" send "udp bind :: 11003\n" - expect "Done" + expect_line "Done" send "pollperiod 100000\n" - expect "Done" + expect_line "Done" sleep 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_1 $expect_out(1,string) - expect "Done" + set addr_1 [get_ipaddr mleid] send "udp open\n" - expect "Done" + expect_line "Done" send "udp bind :: 11004\n" - expect "Done" + expect_line "Done" send "udp connect $addr_2 11003\n" - expect "Done" + expect_line "Done" send "udp send hello\n" - expect "Done" + expect_line "Done" sleep 1 @@ -175,7 +159,7 @@ try { switch_node 2 send "pollperiod 1000\n" - expect "Done" + expect_line "Done" expect "5 bytes from $addr_1 11004 hello" dispose_all @@ -191,32 +175,24 @@ try { spawn_node 1 "rcp" "spinel+hdlc_uart://$host_pty" setup_leader - 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(1) $expect_out(1,string) - expect "Done" + set addr(1) [get_ipaddr mleid] send "udp open\n" - expect "Done" + expect_line "Done" send "udp bind :: 11004\n" - expect "Done" + expect_line "Done" - set max_children 15 + set max_children 10 for {set i 2} {$i <= $max_children + 1} {incr i} { spawn_node $i setup_node $i "-" switch_node $i - 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($i) $expect_out(1,string) - expect "Done" + set addr($i) [get_ipaddr mleid] send "udp open\n" - expect "Done" + expect_line "Done" send "udp bind :: 11003\n" - expect "Done" + expect_line "Done" send "pollperiod 100000\n" - expect "Done" + expect_line "Done" } sleep 1 @@ -224,7 +200,7 @@ try { switch_node 1 for {set i 2} {$i <= $max_children + 1} {incr i} { send "udp send $addr($i) 11003 hello\n" - expect "Done" + expect_line "Done" } sleep 1 @@ -240,13 +216,13 @@ try { for {set i 7} {$i <= 9} {incr i} { switch_node $i send "pollperiod 1000\n" - expect "Done" + expect_line "Done" expect "5 bytes from $addr(1) 11004 hello" } switch_node 4 send "udp send $addr(5) 11003 hello_from_node_4\n" - expect "Done" + expect_line "Done" if {$::env(THREAD_VERSION) != "1.1"} { expect "5 bytes from $addr(1) 11004 hello" } @@ -263,7 +239,7 @@ try { switch_node 5 send "pollperiod 1000\n" - expect "Done" + expect_line "Done" expect "17 bytes from $addr(4) 11003 hello_from_node_4" dispose_all @@ -273,11 +249,11 @@ try { spawn_node 1 "rcp" "spinel+hdlc_uart://$host_pty" send "ifconfig up\n" - expect "Done" + expect_line "Done" send "thread start\n" - expect "Done" + expect_line "Done" wait_for "state" "leader" - expect "Done" + expect_line "Done" send "scan energy 100\n" expect "| Ch | RSSI |" @@ -296,7 +272,7 @@ try { for {set i 11} {$i <= 26} {incr i} { expect -re "\\| +$i \\| +-?\\d+ \\|" } - expect "Done" + expect_line "Done" dispose_all } finally { diff --git a/tests/scripts/expect/posix-rcp.exp b/tests/scripts/expect/posix-rcp.exp index c6dd51d27..d2ccd4dc2 100755 --- a/tests/scripts/expect/posix-rcp.exp +++ b/tests/scripts/expect/posix-rcp.exp @@ -32,7 +32,7 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 send "rcp version\n" -expect "Done" +expect_line "Done" send "rcp something_invalid\n" expect "Error 7: InvalidArgs" diff --git a/tests/scripts/expect/posix-scan-tx-to-sleep.exp b/tests/scripts/expect/posix-scan-tx-to-sleep.exp index 7f2971479..a613737df 100755 --- a/tests/scripts/expect/posix-scan-tx-to-sleep.exp +++ b/tests/scripts/expect/posix-scan-tx-to-sleep.exp @@ -31,44 +31,40 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 "rcp" "spinel+hdlc+uart://$env(OT_SIMULATION_APPS)/ncp/ot-rcp?forkpty-arg=--sleep-to-tx&forkpty-arg=1" send "dataset init new\n" -expect "Done" +expect_line "Done" send "dataset panid 0xface\n" -expect "Done" +expect_line "Done" send "dataset commit active\n" -expect "Done" +expect_line "Done" send "ifconfig up\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" wait_for "state" "leader" -expect "Done" +expect_line "Done" -send "extaddr\n" -expect "extaddr" -expect -re {([0-9a-f]{16})} -set extaddr $expect_out(1,string) -expect "Done" +set extaddr [get_extaddr] send "panid\n" expect "panid" expect -re {([0-9a-f]{4})} set pan $expect_out(1,string) -expect "Done" +expect_line "Done" send "extpanid\n" expect "extpanid" expect -re {([0-9a-f]{16})} set extpan $expect_out(1,string) -expect "Done" +expect_line "Done" expect "> " send "networkname\n" expect "networkname" expect -re {[\r\n]([^\r\n]+)[\r\n]} set network $expect_out(1,string) -expect "Done" +expect_line "Done" send "channel\n" expect "channel" expect -re {(\d+)} set channel $expect_out(1,string) -expect "Done" +expect_line "Done" spawn_node 2 "rcp" "spinel+hdlc+uart://$env(OT_SIMULATION_APPS)/ncp/ot-rcp?forkpty-arg=--sleep-to-tx&forkpty-arg=2" send "scan\n" diff --git a/tests/scripts/expect/simulation-networktime.exp b/tests/scripts/expect/simulation-networktime.exp index df98db2e1..ccbe3b5f6 100755 --- a/tests/scripts/expect/simulation-networktime.exp +++ b/tests/scripts/expect/simulation-networktime.exp @@ -32,12 +32,12 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 send "networktime 20 200\n" -expect "Done" +expect_line "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" +expect_line "Done" send "networktime something_invalid\n" expect "Error 7: InvalidArgs" diff --git a/tests/scripts/expect/tun-dns-client.exp b/tests/scripts/expect/tun-dns-client.exp index ef9c504ef..36909ba57 100755 --- a/tests/scripts/expect/tun-dns-client.exp +++ b/tests/scripts/expect/tun-dns-client.exp @@ -32,16 +32,16 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 send "panid 0xface\n" -expect "Done" +expect_line "Done" send "ifconfig up\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" wait_for "state" "leader" -expect "Done" +expect_line "Done" send "dns resolve ipv6.google.com ::1 53\n" expect "DNS response for ipv6.google.com" -expect "Done" +expect_line "Done" dispose_all diff --git a/tests/scripts/expect/tun-netif.exp b/tests/scripts/expect/tun-netif.exp index d9635c7be..ad6d956d4 100755 --- a/tests/scripts/expect/tun-netif.exp +++ b/tests/scripts/expect/tun-netif.exp @@ -33,6 +33,6 @@ spawn_node 1 send "netif\n" expect -re {[\r\n][^\r\n:]+?:\d+} -expect "Done" +expect_line "Done" dispose_all diff --git a/tests/scripts/expect/tun-netstat.exp b/tests/scripts/expect/tun-netstat.exp index 1e5ed9266..bd33388aa 100755 --- a/tests/scripts/expect/tun-netstat.exp +++ b/tests/scripts/expect/tun-netstat.exp @@ -30,33 +30,29 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 +setup_leader -send "ifconfig up\n" -expect "Done" send "udp open\n" -expect "Done" +expect_line "Done" send "netstat\n" expect "| Local Address | Peer Address |" expect "+-----------------------------------------------+-----------------------------------------------+" expect "| 0:0:0:0:0:0:0:0:* | 0:0:0:0:0:0:0:0:* |" -expect "Done" +expect_line "Done" send "udp bind :: 10001\n" -expect "Done" +expect_line "Done" send "netstat\n" expect "| Local Address | Peer Address |" expect "+-----------------------------------------------+-----------------------------------------------+" expect "| 0:0:0:0:0:0:0:0:10001 | 0:0:0:0:0:0:0:0:* |" -expect "Done" -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_line "Done" +set addr [get_ipaddr mleid] send "udp connect $addr 10001\n" -expect "Done" +expect_line "Done" send "netstat\n" expect "| Local Address | Peer Address |" expect "+-----------------------------------------------+-----------------------------------------------+" expect -re "\\| 0:0:0:0:0:0:0:0:10001 +\\| $addr:10001 +\\|" -expect "Done" +expect_line "Done" dispose_all diff --git a/tests/scripts/expect/tun-realm-local-multicast.exp b/tests/scripts/expect/tun-realm-local-multicast.exp index f87c22fba..e8c054347 100755 --- a/tests/scripts/expect/tun-realm-local-multicast.exp +++ b/tests/scripts/expect/tun-realm-local-multicast.exp @@ -40,13 +40,13 @@ spawn_node 1 setup_default_network send "ifconfig up\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" wait_for "state" "leader" -expect "Done" +expect_line "Done" set extaddr1 [get_extaddr] @@ -54,10 +54,10 @@ spawn_node 2 cli setup_default_network send "ifconfig up\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" wait_for "state" "router" sleep 3 @@ -66,16 +66,16 @@ spawn_node 3 cli setup_default_network send "macfilter addr add ${extaddr1}\n" -expect "Done" +expect_line "Done" send "macfilter addr denylist\n" -expect "Done" +expect_line "Done" send "ifconfig up\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" wait_for "state" "router" sleep 4 @@ -86,19 +86,19 @@ spawn_node 4 cli setup_default_network send "mode rn\n" -expect "Done" +expect_line "Done" send "macfilter addr add ${extaddr3}\n" -expect "Done" +expect_line "Done" send "macfilter addr allowlist\n" -expect "Done" +expect_line "Done" send "ifconfig up\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" wait_for "state" "child" @@ -107,7 +107,7 @@ set mleid4 [get_ipaddr "mleid"] switch_node 1 send "ping ${mleid4}\n" -expect "Done" +expect_line "Done" expect "16 bytes from $mleid4: icmp_seq=1" dispose_all diff --git a/tests/scripts/expect/tun-sntp.exp b/tests/scripts/expect/tun-sntp.exp index aa920d7f8..e45d77c12 100755 --- a/tests/scripts/expect/tun-sntp.exp +++ b/tests/scripts/expect/tun-sntp.exp @@ -38,16 +38,16 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 send "panid 0xface\n" -expect "Done" +expect_line "Done" send "ifconfig up\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" wait_for "state" "leader" -expect "Done" +expect_line "Done" send "sntp query ::1 123\n" expect -re {SNTP response - Unix time: \d+ \(era: \d+\)} -expect "Done" +expect_line "Done" dispose_all diff --git a/tests/scripts/expect/tun-udp.exp b/tests/scripts/expect/tun-udp.exp index 71ce6c386..187bda48a 100755 --- a/tests/scripts/expect/tun-udp.exp +++ b/tests/scripts/expect/tun-udp.exp @@ -36,35 +36,35 @@ spawn_node 1 set timeout 1 send "panid 0xface\n" -expect "Done" +expect_line "Done" send "ifconfig up\n" -expect "Done" +expect_line "Done" send "thread start\n" -expect "Done" +expect_line "Done" wait_for "state" "leader" -expect "Done" +expect_line "Done" send "udp open\n" -expect "Done" +expect_line "Done" send "udp bind :: 1234\n" -expect "Done" +expect_line "Done" send "dataset active\n" expect -re {Mesh Local Prefix: ([0-9a-f:]*)::\/64} set prefix $expect_out(1,string) -expect "Done" +expect_line "Done" send "udp connect $prefix:bb1:ebd6:ad10:f33 1234\n" -expect "Done" +expect_line "Done" send "udp connect :: 1\n" -expect "Done" +expect_line "Done" send "udp close\n" -expect "Done" +expect_line "Done" dispose_all diff --git a/tests/scripts/expect/v1_2-rcp-restoration.exp b/tests/scripts/expect/v1_2-rcp-restoration.exp old mode 100644 new mode 100755 diff --git a/tests/scripts/expect/v1_2-rcp.exp b/tests/scripts/expect/v1_2-rcp.exp index 71de92005..6815baa12 100755 --- a/tests/scripts/expect/v1_2-rcp.exp +++ b/tests/scripts/expect/v1_2-rcp.exp @@ -34,15 +34,12 @@ spawn_node 1 spawn_node 2 mtd send "csl period 5000\n" -expect "Done" +expect_line "Done" setup_two_nodes "-" false switch_node 1 -send "ipaddr mleid\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 addr [get_ipaddr "mleid"] switch_node 2 send "ping $addr\n" diff --git a/tests/scripts/expect/v1_2-sed_mac_send.exp b/tests/scripts/expect/v1_2-sed_mac_send.exp index 4a2e15dc4..faeeb3573 100755 --- a/tests/scripts/expect/v1_2-sed_mac_send.exp +++ b/tests/scripts/expect/v1_2-sed_mac_send.exp @@ -34,8 +34,8 @@ setup_two_nodes "-" switch_node 2 send "mac send emptydata\n" -expect "Done" +expect_line "Done" send "mac send datarequest\n" -expect "Done" +expect_line "Done" dispose_all