]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/hwdb-test.sh
Merge pull request #12802 from irtimmer/fix-openssl
[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>
30dc7898
MP
9
10set -e
11
07b3a026 12export SYSTEMD_LOG_LEVEL=info
30dc7898 13ROOTDIR=$(dirname $(dirname $(readlink -f $0)))
fdf666bc 14SYSTEMD_HWDB=./systemd-hwdb
30dc7898
MP
15
16if [ ! -x "$SYSTEMD_HWDB" ]; then
17 echo "$SYSTEMD_HWDB does not exist, please build first"
18 exit 1
19fi
20
21D=$(mktemp --directory)
22trap "rm -rf '$D'" EXIT INT QUIT PIPE
23mkdir -p "$D/etc/udev"
24ln -s "$ROOTDIR/hwdb" "$D/etc/udev/hwdb.d"
8ce20692 25
49141e0c 26# Test "good" properties" — no warnings or errors allowed
8ce20692 27err=$("$SYSTEMD_HWDB" update --root "$D" 2>&1 >/dev/null) && rc= || rc=$?
30dc7898
MP
28if [ -n "$err" ]; then
29 echo "$err"
8ce20692 30 exit ${rc:-1}
30dc7898 31fi
8ce20692
ZJS
32if [ -n "$rc" ]; then
33 echo "$SYSTEMD_HWDB returned $rc"
34 exit $rc
35fi
36
30dc7898
MP
37if [ ! -e "$D/etc/udev/hwdb.bin" ]; then
38 echo "$D/etc/udev/hwdb.bin was not generated"
39 exit 1
40fi
49141e0c
ZJS
41
42# Test "bad" properties" — warnings required, errors not allowed
43rm -f "$D/etc/udev/hwdb.bin" "$D/etc/udev/hwdb.d"
44
45ln -s "$ROOTDIR/test/hwdb" "$D/etc/udev/hwdb.d"
46err=$("$SYSTEMD_HWDB" update --root "$D" 2>&1 >/dev/null) && rc= || rc=$?
47if [ -n "$rc" ]; then
48 echo "$SYSTEMD_HWDB returned $rc"
49 exit $rc
50fi
51if [ -n "$err" ]; then
52 echo "Expected warnings"
53 echo "$err"
54else
55 echo "$SYSTEMD_HWDB unexpectedly printed no warnings"
56 exit 1
57fi
58
59if [ ! -e "$D/etc/udev/hwdb.bin" ]; then
60 echo "$D/etc/udev/hwdb.bin was not generated"
61 exit 1
62fi