Add support for running pktio validation tests with pcap
vdev interfaces without any physical interfaces.

Test script copied from odp-dpdk.

Signed-off-by: Matias Elo <matias....@nokia.com>
---
 configure.ac                                     |  2 +
 platform/linux-generic/m4/odp_dpdk.m4            |  8 +--
 platform/linux-generic/test/Makefile.am          |  3 +
 platform/linux-generic/test/pktio/Makefile.am    |  3 +
 platform/linux-generic/test/pktio/pktio_run_dpdk | 80 ++++++++++++++++++++++++
 5 files changed, 92 insertions(+), 4 deletions(-)
 create mode 100755 platform/linux-generic/test/pktio/pktio_run_dpdk

diff --git a/configure.ac b/configure.ac
index 257f8c3..c7574c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -85,6 +85,7 @@ AC_SUBST([platform_with_platform_test], 
["platform/${with_platform}/test"])
 # Prepare default values for platform specific optional features
 ##########################################################################
 netmap_support=no
+pktio_dpdk_support=no
 
 ##########################################################################
 # Run platform specific checks and settings
@@ -101,6 +102,7 @@ fi
 # Set conditionals as computed within platform specific files
 ##########################################################################
 AM_CONDITIONAL([netmap_support], [test x$netmap_support = xyes ])
+AM_CONDITIONAL([PKTIO_DPDK], [test x$pktio_dpdk_support = xyes ])
 AM_CONDITIONAL([HAVE_PCAP], [test $have_pcap = yes])
 
 
diff --git a/platform/linux-generic/m4/odp_dpdk.m4 
b/platform/linux-generic/m4/odp_dpdk.m4
index 7fa3387..96bbc5b 100644
--- a/platform/linux-generic/m4/odp_dpdk.m4
+++ b/platform/linux-generic/m4/odp_dpdk.m4
@@ -4,7 +4,7 @@
 AC_ARG_ENABLE([dpdk_support],
     [  --enable-dpdk-support  include dpdk IO support],
     [if test x$enableval = xyes; then
-        dpdk_support=yes
+        pktio_dpdk_support=yes
     fi])
 
 ##########################################################################
@@ -17,7 +17,7 @@ AC_HELP_STRING([--with-dpdk-path=DIR   path to dpdk build 
directory],
     AM_CPPFLAGS="$AM_CPPFLAGS -msse4.2 -isystem $DPDK_PATH/include"
     AM_LDFLAGS="$AM_LDFLAGS -L$DPDK_PATH/lib"
     LIBS="$LIBS -ldpdk -ldl -lpcap"
-    dpdk_support=yes],[])
+    pktio_dpdk_support=yes],[])
 
 ##########################################################################
 # Save and set temporary compilation flags
@@ -28,13 +28,13 @@ CPPFLAGS="$AM_CPPFLAGS $CPPFLAGS"
 ##########################################################################
 # Check for DPDK availability
 ##########################################################################
-if test x$dpdk_support = xyes
+if test x$pktio_dpdk_support = xyes
 then
     AC_CHECK_HEADERS([rte_config.h], [],
         [AC_MSG_FAILURE(["can't find DPDK header"])])
     ODP_CFLAGS="$ODP_CFLAGS -DODP_PKTIO_DPDK"
 else
-    dpdk_support=no
+    pktio_dpdk_support=no
 fi
 
 ##########################################################################
diff --git a/platform/linux-generic/test/Makefile.am 
b/platform/linux-generic/test/Makefile.am
index 1011437..318ee57 100644
--- a/platform/linux-generic/test/Makefile.am
+++ b/platform/linux-generic/test/Makefile.am
@@ -38,6 +38,9 @@ SUBDIRS = $(ODP_MODULES)
 if HAVE_PCAP
 TESTS += pktio/pktio_run_pcap
 endif
+if PKTIO_DPDK
+TESTS += pktio/pktio_run_dpdk
+endif
 endif
 
 dist_check_SCRIPTS = run-test tests-validation.env $(LOG_COMPILER)
diff --git a/platform/linux-generic/test/pktio/Makefile.am 
b/platform/linux-generic/test/pktio/Makefile.am
index ea0ad87..807243c 100644
--- a/platform/linux-generic/test/pktio/Makefile.am
+++ b/platform/linux-generic/test/pktio/Makefile.am
@@ -5,5 +5,8 @@ dist_check_SCRIPTS = pktio_env \
 if HAVE_PCAP
 dist_check_SCRIPTS += pktio_run_pcap
 endif
+if PKTIO_DPDK
+dist_check_SCRIPTS += pktio_run_dpdk
+endif
 
 test_SCRIPTS = $(dist_check_SCRIPTS)
diff --git a/platform/linux-generic/test/pktio/pktio_run_dpdk 
b/platform/linux-generic/test/pktio/pktio_run_dpdk
new file mode 100755
index 0000000..7b9d733
--- /dev/null
+++ b/platform/linux-generic/test/pktio/pktio_run_dpdk
@@ -0,0 +1,80 @@
+#!/bin/sh
+#
+# Copyright (c) 2016, Linaro Limited
+# All rights reserved.
+#
+# SPDX-License-Identifier:     BSD-3-Clause
+#
+
+# directories where pktio_main binary can be found:
+# -in the validation dir when running make check (intree or out of tree)
+# -in the script directory, when running after 'make install', or
+# -in the validation when running standalone (./pktio_run) intree.
+# -in the current directory.
+# running stand alone out of tree requires setting PATH
+PATH=${TEST_DIR}/pktio:$PATH
+PATH=$(dirname $0):$PATH
+PATH=$(dirname $0)/../../../../test/validation/pktio:$PATH
+PATH=.:$PATH
+
+pktio_main_path=$(which pktio_main${EXEEXT})
+if [ -x "$pktio_main_path" ] ; then
+       echo "running with pktio_main: $pktio_run_path"
+else
+       echo "cannot find pktio_main: please set you PATH for it."
+fi
+
+# directory where platform test sources are, including scripts
+TEST_SRC_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
+elif [ -f ${TEST_SRC_DIR}/pktio_env ]; then
+       . ${TEST_SRC_DIR}/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
+
+run_test()
+{
+       local ret=0
+
+       pktio_main${EXEEXT}
+       ret=$?
+       if [ $ret -ne 0 ]; then
+               echo "!!! FAILED !!!"
+       fi
+
+       exit $ret
+}
+
+run()
+{
+       # need to be root to set the interface.
+       if [ "$(id -u)" != "0" ]; then
+               echo "pktio: need to be root to setup DPDK interfaces."
+               return $TEST_SKIPPED
+       fi
+
+       if [ "$ODP_PKTIO_IF0" = "" ]; then
+               setup_pktio_env clean
+               export ODP_PLATFORM_PARAMS="--vdev eth_pcap0,iface=$IF0 --vdev 
eth_pcap1,iface=$IF1"
+               export ODP_PKTIO_IF0=0
+               export ODP_PKTIO_IF1=1
+       fi
+
+       run_test
+}
+
+case "$1" in
+       setup)   setup_pktio_env   ;;
+       cleanup) cleanup_pktio_env ;;
+       *)       run ;;
+esac
-- 
1.9.1

_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to