1#!/usr/bin/expect -f 2# 3# Copyright (c) 2022, 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 33spawn_node 1 34spawn_node 2 35 36switch_node 1 37send "diag start\n" 38expect "start diagnostics mode" 39expect "status 0x00" 40expect_line "Done" 41 42send "diag channel 11\n" 43expect "set channel to 11" 44expect "status 0x00" 45expect_line "Done" 46 47send "diag stats clear\n" 48expect "stats cleared" 49expect_line "Done" 50 51switch_node 2 52 53send "diag start\n" 54expect "start diagnostics mode" 55expect "status 0x00" 56expect_line "Done" 57 58send "diag channel 11\n" 59expect "set channel to 11" 60expect "status 0x00" 61expect_line "Done" 62 63send "diag stats clear\n" 64expect "stats cleared" 65expect_line "Done" 66 67send "diag send 10 100\n" 68expect "sending 0xa packet(s), length 0x64" 69expect "status 0x00" 70expect_line "Done" 71 72sleep 2 73 74send "diag stats\n" 75expect "received packets: 0" 76expect "sent packets: 10" 77expect "first received packet: rssi=0, lqi=0" 78expect "last received packet: rssi=0, lqi=0" 79expect_line "Done" 80 81switch_node 1 82 83send "diag stats\n" 84expect "received packets: 10" 85expect "sent packets: 0" 86expect "first received packet: rssi=-20, lqi=0" 87expect "last received packet: rssi=-20, lqi=0" 88expect_line "Done" 89 90send "diag stats clear\n" 91expect "stats cleared" 92expect_line "Done" 93 94switch_node 2 95 96send "diag repeat 20 100\n" 97expect "sending packets of length 0x64 at the delay of 0x14 ms" 98expect "status 0x00" 99expect_line "Done" 100sleep 1 101send "diag repeat stop\n" 102expect "repeated packet transmission is stopped" 103expect "status 0x00" 104expect_line "Done" 105 106switch_node 1 107 108send "diag stats\n" 109expect -r {received packets: \d+} 110expect "sent packets: 0" 111expect "first received packet: rssi=-20, lqi=0" 112expect "last received packet: rssi=-20, lqi=0" 113expect_line "Done" 114 115send "diag stats clear\n" 116expect "stats cleared" 117expect_line "Done" 118 119dispose_all 120 121 122spawn_node 1 123 124send "diag start\n" 125expect "start diagnostics mode" 126expect "status 0x00" 127expect_line "Done" 128 129send "diag channel 11\n" 130expect "set channel to 11" 131expect "status 0x00" 132expect_line "Done" 133 134send "diag power 10\n" 135expect "set tx power to 10 dBm" 136expect "status 0x00" 137expect_line "Done" 138 139send "diag radio sleep\n" 140expect "set radio from receive to sleep" 141expect "status 0x00" 142expect_line "Done" 143 144send "diag radio state\n" 145expect "sleep" 146expect_line "Done" 147 148send "diag radio receive\n" 149expect "set radio from sleep to receive on channel 11" 150expect "status 0x00" 151expect_line "Done" 152 153send "diag radio state\n" 154expect "receive" 155expect_line "Done" 156 157send "diag gpio set 0 1\n" 158expect_line "Done" 159 160send "diag gpio get 0\n" 161expect "1" 162expect_line "Done" 163 164send "diag gpio mode 0 in\n" 165expect_line "Done" 166 167send "diag gpio mode 0\n" 168expect "in" 169expect_line "Done" 170 171send "diag gpio mode 0 out\n" 172expect_line "Done" 173 174send "diag gpio mode 0\n" 175expect "out" 176expect_line "Done" 177 178send "diag cw start\n" 179expect_line "Done" 180 181send "diag cw stop\n" 182expect_line "Done" 183 184send "diag stream start\n" 185expect_line "Done" 186 187send "diag stream stop\n" 188expect_line "Done" 189 190send "diag rawpowersetting 112233\n" 191expect_line "Done" 192 193send "diag rawpowersetting\n" 194expect "112233" 195expect_line "Done" 196 197send "diag rawpowersetting enable\n" 198expect_line "Done" 199 200send "diag rawpowersetting disable\n" 201expect_line "Done" 202 203send "diag invalid_commad\n" 204expect "Error 35: InvalidCommand" 205 206send "diag stop\n" 207expect_line "Done" 208 209send "diag channel\n" 210expect "failed" 211expect "status 0xd" 212expect "Error 13: InvalidState" 213 214dispose_all 215