summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2020-02-05 15:40:41 -0800
committerCommit Bot <commit-bot@chromium.org>2020-02-06 09:55:32 +0000
commit4d7cb7a4ef37db1e1622382221286e14ce4cefbe (patch)
tree13e588a5533314d4a6e5360ba084c33fa660d61a
parent8f5432e1003b86e72b14bac60a66daa54bd26630 (diff)
downloadvboot-4d7cb7a4ef37db1e1622382221286e14ce4cefbe.tar.gz
test_update.sh: Avoid using grep -q together with -o pipefail
Piping something into 'grep -q' when the shell option '-o pipefail' is set is racy: 'grep -q' exits immediately after seeing the first occurence of the pattern, so if the process at the front of the pipe hasn't written all its data into the pipe buffer yet, it will still try to write more after grep has already exited and die with a SIGPIPE. The recommended solution seems to be using a <<<"herestring" instead. (Also add the test's return code to the FAILED output in run_test_scripts.sh to aid future test script debugging.) BRANCH=None BUG=chromium:1048048 TEST=make runtests Change-Id: I2f2589f223d9179d694565f5733535d4270699ea Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2039946 Reviewed-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
-rwxr-xr-xtests/futility/run_test_scripts.sh2
-rwxr-xr-xtests/futility/test_update.sh2
2 files changed, 2 insertions, 2 deletions
diff --git a/tests/futility/run_test_scripts.sh b/tests/futility/run_test_scripts.sh
index 2ec7abbd..f224bdf1 100755
--- a/tests/futility/run_test_scripts.sh
+++ b/tests/futility/run_test_scripts.sh
@@ -64,7 +64,7 @@ for i in $TESTS; do
: $(( pass++ ))
rm -f ${OUTDIR}/$j.{stdout,stderr,return}
else
- echo -e "${COL_RED}FAILED. Stdout is recorded in" \
+ echo -e "${COL_RED}FAILED (${rc:-0}). Stdout is recorded in" \
"${OUTDIR}/$j.stdout${COL_STOP}"
cat ${OUTDIR}/$j.stderr
fi
diff --git a/tests/futility/test_update.sh b/tests/futility/test_update.sh
index 902ad947..002f1050 100755
--- a/tests/futility/test_update.sh
+++ b/tests/futility/test_update.sh
@@ -161,7 +161,7 @@ test_update() {
echo "*** Test Item: ${test_name}"
if [ "${error_msg}" != "${expected}" ] && [ -n "${error_msg}" ]; then
msg="$(! "${FUTILITY}" update --emulate "${TMP}.emu" "$@" 2>&1)"
- echo "${msg}" | grep -qF -- "${error_msg}"
+ grep -qF -- "${error_msg}" <<<"${msg}"
else
"${FUTILITY}" update --emulate "${TMP}.emu" "$@"
cmp "${TMP}.emu" "${expected}"