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" 31 32spawn_node 1 33setup_leader 34 35set pskd "J01NME" 36set discerner "0xabc/12" 37 38send "netdata typo check $discerner\n" 39expect "InvalidCommand" 40send "netdata steeringdata typo $discerner\n" 41expect "InvalidArgs" 42send "netdata steeringdata check $discerner/0\n" 43expect "InvalidArgs" 44send "netdata steeringdata check $discerner\n" 45expect "InvalidState" 46send "commissioner start\n" 47expect_line "Done" 48expect "Commissioner: active" 49send "commissioner joiner add 1/0 $pskd\n" 50expect "InvalidArgs" 51send "netdata steeringdata check 0xabc/12\n" 52expect "NotFound" 53send "commissioner joiner add $discerner $pskd\n" 54expect_line "Done" 55wait_for "netdata steeringdata check $discerner" "Done" 56send "commissioner joiner remove $discerner\n" 57expect_line "Done" 58wait_for "netdata steeringdata check $discerner" "NotFound" 59send "commissioner joiner add $discerner $pskd\n" 60expect_line "Done" 61 62spawn_node 2 63 64send "mode r\n" 65expect_line "Done" 66send "ifconfig up\n" 67expect_line "Done" 68send "joiner discerner\n" 69expect "NotFound" 70send "joiner discerner 1/1 2\n" 71expect "InvalidArgs" 72send "joiner discerner 1\n" 73expect "InvalidArgs" 74send "joiner discerner 1/\n" 75expect "InvalidArgs" 76send "joiner discerner 1/128\n" 77expect "InvalidArgs" 78send "joiner discerner 1/-1\n" 79expect "InvalidArgs" 80send "joiner discerner 1/0\n" 81expect "InvalidArgs" 82send "joiner discerner invalid/20\n" 83expect "InvalidArgs" 84send "joiner discerner clear\n" 85expect_line "Done" 86send "joiner discerner $discerner\n" 87expect_line "Done" 88send "joiner discerner\n" 89expect "$discerner" 90expect_line "Done" 91send "joiner start $pskd\n" 92expect_line "Done" 93wait_for "" "Join success" "Join failed" 94send "thread start\n" 95expect_line "Done" 96wait_for "state" "child" 97expect_line "Done" 98 99dispose_all 100