[cli] support joiner discerner (#5298)

This commit adds support joiner discerner in CLI. The format of joiner
discerner is `number/length`. For example `0xabc/12` means the discerner
value is `0xabc` and the length is `12`.
This commit is contained in:
Yakun Xu
2020-07-27 20:27:21 -07:00
committed by GitHub
parent 2117dae5f8
commit cbf1a19483
10 changed files with 239 additions and 30 deletions
+34 -2
View File
@@ -27,7 +27,7 @@
# POSSIBILITY OF SUCH DAMAGE.
#
proc wait_for {command expected} {
proc wait_for {command success {failure {[\r\n]FAILURE_NOT_EXPECTED[\r\n]}}} {
set result 0
set timeout 1
for {set i 0} {$i < 20} {incr i} {
@@ -36,9 +36,12 @@ proc wait_for {command expected} {
}
expect {
-re $expected {
-re $success {
set result 1
}
-re $failure {
exit 1
}
timeout {
# Do nothing
}
@@ -64,9 +67,38 @@ proc spawn_node {id} {
return $spawn_id
}
proc setup_leader {} {
# Sets up a Thread network spawn_1 as the leader.
global spawn_1
global spawn_id
global env
set spawn_1 [spawn_node 1]
set spawn_id $spawn_1
send "dataset init new\n"
expect "Done"
send "dataset commit active\n"
expect "Done"
send "ifconfig up\n"
expect "Done"
send "thread start\n"
expect "Done"
wait_for "state" "leader"
expect "Done"
}
proc dispose {} {
send "\x04"
expect eof
}
proc dispose_leader {} {
global spawn_1
global spawn_id
set spawn_id $spawn_1
dispose
}
set timeout 10