]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hwdb-test: properly print error output from systemd-hwdb update
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 30 Nov 2016 03:41:52 +0000 (22:41 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 1 Dec 2016 16:50:17 +0000 (11:50 -0500)
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

index 46383280599a29a72a139551c9c75a3dc1ec6993..bfdafce998441a94e8071eca396b9ad1ce1ff76d 100755 (executable)
@@ -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