]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/hwdb-test.sh
hwdb-test: properly print error output from systemd-hwdb update
[thirdparty/systemd.git] / test / hwdb-test.sh
1 #!/bin/sh
2 # call built systemd-hwdb update on our hwdb files to ensure that they parse
3 # without error
4 #
5 # (C) 2016 Canonical Ltd.
6 # Author: Martin Pitt <martin.pitt@ubuntu.com>
7 #
8 # systemd is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU Lesser General Public License as published by
10 # the Free Software Foundation; either version 2.1 of the License, or
11 # (at your option) any later version.
12
13 # systemd is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
17 #
18 # You should have received a copy of the GNU Lesser General Public License
19 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
20
21 set -e
22
23 ROOTDIR=$(dirname $(dirname $(readlink -f $0)))
24 SYSTEMD_HWDB=${builddir:-.}/systemd-hwdb
25
26 if [ ! -x "$SYSTEMD_HWDB" ]; then
27 echo "$SYSTEMD_HWDB does not exist, please build first"
28 exit 1
29 fi
30
31 D=$(mktemp --directory)
32 trap "rm -rf '$D'" EXIT INT QUIT PIPE
33 mkdir -p "$D/etc/udev"
34 ln -s "$ROOTDIR/hwdb" "$D/etc/udev/hwdb.d"
35
36 err=$("$SYSTEMD_HWDB" update --root "$D" 2>&1 >/dev/null) && rc= || rc=$?
37 if [ -n "$err" ]; then
38 echo "$err"
39 exit ${rc:-1}
40 fi
41 if [ -n "$rc" ]; then
42 echo "$SYSTEMD_HWDB returned $rc"
43 exit $rc
44 fi
45
46 if [ ! -e "$D/etc/udev/hwdb.bin" ]; then
47 echo "$D/etc/udev/hwdb.bin was not generated"
48 exit 1
49 fi