-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor tls-test expect, creating library for other tests
Push out some things that we'll doubtless want in other test cases.
- Loading branch information
Showing
3 changed files
with
91 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
namespace eval expectnmcu::core { | ||
} | ||
|
||
# Establish a serial connection to the device via socat | ||
proc ::expectnmcu::core::connect { dev baud } { | ||
spawn "socat" "STDIO" "${dev},b${baud},rawer,crnl" | ||
close -onexec 1 -i ${spawn_id} | ||
return ${spawn_id} | ||
} | ||
|
||
# Use DTR/RTS signaling to reboot the device | ||
## I'm not sure why we have to keep resetting the mode, but so it goes. | ||
proc ::expectnmcu::core::reboot { dev baud } { | ||
set victimfd [open "${dev}"] | ||
fconfigure ${victimfd} -mode ${baud},n,8,1 -ttycontrol {DTR 0 RTS 1} | ||
sleep 0.1 | ||
fconfigure ${victimfd} -mode ${baud},n,8,1 -ttycontrol {DTR 0 RTS 0} | ||
close ${victimfd} | ||
} | ||
|
||
proc ::expectnmcu::core::waitboot { victim } { | ||
expect { | ||
-i ${victim} "Formatting file system" { | ||
set timeout 60 | ||
exp_continue | ||
} | ||
-i ${victim} "powered by Lua" { } | ||
timeout { return -code error "Timeout" } | ||
} | ||
# Catch nwf's system bootup, in case we're testing an existing system, | ||
# rather than a blank firmware. | ||
expect { | ||
-i ${victim} "Reset delay!" { send "got:stop()\n" ; expect "> " } | ||
-i ${victim} "> " { } | ||
timeout { return -code error "Timeout" } | ||
} | ||
} | ||
|
||
proc ::expectnmcu::core::send_exp_prompt { sid cmd } { | ||
send -i ${sid} -- "${cmd}\n" | ||
expect { | ||
-i ${sid} -ex "\n> " { } | ||
timeout { return -code error "Timeout" } | ||
} | ||
} | ||
|
||
proc ::expectnmcu::core::send_exp_prompt_c { sid cmd } { | ||
send -i ${sid} -- "${cmd}\n" | ||
expect { | ||
-i ${sid} -ex "\n>> " { } | ||
timeout { return -code error "Timeout" } | ||
} | ||
} | ||
|
||
package provide expectnmcu::core 1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Tcl package index file, version 1.1 | ||
# This file is generated by the "pkg_mkIndex" command | ||
# and sourced either when an application starts up or | ||
# by a "package unknown" script. It invokes the | ||
# "package ifneeded" command to set up package-related | ||
# information so that packages will be loaded automatically | ||
# in response to "package require" commands. When this | ||
# script is sourced, the variable $dir must contain the | ||
# full path name of this file's directory. | ||
|
||
package ifneeded expectnmcu::core 1.0 [list source [file join $dir core.tcl]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters