1#!/usr/bin/expect -f 2# 3# Copyright (c) 2023, 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 33for {set i 1} {$i <= 5} {incr i} { 34 spawn_node $i 35} 36 37switch_node 1 38 39send "dataset init new\n" 40expect_line "Done" 41send "dataset networkkey 00112233445566778899aabbccddeeff\n" 42expect_line "Done" 43send "dataset channel 12\n" 44expect_line "Done" 45send "dataset networkname OpenThread-ch12\n" 46expect_line "Done" 47send "dataset commit active\n" 48expect_line "Done" 49send "dataset active -x\n" 50expect -re {([0-9a-f]+)[\r\n]+Done} 51set dataset $expect_out(1,string) 52attach 53 54set extaddr_1 [get_extaddr] 55set extpan_1 [get_extpanid] 56set pan_1 [get_panid] 57 58switch_node 2 59 60send "dataset init new\n" 61expect_line "Done" 62send "dataset channel 23\n" 63expect_line "Done" 64send "dataset networkname OpenThread-ch23\n" 65expect_line "Done" 66send "dataset commit active\n" 67expect_line "Done" 68attach 69 70set extaddr_2 [get_extaddr] 71set extpan_2 [get_extpanid] 72set pan_2 [get_panid] 73 74switch_node 3 75 76send "dataset set active $dataset\n" 77expect_line "Done" 78send "mode r\n" 79expect_line "Done" 80attach "child" 81 82switch_node 4 83 84send "dataset set active $dataset\n" 85expect_line "Done" 86send "mode -\n" 87expect_line "Done" 88attach "child" 89 90for {set i 3} {$i <= 4} {incr i} { 91 switch_node $i 92 93 send "discover\n" 94 expect "| Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |" 95 expect "+------------------+------------------+------+------------------+----+-----+-----+" 96 wait_for "" "\\| OpenThread-ch12 +\\| $extpan_1 \\| $pan_1 \\| $extaddr_1 \\| 12 \\| +-?\\d+ \\| +\\d \\|" 97 wait_for "" "\\| OpenThread-ch23 +\\| $extpan_2 \\| $pan_2 \\| $extaddr_2 \\| 23 \\| +-?\\d+ \\| +\\d \\|" 98 wait_for "" "Done" 99} 100 101if {$::env(THREAD_VERSION) != "1.1" && $::env(OT_NODE_TYPE) == "cli"} { 102 send "csl channel 12\n" 103 expect_line "Done" 104 send "csl period 500000\n" 105 expect_line "Done" 106 107 sleep 1 108 109 send "discover\n" 110 expect "| Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |" 111 expect "+------------------+------------------+------+------------------+----+-----+-----+" 112 wait_for "" "\\| OpenThread-ch12 +\\| $extpan_1 \\| $pan_1 \\| $extaddr_1 \\| 12 \\| +-?\\d+ \\| +\\d \\|" 113 wait_for "" "\\| OpenThread-ch23 +\\| $extpan_2 \\| $pan_2 \\| $extaddr_2 \\| 23 \\| +-?\\d+ \\| +\\d \\|" 114 wait_for "" "Done" 115} 116 117switch_node 1 118send "discover reqcallback enable\n" 119expect_line "Done" 120 121switch_node 5 122send "discover\n" 123expect "Error 13: InvalidState" 124send "ifconfig up\n" 125expect_line "Done" 126send "discover 12\n" 127 128expect "| Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |" 129expect "+------------------+------------------+------+------------------+----+-----+-----+" 130wait_for "" "\\| OpenThread-ch12 +\\| $extpan_1 \\| $pan_1 \\| $extaddr_1 \\| 12 \\| +-?\\d+ \\| +\\d \\|" 131wait_for "" "Done" 132 133switch_node 1 134expect -re {version=\d,joiner=0} 135 136switch_node 5 137send "ifconfig up\n" 138expect_line "Done" 139send "joiner start 123456\n" 140set timeout 10 141expect "NotFound" 142 143switch_node 1 144expect -re {version=\d,joiner=1} 145 146dispose_all 147