2
0

rtpw_test.sh 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. case $(uname -s) in
  40. *CYGWIN*|*MINGW*)
  41. EXE=".exe"
  42. ;;
  43. *Linux*)
  44. EXE=""
  45. if [ -n "$CRYPTO_LIBDIR" ]
  46. then
  47. export LD_LIBRARY_PATH="$CRYPTO_LIBDIR"
  48. fi
  49. ;;
  50. *Darwin*)
  51. EXE=""
  52. if [ -n "$CRYPTO_LIBDIR" ]
  53. then
  54. export DYLD_LIBRARY_PATH="$CRYPTO_LIBDIR"
  55. fi
  56. ;;
  57. esac
  58. RTPW=./rtpw$EXE
  59. [ -n "$MESON_EXE_WRAPPER" ] && RTPW="$MESON_EXE_WRAPPER $RTPW"
  60. DEST_PORT=9999
  61. DURATION=3
  62. key=Ky7cUDT2GnI0XKWYbXv9AYmqbcLsqzL9mvdN9t/G
  63. ARGS="-b $key -a -e 128"
  64. # First, we run "killall" to get rid of all existing rtpw processes.
  65. # This step also enables this script to clean up after itself; if this
  66. # script is interrupted after the rtpw processes are started but before
  67. # they are killed, those processes will linger. Re-running the script
  68. # will get rid of them.
  69. killall rtpw 2>/dev/null
  70. if test -n $MESON_EXE_WRAPPER || test -x $RTPW; then
  71. echo $0 ": starting rtpw receiver process... "
  72. $RTPW $* $ARGS -r 0.0.0.0 $DEST_PORT &
  73. receiver_pid=$!
  74. echo $0 ": receiver PID = $receiver_pid"
  75. sleep 1
  76. # verify that the background job is running
  77. ps -e | grep -q $receiver_pid
  78. retval=$?
  79. echo $retval
  80. if [ $retval != 0 ]; then
  81. echo $0 ": error"
  82. exit 254
  83. fi
  84. echo $0 ": starting rtpw sender process..."
  85. $RTPW $* $ARGS -s 127.0.0.1 $DEST_PORT &
  86. sender_pid=$!
  87. echo $0 ": sender PID = $sender_pid"
  88. # verify that the background job is running
  89. ps -e | grep -q $sender_pid
  90. retval=$?
  91. echo $retval
  92. if [ $retval != 0 ]; then
  93. echo $0 ": error"
  94. exit 255
  95. fi
  96. sleep $DURATION
  97. kill $receiver_pid
  98. kill $sender_pid
  99. wait $receiver_pid 2>/dev/null
  100. wait $sender_pid 2>/dev/null
  101. key=033490ba9e82994fc21013395739038992b2edc5034f61a72345ca598d7bfd0189aa6dc2ecab32fd9af74df6dfc6
  102. ARGS="-k $key -a -e 256"
  103. echo $0 ": starting rtpw receiver process... "
  104. $RTPW $* $ARGS -r 0.0.0.0 $DEST_PORT &
  105. receiver_pid=$!
  106. echo $0 ": receiver PID = $receiver_pid"
  107. sleep 1
  108. # verify that the background job is running
  109. ps -e | grep -q $receiver_pid
  110. retval=$?
  111. echo $retval
  112. if [ $retval != 0 ]; then
  113. echo $0 ": error"
  114. exit 254
  115. fi
  116. echo $0 ": starting rtpw sender process..."
  117. $RTPW $* $ARGS -s 127.0.0.1 $DEST_PORT &
  118. sender_pid=$!
  119. echo $0 ": sender PID = $sender_pid"
  120. # verify that the background job is running
  121. ps -e | grep -q $sender_pid
  122. retval=$?
  123. echo $retval
  124. if [ $retval != 0 ]; then
  125. echo $0 ": error"
  126. exit 255
  127. fi
  128. sleep $DURATION
  129. kill $receiver_pid
  130. kill $sender_pid
  131. wait $receiver_pid 2>/dev/null
  132. wait $sender_pid 2>/dev/null
  133. echo $0 ": done (test passed)"
  134. else
  135. echo "error: can't find executable" $RTPW
  136. exit 1
  137. fi
  138. # EOF