diff mbox

[2/2] example: switch: add validation test

Message ID 1459859265-23834-3-git-send-email-matias.elo@nokia.com
State Accepted
Commit aabd1faab212e7b662125bb4f1f29f1e2fd6acc9
Headers show

Commit Message

Elo, Matias (Nokia - FI/Espoo) April 5, 2016, 12:27 p.m. UTC
Add validation test for the switch example using pcap pktio.
The sizes of the pcap files are compared, but the actual
contents are not, because the timestamps in the files
differ. Only packet broadcast is currently tested as
switching requires further pcap pktio development.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
---
 example/switch/Makefile.am   |   5 +++++
 example/switch/switch_run.sh |  43 +++++++++++++++++++++++++++++++++++++++++++
 example/switch/udp64.pcap    | Bin 0 -> 7624 bytes
 3 files changed, 48 insertions(+)
 create mode 100755 example/switch/switch_run.sh
 create mode 100644 example/switch/udp64.pcap

diff --git a/example/switch/udp64.pcap b/example/switch/udp64.pcap
new file mode 100644
index 0000000000000000000000000000000000000000..45f9d6e6341a331125e1e3e49ab8ad1e71b20712
GIT binary patch
literal 7624
zcmca|c+)~A1{MYw_+QV!zzF1AIDRVZQX4OW4Ui4OOdthJV3Lu8!IgnQ52VaNFl`SP
zPy-M%&2gOL#31#rG%+bTB{eNQBQq;ICpRy@ps;AvtkLiqO%tPeXtbOdEel8Mj?wyY
zv^_D}W*Ti5GK{vPNBat+eXG&_<7gilID#<RE*xzaj<yR&+l8a;!qKvDbPRcP%zboT
XVRY^UIO8<hE*$M6kM@y?=pzFFfL+O&

literal 0
HcmV?d00001
diff mbox

Patch

diff --git a/example/switch/Makefile.am b/example/switch/Makefile.am
index ca3982e..e18c681 100644
--- a/example/switch/Makefile.am
+++ b/example/switch/Makefile.am
@@ -8,3 +8,8 @@  noinst_HEADERS = \
 		  $(top_srcdir)/example/example_debug.h
 
 dist_odp_switch_SOURCES = odp_switch.c
+
+if HAVE_PCAP
+TESTS = switch_run.sh
+endif
+EXTRA_DIST = switch_run.sh udp64.pcap
diff --git a/example/switch/switch_run.sh b/example/switch/switch_run.sh
new file mode 100755
index 0000000..9b32973
--- /dev/null
+++ b/example/switch/switch_run.sh
@@ -0,0 +1,43 @@ 
+#!/bin/bash
+#
+# Copyright (c) 2016, Linaro Limited
+# All rights reserved.
+#
+# SPDX-License-Identifier:     BSD-3-Clause
+#
+
+NUM_RX_PORT=3
+RETVAL=0
+
+PCAP_IN=`find . ${TEST_DIR} $(dirname $0) -name udp64.pcap -print -quit`
+
+echo "Switch test using PCAP_IN = ${PCAP_IN}"
+
+RX_PORTS=""
+for i in `seq 1 $NUM_RX_PORT`;
+do
+	RX_PORTS="${RX_PORTS},pcap:out=pcapout${i}.pcap"
+done
+
+./odp_switch -i pcap:in=${PCAP_IN}${RX_PORTS} &
+
+sleep 1
+kill $!
+wait $!
+STATUS=$?
+
+if [ "$STATUS" -ne 143 ]; then
+  echo "Error: status was: $STATUS, expected 143"
+  RETVAL=1
+fi
+
+for i in `seq 1 $NUM_RX_PORT`;
+do
+	if [ `stat -c %s pcapout${i}.pcap` -ne `stat -c %s udp64.pcap` ]; then
+		echo "Error: Output file $i size not matching"
+		RETVAL=1
+	fi
+	rm -f pcapout${i}.pcap
+done
+
+exit $RETVAL