From 8ce2069263a5ed9237ca03179a760d3023e12fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 29 Nov 2016 22:41:52 -0500 Subject: [PATCH] hwdb-test: properly print error output from systemd-hwdb update Because -e was set, we'd exit immediately when systemd-hwdb failed and the captured error output was never printed. We want to test two things: that 0 is returned, and that nothing is printed to stderr (to catch syntax errors in the hwdb). v2: stop capturing stderr to a variable v3: capture stderr to a variable and test both error types separately --- test/hwdb-test.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/hwdb-test.sh b/test/hwdb-test.sh index 46383280599..bfdafce9984 100755 --- a/test/hwdb-test.sh +++ b/test/hwdb-test.sh @@ -32,11 +32,17 @@ D=$(mktemp --directory) trap "rm -rf '$D'" EXIT INT QUIT PIPE mkdir -p "$D/etc/udev" ln -s "$ROOTDIR/hwdb" "$D/etc/udev/hwdb.d" -err=$("$SYSTEMD_HWDB" update --root "$D" 2>&1 >/dev/null) + +err=$("$SYSTEMD_HWDB" update --root "$D" 2>&1 >/dev/null) && rc= || rc=$? if [ -n "$err" ]; then echo "$err" - exit 1 + exit ${rc:-1} fi +if [ -n "$rc" ]; then + echo "$SYSTEMD_HWDB returned $rc" + exit $rc +fi + if [ ! -e "$D/etc/udev/hwdb.bin" ]; then echo "$D/etc/udev/hwdb.bin was not generated" exit 1