summaryrefslogtreecommitdiff
path: root/distro/tests
diff options
context:
space:
mode:
authorJakub Ružička <jakub.ruzicka@nic.cz>2023-04-26 17:26:30 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2023-08-22 14:59:22 +0200
commit31ef5645e9155365db96705b847968008d378658 (patch)
treead4364648faac6de659ce2aeaa90470fabfd5fe9 /distro/tests
parent215f7161c426975ca821f5d3c1866889287dcdbc (diff)
Distro: Add apkg packaging test
The test was written by Maria Matejka, thanks! Run this using apkg test
Diffstat (limited to 'distro/tests')
-rw-r--r--distro/tests/control3
-rwxr-xr-xdistro/tests/test-bird.sh105
2 files changed, 108 insertions, 0 deletions
diff --git a/distro/tests/control b/distro/tests/control
new file mode 100644
index 00000000..f588af8f
--- /dev/null
+++ b/distro/tests/control
@@ -0,0 +1,3 @@
+Tests: test-bird.sh
+Restrictions: needs-root
+Depends: bird2, iproute2
diff --git a/distro/tests/test-bird.sh b/distro/tests/test-bird.sh
new file mode 100755
index 00000000..464be32f
--- /dev/null
+++ b/distro/tests/test-bird.sh
@@ -0,0 +1,105 @@
+#!/bin/bash
+
+set -e
+
+LOCAL=2001:db8:dead::
+
+EXTERNAL=2001:db8:beef::
+EXTERNAL_NET=${EXTERNAL}/48
+EXTERNAL_NH=${LOCAL}beef
+
+LEARN=2001:db8:feed::
+LEARN_NET=${LEARN}/48
+LEARN_NH=${LOCAL}feed
+
+IFACE=bird-test-dummy
+IFACE_EXISTS=false
+
+BIRD_RUNNING=false
+
+D=$(mktemp -d)
+pushd ${D} >/dev/null
+
+stop_bird() {
+ birdc -l down >/dev/null
+ sleep 1
+ grep -q "<FATAL> Shutdown completed" bird.log
+ [ ! -e bird.pid ]
+ [ ! -e bird.ctl ]
+}
+
+cleanup() {
+ if ${BIRD_RUNNING}; then
+ stop_bird
+ if [ -e bird.pid ]; then
+ kill -9 $(<bird.pid)
+ fi
+ fi
+
+ if ${IFACE_EXISTS}; then
+ ip link del ${IFACE}
+ fi
+
+
+ popd > /dev/null
+ rm -rf ${D}
+}
+
+failed() {
+ cleanup
+ exit 1
+}
+
+trap failed ERR
+trap failed INT
+trap failed HUP
+
+ip link add ${IFACE} type dummy
+IFACE_EXISTS=true
+
+ip link set ${IFACE} up
+ip -6 addr add ${LOCAL}/64 dev bird-test-dummy
+
+ip -6 route add ${LEARN_NET} via ${LEARN_NH}
+
+cat >bird.conf <<EOF
+log "bird.log" all;
+
+protocol device {}
+
+protocol kernel {
+ ipv6 { import all; export all; };
+ learn;
+}
+
+protocol static {
+ ipv6;
+ route ${EXTERNAL_NET} via ${EXTERNAL_NH};
+}
+EOF
+
+bird -l -P bird.pid
+
+if [ ! -S bird.ctl ] || [ ! -f bird.pid ] || [ ! -f bird.log ]; then
+ failed
+fi
+
+BIRD_RUNNING=true
+
+ROUTE_INSERTED=false
+for _ in $(seq 10); do
+ if ip -6 route show ${EXTERNAL_NET} | egrep -q "${EXTERNAL_NET} via ${EXTERNAL_NH} dev ${IFACE} proto bird metric [0-9]+ pref medium"; then
+ ROUTE_INSERTED=true
+ break
+ fi
+ sleep 1
+done
+
+$ROUTE_INSERTED || failed
+
+if birdc -l show route "${LEARN_NET}" | egrep -q "Network not found"; then
+ failed
+fi
+
+cleanup
+exit 0