aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-12-01 10:55:32 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-12-01 11:56:50 -0500
commit49141e0cd1a56e5f97e81e13a6d7be85138c134c (patch)
treee0c26a4832657a796464eb04330da6e71e52b267 /test/hwdb-test.sh
parenthwdb-test: properly print error output from systemd-hwdb update (diff)
downloadsystemd-49141e0cd1a56e5f97e81e13a6d7be85138c134c.tar.gz
systemd-49141e0cd1a56e5f97e81e13a6d7be85138c134c.tar.bz2
systemd-49141e0cd1a56e5f97e81e13a6d7be85138c134c.zip
hwdb: improve and test syntax error messages
Since syntax error are non-fatal, downgrade them to warnings. Use log_syntax to have uniform formatting including the line number. State machine states like DATA and MATCH are internal, user-facing messages should use the names from hwdb(7): match, property, record. Also change "key/value" to "key-value", since there's no alternative here, both parts must be present. [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:2] Property expected, ignoring record with no properties [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:5] Property expected, ignoring record with no properties [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:9] Property expected, ignoring record with no properties [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:11] Key/value pair expected but got " NO_VALUE", ignoring [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:18] Property or empty line expected, got "BAD:7:match at wrong place", ignoring record [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:22] Property or empty line expected, got "BAD:8:match at wrong place", ignoring record [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:23] Match expected but got indented property " Z=z", ignoring line squash! hwdb: improve syntax error messages
Diffstat (limited to 'test/hwdb-test.sh')
-rwxr-xr-xtest/hwdb-test.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/hwdb-test.sh b/test/hwdb-test.sh
index bfdafce99..5373930df 100755
--- a/test/hwdb-test.sh
+++ b/test/hwdb-test.sh
@@ -33,6 +33,7 @@ trap "rm -rf '$D'" EXIT INT QUIT PIPE
mkdir -p "$D/etc/udev"
ln -s "$ROOTDIR/hwdb" "$D/etc/udev/hwdb.d"
+# Test "good" properties" — no warnings or errors allowed
err=$("$SYSTEMD_HWDB" update --root "$D" 2>&1 >/dev/null) && rc= || rc=$?
if [ -n "$err" ]; then
echo "$err"
@@ -47,3 +48,25 @@ if [ ! -e "$D/etc/udev/hwdb.bin" ]; then
echo "$D/etc/udev/hwdb.bin was not generated"
exit 1
fi
+
+# Test "bad" properties" — warnings required, errors not allowed
+rm -f "$D/etc/udev/hwdb.bin" "$D/etc/udev/hwdb.d"
+
+ln -s "$ROOTDIR/test/hwdb" "$D/etc/udev/hwdb.d"
+err=$("$SYSTEMD_HWDB" update --root "$D" 2>&1 >/dev/null) && rc= || rc=$?
+if [ -n "$rc" ]; then
+ echo "$SYSTEMD_HWDB returned $rc"
+ exit $rc
+fi
+if [ -n "$err" ]; then
+ echo "Expected warnings"
+ echo "$err"
+else
+ echo "$SYSTEMD_HWDB unexpectedly printed no warnings"
+ exit 1
+fi
+
+if [ ! -e "$D/etc/udev/hwdb.bin" ]; then
+ echo "$D/etc/udev/hwdb.bin was not generated"
+ exit 1
+fi