From f4df768041d78b538482cca56fb07361e726f659 Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Mon, 18 May 2015 17:17:29 +0930 Subject: [PATCH] Improve test framework: report stderr/stdout of execute within fork So that if execute() is used within a forked process and if that process is terminated prematurely, the log will show what the execute'd command was doing --- testframework.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/testframework.sh b/testframework.sh index 9f691235..4599d730 100644 --- a/testframework.sh +++ b/testframework.sh @@ -829,6 +829,7 @@ _tfw_execute() { fi export TFWSTDOUT="${_tfw_stdout_file:-$_tfw_process_tmp/stdout}" export TFWSTDERR="${_tfw_stderr_file:-$_tfw_process_tmp/stderr}" + echo "$executed" >"$_tfw_process_tmp/executing" { time -p "$_tfw_executable" "$@" >"$TFWSTDOUT" 2>"$TFWSTDERR" } 2>"$_tfw_process_tmp/times" & @@ -874,6 +875,7 @@ _tfw_execute() { done wait $timer_pid fi + rm -f "$_tfw_process_tmp/executing" # Deal with core dump. if $_tfw_opt_core_backtrace && [ -s core ]; then tfw_core_backtrace "$_tfw_executable" core @@ -2050,6 +2052,15 @@ _tfw_forkwait() { cat $_tfw_tmp/fork-$forkid/log.xtrace echo "++++++++++" fi + if [ -s $_tfw_tmp/fork-$forkid/executing ]; then + local executed="$(cat $_tfw_tmp/fork-$forkid/executing)" + echo "++++++++++ $desc stdout of ($executed) ++++++++++" + cat $_tfw_tmp/fork-$forkid/stdout + echo "++++++++++" + echo "++++++++++ $desc stderr of ($executed) ++++++++++" + cat $_tfw_tmp/fork-$forkid/stderr + echo "++++++++++" + fi case $status in 0) ;; 143) ;; # terminated with SIGTERM (probably from fork_terminate)