mirror of
https://github.com/espressif/openthread.git
synced 2026-07-30 23:57:47 +00:00
[test] add expect tests for dataset and networktime (#5145)
This commit is contained in:
Executable
+160
@@ -0,0 +1,160 @@
|
||||
#!/usr/bin/expect -f
|
||||
#
|
||||
# Copyright (c) 2020, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
source "tests/scripts/expect/_common.exp"
|
||||
source "tests/scripts/expect/_multinode.exp"
|
||||
|
||||
set timeout 1
|
||||
setup_nodes
|
||||
|
||||
set spawn_id $spawn_1
|
||||
send "dataset active\n"
|
||||
expect -re {Active Timestamp: \d+}
|
||||
expect -re {Channel: (\d+)}
|
||||
set channel $expect_out(1,string)
|
||||
expect -re {Channel Mask: [0-9a-f]{8}}
|
||||
expect -re {Ext PAN ID: [0-9a-f]{16}}
|
||||
expect -re {Mesh Local Prefix: ([0-9a-f]{1,4}:){3}[0-9a-f]{1,4}\/64}
|
||||
expect -re {Master Key: [0-9a-f]{32}}
|
||||
expect -re {Network Name: [^\r\n]+}
|
||||
expect -re {PAN ID: 0x[0-9a-f]{4}}
|
||||
expect -re {PSKc: [0-9a-f]{32}}
|
||||
expect -re {Security Policy: \d+, o?n?r?c?b?}
|
||||
send "dataset pending\n"
|
||||
expect "Error 23: NotFound"
|
||||
send "dataset init active\n"
|
||||
expect "Done"
|
||||
send "dataset activetimestamp 100\n"
|
||||
expect "Done"
|
||||
if {$channel == 11} {
|
||||
send "dataset channel 18\n"
|
||||
} else {
|
||||
send "dataset channel 11\n"
|
||||
}
|
||||
expect "Done"
|
||||
send "dataset channelmask 0x03fff800\n"
|
||||
expect "Done"
|
||||
send "dataset extpanid aabbccddeeff0011\n"
|
||||
expect "Done"
|
||||
send "dataset masterkey aabbccddeeff00112233445566778899\n"
|
||||
expect "Done"
|
||||
send "dataset meshlocalprefix fdde:4860::\n"
|
||||
expect "Done"
|
||||
send "dataset networkname OT-network\n"
|
||||
expect "Done"
|
||||
send "dataset panid 0xface\n"
|
||||
expect "Done"
|
||||
send "dataset pskc 00112233445566778899aabbccddeeff\n"
|
||||
expect "Done"
|
||||
send "dataset securitypolicy 678 onrcb\n"
|
||||
expect "Done"
|
||||
send "dataset pendingtimestamp 100\n"
|
||||
expect "Done"
|
||||
send "dataset delay 30000\n"
|
||||
expect "Done"
|
||||
send "dataset commit pending\n"
|
||||
expect "Done"
|
||||
send "dataset pending\n"
|
||||
expect "Pending Timestamp: 100"
|
||||
expect "Active Timestamp: 100"
|
||||
if {$channel == 11} {
|
||||
expect "Channel: 18"
|
||||
} else {
|
||||
expect "Channel: 11"
|
||||
}
|
||||
expect "Channel Mask: 03fff800"
|
||||
expect -re {Delay: \d+}
|
||||
expect "Ext PAN ID: aabbccddeeff0011"
|
||||
expect "Mesh Local Prefix: fdde:4860:0:0/64"
|
||||
expect "Master Key: aabbccddeeff00112233445566778899"
|
||||
expect "Network Name: OT-network"
|
||||
expect "PAN ID: 0xface"
|
||||
expect "PSKc: 00112233445566778899aabbccddeeff"
|
||||
expect "Security Policy: 678, onrcb"
|
||||
expect "Done"
|
||||
|
||||
sleep 30
|
||||
|
||||
set spawn_id $spawn_2
|
||||
wait_for "dataset active" "Active Timestamp: 100"
|
||||
expect "Done"
|
||||
send "dataset active\n"
|
||||
expect "Active Timestamp: 100"
|
||||
if {$channel == 11} {
|
||||
expect "Channel: 18"
|
||||
} else {
|
||||
expect "Channel: 11"
|
||||
}
|
||||
expect "Channel Mask: 03fff800"
|
||||
expect "Ext PAN ID: aabbccddeeff0011"
|
||||
expect "Mesh Local Prefix: fdde:4860:0:0/64"
|
||||
expect "Master Key: aabbccddeeff00112233445566778899"
|
||||
expect "Network Name: OT-network"
|
||||
expect "PAN ID: 0xface"
|
||||
expect "PSKc: 00112233445566778899aabbccddeeff"
|
||||
expect "Security Policy: 678, onrcb"
|
||||
expect "Done"
|
||||
send "dataset clear\n"
|
||||
expect "Done"
|
||||
send "dataset init active\n"
|
||||
expect "Done"
|
||||
send "dataset\n"
|
||||
expect "Active Timestamp: 100"
|
||||
if {$channel == 11} {
|
||||
expect "Channel: 18"
|
||||
} else {
|
||||
expect "Channel: 11"
|
||||
}
|
||||
expect "Channel Mask: 03fff800"
|
||||
expect "Ext PAN ID: aabbccddeeff0011"
|
||||
expect "Mesh Local Prefix: fdde:4860:0:0/64"
|
||||
expect "Master Key: aabbccddeeff00112233445566778899"
|
||||
expect "Network Name: OT-network"
|
||||
expect "PAN ID: 0xface"
|
||||
expect "PSKc: 00112233445566778899aabbccddeeff"
|
||||
expect "Security Policy: 678, onrcb"
|
||||
expect "Done"
|
||||
send "dataset init pending\n"
|
||||
expect "Error 23: NotFound"
|
||||
send "dataset active binary\n"
|
||||
expect "dataset active binary"
|
||||
expect -re {([0-9a-f]+)}
|
||||
set binary $expect_out(1,string)
|
||||
expect "Done"
|
||||
send "dataset set pending $binary\n"
|
||||
expect "Done"
|
||||
send "dataset pending binary\n"
|
||||
expect $binary
|
||||
expect "Done"
|
||||
send "dataset set active $binary\n"
|
||||
expect "Done"
|
||||
send "help\n"
|
||||
expect "Done"
|
||||
|
||||
dispose_nodes
|
||||
@@ -146,4 +146,14 @@ expect "0:0:0:0::/64 s low"
|
||||
send "route remove ::/64\n"
|
||||
expect "Done"
|
||||
|
||||
send "networktime 20 200\n"
|
||||
expect "Done"
|
||||
send "networktime\n"
|
||||
expect -re {Network Time: \d+us \((unsynchronized|resync needed|synchronized)\)}
|
||||
expect "Time Sync Period: 20s"
|
||||
expect "XTAL Threshold: 200ppm"
|
||||
expect "Done"
|
||||
send "networktime something_invalid\n"
|
||||
expect "Error 7: InvalidArgs"
|
||||
|
||||
dispose_nodes
|
||||
|
||||
Reference in New Issue
Block a user