diff options
author | Googler <noreply@google.com> | 2018-02-12 07:06:15 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-12 07:07:57 -0800 |
commit | 28bd997c1c8793973f63dcae4c22bbae49e7d8b7 (patch) | |
tree | e58eb8f22a31924bfe5106af151a0f6921ddcd45 /tools | |
parent | 7f1f3a203ae879bd404eccb0937cf03e77b3d61a (diff) |
Fixing test-setup.sh occasionally missing stdout/stderr, on systems where "tail --pid" is supported.
The solutions aren't mine, the new test was taken from Ola's unknown commit and the way to avoid race condition courtesy of sethkoehler@
Mitigates #4608 for compatible Linux systems.
TESTED=manual scripts and new test case.
RELNOTES: None
PiperOrigin-RevId: 185374273
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/test/test-setup.sh | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/tools/test/test-setup.sh b/tools/test/test-setup.sh index aa6f7223b8..328972fe6a 100755 --- a/tools/test/test-setup.sh +++ b/tools/test/test-setup.sh @@ -218,10 +218,30 @@ for signal in $signals; do done start=$(date +%s) -if [ -z "$COVERAGE_DIR" ]; then - "${TEST_PATH}" "$@" 2> >(tee -a "${XML_OUTPUT_FILE}.log" >&2) 1> >(tee -a "${XML_OUTPUT_FILE}.log") 2>&1 || exitCode=$? +# Check if we have tail --pid option +dummy=1 & +pid=$! +has_tail=true +tail -fq --pid $pid -s 0.001 /dev/null &> /dev/null || has_tail=false + +if [ "$has_tail" == true ] && [ -z "$no_echo" ]; then + touch "${XML_OUTPUT_FILE}.log" + if [ -z "$COVERAGE_DIR" ]; then + "${TEST_PATH}" "$@" &>"${XML_OUTPUT_FILE}.log" & + pid=$! + else + "$1" "$TEST_PATH" "${@:3}" &> "${XML_OUTPUT_FILE}.log" & + pid=$! + fi + tail -fq --pid $pid -s 0.001 "${XML_OUTPUT_FILE}.log" + wait $pid + exitCode=$? else - "$1" "$TEST_PATH" "${@:3}" 2> >(tee -a "${XML_OUTPUT_FILE}.log" >&2) 1> >(tee -a "${XML_OUTPUT_FILE}.log") 2>&1 || exitCode=$? + if [ -z "$COVERAGE_DIR" ]; then + "${TEST_PATH}" "$@" 2> >(tee -a "${XML_OUTPUT_FILE}.log" >&2) 1> >(tee -a "${XML_OUTPUT_FILE}.log") 2>&1 || exitCode=$? + else + "$1" "$TEST_PATH" "${@:3}" 2> >(tee -a "${XML_OUTPUT_FILE}.log" >&2) 1> >(tee -a "${XML_OUTPUT_FILE}.log") 2>&1 || exitCode=$? + fi fi for signal in $signals; do |