David McGrew | c79548c | 2006-06-13 15:17:57 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # usage: rtpw_test <rtpw_commands> |
| 4 | # |
| 5 | # tests the rtpw sender and receiver functions |
| 6 | |
Jonathan Lennox | fc9ab4e | 2010-05-14 22:59:38 +0000 | [diff] [blame] | 7 | RTPW=./rtpw |
David McGrew | c79548c | 2006-06-13 15:17:57 +0000 | [diff] [blame] | 8 | DEST_PORT=9999 |
| 9 | DURATION=3 |
| 10 | |
Christian Oien | 9e4c091 | 2014-10-29 09:11:16 +0100 | [diff] [blame] | 11 | key=Ky7cUDT2GnI0XKWYbXv9AYmqbcLsqzL9mvdN9t/G |
David McGrew | c79548c | 2006-06-13 15:17:57 +0000 | [diff] [blame] | 12 | |
Christian Oien | 9e4c091 | 2014-10-29 09:11:16 +0100 | [diff] [blame] | 13 | ARGS="-b $key -a -e 128" |
David McGrew | c79548c | 2006-06-13 15:17:57 +0000 | [diff] [blame] | 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 | |
Jonathan Lennox | cb47eb9 | 2010-05-14 23:00:44 +0000 | [diff] [blame] | 21 | killall rtpw 2>/dev/null |
David McGrew | c79548c | 2006-06-13 15:17:57 +0000 | [diff] [blame] | 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 | |
Jonathan Lennox | 4423605 | 2010-05-17 19:35:20 +0000 | [diff] [blame] | 66 | wait $receiver_pid |
| 67 | wait $sender_pid |
| 68 | |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 69 | |
| 70 | key=033490ba9e82994fc21013395739038992b2edc5034f61a72345ca598d7bfd0189aa6dc2ecab32fd9af74df6dfc6 |
| 71 | |
| 72 | ARGS="-k $key -a -e 256" |
| 73 | |
| 74 | echo $0 ": starting rtpw receiver process... " |
| 75 | |
| 76 | $RTPW $* $ARGS -r 0.0.0.0 $DEST_PORT & |
| 77 | |
| 78 | receiver_pid=$! |
| 79 | |
| 80 | echo $0 ": receiver PID = $receiver_pid" |
| 81 | |
| 82 | sleep 1 |
| 83 | |
| 84 | # verify that the background job is running |
| 85 | ps | grep -q $receiver_pid |
| 86 | retval=$? |
| 87 | echo $retval |
| 88 | if [ $retval != 0 ]; then |
| 89 | echo $0 ": error" |
| 90 | exit 254 |
| 91 | fi |
| 92 | |
| 93 | echo $0 ": starting rtpw sender process..." |
| 94 | |
| 95 | $RTPW $* $ARGS -s 127.0.0.1 $DEST_PORT & |
| 96 | |
| 97 | sender_pid=$! |
| 98 | |
| 99 | echo $0 ": sender PID = $sender_pid" |
| 100 | |
| 101 | # verify that the background job is running |
| 102 | ps | grep -q $sender_pid |
| 103 | retval=$? |
| 104 | echo $retval |
| 105 | if [ $retval != 0 ]; then |
| 106 | echo $0 ": error" |
| 107 | exit 255 |
| 108 | fi |
| 109 | |
| 110 | sleep $DURATION |
| 111 | |
| 112 | kill $receiver_pid |
| 113 | kill $sender_pid |
| 114 | |
| 115 | wait $receiver_pid |
| 116 | wait $sender_pid |
| 117 | |
David McGrew | c79548c | 2006-06-13 15:17:57 +0000 | [diff] [blame] | 118 | echo $0 ": done (test passed)" |
| 119 | |
| 120 | else |
| 121 | |
| 122 | echo "error: can't find executable" $RTPW |
| 123 | exit 1 |
| 124 | |
| 125 | fi |
| 126 | |
| 127 | # EOF |
| 128 | |
| 129 | |