summaryrefslogtreecommitdiffstats
path: root/test/test-network-generator-conversion.sh
blob: d0d083451821511d7e7c77b4f57dc3dc5f5c5ad1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
set -ex

if [[ -n "$1" ]]; then
    generator=$1
elif [[ -x /usr/lib/systemd/systemd-network-generator ]]; then
    generator=/usr/lib/systemd/systemd-network-generator
elif [[ -x /lib/systemd/systemd-network-generator ]]; then
    generator=/lib/systemd/systemd-network-generator
else
    exit 1
fi

src="$(dirname "$0")/testdata/test-network-generator-conversion"

for f in "$src"/test-*.input; do
    echo "*** Running $f"

    (
        out=$(mktemp --directory)
        trap "rm -rf '$out'" EXIT INT QUIT PIPE

        $generator --root "$out" -- $(cat $f)

        if ! diff -u "$out"/run/systemd/network ${f%.input}.expected; then
            echo "**** Unexpected output for $f"
            exit 1
        fi
    ) || exit 1
done