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 35set eui64 "d45e64fa83f81cf7" 36switch_node 1 37send "commissioner joiner add $eui64 J01NME\n" 38expect_line "Done" 39wait_for "netdata steeringdata check $eui64" "Done" 40send "commissioner joiner remove $eui64\n" 41expect_line "Done" 42wait_for "netdata steeringdata check $eui64" "NotFound" 43 44# Stop commissioner so node 2 can start a new one with different id 45send "commissioner stop\n" 46expect "Done" 47 48switch_node 2 49send "commissioner state\n" 50expect "disabled" 51expect_line "Done" 52send "commissioner id\n" 53expect "OpenThread Commissioner" 54expect_line "Done" 55send "commissioner id 12345678901234567890123456789012345678901234567890123456789012345\n" 56expect "Error 7: InvalidArgs" 57send "commissioner id 1234567890123456789012345678901234567890123456789012345678901234\n" 58expect "Done" 59send "commissioner id customId\n" 60expect "Done" 61send "commissioner id\n" 62expect "customId" 63expect_line "Done" 64send "commissioner start\n" 65expect_line "Done" 66expect "Commissioner: active" 67send "commissioner state\n" 68expect "active" 69expect_line "Done" 70send "commissioner id AnotherCustomId\n" 71expect_line "Error 13: InvalidState" 72send "commissioner provisioningurl openthread.io\n" 73expect_line "Done" 74send "commissioner joiner add * J01NME 1\n" 75expect_line "Done" 76send "commissioner joiner remove *\n" 77expect_line "Done" 78send "commissioner sessionid\n" 79expect "commissioner sessionid" 80expect -re {(\d+)} 81set sessionid $expect_out(1,string) 82send "commissioner mgmtset sessionid $sessionid steeringdata ffffffff joinerudpport 10001\n" 83expect_line "Done" 84send "commissioner mgmtset sessionid $sessionid locator 0x0100\n" 85expect_line "Done" 86send "commissioner mgmtget sessionid steeringdata joinerudpport locator -x 0b081209\n" 87expect_line "Done" 88send "commissioner stop\n" 89expect "Commissioner: disabled" 90expect_line "Done" 91send "commissioner state\n" 92expect "disabled" 93expect_line "Done" 94send "commissioner help\n" 95expect_line "Done" 96send "commissioner joiner something_invalid\n" 97expect "Error 7: InvalidArgs" 98send "commissioner mgmtget something_invalid\n" 99expect "Error 7: InvalidArgs" 100send "commissioner mgmtset something_invalid\n" 101expect "Error 7: InvalidArgs" 102send "commissioner\n" 103expect "Error 35: InvalidCommand" 104 105dispose_all 106