From 3367fd27e4dfb1f67468f67433943578db253487 Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Mon, 8 Dec 2014 10:44:39 +0100 Subject: [PATCH] run: avoid buffering of output for expect Due to commit "run: relax IP power plug recognition + serial EOF", when piping the serial command through 'tr', some characters might get buffered, thereby preventing some run scripts to finish correctly. This commit removes the 'tr' hack. Instead, to circumvent the 'expect' problem, which kills under special conditions spawned childs used to obtain serial line content, whenever EOF of the serial command is recognized during the boot phase, the child process gets re-spawned. --- tool/run | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/tool/run b/tool/run index 8372823a0..e74c0fba6 100755 --- a/tool/run +++ b/tool/run @@ -887,24 +887,28 @@ proc spawn_serial { wait_for_re timeout_value kernel_msg } { jtag_load } - # pipe the serial output through 'tr', sometimes expect steps out due to - # unexpected pipe behaviour and reports EOF although the pipe is still active - eval spawn sh -c \"$serial_cmd | tr a a\" - set serial_spawn_id $spawn_id - set timeout 210 - expect { - $kernel_msg { break; } - eof { puts stderr "Serial command process died unexpectedly"; incr retry -1; } - timeout { puts stderr "Boot process timed out"; close; incr retry -1; } + while {true} { + eval spawn $serial_cmd + set serial_spawn_id $spawn_id + expect { + $kernel_msg { + wait_for_output $wait_for_re $timeout_value $serial_spawn_id; + return; + } + eof { continue; } + timeout { + puts stderr "Boot process timed out"; + close; + incr retry -1; + break; + } + } } } - if { $retry == 0 } { - puts stderr "Boot process failed 3 times in series. I give up!"; - exit -1; - } - wait_for_output $wait_for_re $timeout_value $serial_spawn_id + puts stderr "Boot process failed 3 times in series. I give up!"; + exit -1; }