Skip to content

Commit

Permalink
Feature #853 add -w / --write tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fklassen committed Jun 29, 2024
1 parent d5ce8bd commit 2ed8008
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 7 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dnl $Id$
AC_PREREQ([2.69])

dnl Set version info here!
AC_INIT([tcpreplay],[4.5.0-beta2],[https://github.com/appneta/tcpreplay/issues],[tcpreplay],[http://tcpreplay.sourceforge.net/])
AC_INIT([tcpreplay],[4.5.0-beta3],[https://github.com/appneta/tcpreplay/issues],[tcpreplay],[http://tcpreplay.sourceforge.net/])
AC_CONFIG_SRCDIR([src/tcpreplay.c])
AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_AUX_DIR(config)
Expand Down
53 changes: 47 additions & 6 deletions test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ EXTRA_DIST = test.pcap test.auto_bridge test.auto_client test.auto_router \
test.rewrite_mtutrunc test.rewrite_mac_seed test.rewrite_range_portmap \
test.rewrite_mac_seed_keep test.rewrite_l7fuzzing test.rewrite_sequence test.rewrite_fixcsum \
test.rewrite_fixlen_pad test.rewrite_fixlen_trunc test.rewrite_fixlen_del \
test.replay_unique_ip test.replay_include test.replay_exclude \
test2.rewrite_seed test2.rewrite_portmap test2.rewrite_endpoint \
test2.rewrite_pnat test2.rewrite_pad test2.rewrite_trunc \
test2.rewrite_mac test2.rewrite_layer2 test2.rewrite_config \
Expand All @@ -44,7 +45,8 @@ EXTRA_DIST = test.pcap test.auto_bridge test.auto_client test.auto_router \
test2.rewrite_enet_subsmac test2.rewrite_mac_seed \
test2.rewrite_range_portmap test2.rewrite_mac_seed_keep \
test2.rewrite_l7fuzzing test2.rewrite_sequence test2.rewrite_fixcsum \
test2.rewrite_fixlen_pad test2.rewrite_fixlen_trunc test2.rewrite_fixlen_del
test2.rewrite_fixlen_pad test2.rewrite_fixlen_trunc test2.rewrite_fixlen_del \
test2.replay_unique_ip test2.replay_include test2.replay_exclude

test: all
all: clearlog check tcpprep tcpreplay tcprewrite
Expand Down Expand Up @@ -139,6 +141,9 @@ standard_bigendian:
$(TCPREWRITE) -i $(TEST_PCAP) -o test.rewrite_fixlen_pad --fixlen=pad
$(TCPREWRITE) -i $(TEST_PCAP) -o test.rewrite_fixlen_trunc --fixlen=trunc
$(TCPREWRITE) -i $(TEST_PCAP) -o test.rewrite_fixlen_del --fixlen=del
$(TCPREPLAY) -w test.replay_include -t --include=7,11,20-23,174- $(TEST_PCAP)
$(TCPREPLAY) -w test.replay_exclude -t --exclude=23-,11-20,2,3 $(TEST_PCAP)
$(TCPREPLAY) -w test.replay_unique_ip -t --unique-ip --loop=2 $(TEST_PCAP)

standard_littleendian:
$(TCPREWRITE) -i $(TEST_PCAP) -o test2.rewrite_seed -s 55
Expand Down Expand Up @@ -192,6 +197,9 @@ standard_littleendian:
$(TCPREWRITE) -i $(TEST_PCAP) -o test2.rewrite_fixlen_pad --fixlen=pad
$(TCPREWRITE) -i $(TEST_PCAP) -o test2.rewrite_fixlen_trunc --fixlen=trunc
$(TCPREWRITE) -i $(TEST_PCAP) -o test2.rewrite_fixlen_del --fixlen=del
$(TCPREPLAY) -w test2.replay_include -t --include=7,11,20-23,174- $(TEST_PCAP)
$(TCPREPLAY) -w test2.replay_exclude -t --exclude=23-,11-20,2,3 $(TEST_PCAP)
$(TCPREPLAY) -w test2.replay_unique_ip -t --unique-ip --loop=2 $(TEST_PCAP)

tcpprep: auto_router auto_bridge auto_client auto_server auto_first cidr regex \
port mac comment print_info print_comment prep_config \
Expand All @@ -209,7 +217,7 @@ tcprewrite: rewrite_portmap rewrite_range_portmap rewrite_endpoint \

tcpreplay: replay_basic replay_nano_timer replay_cache replay_pps replay_rate replay_top \
replay_config replay_multi replay_pps_multi replay_precache \
replay_stats replay_dualfile replay_maxsleep replay_include replay_exclude
replay_stats replay_dualfile replay_maxsleep replay_include replay_exclude replay_unique_ip

prep_config:
$(PRINTF) "%s" "[tcpprep] Config mode test: "
Expand Down Expand Up @@ -819,17 +827,50 @@ replay_maxsleep:
$(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) --maxsleep=20 $(TEST_PCAP) $(TEST_PCAP) >> test.log 2>&1
if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi

# the following write to a file
replay_include:
$(PRINTF) "%s" "[tcpreplay] Include rule test: "
$(PRINTF) "%s\n" "*** [tcpreplay] Include rule test: " >> test.log
$(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) --include=1-5,9,15,72- $(TEST_PCAP) $(TEST_PCAP) >> test.log 2>&1
if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
$(TCPREPLAY) $(ENABLE_DEBUG) -w test.$@1 -t --include=7,11,20-23,174- $(TEST_PCAP) >> test.log 2>&1
if WORDS_BIGENDIAN
diff $(srcdir)/test.$@ test.$@1 >> test.log 2>&1
else
diff $(srcdir)/test2.$@ test.$@1 >> test.log 2>&1
endif
if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi

replay_exclude:
$(PRINTF) "%s" "[tcpreplay] Exclude rule test: "
$(PRINTF) "%s\n" "*** [tcpreplay] Exclude rule test: " >> test.log
$(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) --include=7-11,3,20,22- $(TEST_PCAP) $(TEST_PCAP) >> test.log 2>&1
if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
$(TCPREPLAY) $(ENABLE_DEBUG) -w test.$@1 -t --exclude=23-,11-20,2,3 $(TEST_PCAP) >> test.log 2>&1
if WORDS_BIGENDIAN
diff $(srcdir)/test.$@ test.$@1 >> test.log 2>&1
else
diff $(srcdir)/test2.$@ test.$@1 >> test.log 2>&1
endif
if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi

replay_unique_ip:
$(PRINTF) "%s" "[tcpreplay] Unique IP test: "
$(PRINTF) "%s\n" "*** [tcpreplay] Unique IP test: " >> test.log
$(TCPREPLAY) $(ENABLE_DEBUG) -w test.$@1 -t --unique-ip --loop=2 $(TEST_PCAP) >> test.log 2>&1
if WORDS_BIGENDIAN
diff $(srcdir)/test.$@ test.$@1 >> test.log 2>&1
else
diff $(srcdir)/test2.$@ test.$@1 >> test.log 2>&1
endif
if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi

rewrite_portmap:
$(PRINTF) "%s" "[tcprewrite] Portmap test: "
$(PRINTF) "%s\n" "*** [tcprewrite] Portmap test: " >> test.log
$(TCPREWRITE) $(ENABLE_DEBUG) -i $(TEST_PCAP) -o test.$@1 -r 80:8080 >> test.log 2>&1
if WORDS_BIGENDIAN
diff $(srcdir)/test.$@ test.$@1 >> test.log 2>&1
else
diff $(srcdir)/test2.$@ test.$@1 >> test.log 2>&1
endif
if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi

clean:
rm -f *1 test.log core* *~ primary.data secondary.data
Expand Down
Binary file added test/test.replay_exclude
Binary file not shown.
Binary file added test/test.replay_include
Binary file not shown.
Binary file added test/test.replay_unique_ip
Binary file not shown.
Binary file added test/test2.replay_exclude
Binary file not shown.
Binary file added test/test2.replay_include
Binary file not shown.
Binary file added test/test2.replay_unique_ip
Binary file not shown.

0 comments on commit 2ed8008

Please sign in to comment.