1#!/usr/bin/expect -f 2# 3# Copyright (c) 2020, The OpenThread Authors. 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are met: 8# 1. Redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer. 10# 2. Redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution. 13# 3. Neither the name of the copyright holder nor the 14# names of its contributors may be used to endorse or promote products 15# derived from this software without specific prior written permission. 16# 17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27# POSSIBILITY OF SUCH DAMAGE. 28# 29 30source "tests/scripts/expect/_common.exp" 31source "tests/scripts/expect/_multinode.exp" 32 33setup_two_nodes 34 35switch_node 1 36 37send "leaderdata\n" 38expect -re {Partition ID: \d+} 39expect -re {Weighting: \d+} 40expect -re {Data Version: \d+} 41expect -re {Stable Data Version: \d+} 42expect -re {Leader Router ID: \d+} 43expect_line "Done" 44 45send "help\n" 46expect_line "Done" 47 48send "bufferinfo\n" 49expect_line "Done" 50 51send "ccathreshold -62\n" 52expect_line "Done" 53send "ccathreshold\n" 54expect -- "-62 dBm" 55expect_line "Done" 56 57send "parent\n" 58expect_line "Done" 59 60send "delaytimermin 1\n" 61expect_line "Done" 62send "delaytimermin\n" 63expect "1" 64expect_line "Done" 65send "delaytimermin 1 2\n" 66send "counters mac 1\n" 67expect "Error 7: InvalidArgs" 68 69send "fem lnagain 11\n" 70expect_line "Done" 71send "fem lnagain\n" 72expect -- "11" 73expect_line "Done" 74send "fem\n" 75expect -- "LNA gain 11 dBm" 76expect_line "Done" 77 78send "ifconfig down\n" 79expect_line "Done" 80send "ifconfig\n" 81expect "down" 82expect_line "Done" 83send "ifconfig up\n" 84expect_line "Done" 85send "ifconfig\n" 86expect "up" 87expect_line "Done" 88 89send "instanceid\n" 90expect -re {\d+} 91expect_line "Done" 92 93send "ipaddr add ::\n" 94expect_line "Done" 95send "ipaddr del ::\n" 96expect_line "Done" 97 98send "leaderweight 1\n" 99expect_line "Done" 100send "leaderweight\n" 101expect "1" 102expect_line "Done" 103 104send "mode rdn\n" 105expect_line "Done" 106send "mode\n" 107expect -re "(?=.*r)(?=.*d)(?=.*n)" 108 109send "parent\n" 110expect_line "Done" 111 112send "singleton\n" 113expect -re "true|false" 114expect_line "Done" 115 116send "state\n" 117expect "disabled" 118expect_line "Done" 119 120send "txpower -10\n" 121expect_line "Done" 122send "txpower\n" 123expect -- "-10 dBm" 124expect_line "Done" 125 126send "thread version\n" 127expect_line "Done" 128 129send "version\n" 130expect_line "Done" 131send "version api\n" 132expect -re {\d+} 133expect_line "Done" 134send "version something_invalid\n" 135expect "Error 35: InvalidCommand" 136 137send "joinerport 10001\n" 138expect_line "Done" 139send "joinerport\n" 140expect "10001" 141expect_line "Done" 142 143send "parentpriority 1\n" 144expect_line "Done" 145send "parentpriority\n" 146expect "1" 147expect_line "Done" 148 149send "pollperiod 100000\n" 150expect_line "Done" 151send "pollperiod\n" 152expect "100000" 153expect_line "Done" 154 155send "prefix add ::/64 low pdcrosn\n" 156expect_line "Done" 157send "prefix\n" 158expect "0:0:0:0::/64 pdcrosn low" 159expect_line "Done" 160 161send "preferrouterid 1\n" 162expect_line "Done" 163 164send "route add ::/64 s low\n" 165expect_line "Done" 166send "route\n" 167expect "0:0:0:0::/64 s low" 168send "route remove ::/64\n" 169expect_line "Done" 170 171send "route add ::/0 s low\n" 172expect_line "Done" 173send "route\n" 174expect "::/0 s low" 175send "route remove ::/0\n" 176expect_line "Done" 177 178send "diag start\n" 179expect ": InvalidState" 180 181send "ba port\n" 182expect "Done" 183 184send "ba state\n" 185expect "Done" 186 187send "prefix meshlocal fd00:dead:beef:cafe::/96\n" 188expect_line "Error 7: InvalidArgs" 189send "prefix meshlocal fd00:dead:beef:cafe::/64\n" 190expect_line "Done" 191send "prefix meshlocal\n" 192expect_line "fd00:dead:beef:cafe::/64" 193 194send "invalidcommand\n" 195expect_line "Error 35: InvalidCommand" 196 197dispose_all 198