1#!/bin/sh
2# 
3# usage: rtpw_test <rtpw_commands>
4# 
5# tests the rtpw sender and receiver functions
6
7RTPW=./rtpw
8DEST_PORT=9999
9DURATION=3
10
11key=2b2edc5034f61a72345ca5986d7bfd0189aa6dc2ecab32fd9af74df6dfc6
12
13ARGS="-k $key -ae"
14
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
21killall rtpw 2>/dev/null
22
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
66echo $0 ": done (test passed)"
67
68else 
69
70echo "error: can't find executable" $RTPW
71exit 1
72
73fi
74
75# EOF
76
77
78