From patchwork Wed Jan 27 18:37:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 60641 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp15097lbb; Wed, 27 Jan 2016 10:38:14 -0800 (PST) X-Received: by 10.140.242.216 with SMTP id n207mr38356982qhc.37.1453919894016; Wed, 27 Jan 2016 10:38:14 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 69si7793801qgg.2.2016.01.27.10.38.13; Wed, 27 Jan 2016 10:38:13 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 835DF617DA; Wed, 27 Jan 2016 18:38:13 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=U0trmmba; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,T_DKIM_INVALID,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id AACC16180A; Wed, 27 Jan 2016 18:37:41 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 66191617F8; Wed, 27 Jan 2016 18:37:27 +0000 (UTC) Received: from mail-qg0-f46.google.com (mail-qg0-f46.google.com [209.85.192.46]) by lists.linaro.org (Postfix) with ESMTPS id 7525F61775 for ; Wed, 27 Jan 2016 18:37:20 +0000 (UTC) Received: by mail-qg0-f46.google.com with SMTP id 6so14252693qgy.1 for ; Wed, 27 Jan 2016 10:37:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=But8j0lG3HnqCVbO6fbRh//D7nE2Hsf77L+9dXkxw6Y=; b=U0trmmba+xI2rExfVobmpq1dKwtXzOFareaSgNjAUK6TKDSYqyik8aVJqr+x6W9+3M yjdYIRWolOe496k7tYdZ4SlO2TKEvzAfBujAiH56T0R66JNbbzcdbVsGUaBStXVmk5Nf wLDe5XYyXLmvm+gY0p3bAW2apopT/fooCbTD4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=But8j0lG3HnqCVbO6fbRh//D7nE2Hsf77L+9dXkxw6Y=; b=bHZVz6uQa3xX/3RYw2yvKeOpRySdCLCEsJaeU59hgu6StKV9bBTDh/8t7Z2pjP4EXT FV7UcSXwuDK3RE3mSqywj4jTjLIckLEy7OB6eu5tzDc2AmamRwBEr4yemksNcMkllfH/ A0xyLj1IbVA/hy2lOWK6Q9YVGlFr5HUf6LPlsHGOMkq8/4IvC5qXTFmQi70B3Vt8me9Q ENXptVZ/bxDquHAXsyzR8aERdqiCBx1ne7aCEOrLnIW1Dm2RhtViVA1rF3QBWGCCqYKL ZSF+7IpAH90Pc5SNnKcbiJ/gjW1WZm0ivzr5KZZEPuk9JUMm4ePSN+OQwTvC3c8VjwNq 5cgw== X-Gm-Message-State: AG10YOQj6/lf9sX3VTTWE2HALBx3Xrdg/3gLCuQKFxIC67tud2jwqTC32zDmLLh+DZnSxZFacuI= X-Received: by 10.140.100.229 with SMTP id s92mr35978936qge.19.1453919840216; Wed, 27 Jan 2016 10:37:20 -0800 (PST) Received: from localhost.localdomain (c-98-221-136-245.hsd1.nj.comcast.net. [98.221.136.245]) by smtp.gmail.com with ESMTPSA id v74sm2185004qka.7.2016.01.27.10.37.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Jan 2016 10:37:19 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Wed, 27 Jan 2016 13:37:12 -0500 Message-Id: <1453919833-19364-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.5.0 X-Topics: patch Subject: [lng-odp] [PATCH v3 1/2] linux-generic: test: move validation tests to their own directory X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" 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 --- 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 -# 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 +# 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