Merge pull request #4729 from martinpitt/hwdb

fix hwdb syntax error and add test for it
This commit is contained in:
Martin Pitt 2016-11-24 18:19:59 +01:00 committed by GitHub
commit c495dfb9c3
4 changed files with 49 additions and 3 deletions

View file

@ -3897,7 +3897,8 @@ EXTRA_DIST += \
# ------------------------------------------------------------------------------
if ENABLE_TESTS
TESTS += \
test/udev-test.pl
test/udev-test.pl \
test/hwdb-test.sh
if HAVE_PYTHON
TESTS += \
@ -3952,6 +3953,7 @@ DISTCLEAN_LOCAL_HOOKS += test-sys-distclean
EXTRA_DIST += \
test/sys.tar.xz \
test/udev-test.pl \
test/hwdb-test.sh \
test/rule-syntax-check.py \
test/sysv-generator-test.py \
test/mocks/fsck \

View file

@ -416,7 +416,7 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnHewlett-Packard*:pnHP*Pavilion*dv7*Notebook*PC:
KEYBOARD_KEY_94=reserved
# Pavilion x360 13 (Prevents random airplane mode activation)
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnHewlett-Packard*:pn*[pP][aA][vV][iI][lL][iI][oO][nN]*13*x360*:pvr*
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnHewlett-Packard*:pn*[pP][aA][vV][iI][lL][iI][oO][nN]*13*x360*:pvr*
KEYBOARD_KEY_d7=unknown
# Elitebook

View file

@ -133,7 +133,8 @@ def convert_properties(group):
def parse(fname):
grammar = hwdb_grammar()
try:
parsed = grammar.parseFile(fname)
with open(fname, 'r', encoding='UTF-8') as f:
parsed = grammar.parseFile(f)
except ParseBaseException as e:
error('Cannot parse {}: {}', fname, e)
return []

43
test/hwdb-test.sh Executable file
View file

@ -0,0 +1,43 @@
#!/bin/sh
# call built systemd-hwdb update on our hwdb files to ensure that they parse
# without error
#
# (C) 2016 Canonical Ltd.
# Author: Martin Pitt <martin.pitt@ubuntu.com>
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
# systemd is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
set -e
ROOTDIR=$(dirname $(dirname $(readlink -f $0)))
SYSTEMD_HWDB=${builddir:-.}/systemd-hwdb
if [ ! -x "$SYSTEMD_HWDB" ]; then
echo "$SYSTEMD_HWDB does not exist, please build first"
exit 1
fi
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)
if [ -n "$err" ]; then
echo "$err"
exit 1
fi
if [ ! -e "$D/etc/udev/hwdb.bin" ]; then
echo "$D/etc/udev/hwdb.bin was not generated"
exit 1
fi