]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/hwdb-test.sh
core: use id unit when retrieving unit file state (#8038)
[thirdparty/systemd.git] / test / hwdb-test.sh
CommitLineData
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
23set -e
24
07b3a026 25export SYSTEMD_LOG_LEVEL=info
30dc7898 26ROOTDIR=$(dirname $(dirname $(readlink -f $0)))
fdf666bc 27SYSTEMD_HWDB=./systemd-hwdb
30dc7898
MP
28
29if [ ! -x "$SYSTEMD_HWDB" ]; then
30 echo "$SYSTEMD_HWDB does not exist, please build first"
31 exit 1
32fi
33
34D=$(mktemp --directory)
35trap "rm -rf '$D'" EXIT INT QUIT PIPE
36mkdir -p "$D/etc/udev"
37ln -s "$ROOTDIR/hwdb" "$D/etc/udev/hwdb.d"
8ce20692 38
49141e0c 39# Test "good" properties" — no warnings or errors allowed
8ce20692 40err=$("$SYSTEMD_HWDB" update --root "$D" 2>&1 >/dev/null) && rc= || rc=$?
30dc7898
MP
41if [ -n "$err" ]; then
42 echo "$err"
8ce20692 43 exit ${rc:-1}
30dc7898 44fi
8ce20692
ZJS
45if [ -n "$rc" ]; then
46 echo "$SYSTEMD_HWDB returned $rc"
47 exit $rc
48fi
49
30dc7898
MP
50if [ ! -e "$D/etc/udev/hwdb.bin" ]; then
51 echo "$D/etc/udev/hwdb.bin was not generated"
52 exit 1
53fi
49141e0c
ZJS
54
55# Test "bad" properties" — warnings required, errors not allowed
56rm -f "$D/etc/udev/hwdb.bin" "$D/etc/udev/hwdb.d"
57
58ln -s "$ROOTDIR/test/hwdb" "$D/etc/udev/hwdb.d"
59err=$("$SYSTEMD_HWDB" update --root "$D" 2>&1 >/dev/null) && rc= || rc=$?
60if [ -n "$rc" ]; then
61 echo "$SYSTEMD_HWDB returned $rc"
62 exit $rc
63fi
64if [ -n "$err" ]; then
65 echo "Expected warnings"
66 echo "$err"
67else
68 echo "$SYSTEMD_HWDB unexpectedly printed no warnings"
69 exit 1
70fi
71
72if [ ! -e "$D/etc/udev/hwdb.bin" ]; then
73 echo "$D/etc/udev/hwdb.bin was not generated"
74 exit 1
75fi