mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-21 09:51:50 +00:00
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
This commit is contained in:
parent
c560374da5
commit
f4df768041
@ -829,6 +829,7 @@ _tfw_execute() {
|
|||||||
fi
|
fi
|
||||||
export TFWSTDOUT="${_tfw_stdout_file:-$_tfw_process_tmp/stdout}"
|
export TFWSTDOUT="${_tfw_stdout_file:-$_tfw_process_tmp/stdout}"
|
||||||
export TFWSTDERR="${_tfw_stderr_file:-$_tfw_process_tmp/stderr}"
|
export TFWSTDERR="${_tfw_stderr_file:-$_tfw_process_tmp/stderr}"
|
||||||
|
echo "$executed" >"$_tfw_process_tmp/executing"
|
||||||
{
|
{
|
||||||
time -p "$_tfw_executable" "$@" >"$TFWSTDOUT" 2>"$TFWSTDERR"
|
time -p "$_tfw_executable" "$@" >"$TFWSTDOUT" 2>"$TFWSTDERR"
|
||||||
} 2>"$_tfw_process_tmp/times" &
|
} 2>"$_tfw_process_tmp/times" &
|
||||||
@ -874,6 +875,7 @@ _tfw_execute() {
|
|||||||
done
|
done
|
||||||
wait $timer_pid
|
wait $timer_pid
|
||||||
fi
|
fi
|
||||||
|
rm -f "$_tfw_process_tmp/executing"
|
||||||
# Deal with core dump.
|
# Deal with core dump.
|
||||||
if $_tfw_opt_core_backtrace && [ -s core ]; then
|
if $_tfw_opt_core_backtrace && [ -s core ]; then
|
||||||
tfw_core_backtrace "$_tfw_executable" core
|
tfw_core_backtrace "$_tfw_executable" core
|
||||||
@ -2050,6 +2052,15 @@ _tfw_forkwait() {
|
|||||||
cat $_tfw_tmp/fork-$forkid/log.xtrace
|
cat $_tfw_tmp/fork-$forkid/log.xtrace
|
||||||
echo "++++++++++"
|
echo "++++++++++"
|
||||||
fi
|
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
|
case $status in
|
||||||
0) ;;
|
0) ;;
|
||||||
143) ;; # terminated with SIGTERM (probably from fork_terminate)
|
143) ;; # terminated with SIGTERM (probably from fork_terminate)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user