Makefile.am 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. MAKEFLAGS=-s -k
  2. PRINTF = @PRINTF@
  3. HOST = @host@
  4. TARGET = @target@
  5. BUILD = @build@
  6. nic1 = @nic1@
  7. nic2 = @nic2@
  8. ENABLE_DEBUG = @debug_flag@
  9. TCPPREP=../src/tcpprep --no-arg-comment
  10. TCPREPLAY=../src/tcpreplay
  11. TCPREWRITE=../src/tcprewrite
  12. TCPBRIDGE=../src/tcpbridge
  13. EXTRA_DIST = test.pcap test.auto_bridge test.auto_client test.auto_router \
  14. test.auto_server test.cidr test.comment test.port \
  15. test.prep_config test.primary test.regex test.secondary
  16. test: all
  17. all: clearlog check tcpprep tcpreplay
  18. clearlog:
  19. -rm test.log
  20. check:
  21. $(PRINTF) "%s\n" "NOTICE: Tests must be run as root"
  22. $(PRINTF) "%s\n" "Sending traffic on '$(nic1)' and '$(nic2)'"
  23. # the cache files to be used as the standard; be sure to do a cvs commit
  24. # afterwords!
  25. standard:
  26. $(TCPPREP) -i test.pcap -o test.auto_router -a router
  27. $(TCPPREP) -i test.pcap -o test.auto_bridge -a bridge
  28. $(TCPPREP) -i test.pcap -o test.auto_client -a client
  29. $(TCPPREP) -i test.pcap -o test.auto_server -a server
  30. $(TCPPREP) --load-opts config -o test.prep_config
  31. $(TCPPREP) -i test.pcap -o test.port -p
  32. $(TCPPREP) -i test.pcap -o test.cidr -c '216.27.178.0/24'
  33. $(TCPPREP) -i test.pcap -o test.regex -r '216.27.178.*'
  34. $(TCPPREP) -i test.pcap -o test.comment -C "This is a comment" -p
  35. tcpprep: auto_router auto_bridge auto_client auto_server cidr regex port comment print_info print_comment prep_config
  36. tcprewrite: rewrite_cache rewrite_cidr rewrite_trunc rewrite_pad rewrite_rand rewrite_layer2 rewrite_config
  37. tcpreplay: replay_basic replay_cache replay_pps replay_rate replay_top replay_config replay_multi
  38. prep_config:
  39. $(PRINTF) "%s" "[tcpprep] Config mode test: "
  40. $(PRINTF) "%s\n" "*** [tcpprep] Config mode test: " >>test.log
  41. $(TCPPREP) $(ENABLE_DEBUG) --load-opts=config -o test.$@1 2>>test.log
  42. diff test.$@ test.$@1 >>test.log 2>&1
  43. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  44. auto_router:
  45. $(PRINTF) "%s" "[tcpprep] Auto/Router mode test: "
  46. $(PRINTF) "%s\n" "*** [tcpprep] Auto/Router mode test: " >>test.log
  47. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a router 2>>test.log
  48. diff test.$@ test.$@1 >>test.log 2>&1
  49. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  50. auto_bridge:
  51. $(PRINTF) "%s" "[tcpprep] Auto/Bridge mode test: "
  52. $(PRINTF) "%s\n" "*** [tcpprep] Auto/Bridge mode test: " >>test.log
  53. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a bridge 2>>test.log
  54. diff test.$@ test.$@1 >>test.log 2>&1
  55. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  56. auto_client:
  57. $(PRINTF) "%s" "[tcpprep] Auto/Client mode test: "
  58. $(PRINTF) "%s\n" "*** [tcpprep] Auto/Client mode test: " >>test.log
  59. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a client 2>>test.log
  60. diff test.$@ test.$@1 >>test.log 2>&1
  61. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  62. auto_server:
  63. $(PRINTF) "%s" "[tcpprep] Auto/Server mode test: "
  64. $(PRINTF) "%s\n" "*** [tcpprep] Auto/Server mode test: " >>test.log
  65. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a server 2>>test.log
  66. diff test.$@ test.$@1 >>test.log 2>&1
  67. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  68. regex:
  69. $(PRINTF) "%s" "[tcpprep] Regex mode test: "
  70. $(PRINTF) "%s\n" "*** [tcpprep] Regex mode test: " >>test.log
  71. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -r '216.27.178.*' 2>>test.log
  72. diff test.$@ test.$@1 >>test.log 2>&1
  73. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  74. cidr:
  75. $(PRINTF) "%s" "[tcpprep] CIDR mode test: "
  76. $(PRINTF) "%s\n" "*** [tcpprep] CIDR mode test: " >>test.log
  77. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -c '216.27.178.0/24' 2>>test.log
  78. diff test.$@ test.$@1 >>test.log 2>&1
  79. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  80. port:
  81. $(PRINTF) "%s" "[tcpprep] Port mode test: "
  82. $(PRINTF) "%s\n" "*** [tcpprep] Port mode test: " >>test.log
  83. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -p 2>>test.log
  84. diff test.$@ test.$@1 >>test.log 2>&1
  85. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  86. comment:
  87. $(PRINTF) "%s" "[tcpprep] Comment mode test: "
  88. $(PRINTF) "%s\n" "*** [tcpprep] Comment mode test: " >>test.log
  89. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -C "This is a comment" -p 2>>test.log
  90. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  91. print_comment:
  92. $(PRINTF) "%s" "[tcpprep] Print comment mode test: "
  93. $(PRINTF) "%s\n" "*** [tcpprep] Print comment mode test: " >>test.log
  94. $(TCPPREP) $(ENABLE_DEBUG) -P test.comment >test.$@1 2>>test.log
  95. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  96. print_info:
  97. $(PRINTF) "%s" "[tcpprep] Print info mode test: "
  98. $(PRINTF) "%s\n" "*** [tcpprep] Print info mode test: " >>test.log
  99. $(TCPPREP) $(ENABLE_DEBUG) -I test.comment >test.$@1 2>>test.log
  100. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  101. replay_basic:
  102. $(PRINTF) "%s" "[tcpreplay] Basic test: "
  103. $(PRINTF) "%s\n" "*** [tcpreplay] Basic test: " >>test.log
  104. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -t test.pcap >>test.log 2>&1
  105. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  106. replay_cache:
  107. $(PRINTF) "%s" "[tcpreplay] Cache test: "
  108. $(PRINTF) "%s\n" "*** [tcpreplay] Cache test: " >>test.log
  109. $(TCPREPLAY) $(ENABLE_DEBUG) -c test.cidr -i $(nic1) -I $(nic2) -t test.pcap >>test.log 2>&1
  110. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  111. rewrite_cidr:
  112. $(PRINTF) "%s" "[tcpreplay] CIDR test: "
  113. $(PRINTF) "%s\n" "*** [tcpreplay] CIDR test: " >>test.log
  114. $(TCPREPLAY) $(ENABLE_DEBUG) -C 216.27.178.0/24 -i $(nic1) -I $(nic2) -t test.pcap >>test.log 2>&1
  115. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  116. rewrite_trunc:
  117. $(PRINTF) "%s" "[tcpreplay] Truncate test: "
  118. $(PRINTF) "%s\n" "*** [tcpreplay] Truncate test: " >>test.log
  119. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -u trunc -t test.pcap >>test.log 2>&1
  120. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  121. rewrite_pad:
  122. $(PRINTF) "%s" "[tcpreplay] Pad test: "
  123. $(PRINTF) "%s\n" "*** [tcpreplay] Pad test: " >>test.log
  124. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -u pad -R test.pcap >>test.log 2>&1
  125. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  126. rewrite_rand:
  127. $(PRINTF) "%s" "[tcpreplay] Random IP test: "
  128. $(PRINTF) "%s\n" "*** [tcpreplay] Random IP test: " >>test.log
  129. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -s 666 -R test.pcap >>test.log 2>&1
  130. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  131. replay_include:
  132. $(PRINTF) "%s" "[tcpreplay] Include only test: "
  133. $(PRINTF) "%s\n" "*** [tcpreplay] Include only test: " >>test.log
  134. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -x P:1,5,7-53,88,93-100 -R test.pcap >>test.log 2>&1
  135. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  136. replay_exclude:
  137. $(PRINTF) "%s" "[tcpreplay] Exclude test: "
  138. $(PRINTF) "%s\n" "*** [tcpreplay] Exclude test: " >>test.log
  139. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -X P:1,5,7-53,88,93-100 -R test.pcap >>test.log 2>&1
  140. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  141. rewrite_layer2:
  142. $(PRINTF) "%s" "[tcpreplay] Layer2 test: "
  143. $(PRINTF) "%s\n" "*** [tcpreplay] Layer2 test: " >>test.log
  144. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -2 00,50,da,5d,46,55,0,7,eb,30,a4,c3,08,0 -R test.pcap >>test.log 2>&1
  145. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  146. replay_pps:
  147. $(PRINTF) "%s" "[tcpreplay] Packets/sec test: "
  148. $(PRINTF) "%s\n" "*** [tcpreplay] Packets/sec test: " >>test.log
  149. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -p 25 test.pcap >>test.log 2>&1
  150. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  151. replay_rate:
  152. $(PRINTF) "%s" "[tcpreplay] Mbps test: "
  153. $(PRINTF) "%s\n" "*** [tcpreplay] Mbps test: " >>test.log
  154. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -M 25.0 test.pcap >>test.log 2>&1
  155. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  156. replay_multi:
  157. $(PRINTF) "%s" "[tcpreplay] Multiplier test: "
  158. $(PRINTF) "%s\n" "*** [tcpreplay] Multiplier test: " >>test.log
  159. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -m 25.0 test.pcap >>test.log 2>&1
  160. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  161. replay_top:
  162. $(PRINTF) "%s" "[tcpreplay] Topspeed test: "
  163. $(PRINTF) "%s\n" "*** [tcpreplay] Topspeed test: " >>test.log
  164. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -t test.pcap >>test.log 2>&1
  165. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  166. datadump_mode:
  167. $(PRINTF) "%s" "[tcpreplay] Data dump mode test: "
  168. $(PRINTF) "%s\n" "*** [tcpreplay] Data dump mode test: " >>test.log
  169. $(TCPREPLAY) $(ENABLE_DEBUG) -D -i $(nic1) -j $(nic2) -w primary.data -W secondary.data -c test.cidr -R test.pcap >>test.log 2>&1
  170. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  171. replay_config:
  172. $(PRINTF) "%s" "[tcpreplay] Config file mode test: "
  173. $(PRINTF) "%s\n" "*** [tcpreplay] Config file mode test: " >>test.log
  174. $(TCPREPLAY) $(ENABLE_DEBUG) --load-opts=config test.pcap >>test.log 2>&1
  175. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  176. clean:
  177. rm -f *1 test.log core* *~ primary.data secondary.data
  178. distclean: clean
  179. rm -f Makefile config
  180. maintainer-clean: distclean