]>
Commit | Line | Data |
---|---|---|
30dc7898 | 1 | #!/bin/sh |
d9215cd8 ZJS |
2 | # SPDX-License-Identifier: LGPL-2.1+ |
3 | # | |
4 | # Call built systemd-hwdb update on our hwdb files to ensure that they parse | |
30dc7898 MP |
5 | # without error |
6 | # | |
7 | # (C) 2016 Canonical Ltd. | |
8 | # Author: Martin Pitt <martin.pitt@ubuntu.com> | |
9 | # | |
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. | |
d9215cd8 | 14 | # |
30dc7898 MP |
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. | |
19 | # | |
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/>. | |
22 | ||
23 | set -e | |
24 | ||
07b3a026 | 25 | export SYSTEMD_LOG_LEVEL=info |
30dc7898 | 26 | ROOTDIR=$(dirname $(dirname $(readlink -f $0))) |
fdf666bc | 27 | SYSTEMD_HWDB=./systemd-hwdb |
30dc7898 MP |
28 | |
29 | if [ ! -x "$SYSTEMD_HWDB" ]; then | |
30 | echo "$SYSTEMD_HWDB does not exist, please build first" | |
31 | exit 1 | |
32 | fi | |
33 | ||
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" | |
8ce20692 | 38 | |
49141e0c | 39 | # Test "good" properties" — no warnings or errors allowed |
8ce20692 | 40 | err=$("$SYSTEMD_HWDB" update --root "$D" 2>&1 >/dev/null) && rc= || rc=$? |
30dc7898 MP |
41 | if [ -n "$err" ]; then |
42 | echo "$err" | |
8ce20692 | 43 | exit ${rc:-1} |
30dc7898 | 44 | fi |
8ce20692 ZJS |
45 | if [ -n "$rc" ]; then |
46 | echo "$SYSTEMD_HWDB returned $rc" | |
47 | exit $rc | |
48 | fi | |
49 | ||
30dc7898 MP |
50 | if [ ! -e "$D/etc/udev/hwdb.bin" ]; then |
51 | echo "$D/etc/udev/hwdb.bin was not generated" | |
52 | exit 1 | |
53 | fi | |
49141e0c ZJS |
54 | |
55 | # Test "bad" properties" — warnings required, errors not allowed | |
56 | rm -f "$D/etc/udev/hwdb.bin" "$D/etc/udev/hwdb.d" | |
57 | ||
58 | ln -s "$ROOTDIR/test/hwdb" "$D/etc/udev/hwdb.d" | |
59 | err=$("$SYSTEMD_HWDB" update --root "$D" 2>&1 >/dev/null) && rc= || rc=$? | |
60 | if [ -n "$rc" ]; then | |
61 | echo "$SYSTEMD_HWDB returned $rc" | |
62 | exit $rc | |
63 | fi | |
64 | if [ -n "$err" ]; then | |
65 | echo "Expected warnings" | |
66 | echo "$err" | |
67 | else | |
68 | echo "$SYSTEMD_HWDB unexpectedly printed no warnings" | |
69 | exit 1 | |
70 | fi | |
71 | ||
72 | if [ ! -e "$D/etc/udev/hwdb.bin" ]; then | |
73 | echo "$D/etc/udev/hwdb.bin was not generated" | |
74 | exit 1 | |
75 | fi |