2015-01-08 21:08:48 +00:00
|
|
|
##
|
|
|
|
# Get the output of the target machine via serial connection
|
|
|
|
#
|
2015-02-12 11:35:37 +00:00
|
|
|
# \param --log-serial-cmd Cmd that is executed to capture the output
|
|
|
|
# \param --log-serial-filter Sanitize output by piping it through a filter
|
2015-01-08 21:08:48 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
source [genode_dir]/tool/run/log.inc
|
|
|
|
|
|
|
|
|
|
|
|
set default_serial_cmd "picocom -b 115200 /dev/ttyUSB0"
|
|
|
|
|
|
|
|
|
|
|
|
proc log_serial_cmd { } {
|
|
|
|
global default_serial_cmd
|
|
|
|
return [get_cmd_arg --log-serial-cmd $default_serial_cmd]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-12 11:35:37 +00:00
|
|
|
proc log_serial_filter { } {
|
|
|
|
return [get_cmd_arg --log-serial-filter ""]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-08 21:08:48 +00:00
|
|
|
##
|
|
|
|
# Log output of the test machine via serial device
|
|
|
|
#
|
|
|
|
proc run_log { wait_for_re timeout_value } {
|
|
|
|
global output_spawn_id
|
|
|
|
|
2015-02-06 17:02:55 +00:00
|
|
|
set kernel_msg [run_boot_string]
|
|
|
|
|
2015-02-12 11:35:37 +00:00
|
|
|
#
|
|
|
|
# Certain devices send garbage through the serial connection that may
|
|
|
|
# result in an unexpected EOF in expect. This is caused by TCL using the
|
|
|
|
# terminal encoding for the channel to the spawned program and interpreting
|
|
|
|
# the input for conversion to UTF-8. In the case of the serial connection,
|
|
|
|
# this may not be valid with garbage bytes in the character stream. If any
|
|
|
|
# garbage coming from the serial connection is interpreted as the beginning
|
|
|
|
# of a UTF-8 multi-byte sequence but does not resemble the complete
|
|
|
|
# sequence (i.e., is truncated), parsing may result in EOF. To prevent this
|
|
|
|
# from happening one may use a filter that sanitizes the serial output,
|
|
|
|
# i.e., lets only ASCII characters through.
|
|
|
|
#
|
|
|
|
set serial_cmd_chain [log_serial_cmd]
|
|
|
|
if {[get_cmd_switch --log-serial-filter]} {
|
|
|
|
set serial_cmd_chain "$serial_cmd_chain | [log_serial_filter]"
|
|
|
|
}
|
2015-02-06 17:02:55 +00:00
|
|
|
|
2015-02-12 11:35:37 +00:00
|
|
|
#
|
|
|
|
# XXX the initial timeout was estimated by testing and is merely enough
|
|
|
|
# to load large scenarios via TFTP.
|
|
|
|
#
|
2015-02-06 17:02:55 +00:00
|
|
|
set timeout 210
|
2015-02-12 11:35:37 +00:00
|
|
|
|
|
|
|
spawn /bin/sh -c "$serial_cmd_chain"
|
|
|
|
set output_spawn_id $spawn_id
|
|
|
|
|
2015-02-06 17:02:55 +00:00
|
|
|
expect {
|
2015-02-12 11:35:37 +00:00
|
|
|
-i $output_spawn_id $kernel_msg { }
|
2015-02-06 17:02:55 +00:00
|
|
|
eof {
|
2015-02-12 11:35:37 +00:00
|
|
|
puts stderr "Aborting, received EOF"
|
2015-02-06 17:02:55 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
timeout {
|
|
|
|
puts stderr "Boot process timed out"
|
|
|
|
close
|
|
|
|
return false
|
2015-01-08 21:08:48 +00:00
|
|
|
}
|
|
|
|
}
|
2015-02-06 17:02:55 +00:00
|
|
|
|
|
|
|
wait_for_output $wait_for_re $timeout_value $output_spawn_id
|
|
|
|
return true
|
2015-01-08 21:08:48 +00:00
|
|
|
}
|