summaryrefslogtreecommitdiff
path: root/test.sh
blob: e14512b4f44e054f33ccdecadc226687f6dcf6a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh
# this script tests basic udpastcp functionality.

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."
    exit 1
fi