summaryrefslogtreecommitdiff
path: root/test.sh
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2016-07-06 20:35:16 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2016-07-06 20:35:16 -0400
commite6cec2f2553a4187a09d92f3a79c0cc0b5049b79 (patch)
tree24b2e9b9c53d2628d48857695cdd2b29d55c9e31 /test.sh
parentc68c67ce7d88dcfc9db29e572d60e1c43ddb2519 (diff)
downloadudpastcp-e6cec2f2553a4187a09d92f3a79c0cc0b5049b79.tar.xz
udpastcp-e6cec2f2553a4187a09d92f3a79c0cc0b5049b79.zip
Add IPv4 support.
Diffstat (limited to 'test.sh')
-rwxr-xr-xtest.sh27
1 files changed, 18 insertions, 9 deletions
diff --git a/test.sh b/test.sh
index c0668fb..842d530 100755
--- a/test.sh
+++ b/test.sh
@@ -1,17 +1,17 @@
#!/bin/sh
# this script tests basic udpastcp functionality.
-test1() {
+test_bidi() {
(
pids=
trap 'kill $pids' EXIT
- ./udpastcp client localhost 36563 localhost 64109 &
+ ./udpastcp client "$1" 36563 "$1" 64109 &
pids="$!"
- ./udpastcp server localhost 64109 localhost 41465 &
+ ./udpastcp server "$1" 64109 "$1" 41465 &
pids="$pids $!"
- ( ( sleep 0.4; echo BBBBBBBB; ) | socat udp6-listen:41465 - ) &
+ ( ( sleep 0.4; echo BBBBBBBB; ) | socat "udp-listen:41465,pf=${2}" - ) &
pids="$pids $!"
- ( ( sleep 0.2; echo AAAAAAAA; ) | socat - 'udp-connect:[::1]:36563' ) &
+ ( ( sleep 0.2; echo AAAAAAAA; ) | socat - "udp-connect:localhost:36563,pf=${2}" ) &
pids="$pids $!"
sleep 0.5
)
@@ -20,9 +20,18 @@ test1() {
nl='
'
-if [ "$( test1 )" = "AAAAAAAA${nl}BBBBBBBB" ]; then
- echo "Test succeeded."
+if [ "$( test_bidi 127.0.0.1 ip4 )" = "AAAAAAAA${nl}BBBBBBBB" ]; then
+ echo "IPv4 test succeeded."
else
- echo "Test failed."
- exit 1
+ echo "IPv4 test failed."
+ r=1
fi
+
+if [ "$( test_bidi ::1 ip6 )" = "AAAAAAAA${nl}BBBBBBBB" ]; then
+ echo "IPv6 test succeeded."
+else
+ echo "IPv6 test failed."
+ r=1
+fi
+
+exit $r