Home | History | Annotate | Download | only in test
      1 #!/bin/sh
      2 # 
      3 # usage: rtpw_test <rtpw_commands>
      4 # 
      5 # tests the rtpw sender and receiver functions
      6 
      7 RTPW=./rtpw
      8 DEST_PORT=9999
      9 DURATION=3
     10 
     11 key=2b2edc5034f61a72345ca5986d7bfd0189aa6dc2ecab32fd9af74df6dfc6
     12 
     13 ARGS="-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 
     21 killall rtpw 2>/dev/null
     22 
     23 if test -x $RTPW; then
     24 
     25 echo  $0 ": starting rtpw receiver process... "
     26 
     27 $RTPW $* $ARGS -r 0.0.0.0 $DEST_PORT  &
     28 
     29 receiver_pid=$!
     30 
     31 echo $0 ": receiver PID = $receiver_pid"
     32 
     33 sleep 1 
     34 
     35 # verify that the background job is running
     36 ps | grep -q $receiver_pid
     37 retval=$?
     38 echo $retval
     39 if [ $retval != 0 ]; then
     40     echo $0 ": error"
     41     exit 254
     42 fi
     43 
     44 echo  $0 ": starting rtpw sender process..."
     45 
     46 $RTPW $* $ARGS -s 127.0.0.1 $DEST_PORT  &
     47 
     48 sender_pid=$!
     49 
     50 echo $0 ": sender PID = $sender_pid"
     51 
     52 # verify that the background job is running
     53 ps | grep -q $sender_pid
     54 retval=$?
     55 echo $retval
     56 if [ $retval != 0 ]; then
     57     echo $0 ": error"
     58     exit 255
     59 fi
     60 
     61 sleep $DURATION
     62 
     63 kill $receiver_pid
     64 kill $sender_pid
     65 
     66 echo $0 ": done (test passed)"
     67 
     68 else 
     69 
     70 echo "error: can't find executable" $RTPW
     71 exit 1
     72 
     73 fi
     74 
     75 # EOF
     76 
     77 
     78