blob: cd2aa6ab19b05ca317298d4f34ffc3479fad7631 [file] [log] [blame]
David McGrewc79548c2006-06-13 15:17:57 +00001#!/bin/sh
2#
3# usage: rtpw_test <rtpw_commands>
4#
5# tests the rtpw sender and receiver functions
6
Jonathan Lennoxfc9ab4e2010-05-14 22:59:38 +00007RTPW=./rtpw
David McGrewc79548c2006-06-13 15:17:57 +00008DEST_PORT=9999
9DURATION=3
10
Christian Oien9e4c0912014-10-29 09:11:16 +010011key=Ky7cUDT2GnI0XKWYbXv9AYmqbcLsqzL9mvdN9t/G
David McGrewc79548c2006-06-13 15:17:57 +000012
Christian Oien9e4c0912014-10-29 09:11:16 +010013ARGS="-b $key -a -e 128"
David McGrewc79548c2006-06-13 15:17:57 +000014
15# First, we run "killall" to get rid of all existing rtpw processes.
16# This step also enables this script to clean up after itself; if this
17# script is interrupted after the rtpw processes are started but before
18# they are killed, those processes will linger. Re-running the script
19# will get rid of them.
20
Jonathan Lennoxcb47eb92010-05-14 23:00:44 +000021killall rtpw 2>/dev/null
David McGrewc79548c2006-06-13 15:17:57 +000022
23if test -x $RTPW; then
24
25echo $0 ": starting rtpw receiver process... "
26
27$RTPW $* $ARGS -r 0.0.0.0 $DEST_PORT &
28
29receiver_pid=$!
30
31echo $0 ": receiver PID = $receiver_pid"
32
33sleep 1
34
35# verify that the background job is running
36ps | grep -q $receiver_pid
37retval=$?
38echo $retval
39if [ $retval != 0 ]; then
40 echo $0 ": error"
41 exit 254
42fi
43
44echo $0 ": starting rtpw sender process..."
45
46$RTPW $* $ARGS -s 127.0.0.1 $DEST_PORT &
47
48sender_pid=$!
49
50echo $0 ": sender PID = $sender_pid"
51
52# verify that the background job is running
53ps | grep -q $sender_pid
54retval=$?
55echo $retval
56if [ $retval != 0 ]; then
57 echo $0 ": error"
58 exit 255
59fi
60
61sleep $DURATION
62
63kill $receiver_pid
64kill $sender_pid
65
Jonathan Lennox44236052010-05-17 19:35:20 +000066wait $receiver_pid
67wait $sender_pid
68
jfigus8c36da22013-10-01 16:41:19 -040069
70key=033490ba9e82994fc21013395739038992b2edc5034f61a72345ca598d7bfd0189aa6dc2ecab32fd9af74df6dfc6
71
72ARGS="-k $key -a -e 256"
73
74echo $0 ": starting rtpw receiver process... "
75
76$RTPW $* $ARGS -r 0.0.0.0 $DEST_PORT &
77
78receiver_pid=$!
79
80echo $0 ": receiver PID = $receiver_pid"
81
82sleep 1
83
84# verify that the background job is running
85ps | grep -q $receiver_pid
86retval=$?
87echo $retval
88if [ $retval != 0 ]; then
89 echo $0 ": error"
90 exit 254
91fi
92
93echo $0 ": starting rtpw sender process..."
94
95$RTPW $* $ARGS -s 127.0.0.1 $DEST_PORT &
96
97sender_pid=$!
98
99echo $0 ": sender PID = $sender_pid"
100
101# verify that the background job is running
102ps | grep -q $sender_pid
103retval=$?
104echo $retval
105if [ $retval != 0 ]; then
106 echo $0 ": error"
107 exit 255
108fi
109
110sleep $DURATION
111
112kill $receiver_pid
113kill $sender_pid
114
115wait $receiver_pid
116wait $sender_pid
117
David McGrewc79548c2006-06-13 15:17:57 +0000118echo $0 ": done (test passed)"
119
120else
121
122echo "error: can't find executable" $RTPW
123exit 1
124
125fi
126
127# EOF
128
129