]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/hwdb-test.sh
systemctl: don't use get_process_comm() on non-local PIDs (#7518)
[thirdparty/systemd.git] / test / hwdb-test.sh
1 #!/bin/sh
2 # SPDX-License-Identifier: LGPL-2.1+
3 #
4 # Call built systemd-hwdb update on our hwdb files to ensure that they parse
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.
14 #
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
25 export SYSTEMD_LOG_LEVEL=info
26 ROOTDIR=$(dirname $(dirname $(readlink -f $0)))
27 SYSTEMD_HWDB=./systemd-hwdb
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"
38
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
42 echo "$err"
43 exit ${rc:-1}
44 fi
45 if [ -n "$rc" ]; then
46 echo "$SYSTEMD_HWDB returned $rc"
47 exit $rc
48 fi
49
50 if [ ! -e "$D/etc/udev/hwdb.bin" ]; then
51 echo "$D/etc/udev/hwdb.bin was not generated"
52 exit 1
53 fi
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