summaryrefslogtreecommitdiffhomepage
path: root/src/tests/netns.sh
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-10-04 04:24:36 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-10-05 15:22:00 +0200
commit38b722ccee5c68fc49aa2d59172a08148d01f7df (patch)
treef3c04591b91cbdaedcd28d05dc8e6389d1cb3379 /src/tests/netns.sh
parent8a7c439c858edbd65cbf44a3a5f68581093884d2 (diff)
send: put keypair reference
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/tests/netns.sh')
-rwxr-xr-xsrc/tests/netns.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/tests/netns.sh b/src/tests/netns.sh
index a11fb3f..a3145b8 100755
--- a/src/tests/netns.sh
+++ b/src/tests/netns.sh
@@ -39,6 +39,7 @@ ip2() { pretty 2 "ip $*"; ip -n $netns2 "$@"; }
sleep() { read -t "$1" -N 0 || true; }
waitiperf() { pretty "${1//*-}" "wait for iperf:5201"; while [[ $(ss -N "$1" -tlp 'sport = 5201') != *iperf3* ]]; do sleep 0.1; done; }
waitncatudp() { pretty "${1//*-}" "wait for udp:1111"; while [[ $(ss -N "$1" -ulp 'sport = 1111') != *ncat* ]]; do sleep 0.1; done; }
+waitncattcp() { pretty "${1//*-}" "wait for tcp:1111"; while [[ $(ss -N "$1" -tlp 'sport = 1111') != *ncat* ]]; do sleep 0.1; done; }
waitiface() { pretty "${1//*-}" "wait for $2 to come up"; ip netns exec "$1" bash -c "while [[ \$(< \"/sys/class/net/$2/operstate\") != up ]]; do read -t .1 -N 0 || true; done;"; }
cleanup() {
@@ -405,4 +406,22 @@ while read -r line; do
done < <(n0 wg show wg0 allowed-ips)
((i == 40))
ip0 link del wg0
+
! n0 wg show doesnotexist || false
+
+declare -A objects
+n0 ncat -i 1 -l -p 1111 < /dev/kmsg &
+waitncattcp $netns0
+while read -r line; do
+ [[ $line =~ .*(wg[0-9]+:\ [A-Z][a-z]+\ [0-9]+)\ .*(created|destroyed).* ]] || continue
+ objects["${BASH_REMATCH[1]}"]+="${BASH_REMATCH[2]}"
+done < <(n0 ncat -i 1 127.0.0.1 1111)
+alldeleted=1
+for object in "${!objects[@]}"; do
+ if [[ ${objects["$object"]} != *createddestroyed ]]; then
+ echo "Error: $object: merely ${objects["$object"]}" >&3
+ alldeleted=0
+ fi
+done
+[[ $alldeleted -eq 1 ]]
+pretty "" "Objects that were created were also destroyed."