init_colors=''
fi
+TIME_SCRIPT="$(realpath -e -- "$(dirname "$0")")/tap/clock"
+
# :; is there to work around a bug in bash 3.2 (and earlier) which
# does not always set '$?' properly on redirection failure.
# See the Autoconf manual for more details.
else
exec 2>&3
fi
- "$@"
+ # Since stderr and stdout may go to the same file and the script
+ # may run in situations with different types of buffering, enforce
+ # line buffering for both FDs. This helps to prevent interleave between
+ # the outputs in the resulting file for half written lines, eg.
+ # ok 93 - Tes# PERROR - xxxx
+ # t some function
+ if [ "${LTTNG_TESTS_TAP_AUTOTIME:-}" != 0 ]; then
+ stdbuf -eL -oL -- "$@"
+ else
+ "$@"
+ fi
echo $?
) | LC_ALL=C ${AM_TAP_AWK-awk} \
-v me="$me" \
-v ignore_exit="$ignore_exit" \
-v comments="$comments" \
-v diag_string="$diag_string" \
+ -v time_script="${TIME_SCRIPT}" \
'
# TODO: the usages of "cat >&3" below could be optimized when using
# GNU awk, and/on on systems that supports /dev/fd/.
return 0
}
+function gettime_ns( r)
+{
+ r = ""
+ if (time_script | getline r) {
+ r = r
+ }
+ close(time_script)
+ return sprintf("%f", r)
+}
+
function get_global_test_result()
{
if ("ERROR" in test_results_seen)
print ":global-test-result: " get_global_test_result() > trs_file
print ":recheck: " yn(must_recheck()) > trs_file
print ":copy-in-global-log: " yn(copy_in_global_log()) > trs_file
+ print ":time-taken: " sprintf("%f", gettime_ns() - TIME_START) > trs_file
for (i = 0; i < test_results_index; i += 1)
print ":test-result: " test_results_list[i] > trs_file
close(trs_file);
# it is ("early" is seen before any test result, "late" otherwise).
plan_seen = NO_PLAN
+TIME_START = gettime_ns();
## --------- ##
## PARSING ##
## --------- ##