]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/hwdb-test.sh
Merge pull request #6465 from keszybz/drop-kdbus
[thirdparty/systemd.git] / test / hwdb-test.sh
CommitLineData
30dc7898
MP
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
21set -e
22
23ROOTDIR=$(dirname $(dirname $(readlink -f $0)))
24SYSTEMD_HWDB=${builddir:-.}/systemd-hwdb
25
26if [ ! -x "$SYSTEMD_HWDB" ]; then
27 echo "$SYSTEMD_HWDB does not exist, please build first"
28 exit 1
29fi
30
31D=$(mktemp --directory)
32trap "rm -rf '$D'" EXIT INT QUIT PIPE
33mkdir -p "$D/etc/udev"
34ln -s "$ROOTDIR/hwdb" "$D/etc/udev/hwdb.d"
8ce20692 35
49141e0c 36# Test "good" properties" — no warnings or errors allowed
8ce20692 37err=$("$SYSTEMD_HWDB" update --root "$D" 2>&1 >/dev/null) && rc= || rc=$?
30dc7898
MP
38if [ -n "$err" ]; then
39 echo "$err"
8ce20692 40 exit ${rc:-1}
30dc7898 41fi
8ce20692
ZJS
42if [ -n "$rc" ]; then
43 echo "$SYSTEMD_HWDB returned $rc"
44 exit $rc
45fi
46
30dc7898
MP
47if [ ! -e "$D/etc/udev/hwdb.bin" ]; then
48 echo "$D/etc/udev/hwdb.bin was not generated"
49 exit 1
50fi
49141e0c
ZJS
51
52# Test "bad" properties" — warnings required, errors not allowed
53rm -f "$D/etc/udev/hwdb.bin" "$D/etc/udev/hwdb.d"
54
55ln -s "$ROOTDIR/test/hwdb" "$D/etc/udev/hwdb.d"
56err=$("$SYSTEMD_HWDB" update --root "$D" 2>&1 >/dev/null) && rc= || rc=$?
57if [ -n "$rc" ]; then
58 echo "$SYSTEMD_HWDB returned $rc"
59 exit $rc
60fi
61if [ -n "$err" ]; then
62 echo "Expected warnings"
63 echo "$err"
64else
65 echo "$SYSTEMD_HWDB unexpectedly printed no warnings"
66 exit 1
67fi
68
69if [ ! -e "$D/etc/udev/hwdb.bin" ]; then
70 echo "$D/etc/udev/hwdb.bin was not generated"
71 exit 1
72fi