summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2016-07-02 08:58:13 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2016-07-02 08:58:13 -0400
commitaac5ecd47b3008d770671a024c5f078fd74640a2 (patch)
tree6cb00825e76b28c6235014c5a0f1a8fced41b21a
parent03ab3332e411ce1980b9e12f3f095f867a4f0013 (diff)
downloadudpastcp-aac5ecd47b3008d770671a024c5f078fd74640a2.tar.xz
udpastcp-aac5ecd47b3008d770671a024c5f078fd74640a2.zip
Add bidirectional testing.
-rwxr-xr-xtest.sh34
1 files changed, 21 insertions, 13 deletions
diff --git a/test.sh b/test.sh
index 432128f..e14512b 100755
--- a/test.sh
+++ b/test.sh
@@ -1,18 +1,26 @@
#!/bin/sh
# this script tests basic udpastcp functionality.
-if (
-pids=
-trap 'kill $pids' EXIT
-./udpastcp client localhost 36563 localhost 64109 &
-pids="$!"
-./udpastcp server localhost 64109 localhost 41465 &
-pids+=" $!"
-socat udp6-listen:41465 - &
-pids+=" $!"
-( sleep 1; echo AAAAAAAA | socat - 'udp-connect:[::1]:36563' ) &
-pids+=" $!"
-sleep 2
-) 2>/dev/null | grep AAAAAAAA >/dev/null; then
+
+test1() {
+ (
+ pids=
+ trap 'kill $pids' EXIT
+ ./udpastcp client localhost 36563 localhost 64109 &
+ pids="$!"
+ ./udpastcp server localhost 64109 localhost 41465 &
+ pids+=" $!"
+ ( ( sleep 0.2; echo BBBBBBBB; ) | socat udp6-listen:41465 - ) &
+ pids+=" $!"
+ ( ( sleep 0.1; echo AAAAAAAA; ) | socat - 'udp-connect:[::1]:36563' ) &
+ pids+=" $!"
+ sleep 0.3
+ )
+}
+
+nl='
+'
+
+if [ "$( test1 )" = "AAAAAAAA${nl}BBBBBBBB" ]; then
echo "Test succeeded."
else
echo "Test failed."