1
0

Makefile.am 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. # $Id$
  2. MAKEFLAGS=-s -k
  3. PRINTF = @PRINTF@
  4. HOST = @host@
  5. TARGET = @target@
  6. BUILD = @build@
  7. nic1 = @nic1@
  8. nic2 = @nic2@
  9. ENABLE_DEBUG = @debug_flag@
  10. TCPPREP=../src/tcpprep --no-arg-comment
  11. TCPREPLAY=../src/tcpreplay
  12. TCPREWRITE=../src/tcprewrite
  13. TCPBRIDGE=../src/tcpbridge
  14. EXTRA_DIST = test.pcap test.auto_bridge test.auto_client test.auto_router \
  15. test.auto_server test.cidr test.comment test.port test.mac \
  16. test.prep_config test.primary test.regex test.secondary \
  17. test.rewrite_seed test.rewrite_portmap test.rewrite_endpoint \
  18. test.rewrite_pnat test.rewrite_pad test.rewrite_trunc \
  19. test.rewrite_mac test.rewrite_layer2 test.rewrite_config \
  20. test.rewrite_skip test.rewrite_dlt
  21. test: all
  22. all: clearlog check tcpprep tcpreplay tcprewrite
  23. clearlog:
  24. -rm test.log
  25. check:
  26. $(PRINTF) "%s\n" "NOTICE: Tests must be run as root"
  27. $(PRINTF) "%s\n" "Sending traffic on '$(nic1)' and '$(nic2)'"
  28. # the cache files to be used as the standard; be sure to do a cvs commit
  29. # afterwords!
  30. standard:
  31. $(TCPPREP) -i test.pcap -o test.auto_router -a router
  32. $(TCPPREP) -i test.pcap -o test.auto_bridge -a bridge
  33. $(TCPPREP) -i test.pcap -o test.auto_client -a client
  34. $(TCPPREP) -i test.pcap -o test.auto_server -a server
  35. $(TCPPREP) --load-opts config -o test.prep_config
  36. $(TCPPREP) -i test.pcap -o test.port -p
  37. $(TCPPREP) -i test.pcap -o test.mac -e 00:02:3b:00:3d:ce
  38. $(TCPPREP) -i test.pcap -o test.cidr -c '216.27.178.0/24'
  39. $(TCPPREP) -i test.pcap -o test.regex -r '216.27.178.*'
  40. $(TCPPREP) -i test.pcap -o test.comment -C "This is a comment" -p
  41. $(TCPREWRITE) -i test.pcap -o test.rewrite_seed -s 55
  42. $(TCPREWRITE) -i test.pcap -o test.rewrite_portmap -r 80:8080
  43. $(TCPREWRITE) -i test.pcap -o test.rewrite_endpoint \
  44. -e 10.10.0.1:10.10.0.2 -c test.auto_router
  45. $(TCPREWRITE) -i test.pcap -o test.rewrite_pnat \
  46. -N 216.27.178.0/24:172.16.0.0/24
  47. $(TCPREWRITE) -i test.pcap -o test.rewrite_pad -F pad
  48. $(TCPREWRITE) -i test.pcap -o test.rewrite_trunc -F trunc
  49. $(TCPREWRITE) -i test.pcap -o test.rewrite_mac \
  50. -D 00:12:13:14:15:16,00:22:33:44:55:66 \
  51. -S 00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router
  52. $(TCPREWRITE) -i test.pcap -o test.rewrite_layer2 \
  53. -l 00,50,da,5d,46,55,0,7,eb,30,a4,c3,08,0
  54. $(TCPREWRITE) -i test.pcap -o test.rewrite_config --vlan=add --vlan-tag=45 \
  55. --vlan-cfi=1 --vlan-pri=5
  56. $(TCPREWRITE) -i test.pcap -o test.rewrite_skip -b -s 55 \
  57. -D 00:12:13:14:15:16,00:22:33:44:55:66 \
  58. -S 00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router
  59. $(TCPREWRITE) -i test.pcap -o test.rewrite_dlt \
  60. --dlink=0x0f,0x00,0x08,0x00 --dlt=104
  61. tcpprep: auto_router auto_bridge auto_client auto_server cidr regex port \
  62. mac comment print_info print_comment prep_config
  63. tcprewrite: rewrite_portmap rewrite_endpoint rewrite_pnat rewrite_trunc \
  64. rewrite_pad rewrite_seed rewrite_mac rewrite_layer2 rewrite_config \
  65. rewrite_skip rewrite_dlt
  66. tcpreplay: replay_basic replay_cache replay_pps replay_rate replay_top \
  67. replay_config replay_multi replay_accurate
  68. prep_config:
  69. $(PRINTF) "%s" "[tcpprep] Config mode test: "
  70. $(PRINTF) "%s\n" "*** [tcpprep] Config mode test: " >>test.log
  71. $(TCPPREP) $(ENABLE_DEBUG) --load-opts=config -o test.$@1 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. auto_router:
  75. $(PRINTF) "%s" "[tcpprep] Auto/Router mode test: "
  76. $(PRINTF) "%s\n" "*** [tcpprep] Auto/Router mode test: " >>test.log
  77. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a router 2>>test.log
  78. diff test.$@ test.$@1 >>test.log 2>&1
  79. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  80. auto_bridge:
  81. $(PRINTF) "%s" "[tcpprep] Auto/Bridge mode test: "
  82. $(PRINTF) "%s\n" "*** [tcpprep] Auto/Bridge mode test: " >>test.log
  83. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a bridge 2>>test.log
  84. diff test.$@ test.$@1 >>test.log 2>&1
  85. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  86. auto_client:
  87. $(PRINTF) "%s" "[tcpprep] Auto/Client mode test: "
  88. $(PRINTF) "%s\n" "*** [tcpprep] Auto/Client mode test: " >>test.log
  89. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a client 2>>test.log
  90. diff test.$@ test.$@1 >>test.log 2>&1
  91. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  92. auto_server:
  93. $(PRINTF) "%s" "[tcpprep] Auto/Server mode test: "
  94. $(PRINTF) "%s\n" "*** [tcpprep] Auto/Server mode test: " >>test.log
  95. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a server 2>>test.log
  96. diff test.$@ test.$@1 >>test.log 2>&1
  97. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  98. regex:
  99. $(PRINTF) "%s" "[tcpprep] Regex mode test: "
  100. $(PRINTF) "%s\n" "*** [tcpprep] Regex mode test: " >>test.log
  101. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -r '216.27.178.*' 2>>test.log
  102. diff test.$@ test.$@1 >>test.log 2>&1
  103. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  104. cidr:
  105. $(PRINTF) "%s" "[tcpprep] CIDR mode test: "
  106. $(PRINTF) "%s\n" "*** [tcpprep] CIDR mode test: " >>test.log
  107. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -c '216.27.178.0/24' 2>>test.log
  108. diff test.$@ test.$@1 >>test.log 2>&1
  109. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  110. port:
  111. $(PRINTF) "%s" "[tcpprep] Port mode test: "
  112. $(PRINTF) "%s\n" "*** [tcpprep] Port mode test: " >>test.log
  113. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -p 2>>test.log
  114. diff test.$@ test.$@1 >>test.log 2>&1
  115. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  116. mac:
  117. $(PRINTF) "%s" "[tcpprep] MAC mode test: "
  118. $(PRINTF) "%s\n" "*** [tcpprep] MAC mode test: " >>test.log
  119. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -e 00:02:3b:00:3d:ce 2>>test.log
  120. diff test.$@ test.$@1 >>test.log 2>&1
  121. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  122. comment:
  123. $(PRINTF) "%s" "[tcpprep] Comment mode test: "
  124. $(PRINTF) "%s\n" "*** [tcpprep] Comment mode test: " >>test.log
  125. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -C "This is a comment" -p 2>>test.log
  126. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  127. print_comment:
  128. $(PRINTF) "%s" "[tcpprep] Print comment mode test: "
  129. $(PRINTF) "%s\n" "*** [tcpprep] Print comment mode test: " >>test.log
  130. $(TCPPREP) $(ENABLE_DEBUG) -P test.comment >test.$@1 2>>test.log
  131. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  132. print_info:
  133. $(PRINTF) "%s" "[tcpprep] Print info mode test: "
  134. $(PRINTF) "%s\n" "*** [tcpprep] Print info mode test: " >>test.log
  135. $(TCPPREP) $(ENABLE_DEBUG) -I test.comment >test.$@1 2>>test.log
  136. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  137. replay_basic:
  138. $(PRINTF) "%s" "[tcpreplay] Basic test: "
  139. $(PRINTF) "%s\n" "*** [tcpreplay] Basic test: " >>test.log
  140. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -t test.pcap >>test.log 2>&1
  141. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  142. replay_cache:
  143. $(PRINTF) "%s" "[tcpreplay] Cache test: "
  144. $(PRINTF) "%s\n" "*** [tcpreplay] Cache test: " >>test.log
  145. $(TCPREPLAY) $(ENABLE_DEBUG) -c test.cidr -i $(nic1) -I $(nic2) -t test.pcap >>test.log 2>&1
  146. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  147. replay_accurate:
  148. $(PRINTF) "%s" "[tcpreplay] Accurate test: "
  149. $(PRINTF) "%s\n" "*** [tcpreplay] Accurate test: " >>test.log
  150. $(TCPREPLAY) $(ENABLE_DEBUG) -a -i $(nic1) test.pcap >>test.log 2>&1
  151. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  152. rewrite_portmap:
  153. $(PRINTF) "%s" "[tcprewrite] Portmap test: "
  154. $(PRINTF) "%s\n" "[tcprewrite] Portmap test: " >>test.log
  155. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_portmap1 -r 80:8080 >>test.log 2>&1
  156. diff test.$@ test.$@1 >>test.log 2>&1
  157. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  158. rewrite_endpoint:
  159. $(PRINTF) "%s" "[tcprewrite] Endpoint test: "
  160. $(PRINTF) "%s\n" "[tcprewrite] Endpoint test: " >>test.log
  161. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_endpoint1 -e 10.10.0.1:10.10.0.2 -c test.auto_router
  162. diff test.$@ test.$@1 >>test.log 2>&1
  163. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  164. rewrite_pnat:
  165. $(PRINTF) "%s" "[tcprewrite] Pseudo NAT test: "
  166. $(PRINTF) "%s\n" "[tcprewrite] Pseudo NAT test: " >>test.log
  167. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_pnat1 -N 216.27.178.0/24:172.16.0.0/24
  168. diff test.$@ test.$@1 >>test.log 2>&1
  169. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  170. rewrite_mac:
  171. $(PRINTF) "%s" "[tcprewrite] Src/Dst MAC test: "
  172. $(PRINTF) "%s\n" "[tcprewrite] Src/Dst MAC test: " >>test.log
  173. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_mac1 \
  174. -D 00:12:13:14:15:16,00:22:33:44:55:66 \
  175. -S 00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router
  176. diff test.$@ test.$@1 >>test.log 2>&1
  177. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  178. rewrite_trunc:
  179. $(PRINTF) "%s" "[tcprewrite] Truncate test: "
  180. $(PRINTF) "%s\n" "*** [tcprewrite] Truncate test: " >>test.log
  181. $(TCPREWRITE) $(ENABLE_DEBUG) -F trunc -i test.pcap -o test.rewrite_trunc1 >>test.log 2>&1
  182. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  183. rewrite_pad:
  184. $(PRINTF) "%s" "[tcprewrite] Pad test: "
  185. $(PRINTF) "%s\n" "*** [tcprewrite] Pad test: " >>test.log
  186. $(TCPREWRITE) $(ENABLE_DEBUG) -F pad -i test.pcap -o test.rewrite_pad1 >>test.log 2>&1
  187. diff test.$@ test.$@1 >>test.log 2>&1
  188. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  189. rewrite_seed:
  190. $(PRINTF) "%s" "[tcprewrite] Seed IP test: "
  191. $(PRINTF) "%s\n" "*** [tcprewrite] Seed IP test: " >>test.log
  192. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_seed1 -s 55 >>test.log 2>&1
  193. diff test.$@ test.$@1 >>test.log 2>&1
  194. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  195. rewrite_layer2:
  196. $(PRINTF) "%s" "[tcprewrite] Layer2 test: "
  197. $(PRINTF) "%s\n" "*** [tcprewrite] Layer2 test: " >>test.log
  198. $(TCPREWRITE) $(ENABLE_DEBUG) -l 00,50,da,5d,46,55,0,7,eb,30,a4,c3,08,0 \
  199. -i test.pcap -o test.rewrite_layer21 >>test.log 2>&1
  200. diff test.$@ test.$@1 >>test.log 2>&1
  201. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  202. rewrite_config:
  203. $(PRINTF) "%s" "[tcprewrite] Config test: "
  204. $(PRINTF) "%s\n" "*** [tcprewrite] Config test: " >>test.log
  205. $(TCPREWRITE) -i test.pcap -o test.rewrite_config1 --load-opts config
  206. diff test.$@ test.$@1 >>test.log 2>&1
  207. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  208. rewrite_skip:
  209. $(PRINTF) "%s" "[tcprewrite] Skip bcast test: "
  210. $(PRINTF) "%s\n" "*** [tcprewrite] Skip bcast test: " >>test.log
  211. $(TCPREWRITE) -i test.pcap -o test.rewrite_skip1 -b -s 55 \
  212. -D 00:12:13:14:15:16,00:22:33:44:55:66 \
  213. -S 00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router
  214. diff test.$@ test.$@1 >>test.log 2>&1
  215. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  216. rewrite_dlt:
  217. $(PRINTF) "%s" "[tcprewrite] DLT test: "
  218. $(PRINTF) "%s\n" "*** [tcprewrite] DLT test: " >>test.log
  219. $(TCPREWRITE) -i test.pcap -o test.rewrite_dlt1 \
  220. --dlink=0x0f,0x00,0x08,0x00 --dlt=104
  221. diff test.$@ test.$@1 >>test.log 2>&1
  222. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  223. replay_pps:
  224. $(PRINTF) "%s" "[tcpreplay] Packets/sec test: "
  225. $(PRINTF) "%s\n" "*** [tcpreplay] Packets/sec test: " >>test.log
  226. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -p 25 test.pcap >>test.log 2>&1
  227. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  228. replay_rate:
  229. $(PRINTF) "%s" "[tcpreplay] Mbps test: "
  230. $(PRINTF) "%s\n" "*** [tcpreplay] Mbps test: " >>test.log
  231. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -M 25.0 test.pcap >>test.log 2>&1
  232. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  233. replay_multi:
  234. $(PRINTF) "%s" "[tcpreplay] Multiplier test: "
  235. $(PRINTF) "%s\n" "*** [tcpreplay] Multiplier test: " >>test.log
  236. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -m 25.0 test.pcap >>test.log 2>&1
  237. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  238. replay_top:
  239. $(PRINTF) "%s" "[tcpreplay] Topspeed test: "
  240. $(PRINTF) "%s\n" "*** [tcpreplay] Topspeed test: " >>test.log
  241. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -t test.pcap >>test.log 2>&1
  242. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  243. datadump_mode:
  244. $(PRINTF) "%s" "[tcpreplay] Data dump test: "
  245. $(PRINTF) "%s\n" "*** [tcpreplay] Data dump mode test: " >>test.log
  246. $(TCPREPLAY) $(ENABLE_DEBUG) -D -i $(nic1) -j $(nic2) -w primary.data -W secondary.data -c test.cidr -R test.pcap >>test.log 2>&1
  247. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  248. replay_config:
  249. $(PRINTF) "%s" "[tcpreplay] Config file/VLAN add test: "
  250. $(PRINTF) "%s\n" "*** [tcpreplay] Config file/VLAN add test: " >>test.log
  251. $(TCPREPLAY) $(ENABLE_DEBUG) --load-opts=config test.pcap >>test.log 2>&1
  252. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  253. clean:
  254. rm -f *1 test.log core* *~ primary.data secondary.data
  255. distclean: clean
  256. rm -f Makefile config
  257. maintainer-clean: distclean