From 11c3088cb1cc119ddbee6a8920efec54e749ff4a Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Wed, 4 Jan 2023 11:20:49 +0100 Subject: [PATCH] add simple test for parsing default config Related: #2143264 --- tests/defconfig/runtest.sh | 30 ++++++++++++++++++++++++++++++ tests/tests.yml | 9 +++++++++ 2 files changed, 39 insertions(+) create mode 100755 tests/defconfig/runtest.sh create mode 100644 tests/tests.yml diff --git a/tests/defconfig/runtest.sh b/tests/defconfig/runtest.sh new file mode 100755 index 0000000..0fc523b --- /dev/null +++ b/tests/defconfig/runtest.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Test if synce4l can parse default configuration + +set -ex + +# Find a nonexistent network device +i=1 +while ip link show eth$i &> /dev/null; do + i=$((i + 1)) +done +eth=eth$i + +tmpconf=$(mktemp) + +sed "s/^\[eth0\]/\[eth$i\]/" < /etc/synce4l.conf > "$tmpconf" + +out=$(synce4l -m -q -l 7 -f "$tmpconf" 2>&1 || :) + +echo "$out" | grep -q "config item synce1" +echo "$out" | grep -q "ioctl SIOCGIFHWADDR failed: No such device" + +echo "unknownoption 1" >> "$tmpconf" + +out=$(synce4l -m -q -l 7 -f "$tmpconf" 2>&1 || :) + +echo "$out" | grep -q "failed to parse configuration file" + +rm "$tmpconf" + +exit 0 diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..97de2fe --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,9 @@ +- hosts: localhost + roles: + - role: standard-test-basic + tags: + - classic + tests: + - defconfig + required_packages: + - iproute