Simplify adding platform performance tests by mirroring the test directory structure and moving the validation tests to their own directory.
Signed-off-by: Mike Holmes <[email protected]> --- platform/linux-generic/m4/configure.m4 | 3 +- platform/linux-generic/test/Makefile.am | 51 +-------- platform/linux-generic/test/pktio/.gitignore | 2 - platform/linux-generic/test/pktio/Makefile.am | 9 -- platform/linux-generic/test/pktio/pktio_env | 120 --------------------- platform/linux-generic/test/pktio/pktio_run | 110 ------------------- platform/linux-generic/test/pktio/pktio_run_pcap | 33 ------ platform/linux-generic/test/pktio/pktio_run_tap | 115 -------------------- platform/linux-generic/test/validation/Makefile.am | 44 ++++++++ .../linux-generic/test/validation/pktio/.gitignore | 2 + .../test/validation/pktio/Makefile.am | 9 ++ .../linux-generic/test/validation/pktio/pktio_env | 120 +++++++++++++++++++++ .../linux-generic/test/validation/pktio/pktio_run | 110 +++++++++++++++++++ .../test/validation/pktio/pktio_run_pcap | 33 ++++++ .../test/validation/pktio/pktio_run_tap | 115 ++++++++++++++++++++ test/performance/odp_l2fwd_run | 6 +- 16 files changed, 442 insertions(+), 440 deletions(-) delete mode 100644 platform/linux-generic/test/pktio/.gitignore delete mode 100644 platform/linux-generic/test/pktio/Makefile.am delete mode 100644 platform/linux-generic/test/pktio/pktio_env delete mode 100755 platform/linux-generic/test/pktio/pktio_run delete mode 100755 platform/linux-generic/test/pktio/pktio_run_pcap delete mode 100755 platform/linux-generic/test/pktio/pktio_run_tap create mode 100644 platform/linux-generic/test/validation/Makefile.am create mode 100644 platform/linux-generic/test/validation/pktio/.gitignore create mode 100644 platform/linux-generic/test/validation/pktio/Makefile.am create mode 100644 platform/linux-generic/test/validation/pktio/pktio_env create mode 100755 platform/linux-generic/test/validation/pktio/pktio_run create mode 100755 platform/linux-generic/test/validation/pktio/pktio_run_pcap create mode 100755 platform/linux-generic/test/validation/pktio/pktio_run_tap diff --git a/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4 index df6dc64..97c15fa 100644 --- a/platform/linux-generic/m4/configure.m4 +++ b/platform/linux-generic/m4/configure.m4 @@ -23,4 +23,5 @@ m4_include([platform/linux-generic/m4/odp_pcap.m4]) AC_CONFIG_FILES([platform/linux-generic/Makefile platform/linux-generic/test/Makefile - platform/linux-generic/test/pktio/Makefile]) + platform/linux-generic/test/validation/Makefile + platform/linux-generic/test/validation/pktio/Makefile]) diff --git a/platform/linux-generic/test/Makefile.am b/platform/linux-generic/test/Makefile.am index e629872..3cf638d 100644 --- a/platform/linux-generic/test/Makefile.am +++ b/platform/linux-generic/test/Makefile.am @@ -1,56 +1,13 @@ -include $(top_srcdir)/test/Makefile.inc -TESTS_ENVIRONMENT += TEST_DIR=${top_builddir}/test/validation - -ODP_MODULES = pktio +SUBDIRS = if test_vald -TESTS = pktio/pktio_run \ - pktio/pktio_run_tap \ - ${top_builddir}/test/validation/buffer/buffer_main$(EXEEXT) \ - ${top_builddir}/test/validation/classification/classification_main$(EXEEXT) \ - ${top_builddir}/test/validation/config/config_main$(EXEEXT) \ - ${top_builddir}/test/validation/cpumask/cpumask_main$(EXEEXT) \ - ${top_builddir}/test/validation/crypto/crypto_main$(EXEEXT) \ - ${top_builddir}/test/validation/errno/errno_main$(EXEEXT) \ - ${top_builddir}/test/validation/hash/hash_main$(EXEEXT) \ - ${top_builddir}/test/validation/init/init_main_ok$(EXEEXT) \ - ${top_builddir}/test/validation/init/init_main_abort$(EXEEXT) \ - ${top_builddir}/test/validation/init/init_main_log$(EXEEXT) \ - ${top_builddir}/test/validation/packet/packet_main$(EXEEXT) \ - ${top_builddir}/test/validation/pool/pool_main$(EXEEXT) \ - ${top_builddir}/test/validation/queue/queue_main$(EXEEXT) \ - ${top_builddir}/test/validation/random/random_main$(EXEEXT) \ - ${top_builddir}/test/validation/scheduler/scheduler_main$(EXEEXT) \ - ${top_builddir}/test/validation/std_clib/std_clib_main$(EXEEXT) \ - ${top_builddir}/test/validation/synchronizers/synchronizers_main$(EXEEXT) \ - ${top_builddir}/test/validation/thread/thread_main$(EXEEXT) \ - ${top_builddir}/test/validation/time/time_main$(EXEEXT) \ - ${top_builddir}/test/validation/timer/timer_main$(EXEEXT) \ - ${top_builddir}/test/validation/shmem/shmem_main$(EXEEXT) \ - ${top_builddir}/test/validation/system/system_main$(EXEEXT) - -SUBDIRS = $(ODP_MODULES) - -if HAVE_PCAP -TESTS += pktio/pktio_run_pcap +SUBDIRS += validation endif -endif - -dist_check_SCRIPTS = run-test tests-validation.env $(LOG_COMPILER) - -test_SCRIPTS = $(dist_check_SCRIPTS) - -tests-validation.env: - echo "TESTS=\"$(TESTS)\"" > $@ - echo "$(TESTS_ENVIRONMENT)" >> $@ - echo "$(LOG_COMPILER)" >> $@ if test_installdir installcheck-local: $(DESTDIR)/$(testdir)/run-test endif -#performance tests refer to pktio_env -if test_perf -SUBDIRS = pktio -endif +dist_check_SCRIPTS = run-test $(LOG_COMPILER) +test_SCRIPTS = $(dist_check_SCRIPTS) \ No newline at end of file diff --git a/platform/linux-generic/test/pktio/.gitignore b/platform/linux-generic/test/pktio/.gitignore deleted file mode 100644 index 7e563b8..0000000 --- a/platform/linux-generic/test/pktio/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.log -*.trs diff --git a/platform/linux-generic/test/pktio/Makefile.am b/platform/linux-generic/test/pktio/Makefile.am deleted file mode 100644 index ea0ad87..0000000 --- a/platform/linux-generic/test/pktio/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -dist_check_SCRIPTS = pktio_env \ - pktio_run \ - pktio_run_tap - -if HAVE_PCAP -dist_check_SCRIPTS += pktio_run_pcap -endif - -test_SCRIPTS = $(dist_check_SCRIPTS) diff --git a/platform/linux-generic/test/pktio/pktio_env b/platform/linux-generic/test/pktio/pktio_env deleted file mode 100644 index 345b5bd..0000000 --- a/platform/linux-generic/test/pktio/pktio_env +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2015, Linaro Limited -# All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Test script wrapper for running ODP pktio apps on linux-generic. -# -# For linux-generic the default behavior is to create two pairs of -# virtual Ethernet interfaces and provide the names of these via -# environment variables to pktio apps, the interfaces will be removed -# before the script exits. -# -# Note that the creation of virtual Ethernet devices depends on having -# CONFIG_VETH enabled in the kernel, if not enabled the env setup will be skipped. -# -# Network set up -# IF0 <---> IF1 -# IF2 <---> IF3 -IF0=pktiop0p1 -IF1=pktiop1p0 -IF2=pktiop2p3 -IF3=pktiop3p2 - -if [ "$0" = "$BASH_SOURCE" ]; then - echo "Error: Platform specific env file has to be sourced." -fi - -check_for_root() -{ - if [ "$(id -u)" != "0" ]; then - echo "check_for_root(): need to be root to setup VETH" - return 1 - fi - return 0 -} - -# wait for a network interface's operational state to be "up" -wait_for_iface_up() -{ - iface=$1 - cnt=0 - - while [ $cnt -lt 50 ]; do - read operstate < /sys/class/net/$iface/operstate - - if [ $? -ne 0 ]; then - break - elif [ "$operstate" = "up" ]; then - return 0 - fi - - sleep 0.1 - cnt=`expr $cnt + 1` - done - - return 1 -} - -setup_pktio_env() -{ - echo "pktio: setting up test interfaces $IF0, $IF1, $IF2, $IF3." - - check_for_root - if [ $? -ne 0 ]; then - return 1 - fi - - for iface in $IF0 $IF1 $IF2 $IF3; do - ip link show $iface 2> /dev/null - if [ $? -eq 0 ]; then - echo "pktio: interface $iface already exist $?" - return 2 - fi - done - - if [ "$1" = "clean" ]; then - trap cleanup_pktio_env EXIT - fi - - ip link add $IF0 type veth peer name $IF1 - if [ $? -ne 0 ]; then - echo "pktio: error: unable to create veth pair" - return 3 - fi - ip link add $IF2 type veth peer name $IF3 - if [ $? -ne 0 ]; then - echo "pktio: error: unable to create veth pair" - return 4 - fi - - for iface in $IF0 $IF1 $IF2 $IF3; do - ip link set $iface mtu 9216 up - ifconfig $iface -arp - done - - # check that the interface has come up before starting the test - for iface in $IF0 $IF1 $IF2 $IF3; do - wait_for_iface_up $iface - if [ $? -ne 0 ]; then - echo "pktio: interface $iface failed to come up" - return 5 - fi - done -} - -cleanup_pktio_env() -{ - echo "pktio: removing test interfaces $IF0, $IF1, $IF2, $IF3" - check_for_root - if [ $? -ne 0 ]; then - return 1 - fi - - for iface in $IF0 $IF1 $IF2 $IF3; do - ip link del $iface 2> /dev/null - done - return 0 -} diff --git a/platform/linux-generic/test/pktio/pktio_run b/platform/linux-generic/test/pktio/pktio_run deleted file mode 100755 index 7029ab2..0000000 --- a/platform/linux-generic/test/pktio/pktio_run +++ /dev/null @@ -1,110 +0,0 @@ -#!/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_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 - - # environment variables are used to control which socket method is - # used, so try each combination to ensure decent coverage. - for distype in MMAP MMSG; do - unset ODP_PKTIO_DISABLE_SOCKET_${distype} - done - - # this script doesn't support testing with netmap - export ODP_PKTIO_DISABLE_NETMAP=y - - for distype in SKIP MMAP; do - if [ "$disabletype" != "SKIP" ]; then - export ODP_PKTIO_DISABLE_SOCKET_${distype}=y - fi - pktio_main${EXEEXT} - if [ $? -ne 0 ]; then - ret=1 - fi - done - - if [ $ret -ne 0 ]; then - echo "!!! FAILED !!!" - fi - - return $ret -} - -run() -{ - echo "pktio: using 'loop' device" - pktio_main${EXEEXT} - loop_ret=$? - - # need to be root to run tests with real interfaces - if [ "$(id -u)" != "0" ]; then - exit $ret - fi - - if [ "$ODP_PKTIO_IF0" = "" ]; then - # no interfaces specified, use default veth interfaces - # setup by the pktio_env script - setup_pktio_env clean - if [ $? != 0 ]; then - echo "Failed to setup test environment, skipping test." - exit $TEST_SKIPPED - fi - export ODP_PKTIO_IF0=$IF0 - export ODP_PKTIO_IF1=$IF1 - fi - - run_test - ret=$? - - [ $ret = 0 ] && ret=$loop_ret - - exit $ret -} - -case "$1" in - setup) setup_pktio_env ;; - cleanup) cleanup_pktio_env ;; - *) run ;; -esac diff --git a/platform/linux-generic/test/pktio/pktio_run_pcap b/platform/linux-generic/test/pktio/pktio_run_pcap deleted file mode 100755 index c130417..0000000 --- a/platform/linux-generic/test/pktio/pktio_run_pcap +++ /dev/null @@ -1,33 +0,0 @@ -#!/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 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_path" -else - echo "cannot find pktio_main${EXEEXT}: please set you PATH for it." -fi - -PCAP_FNAME=vald.pcap -export ODP_PKTIO_IF0="pcap:out=${PCAP_FNAME}" -export ODP_PKTIO_IF1="pcap:in=${PCAP_FNAME}" -pktio_main${EXEEXT} -ret=$? -rm -f ${PCAP_FNAME} -exit $ret diff --git a/platform/linux-generic/test/pktio/pktio_run_tap b/platform/linux-generic/test/pktio/pktio_run_tap deleted file mode 100755 index 975da81..0000000 --- a/platform/linux-generic/test/pktio/pktio_run_tap +++ /dev/null @@ -1,115 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2015, Ilya Maximets <[email protected]> -# 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 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_path" -else - echo "cannot find pktio_main${EXEEXT}: please set you PATH for it." -fi - -# exit code expected by automake for skipped tests -TEST_SKIPPED=77 - -TAP_BASE_NAME=iotap_vald -IF0=${TAP_BASE_NAME}0 -IF1=${TAP_BASE_NAME}1 -BR=${TAP_BASE_NAME}_br - -export ODP_PKTIO_IF0="tap:$IF0" -export ODP_PKTIO_IF1="tap:$IF1" - -tap_cleanup() -{ - ret=$? - - for iface in $IF0 $IF1; do - ip link set dev $iface nomaster - done - - ip link delete $BR type bridge - - for iface in $IF0 $IF1; do - ip tuntap del mode tap $iface - done - - trap - EXIT - exit $ret -} - -tap_setup() -{ - if [ "$(id -u)" != "0" ]; then - echo "pktio: need to be root to setup TAP interfaces." - return $TEST_SKIPPED - fi - - for iface in $IF0 $IF1 $BR; do - ip link show $iface 2> /dev/null - if [ $? -eq 0 ]; then - echo "pktio: interface $iface already exist $?" - return 2 - fi - done - - trap tap_cleanup EXIT - - for iface in $IF0 $IF1; do - ip tuntap add mode tap $iface - if [ $? -ne 0 ]; then - echo "pktio: error: unable to create TAP device $iface" - return 3 - fi - done - - ip link add name $BR type bridge - if [ $? -ne 0 ]; then - echo "pktio: error: unable to create bridge $BR" - return 3 - fi - - for iface in $IF0 $IF1; do - ip link set dev $iface master $BR - if [ $? -ne 0 ]; then - echo "pktio: error: unable to add $iface to bridge $BR" - return 4 - fi - done - - for iface in $IF0 $IF1 $BR; do - ifconfig $iface -arp - sysctl -w net.ipv6.conf.${iface}.disable_ipv6=1 - ip link set dev $iface mtu 9216 up - done - - return 0 -} - -tap_setup -ret=$? -if [ $ret -ne 0 ]; then - echo "pktio: tap_setup() FAILED!" - exit $ret -fi - -# Using ODP_WAIT_FOR_NETWORK to prevent fail if tap still not enabled in bridge -ODP_WAIT_FOR_NETWORK=yes pktio_main${EXEEXT} -ret=$? - -exit $ret diff --git a/platform/linux-generic/test/validation/Makefile.am b/platform/linux-generic/test/validation/Makefile.am new file mode 100644 index 0000000..39c6cdd --- /dev/null +++ b/platform/linux-generic/test/validation/Makefile.am @@ -0,0 +1,44 @@ +include $(top_srcdir)/test/Makefile.inc +TESTS_ENVIRONMENT += TEST_DIR=${top_builddir}/test/validation + +ODP_MODULES = pktio + +TESTS = pktio/pktio_run \ + pktio/pktio_run_tap \ + ${top_builddir}/test/validation/buffer/buffer_main$(EXEEXT) \ + ${top_builddir}/test/validation/classification/classification_main$(EXEEXT) \ + ${top_builddir}/test/validation/config/config_main$(EXEEXT) \ + ${top_builddir}/test/validation/cpumask/cpumask_main$(EXEEXT) \ + ${top_builddir}/test/validation/crypto/crypto_main$(EXEEXT) \ + ${top_builddir}/test/validation/errno/errno_main$(EXEEXT) \ + ${top_builddir}/test/validation/hash/hash_main$(EXEEXT) \ + ${top_builddir}/test/validation/init/init_main_ok$(EXEEXT) \ + ${top_builddir}/test/validation/init/init_main_abort$(EXEEXT) \ + ${top_builddir}/test/validation/init/init_main_log$(EXEEXT) \ + ${top_builddir}/test/validation/packet/packet_main$(EXEEXT) \ + ${top_builddir}/test/validation/pool/pool_main$(EXEEXT) \ + ${top_builddir}/test/validation/queue/queue_main$(EXEEXT) \ + ${top_builddir}/test/validation/random/random_main$(EXEEXT) \ + ${top_builddir}/test/validation/scheduler/scheduler_main$(EXEEXT) \ + ${top_builddir}/test/validation/std_clib/std_clib_main$(EXEEXT) \ + ${top_builddir}/test/validation/synchronizers/synchronizers_main$(EXEEXT) \ + ${top_builddir}/test/validation/thread/thread_main$(EXEEXT) \ + ${top_builddir}/test/validation/time/time_main$(EXEEXT) \ + ${top_builddir}/test/validation/timer/timer_main$(EXEEXT) \ + ${top_builddir}/test/validation/shmem/shmem_main$(EXEEXT) \ + ${top_builddir}/test/validation/system/system_main$(EXEEXT) + +SUBDIRS = $(ODP_MODULES) + +if HAVE_PCAP +TESTS += pktio/pktio_run_pcap +endif + +dist_check_SCRIPTS = tests-validation.env + +test_SCRIPTS = $(dist_check_SCRIPTS) + +tests-validation.env: + echo "TESTS=\"$(TESTS)\"" > $@ + echo "$(TESTS_ENVIRONMENT)" >> $@ + echo "$(LOG_COMPILER)" >> $@ diff --git a/platform/linux-generic/test/validation/pktio/.gitignore b/platform/linux-generic/test/validation/pktio/.gitignore new file mode 100644 index 0000000..7e563b8 --- /dev/null +++ b/platform/linux-generic/test/validation/pktio/.gitignore @@ -0,0 +1,2 @@ +*.log +*.trs diff --git a/platform/linux-generic/test/validation/pktio/Makefile.am b/platform/linux-generic/test/validation/pktio/Makefile.am new file mode 100644 index 0000000..ea0ad87 --- /dev/null +++ b/platform/linux-generic/test/validation/pktio/Makefile.am @@ -0,0 +1,9 @@ +dist_check_SCRIPTS = pktio_env \ + pktio_run \ + pktio_run_tap + +if HAVE_PCAP +dist_check_SCRIPTS += pktio_run_pcap +endif + +test_SCRIPTS = $(dist_check_SCRIPTS) diff --git a/platform/linux-generic/test/validation/pktio/pktio_env b/platform/linux-generic/test/validation/pktio/pktio_env new file mode 100644 index 0000000..345b5bd --- /dev/null +++ b/platform/linux-generic/test/validation/pktio/pktio_env @@ -0,0 +1,120 @@ +#!/bin/sh +# +# Copyright (c) 2015, Linaro Limited +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Test script wrapper for running ODP pktio apps on linux-generic. +# +# For linux-generic the default behavior is to create two pairs of +# virtual Ethernet interfaces and provide the names of these via +# environment variables to pktio apps, the interfaces will be removed +# before the script exits. +# +# Note that the creation of virtual Ethernet devices depends on having +# CONFIG_VETH enabled in the kernel, if not enabled the env setup will be skipped. +# +# Network set up +# IF0 <---> IF1 +# IF2 <---> IF3 +IF0=pktiop0p1 +IF1=pktiop1p0 +IF2=pktiop2p3 +IF3=pktiop3p2 + +if [ "$0" = "$BASH_SOURCE" ]; then + echo "Error: Platform specific env file has to be sourced." +fi + +check_for_root() +{ + if [ "$(id -u)" != "0" ]; then + echo "check_for_root(): need to be root to setup VETH" + return 1 + fi + return 0 +} + +# wait for a network interface's operational state to be "up" +wait_for_iface_up() +{ + iface=$1 + cnt=0 + + while [ $cnt -lt 50 ]; do + read operstate < /sys/class/net/$iface/operstate + + if [ $? -ne 0 ]; then + break + elif [ "$operstate" = "up" ]; then + return 0 + fi + + sleep 0.1 + cnt=`expr $cnt + 1` + done + + return 1 +} + +setup_pktio_env() +{ + echo "pktio: setting up test interfaces $IF0, $IF1, $IF2, $IF3." + + check_for_root + if [ $? -ne 0 ]; then + return 1 + fi + + for iface in $IF0 $IF1 $IF2 $IF3; do + ip link show $iface 2> /dev/null + if [ $? -eq 0 ]; then + echo "pktio: interface $iface already exist $?" + return 2 + fi + done + + if [ "$1" = "clean" ]; then + trap cleanup_pktio_env EXIT + fi + + ip link add $IF0 type veth peer name $IF1 + if [ $? -ne 0 ]; then + echo "pktio: error: unable to create veth pair" + return 3 + fi + ip link add $IF2 type veth peer name $IF3 + if [ $? -ne 0 ]; then + echo "pktio: error: unable to create veth pair" + return 4 + fi + + for iface in $IF0 $IF1 $IF2 $IF3; do + ip link set $iface mtu 9216 up + ifconfig $iface -arp + done + + # check that the interface has come up before starting the test + for iface in $IF0 $IF1 $IF2 $IF3; do + wait_for_iface_up $iface + if [ $? -ne 0 ]; then + echo "pktio: interface $iface failed to come up" + return 5 + fi + done +} + +cleanup_pktio_env() +{ + echo "pktio: removing test interfaces $IF0, $IF1, $IF2, $IF3" + check_for_root + if [ $? -ne 0 ]; then + return 1 + fi + + for iface in $IF0 $IF1 $IF2 $IF3; do + ip link del $iface 2> /dev/null + done + return 0 +} diff --git a/platform/linux-generic/test/validation/pktio/pktio_run b/platform/linux-generic/test/validation/pktio/pktio_run new file mode 100755 index 0000000..7029ab2 --- /dev/null +++ b/platform/linux-generic/test/validation/pktio/pktio_run @@ -0,0 +1,110 @@ +#!/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_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 + + # environment variables are used to control which socket method is + # used, so try each combination to ensure decent coverage. + for distype in MMAP MMSG; do + unset ODP_PKTIO_DISABLE_SOCKET_${distype} + done + + # this script doesn't support testing with netmap + export ODP_PKTIO_DISABLE_NETMAP=y + + for distype in SKIP MMAP; do + if [ "$disabletype" != "SKIP" ]; then + export ODP_PKTIO_DISABLE_SOCKET_${distype}=y + fi + pktio_main${EXEEXT} + if [ $? -ne 0 ]; then + ret=1 + fi + done + + if [ $ret -ne 0 ]; then + echo "!!! FAILED !!!" + fi + + return $ret +} + +run() +{ + echo "pktio: using 'loop' device" + pktio_main${EXEEXT} + loop_ret=$? + + # need to be root to run tests with real interfaces + if [ "$(id -u)" != "0" ]; then + exit $ret + fi + + if [ "$ODP_PKTIO_IF0" = "" ]; then + # no interfaces specified, use default veth interfaces + # setup by the pktio_env script + setup_pktio_env clean + if [ $? != 0 ]; then + echo "Failed to setup test environment, skipping test." + exit $TEST_SKIPPED + fi + export ODP_PKTIO_IF0=$IF0 + export ODP_PKTIO_IF1=$IF1 + fi + + run_test + ret=$? + + [ $ret = 0 ] && ret=$loop_ret + + exit $ret +} + +case "$1" in + setup) setup_pktio_env ;; + cleanup) cleanup_pktio_env ;; + *) run ;; +esac diff --git a/platform/linux-generic/test/validation/pktio/pktio_run_pcap b/platform/linux-generic/test/validation/pktio/pktio_run_pcap new file mode 100755 index 0000000..c130417 --- /dev/null +++ b/platform/linux-generic/test/validation/pktio/pktio_run_pcap @@ -0,0 +1,33 @@ +#!/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 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_path" +else + echo "cannot find pktio_main${EXEEXT}: please set you PATH for it." +fi + +PCAP_FNAME=vald.pcap +export ODP_PKTIO_IF0="pcap:out=${PCAP_FNAME}" +export ODP_PKTIO_IF1="pcap:in=${PCAP_FNAME}" +pktio_main${EXEEXT} +ret=$? +rm -f ${PCAP_FNAME} +exit $ret diff --git a/platform/linux-generic/test/validation/pktio/pktio_run_tap b/platform/linux-generic/test/validation/pktio/pktio_run_tap new file mode 100755 index 0000000..975da81 --- /dev/null +++ b/platform/linux-generic/test/validation/pktio/pktio_run_tap @@ -0,0 +1,115 @@ +#!/bin/sh +# +# Copyright (c) 2015, Ilya Maximets <[email protected]> +# 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 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_path" +else + echo "cannot find pktio_main${EXEEXT}: please set you PATH for it." +fi + +# exit code expected by automake for skipped tests +TEST_SKIPPED=77 + +TAP_BASE_NAME=iotap_vald +IF0=${TAP_BASE_NAME}0 +IF1=${TAP_BASE_NAME}1 +BR=${TAP_BASE_NAME}_br + +export ODP_PKTIO_IF0="tap:$IF0" +export ODP_PKTIO_IF1="tap:$IF1" + +tap_cleanup() +{ + ret=$? + + for iface in $IF0 $IF1; do + ip link set dev $iface nomaster + done + + ip link delete $BR type bridge + + for iface in $IF0 $IF1; do + ip tuntap del mode tap $iface + done + + trap - EXIT + exit $ret +} + +tap_setup() +{ + if [ "$(id -u)" != "0" ]; then + echo "pktio: need to be root to setup TAP interfaces." + return $TEST_SKIPPED + fi + + for iface in $IF0 $IF1 $BR; do + ip link show $iface 2> /dev/null + if [ $? -eq 0 ]; then + echo "pktio: interface $iface already exist $?" + return 2 + fi + done + + trap tap_cleanup EXIT + + for iface in $IF0 $IF1; do + ip tuntap add mode tap $iface + if [ $? -ne 0 ]; then + echo "pktio: error: unable to create TAP device $iface" + return 3 + fi + done + + ip link add name $BR type bridge + if [ $? -ne 0 ]; then + echo "pktio: error: unable to create bridge $BR" + return 3 + fi + + for iface in $IF0 $IF1; do + ip link set dev $iface master $BR + if [ $? -ne 0 ]; then + echo "pktio: error: unable to add $iface to bridge $BR" + return 4 + fi + done + + for iface in $IF0 $IF1 $BR; do + ifconfig $iface -arp + sysctl -w net.ipv6.conf.${iface}.disable_ipv6=1 + ip link set dev $iface mtu 9216 up + done + + return 0 +} + +tap_setup +ret=$? +if [ $ret -ne 0 ]; then + echo "pktio: tap_setup() FAILED!" + exit $ret +fi + +# Using ODP_WAIT_FOR_NETWORK to prevent fail if tap still not enabled in bridge +ODP_WAIT_FOR_NETWORK=yes pktio_main${EXEEXT} +ret=$? + +exit $ret diff --git a/test/performance/odp_l2fwd_run b/test/performance/odp_l2fwd_run index cab97a8..8dfb415 100755 --- a/test/performance/odp_l2fwd_run +++ b/test/performance/odp_l2fwd_run @@ -37,11 +37,11 @@ elif [ "$ODP_PLATFORM" = "" ]; then echo "$0: error: ODP_PLATFORM must be defined" # not skipped as this should never happen via "make check" exit 1 -elif [ -f ${TEST_SRC_DIR}/../../platform/$ODP_PLATFORM/test/pktio/pktio_env ]; then - . ${TEST_SRC_DIR}/../../platform/$ODP_PLATFORM/test/pktio/pktio_env +elif [ -f ${TEST_SRC_DIR}/../../platform/$ODP_PLATFORM/test/validation/pktio/pktio_env ]; then + . ${TEST_SRC_DIR}/../../platform/$ODP_PLATFORM/test/validation/pktio/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 "pktio_env has to be in current directory or in platform/\$ODP_PLATFORM/validation/test." echo "ODP_PLATFORM=\"$ODP_PLATFORM\"" exit 1 fi -- 2.5.0 _______________________________________________ lng-odp mailing list [email protected] https://lists.linaro.org/mailman/listinfo/lng-odp
