]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/hwdb-test.sh
test-cpu-set-util.c: fix typo in comment (#6916)
[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=./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 # Test "good" properties" — no warnings or errors allowed
37 err=$("$SYSTEMD_HWDB" update --root "$D" 2>&1 >/dev/null) && rc= || rc=$?
38 if [ -n "$err" ]; then
39 echo "$err"
40 exit ${rc:-1}
41 fi
42 if [ -n "$rc" ]; then
43 echo "$SYSTEMD_HWDB returned $rc"
44 exit $rc
45 fi
46
47 if [ ! -e "$D/etc/udev/hwdb.bin" ]; then
48 echo "$D/etc/udev/hwdb.bin was not generated"
49 exit 1
50 fi
51
52 # Test "bad" properties" — warnings required, errors not allowed
53 rm -f "$D/etc/udev/hwdb.bin" "$D/etc/udev/hwdb.d"
54
55 ln -s "$ROOTDIR/test/hwdb" "$D/etc/udev/hwdb.d"
56 err=$("$SYSTEMD_HWDB" update --root "$D" 2>&1 >/dev/null) && rc= || rc=$?
57 if [ -n "$rc" ]; then
58 echo "$SYSTEMD_HWDB returned $rc"
59 exit $rc
60 fi
61 if [ -n "$err" ]; then
62 echo "Expected warnings"
63 echo "$err"
64 else
65 echo "$SYSTEMD_HWDB unexpectedly printed no warnings"
66 exit 1
67 fi
68
69 if [ ! -e "$D/etc/udev/hwdb.bin" ]; then
70 echo "$D/etc/udev/hwdb.bin was not generated"
71 exit 1
72 fi