rtpw_test.sh (4321B)
1 #!/bin/sh 2 # 3 # usage: rtpw_test <rtpw_commands> 4 # 5 # tests the rtpw sender and receiver functions 6 # 7 # Copyright (c) 2001-2017, Cisco Systems, Inc. 8 # All rights reserved. 9 # 10 # Redistribution and use in source and binary forms, with or without 11 # modification, are permitted provided that the following conditions 12 # are met: 13 # 14 # Redistributions of source code must retain the above copyright 15 # notice, this list of conditions and the following disclaimer. 16 # 17 # Redistributions in binary form must reproduce the above 18 # copyright notice, this list of conditions and the following 19 # disclaimer in the documentation and/or other materials provided 20 # with the distribution. 21 # 22 # Neither the name of the Cisco Systems, Inc. nor the names of its 23 # contributors may be used to endorse or promote products derived 24 # from this software without specific prior written permission. 25 # 26 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 29 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 30 # COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 31 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 32 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 33 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 35 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 37 # OF THE POSSIBILITY OF SUCH DAMAGE. 38 # 39 40 case $(uname -s) in 41 *CYGWIN*|*MINGW*) 42 EXE=".exe" 43 ;; 44 *Linux*) 45 EXE="" 46 if [ -n "$CRYPTO_LIBDIR" ] 47 then 48 export LD_LIBRARY_PATH="$CRYPTO_LIBDIR" 49 fi 50 ;; 51 *Darwin*) 52 EXE="" 53 if [ -n "$CRYPTO_LIBDIR" ] 54 then 55 export DYLD_LIBRARY_PATH="$CRYPTO_LIBDIR" 56 fi 57 ;; 58 esac 59 60 RTPW=./rtpw$EXE 61 [ -n "$MESON_EXE_WRAPPER" ] && RTPW="$MESON_EXE_WRAPPER $RTPW" 62 DEST_PORT=9999 63 DURATION=3 64 65 key=Ky7cUDT2GnI0XKWYbXv9AYmqbcLsqzL9mvdN9t/G 66 67 ARGS="-b $key -a -e 128" 68 69 # First, we run "pkill" to get rid of all existing rtpw processes. 70 # This step also enables this script to clean up after itself; if this 71 # script is interrupted after the rtpw processes are started but before 72 # they are killed, those processes will linger. Re-running the script 73 # will get rid of them. 74 75 pkill -x rtpw 2>/dev/null 76 77 if test -n $MESON_EXE_WRAPPER || test -x $RTPW; then 78 79 echo $0 ": starting rtpw receiver process... " 80 81 $RTPW $* $ARGS -r 0.0.0.0 $DEST_PORT & 82 83 receiver_pid=$! 84 85 echo $0 ": receiver PID = $receiver_pid" 86 87 sleep 1 88 89 # verify that the background job is running 90 ps -e | grep -q $receiver_pid 91 retval=$? 92 echo $retval 93 if [ $retval != 0 ]; then 94 echo $0 ": error" 95 exit 254 96 fi 97 98 echo $0 ": starting rtpw sender process..." 99 100 $RTPW $* $ARGS -s 127.0.0.1 $DEST_PORT & 101 102 sender_pid=$! 103 104 echo $0 ": sender PID = $sender_pid" 105 106 # verify that the background job is running 107 ps -e | grep -q $sender_pid 108 retval=$? 109 echo $retval 110 if [ $retval != 0 ]; then 111 echo $0 ": error" 112 exit 255 113 fi 114 115 sleep $DURATION 116 117 kill $receiver_pid 118 kill $sender_pid 119 120 wait $receiver_pid 2>/dev/null 121 wait $sender_pid 2>/dev/null 122 123 124 key=033490ba9e82994fc21013395739038992b2edc5034f61a72345ca598d7bfd0189aa6dc2ecab32fd9af74df6dfc6 125 126 ARGS="-k $key -a -e 256" 127 128 echo $0 ": starting rtpw receiver process... " 129 130 $RTPW $* $ARGS -r 0.0.0.0 $DEST_PORT & 131 132 receiver_pid=$! 133 134 echo $0 ": receiver PID = $receiver_pid" 135 136 sleep 1 137 138 # verify that the background job is running 139 ps -e | grep -q $receiver_pid 140 retval=$? 141 echo $retval 142 if [ $retval != 0 ]; then 143 echo $0 ": error" 144 exit 254 145 fi 146 147 echo $0 ": starting rtpw sender process..." 148 149 $RTPW $* $ARGS -s 127.0.0.1 $DEST_PORT & 150 151 sender_pid=$! 152 153 echo $0 ": sender PID = $sender_pid" 154 155 # verify that the background job is running 156 ps -e | grep -q $sender_pid 157 retval=$? 158 echo $retval 159 if [ $retval != 0 ]; then 160 echo $0 ": error" 161 exit 255 162 fi 163 164 sleep $DURATION 165 166 kill $receiver_pid 167 kill $sender_pid 168 169 wait $receiver_pid 2>/dev/null 170 wait $sender_pid 2>/dev/null 171 172 echo $0 ": done (test passed)" 173 174 else 175 176 echo "error: can't find executable" $RTPW 177 exit 1 178 179 fi 180 181 # EOF