From 30dc7898d5a0311a88f069e39e7ff552b3fc3190 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Thu, 24 Nov 2016 11:29:42 +0100 Subject: [PATCH] tests: add hwdb parsing test This calls the built "systemd-hwdb update" on the source tree's hwdb/ in a temporary directory and verifies that there are no error messages. --- Makefile.am | 4 +++- test/hwdb-test.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100755 test/hwdb-test.sh diff --git a/Makefile.am b/Makefile.am index 3aeb7b9..5cec19f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/test/hwdb-test.sh b/test/hwdb-test.sh new file mode 100755 index 0000000..4638328 --- /dev/null +++ b/test/hwdb-test.sh @@ -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 +# +# 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 . + +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 -- 2.7.4