projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add support for meson build system
[tinc]
/
test
/
ns-ping.test
diff --git
a/test/ns-ping.test
b/test/ns-ping.test
index
54a9199
..
33e7270
100755
(executable)
--- a/
test/ns-ping.test
+++ b/
test/ns-ping.test
@@
-1,18
+1,26
@@
#!/bin/sh
#!/bin/sh
-# shellcheck
source=testlib.sh
-.
./testlib.sh
+# shellcheck
disable=SC1090
+.
"$TESTLIB_PATH"
-echo "[STEP] Skip this test if we aren't root or if 'ip netns' does not exist"
-
-test "$(id -u)" = "0" || exit $EXIT_SKIP_TEST
-test -e /dev/net/tun || exit $EXIT_SKIP_TEST
-ip netns list || exit $EXIT_SKIP_TEST
+require_root "$0" "$@"
+test -e /dev/net/tun || exit "$EXIT_SKIP_TEST"
+ip netns list || exit "$EXIT_SKIP_TEST"
ip_foo=192.168.1.1
ip_bar=192.168.1.2
mask=24
ip_foo=192.168.1.1
ip_bar=192.168.1.2
mask=24
+echo [STEP] Create network namespaces
+
+ip netns add ping.test1
+ip netns add ping.test2
+
+cleanup_hook() {
+ ip netns del ping.test1
+ ip netns del ping.test2
+}
+
echo [STEP] Initialize two nodes
tinc foo <<EOF
echo [STEP] Initialize two nodes
tinc foo <<EOF
@@
-26,7
+34,6
@@
EOF
# shellcheck disable=SC2016
create_script foo tinc-up "
# shellcheck disable=SC2016
create_script foo tinc-up "
- ip netns add ping.test1
ip link set dev \$INTERFACE netns ping.test1
ip netns exec ping.test1 ip addr add $ip_foo/$mask dev \$INTERFACE
ip netns exec ping.test1 ip link set \$INTERFACE up
ip link set dev \$INTERFACE netns ping.test1
ip netns exec ping.test1 ip addr add $ip_foo/$mask dev \$INTERFACE
ip netns exec ping.test1 ip link set \$INTERFACE up
@@
-42,7
+49,6
@@
EOF
# shellcheck disable=SC2016
create_script bar tinc-up "
# shellcheck disable=SC2016
create_script bar tinc-up "
- ip netns add ping.test2
ip link set dev \$INTERFACE netns ping.test2
ip netns exec ping.test2 ip addr add $ip_bar/$mask dev \$INTERFACE
ip netns exec ping.test2 ip link set \$INTERFACE up
ip link set dev \$INTERFACE netns ping.test2
ip netns exec ping.test2 ip addr add $ip_bar/$mask dev \$INTERFACE
ip netns exec ping.test2 ip link set \$INTERFACE up
@@
-72,8
+78,3
@@
tinc bar add ConnectTo foo
wait_script bar hosts/foo-up
ip netns exec ping.test1 ping -W1 -c3 $ip_bar
wait_script bar hosts/foo-up
ip netns exec ping.test1 ping -W1 -c3 $ip_bar
-
-echo [STEP] Clean up
-
-ip netns del ping.test2
-ip netns del ping.test1