rtpw_test.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #!/bin/sh
  2. #
  3. # usage: rtpw_test <rtpw_commands>
  4. #
  5. # tests the rtpw sender and receiver functions
  6. RTPW=./rtpw
  7. DEST_PORT=9999
  8. DURATION=3
  9. key=2b2edc5034f61a72345ca5986d7bfd0189aa6dc2ecab32fd9af74df6dfc6
  10. ARGS="-k $key -a -e 128"
  11. # First, we run "killall" to get rid of all existing rtpw processes.
  12. # This step also enables this script to clean up after itself; if this
  13. # script is interrupted after the rtpw processes are started but before
  14. # they are killed, those processes will linger. Re-running the script
  15. # will get rid of them.
  16. killall rtpw 2>/dev/null
  17. if test -x $RTPW; then
  18. echo $0 ": starting rtpw receiver process... "
  19. $RTPW $* $ARGS -r 0.0.0.0 $DEST_PORT &
  20. receiver_pid=$!
  21. echo $0 ": receiver PID = $receiver_pid"
  22. sleep 1
  23. # verify that the background job is running
  24. ps | grep -q $receiver_pid
  25. retval=$?
  26. echo $retval
  27. if [ $retval != 0 ]; then
  28. echo $0 ": error"
  29. exit 254
  30. fi
  31. echo $0 ": starting rtpw sender process..."
  32. $RTPW $* $ARGS -s 127.0.0.1 $DEST_PORT &
  33. sender_pid=$!
  34. echo $0 ": sender PID = $sender_pid"
  35. # verify that the background job is running
  36. ps | grep -q $sender_pid
  37. retval=$?
  38. echo $retval
  39. if [ $retval != 0 ]; then
  40. echo $0 ": error"
  41. exit 255
  42. fi
  43. sleep $DURATION
  44. kill $receiver_pid
  45. kill $sender_pid
  46. wait $receiver_pid
  47. wait $sender_pid
  48. key=033490ba9e82994fc21013395739038992b2edc5034f61a72345ca598d7bfd0189aa6dc2ecab32fd9af74df6dfc6
  49. ARGS="-k $key -a -e 256"
  50. echo $0 ": starting rtpw receiver process... "
  51. $RTPW $* $ARGS -r 0.0.0.0 $DEST_PORT &
  52. receiver_pid=$!
  53. echo $0 ": receiver PID = $receiver_pid"
  54. sleep 1
  55. # verify that the background job is running
  56. ps | grep -q $receiver_pid
  57. retval=$?
  58. echo $retval
  59. if [ $retval != 0 ]; then
  60. echo $0 ": error"
  61. exit 254
  62. fi
  63. echo $0 ": starting rtpw sender process..."
  64. $RTPW $* $ARGS -s 127.0.0.1 $DEST_PORT &
  65. sender_pid=$!
  66. echo $0 ": sender PID = $sender_pid"
  67. # verify that the background job is running
  68. ps | grep -q $sender_pid
  69. retval=$?
  70. echo $retval
  71. if [ $retval != 0 ]; then
  72. echo $0 ": error"
  73. exit 255
  74. fi
  75. sleep $DURATION
  76. kill $receiver_pid
  77. kill $sender_pid
  78. wait $receiver_pid
  79. wait $sender_pid
  80. echo $0 ": done (test passed)"
  81. else
  82. echo "error: can't find executable" $RTPW
  83. exit 1
  84. fi
  85. # EOF