]>
git.ipfire.org Git - thirdparty/systemd.git/blob - test/hwdb-test.sh
2 # SPDX-License-Identifier: LGPL-2.1+
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>
10 # systemd is free software; you can redistribute it and/or modify it
11 # under the terms of the GNU Lesser General Public License as published by
12 # the Free Software Foundation; either version 2.1 of the License, or
13 # (at your option) any later version.
15 # systemd is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # Lesser General Public License for more details.
20 # You should have received a copy of the GNU Lesser General Public License
21 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
25 export SYSTEMD_LOG_LEVEL
=info
26 ROOTDIR
=$
(dirname $
(dirname $
(readlink
-f $0)))
27 SYSTEMD_HWDB
=.
/systemd-hwdb
29 if [ ! -x "$SYSTEMD_HWDB" ]; then
30 echo "$SYSTEMD_HWDB does not exist, please build first"
34 D
=$
(mktemp
--directory)
35 trap "rm -rf '$D'" EXIT INT QUIT PIPE
36 mkdir
-p "$D/etc/udev"
37 ln -s "$ROOTDIR/hwdb" "$D/etc/udev/hwdb.d"
39 # Test "good" properties" — no warnings or errors allowed
40 err
=$
("$SYSTEMD_HWDB" update
--root "$D" 2>&1 >/dev
/null
) && rc
= || rc
=$?
41 if [ -n "$err" ]; then
46 echo "$SYSTEMD_HWDB returned $rc"
50 if [ ! -e "$D/etc/udev/hwdb.bin" ]; then
51 echo "$D/etc/udev/hwdb.bin was not generated"
55 # Test "bad" properties" — warnings required, errors not allowed
56 rm -f "$D/etc/udev/hwdb.bin" "$D/etc/udev/hwdb.d"
58 ln -s "$ROOTDIR/test/hwdb" "$D/etc/udev/hwdb.d"
59 err
=$
("$SYSTEMD_HWDB" update
--root "$D" 2>&1 >/dev
/null
) && rc
= || rc
=$?
61 echo "$SYSTEMD_HWDB returned $rc"
64 if [ -n "$err" ]; then
65 echo "Expected warnings"
68 echo "$SYSTEMD_HWDB unexpectedly printed no warnings"
72 if [ ! -e "$D/etc/udev/hwdb.bin" ]; then
73 echo "$D/etc/udev/hwdb.bin was not generated"