]>
git.ipfire.org Git - thirdparty/systemd.git/blob - test/hwdb-test.sh
2 # SPDX-License-Identifier: LGPL-2.1-or-later
4 # Call built systemd-hwdb update on our hwdb files to ensure that they parse
7 # (C) 2016 Canonical Ltd.
8 # Author: Martin Pitt <martin.pitt@ubuntu.com>
12 export SYSTEMD_LOG_LEVEL
=info
13 ROOTDIR
=$
(dirname $
(dirname $
(readlink
-f $0)))
14 SYSTEMD_HWDB
=.
/systemd-hwdb
16 if [ ! -x "$SYSTEMD_HWDB" ]; then
17 echo "$SYSTEMD_HWDB does not exist, please build first"
21 D
=$
(mktemp
--tmpdir --directory "hwdb-test.XXXXXXXXXX")
22 trap "rm -rf '$D'" EXIT INT QUIT PIPE
23 mkdir
-p "$D/etc/udev"
24 ln -s "$ROOTDIR/hwdb.d" "$D/etc/udev/hwdb.d"
26 # Test "good" properties" — no warnings or errors allowed
27 err
=$
("$SYSTEMD_HWDB" update
--root "$D" 2>&1 >/dev
/null
) && rc
= || rc
=$?
28 if [ -n "$err" ]; then
33 echo "$SYSTEMD_HWDB returned $rc"
37 if [ ! -e "$D/etc/udev/hwdb.bin" ]; then
38 echo "$D/etc/udev/hwdb.bin was not generated"
42 # Test "bad" properties" — warnings required, errors not allowed
43 rm -f "$D/etc/udev/hwdb.bin" "$D/etc/udev/hwdb.d"
45 ln -s "$ROOTDIR/test/hwdb.d" "$D/etc/udev/hwdb.d"
46 err
=$
("$SYSTEMD_HWDB" update
--root "$D" 2>&1 >/dev
/null
) && rc
= || rc
=$?
48 echo "$SYSTEMD_HWDB returned $rc"
51 if [ -n "$err" ]; then
52 echo "Expected warnings"
55 echo "$SYSTEMD_HWDB unexpectedly printed no warnings"
59 if [ ! -e "$D/etc/udev/hwdb.bin" ]; then
60 echo "$D/etc/udev/hwdb.bin was not generated"