2020-03-14 20:31:20 +00:00
|
|
|
##
|
|
|
|
## init.exp - u6a test init script
|
|
|
|
##
|
|
|
|
## Copyright (C) 2020 CismonX <admin@cismon.net>
|
|
|
|
##
|
|
|
|
## This program is free software: you can redistribute it and/or modify
|
|
|
|
## it under the terms of the GNU General Public License as published by
|
|
|
|
## the Free Software Foundation, either version 3 of the License, or
|
|
|
|
## (at your option) any later version.
|
|
|
|
##
|
|
|
|
## This program is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
|
|
|
## You should have received a copy of the GNU General Public License
|
|
|
|
## along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
##
|
|
|
|
|
|
|
|
proc u6a_run { src_code u6ac_opts u6a_opts has_input } {
|
2020-03-14 21:08:01 +00:00
|
|
|
global U6A_BIN U6AC_BIN U6A_RUN B64_FLAGS
|
2020-03-14 20:31:20 +00:00
|
|
|
set u6ac "$U6AC_BIN $u6ac_opts"
|
|
|
|
set u6a "$U6A_BIN $u6a_opts"
|
2020-03-14 21:08:01 +00:00
|
|
|
set base64 "base64 $B64_FLAGS"
|
|
|
|
set run_cmd [ list $U6A_RUN $u6ac $u6a $base64 $src_code ]
|
2020-03-14 20:31:20 +00:00
|
|
|
if $has_input {
|
|
|
|
lappend run_cmd -
|
|
|
|
set stty_init -echo
|
|
|
|
} else {
|
|
|
|
set stty_init { raw -echo }
|
|
|
|
}
|
|
|
|
global spawn_id
|
|
|
|
spawn {*}$run_cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
proc u6a_stop { send_eof } {
|
|
|
|
global spawn_id
|
|
|
|
if $send_eof {
|
|
|
|
send \x04
|
|
|
|
expect eof
|
|
|
|
}
|
|
|
|
catch wait result
|
|
|
|
if [ set exit_code [ lindex $result 3 ] ] {
|
|
|
|
fail "program exited with code $exit_code"
|
|
|
|
}
|
|
|
|
}
|