未验证 提交 e1c88369 编写于 作者: R Rudá Moura

examples.wrappers: Turn ltrace.sh smarter.

Use 'set -e' to exit in the first error problem, for example, when
the ltrace command is not installed.

The script now looks inside the log to probe for exit code, after
that, it tries to look if the process has been killed by a signal.
This order is different from the previous implementation.

The regular expression to probe for exit code and signals are improved.
Signed-off-by: NRudá Moura <rmoura@redhat.com>
上级 79dfd3e8
#!/bin/bash
#
# Run process inside ltrace.
#
set -e
# Map interesting signals to exit codes (see kill -L)
# Example: SIGHUP (kill -1) 128+1 = 129
......@@ -30,16 +35,16 @@ signal_map[SIGPWR]=158
signal_map[SIGSYS]=159
signal_map[UNKNOWN_SIGNAL]=160
ltrace -f -o $AVOCADO_TEST_LOGDIR/ltrace.log.$$ -- $@
signal_name=$(sed -ne 's/^.*+++ killed by \([A-Z_]\+\) +++$/\1/p' $AVOCADO_TEST_LOGDIR/ltrace.log.$$)
if [ -n "$signal_name" ] ; then
exit ${signal_map[$signal_name]}
fi
ltrace -f -o $AVOCADO_TEST_LOGDIR/ltrace.log.$$ -- "$@"
exit_status=$(sed -ne 's/^.*+++ exited (status \([0-9]\+\)) +++$/\1/p' $AVOCADO_TEST_LOGDIR/ltrace.log.$$)
exit_status=$(sed -ne 's/^[0-9]\+ +++ exited (status \([0-9]\+\)) +++$/\1/p' $AVOCADO_TEST_LOGDIR/ltrace.log.$$ | tail -1)
if [ -n "$exit_status" ] ; then
exit $exit_status
fi
signal_name=$(sed -ne 's/^[0-9]\+ +++ killed by \([A-Z_]\+\) +++$/\1/p' $AVOCADO_TEST_LOGDIR/ltrace.log.$$ | tail -1)
if [ -n "$signal_name" ] ; then
exit ${signal_map[$signal_name]}
fi
exit 0
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册