tests: Fix reporting of scons builds failure in jenkins scripts
Change-Id: I668d0d90e60dba1786643c01149d48ad687912ec
Signed-off-by: Sean Wilson <spwilson2@wisc.edu>
diff --git a/tests/jenkins/continuous.sh b/tests/jenkins/continuous.sh
index 82fb1b0..7e82632 100755
--- a/tests/jenkins/continuous.sh
+++ b/tests/jenkins/continuous.sh
@@ -39,14 +39,10 @@
# Sean Wilson
set -e
-set -o pipefail
# Use ccache with the default directory for caching
export PATH="/usr/lib/ccache:$PATH"
-export LOGFILE="continuous-output"
-rm -f "${LOGFILE}"
-
cd git/jenkins-gem5-prod
BUILD_JOBS=4
@@ -56,27 +52,49 @@
TARGETS=
for A in ${GEM5_ARCH}; do
- TARGETS="${TARGETS} build/${A}/gem5.${GEM5_VARIANT}"
+ TARGETS+=" build/${A}/gem5.${GEM5_VARIANT}"
done
export TEST_TARGETS=""
for A in ${GEM5_ARCH}; do
- TEST_TARGETS="${TEST_TARGETS} build/${A}/tests/${GEM5_VARIANT}\
-/quick/"
+ TEST_TARGETS+=" build/${A}/tests/${GEM5_VARIANT}/quick/"
done
runtests () {
- scons --ignore-style ${TARGETS} -j${BUILD_JOBS} &>> "${LOGFILE}"
+ # Set pipefail incase scons test fails out while reading.
+ set -e
+ set -o pipefail
- # Run the tests and check for a failure, return "0" for success
+ # Build the gem5 binaries.
+ scons --ignore-style ${TARGETS} -j${BUILD_JOBS}
+
+ # Keep pushing out SCons output and check the fail status after we have read
+ # through all of the tests.
scons --ignore-style ${TEST_TARGETS} -j${BUILD_JOBS} |\
- tee -a "${LOGFILE}" | grep 'FAILED!' | wc -l
+ {
+ FAILED=""
+ while read line; do
+ echo "${line}"
+ failed_lines="$(echo "${line}" | grep "FAILED!"; true)"
+ if ! [ "${failed_lines}" = "" ]; then
+ FAILED="fail"
+ fi
+ done
+ test "${FAILED}" = ""
+ }
- exit 0
+ exit 0
+ }
+
+ # Print out the output as it comes to us, but don't exit right away
+ # if runtests fails, we want to print the final status on our own.
+ runtests | {
+ while read line; do
+ echo "${line}"
+ done
}
-# Check that there were zero failed tests and the subcommand was successful
-if [ "$(runtests 2>> ${LOGFILE})" = "0" -a "$?" = "0" ]; then
+if [ "${PIPESTATUS[0]}" = "0" ]; then
echo "SUCCESS"
exit 0
else
diff --git a/tests/jenkins/presubmit.sh b/tests/jenkins/presubmit.sh
index 79a9648..f00f396 100755
--- a/tests/jenkins/presubmit.sh
+++ b/tests/jenkins/presubmit.sh
@@ -39,14 +39,10 @@
# Sean Wilson
set -e
-set -o pipefail
# Use ccache with the default directory for caching
export PATH="/usr/lib/ccache:$PATH"
-export LOGFILE="presubmit-output"
-rm -f "${LOGFILE}"
-
cd git/jenkins-gem5-prod
BUILD_JOBS=4
@@ -56,27 +52,49 @@
TARGETS=
for A in ${GEM5_ARCH}; do
- TARGETS="${TARGETS} build/${A}/gem5.${GEM5_VARIANT}"
+ TARGETS+=" build/${A}/gem5.${GEM5_VARIANT}"
done
export TEST_TARGETS=""
for A in ${GEM5_ARCH}; do
- TEST_TARGETS="${TEST_TARGETS} build/${A}/tests/${GEM5_VARIANT}\
-/quick/se/00.hello"
+ TEST_TARGETS+=" build/${A}/tests/${GEM5_VARIANT}/quick/se/00.hello"
done
runtests () {
- scons --ignore-style ${TARGETS} -j${BUILD_JOBS} &>> "${LOGFILE}"
+ # Set pipefail incase scons test fails out while reading.
+ set -e
+ set -o pipefail
- # Run the tests and check for a failure, return "0" for success
+ # Build the gem5 binaries.
+ scons --ignore-style ${TARGETS} -j${BUILD_JOBS}
+
+ # Keep pushing out SCons output and check the fail status after we have read
+ # through all of the tests.
scons --ignore-style ${TEST_TARGETS} -j${BUILD_JOBS} |\
- tee -a "${LOGFILE}" | grep 'FAILED!' | wc -l
+ {
+ FAILED=""
+ while read line; do
+ echo "${line}"
+ failed_lines="$(echo "${line}" | grep "FAILED!"; true)"
+ if ! [ "${failed_lines}" = "" ]; then
+ FAILED="fail"
+ fi
+ done
+ test "${FAILED}" = ""
+ }
- exit 0
+ exit 0
+ }
+
+ # Print out the output as it comes to us, but don't exit right away
+ # if runtests fails, we want to print the final status on our own.
+ runtests | {
+ while read line; do
+ echo "${line}"
+ done
}
-# Check that there were zero failed tests and the subcommand was successful
-if [ "$(runtests 2>> ${LOGFILE})" = "0" -a "$?" = "0" ]; then
+if [ "${PIPESTATUS[0]}" = "0" ]; then
echo "SUCCESS"
exit 0
else