@@ -34,6 +34,11 @@ SUBDIRS = $(ODP_MODULES)
if HAVE_PCAP
TESTS += pktio/pktio_run_pcap
endif
+
+if netmap_support
+TESTS += pktio/pktio_run_netmap
+endif
+
endif
dist_check_SCRIPTS = run-test tests-validation.env $(LOG_COMPILER)
new file mode 100755
@@ -0,0 +1,133 @@
+#!/bin/sh
+#
+# Copyright (c) 2015, 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_main_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 the test directory
+if [ -f "./pktio_env" ]; then
+ . ./pktio_env
+elif [ -f ${TEST_SRC_DIR}/pktio_env ]; then
+ . ${TEST_SRC_DIR}/pktio_env
+else
+ echo "ERROR: unable to find pktio_env!"
+ echo "pktio_env has to be in current directory or in ${TEST_SRC_DIR}"
+ exit 1
+fi
+
+run_test()
+{
+ local ret=0
+
+ pktio_main${EXEEXT}
+ ret=$?
+
+ if [ $ret -ne 0 ]; then
+ echo "!!! FAILED !!!"
+ fi
+
+ return $ret
+}
+
+run_test_vale()
+{
+ # use two vale ports on the same switch
+ export ODP_PKTIO_IF0=valetest:0
+ export ODP_PKTIO_IF1=valetest:1
+ run_test
+ return $?
+}
+
+run_test_pipe()
+{
+ # use a netmap pipe
+ export ODP_PKTIO_IF0=valetest:0{0
+ export ODP_PKTIO_IF1=valetest:0}0
+ run_test
+ return $?
+}
+
+run_test_veth()
+{
+ if [ "$(lsmod | grep netmap | grep veth)" = "" ]; then
+ echo "netmap enabled veth module not loaded, skipping test."
+ return 0
+ fi
+
+ setup_pktio_env clean
+ export ODP_PKTIO_IF0=$IF0
+ export ODP_PKTIO_IF1=$IF1
+ run_test
+ return $?
+}
+
+run()
+{
+ local ret=0
+
+ # need to be root to run these tests
+ if [ "$(id -u)" != "0" ]; then
+ echo "netmap tests must be run as root, skipping test."
+ exit $TEST_SKIPPED
+ fi
+
+ NETMAP_PARAMS=/sys/module/netmap/parameters
+ if [ ! -d $NETMAP_PARAMS ]; then
+ echo "netmap kernel module not loaded, skipping test."
+ exit $TEST_SKIPPED
+ fi
+
+ NM_BUF_SIZE=9216
+ NM_PARAM_BUF_SIZE=$(cat $NETMAP_PARAMS/buf_size)
+ NM_PARAM_PRIV_BUF_SIZE=$(cat $NETMAP_PARAMS/priv_buf_size)
+
+ echo "Setting netmap buffer size to $NM_BUF_SIZE"
+ echo $NM_BUF_SIZE > $NETMAP_PARAMS/buf_size
+ echo $NM_BUF_SIZE > $NETMAP_PARAMS/priv_buf_size
+
+ if [ "$ODP_PKTIO_IF0" != "" ]; then
+ run_test
+ ret=$?
+ else
+ run_test_vale
+ r=$?; [ $ret = 0 ] && ret=$r
+ run_test_pipe
+ r=$?; [ $ret = 0 ] && ret=$r
+ run_test_veth
+ r=$?; [ $ret = 0 ] && ret=$r
+ fi
+
+ echo "Restoring buffer sizes"
+ echo $NM_PARAM_BUF_SIZE > $NETMAP_PARAMS/buf_size
+ echo $NM_PARAM_PRIV_BUF_SIZE > $NETMAP_PARAMS/priv_buf_size
+
+ exit $ret
+}
+
+run
Add a test for the netmap pktio type. This test will only run as root and if the netmap kernel module is loaded, otherwise it will be skipped. There are three different interface types tested by default, VALE ports, pipe ports and veth (veth only if the netmap enabled veth module is loaded). Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org> --- platform/linux-generic/test/Makefile.am | 5 + platform/linux-generic/test/pktio/pktio_run_netmap | 133 +++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100755 platform/linux-generic/test/pktio/pktio_run_netmap