[PATCHv9,4/4] validation: add new test l2fwd_run

Message ID 1428001414-7018-5-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov April 2, 2015, 7:03 p.m.
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 test/performance/Makefile.am   |  2 +-
 test/performance/odp_l2fwd_run | 63 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+), 1 deletion(-)
 create mode 100755 test/performance/odp_l2fwd_run

Patch

diff --git a/test/performance/Makefile.am b/test/performance/Makefile.am
index b501584..63f73e0 100644
--- a/test/performance/Makefile.am
+++ b/test/performance/Makefile.am
@@ -6,7 +6,7 @@  EXECUTABLES = odp_atomic
 
 COMPILE_ONLY = odp_scheduling odp_l2fwd
 
-TESTSCRIPTS = odp_scheduling_run
+TESTSCRIPTS = odp_scheduling_run odp_l2fwd_run
 
 if test_perf
 TESTS = $(EXECUTABLES) $(TESTSCRIPTS)
diff --git a/test/performance/odp_l2fwd_run b/test/performance/odp_l2fwd_run
new file mode 100755
index 0000000..1b0273f
--- /dev/null
+++ b/test/performance/odp_l2fwd_run
@@ -0,0 +1,63 @@ 
+#!/bin/sh
+#
+# Copyright (c) 2015, Linaro Limited
+# All rights reserved.
+#
+# SPDX-License-Identifier:	BSD-3-Clause
+#
+
+TEST_DIR=$(dirname $0)
+
+# exit codes expected by automake for skipped tests
+TEST_SKIPPED=77
+
+# Use installed pktio env or for make check take it from platform directory
+if [ -f "./pktio_env" ]; then
+	. ./pktio_env
+else if  [ "$ODP_PLATFORM" = "" ]; then
+	echo "$0: error: ODP_PLATFORM must be defined"
+	# not skipped as this should never happen via "make check"
+	exit 1
+else if [ -f ${TEST_DIR}/../../platform/$ODP_PLATFORM/test/pktio_env ]; then
+	. ${TEST_DIR}/../../platform/$ODP_PLATFORM/test/pktio_env
+else
+	echo "BUG: unable to find pktio_env!"
+	echo "pktio_env has to be in current directory or in platform/\$ODP_PLATFORM/test."
+	echo "ODP_PLATFORM=\"$ODP_PLATFORM\""
+	exit 1
+	fi
+fi
+fi
+
+run_l2fwd()
+{
+	setup_pktio_env
+	if [ $? -ne 0 ]; then
+		echo "setup_pktio_env error $?"
+		exit $TEST_SKIPPED
+	fi
+
+	#@todo: limit odp_generator to cores
+	#https://bugs.linaro.org/show_bug.cgi?id=1398
+	($TEST_DIR/../../example/generator/odp_generator -I $IF0 \
+			--srcmac fe:0f:97:c9:e0:44  --dstmac 32:cb:9b:27:2f:1a \
+			--srcip 192.168.0.1 --dstip 192.168.0.2 -m u 2>&1 > /dev/null) \
+			2>&1 > /dev/null &
+
+	echo "Run ./odp_l2fwd -i $IF1,$IF2 -m 0 -t 30 -c 2"
+	./odp_l2fwd -i $IF1,$IF2 -m 0 -t 30 -c 2
+
+	cleanup_pktio_env
+	if [ $? -ne 0 ]; then
+		echo "cleanup_pktio_env error $?"
+		exit $TEST_SKIPPED
+	fi
+
+	exit 0
+}
+
+case "$1" in
+	setup)   setup_pktio_env   ;;
+	cleanup) cleanup_pktio_env ;;
+	*)       run_l2fwd ;;
+esac