From 115a605658d2dcfedd009b9f113f7d29a2717164 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Mon, 26 Oct 2015 15:02:14 +0100 Subject: [PATCH] run: try to detect reboots of platform --- tool/run/log/amt | 36 +++++++++++++++--------------------- tool/run/log/qemu | 19 ++++++++++++++++++- tool/run/run | 6 ++++++ 3 files changed, 39 insertions(+), 22 deletions(-) diff --git a/tool/run/log/amt b/tool/run/log/amt index 601e6bff4..efbc340c8 100644 --- a/tool/run/log/amt +++ b/tool/run/log/amt @@ -41,30 +41,24 @@ proc run_log { wait_for_re timeout_value } { } set exit_result 1 - while { $exit_result != 0 } { - set time_start [ clock seconds ] - eval spawn $amtterm - set output_spawn_id $spawn_id - expect { - -i $output_spawn_id -re $wait_for_re { break } - eof { continue } - timeout { puts "Error: Test execution timed out"; exit -2 } + eval spawn $amtterm + set output_spawn_id $spawn_id + + set kernel_msg [run_boot_string] + + expect { + -i $output_spawn_id $kernel_msg { } + eof { + puts stderr "Aborting, received EOF" + return false } - catch wait result - set time_end [ clock seconds ] - if {[expr $time_end - $time_start] <= 1} { - incr timeout -1 - } else { - incr timeout [expr -1 * ($time_end - $time_start)] + timeout { + puts stderr "Boot process timed out" + close + return false } - if {$timeout < 0} { - set timeout 0 - } - set exit_result [lindex $result 3] } - global output - set output $expect_out(buffer) - + wait_for_output $wait_for_re $timeout_value $output_spawn_id return true } diff --git a/tool/run/log/qemu b/tool/run/log/qemu index 2d4f69e8f..f7aa14d9e 100644 --- a/tool/run/log/qemu +++ b/tool/run/log/qemu @@ -12,6 +12,23 @@ proc run_log { wait_for_re timeout_value } { set output_spawn_id $qemu_spawn_id + set kernel_msg [run_boot_string] + + set timeout $timeout_value + + expect { + -i $output_spawn_id $kernel_msg { } + eof { + puts stderr "Aborting, received EOF" + return false + } + timeout { + puts stderr "Boot process timed out" + close + return false + } + } + wait_for_output $wait_for_re $timeout_value $qemu_spawn_id - return true; + return true } diff --git a/tool/run/run b/tool/run/run index 3db63fff9..fab251c7b 100755 --- a/tool/run/run +++ b/tool/run/run @@ -475,7 +475,13 @@ proc wait_for_output { wait_for_re timeout_value running_spawn_id } { set timeout $timeout_value } + set platform_msg [run_boot_string] + if {$platform_msg eq ""} { + set platform_msg "undefined platform command startup string sequence" + } + expect { + -i $running_spawn_id $platform_msg { puts stderr "Error: platform rebooted unexpectedly"; exit -4 } -i $running_spawn_id -re $wait_for_re { } eof { puts stderr "Error: Spawned process died unexpectedly"; exit -3 } timeout { puts stderr "Error: Test execution timed out"; exit -2 }