1 #!/bin/sh 2 # 3 # usage: rtpw_test <rtpw_commands> 4 # 5 # tests the rtpw sender and receiver functions 6 # Copyright (c) 2001-2006, Cisco Systems, Inc. 7 # All rights reserved. 8 # 9 # Redistribution and use in source and binary forms, with or without 10 # modification, are permitted provided that the following conditions 11 # are met: 12 # 13 # Redistributions of source code must retain the above copyright 14 # notice, this list of conditions and the following disclaimer. 15 # 16 # Redistributions in binary form must reproduce the above 17 # copyright notice, this list of conditions and the following 18 # disclaimer in the documentation and/or other materials provided 19 # with the distribution. 20 # 21 # Neither the name of the Cisco Systems, Inc. nor the names of its 22 # contributors may be used to endorse or promote products derived 23 # from this software without specific prior written permission. 24 # 25 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 28 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 29 # COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 30 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 31 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 34 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 36 # OF THE POSSIBILITY OF SUCH DAMAGE. 37 38 RTPW=./rtpw 39 DEST_PORT=9999 40 DURATION=3 41 42 key=2b2edc5034f61a72345ca5986d7bfd0189aa6dc2ecab32fd9af74df6dfc6 43 44 ARGS="-k $key -ae" 45 46 # First, we run "killall" to get rid of all existing rtpw processes. 47 # This step also enables this script to clean up after itself; if this 48 # script is interrupted after the rtpw processes are started but before 49 # they are killed, those processes will linger. Re-running the script 50 # will get rid of them. 51 52 killall rtpw 2>/dev/null 53 54 if test -x $RTPW; then 55 56 echo $0 ": starting rtpw receiver process... " 57 58 $RTPW $* $ARGS -r 0.0.0.0 $DEST_PORT & 59 60 receiver_pid=$! 61 62 echo $0 ": receiver PID = $receiver_pid" 63 64 sleep 1 65 66 # verify that the background job is running 67 ps | grep -q $receiver_pid 68 retval=$? 69 echo $retval 70 if [ $retval != 0 ]; then 71 echo $0 ": error" 72 exit 254 73 fi 74 75 echo $0 ": starting rtpw sender process..." 76 77 $RTPW $* $ARGS -s 127.0.0.1 $DEST_PORT & 78 79 sender_pid=$! 80 81 echo $0 ": sender PID = $sender_pid" 82 83 # verify that the background job is running 84 ps | grep -q $sender_pid 85 retval=$? 86 echo $retval 87 if [ $retval != 0 ]; then 88 echo $0 ": error" 89 exit 255 90 fi 91 92 sleep $DURATION 93 94 kill $receiver_pid 95 kill $sender_pid 96 97 wait $receiver_pid 98 wait $sender_pid 99 100 echo $0 ": done (test passed)" 101 102 else 103 104 echo "error: can't find executable" $RTPW 105 exit 1 106 107 fi 108 109 # EOF 110 111 112