From patchwork Wed Apr 1 13:40:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 47080 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 86A1921416 for ; Sat, 11 Apr 2015 09:54:27 +0000 (UTC) Received: by lbcne10 with SMTP id ne10sf8792631lbc.1 for ; Sat, 11 Apr 2015 02:54:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=OUuk12gD7aIvvxT3qnlC+ydVRgg2yi9EIHYbAEaIJBA=; b=OO8wpNeexEm/0oAeFgTSGnlaUrQiomcbs1k5RtpVN+v43J6o3bRd05DawBRoxdqlgu KEixXKWnptYLrM1T+XOlc9k3Iwoa1akgBgSwMnpRPVr9G8ethDd8YsI1vPiFe4ZbrjqA 1B0Hr7C4GQn4FlYf8Xd9EKCCl/W09IrvCgooJ+dH0tMuXYHVekSR6fKVVb36ta1cYQ5R LynfMJrSi698DLYgcoXEe8EvMZfmJADwnYH8P/I5k5pKF9smJJKnXxCc+5RQHJwqWKEj DOe+Q/bqrWwISjZTybCyoU7wHLHWq7jH9kv5gLChcO7A9IfDePtpie8ESZNpHrxtUu8O rr7w== X-Gm-Message-State: ALoCoQlNSmxcB7mBWSi6YaaPoa0wVEk2kN15QIaTB7rPL3tUEPi6Q+IoLj3lTjVo7tvS7ZLqfSer X-Received: by 10.112.142.170 with SMTP id rx10mr180638lbb.12.1428746066518; Sat, 11 Apr 2015 02:54:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.121.5 with SMTP id lg5ls447832lab.106.gmail; Sat, 11 Apr 2015 02:54:26 -0700 (PDT) X-Received: by 10.153.7.133 with SMTP id dc5mr4950342lad.17.1428746066132; Sat, 11 Apr 2015 02:54:26 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id t17si3498040laz.27.2015.04.11.02.54.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Apr 2015 02:54:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by labbd9 with SMTP id bd9so28284268lab.2 for ; Sat, 11 Apr 2015 02:54:25 -0700 (PDT) X-Received: by 10.152.4.72 with SMTP id i8mr4932701lai.29.1428746065837; Sat, 11 Apr 2015 02:54:25 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp230962lbt; Sat, 11 Apr 2015 02:54:25 -0700 (PDT) X-Received: by 10.140.148.20 with SMTP id 20mr6681331qhu.67.1428746064239; Sat, 11 Apr 2015 02:54:24 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id e90si4358588qgd.75.2015.04.11.02.54.23; Sat, 11 Apr 2015 02:54:24 -0700 (PDT) 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; Received: by lists.linaro.org (Postfix, from userid 109) id 831EA6354B; Sat, 11 Apr 2015 09:54:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id D08D965138; Sat, 11 Apr 2015 09:52:19 +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 D18DC64FA0; Wed, 1 Apr 2015 13:40:15 +0000 (UTC) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com [209.85.215.52]) by lists.linaro.org (Postfix) with ESMTPS id 9F4B364FA0 for ; Wed, 1 Apr 2015 13:40:13 +0000 (UTC) Received: by lahf3 with SMTP id f3so36313113lah.2 for ; Wed, 01 Apr 2015 06:40:12 -0700 (PDT) X-Received: by 10.112.136.232 with SMTP id qd8mr17196345lbb.1.1427895612061; Wed, 01 Apr 2015 06:40:12 -0700 (PDT) Received: from localhost.localdomain (ppp91-76-169-66.pppoe.mtu-net.ru. [91.76.169.66]) by mx.google.com with ESMTPSA id d10sm428461lag.29.2015.04.01.06.40.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Apr 2015 06:40:11 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 1 Apr 2015 16:40:01 +0300 Message-Id: <1427895604-15031-2-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427895604-15031-1-git-send-email-maxim.uvarov@linaro.org> References: <1427895604-15031-1-git-send-email-maxim.uvarov@linaro.org> X-Mailman-Approved-At: Wed, 01 Apr 2015 13:41:43 +0000 X-Topics: patch Cc: petri.savolainen@nokia.com Subject: [lng-odp] [PATCHv7 1/4] validation: implement platform env X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Different platforms need different steps to set up pktio for testing. That might be veth devices for linux-generic, kernel modules and extended set up for dpdk and simple set pktio testing names for other platforms. This patch implements platform/test/pktio_env file which sets up global envs for pktio. Signed-off-by: Maxim Uvarov --- platform/linux-generic/Makefile.am | 2 + platform/linux-generic/m4/configure.m4 | 2 + platform/linux-generic/test/Makefile.am | 1 + platform/linux-generic/test/pktio_env | 120 ++++++++++++++++++++++++++++++ test/validation/odp_pktio_run | 125 ++++++-------------------------- 5 files changed, 146 insertions(+), 104 deletions(-) create mode 100644 platform/linux-generic/test/Makefile.am create mode 100644 platform/linux-generic/test/pktio_env diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index e5558ac..033be51 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -5,6 +5,8 @@ AM_CFLAGS += -I$(srcdir)/include AM_CFLAGS += -I$(top_srcdir)/include AM_CFLAGS += -I$(top_srcdir)/helper/include +SUBDIRS = test + include_HEADERS = \ $(top_srcdir)/include/odp.h diff --git a/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4 index 00f2f89..55124f1 100644 --- a/platform/linux-generic/m4/configure.m4 +++ b/platform/linux-generic/m4/configure.m4 @@ -15,3 +15,5 @@ AC_LINK_IFELSE( echo "GCC-style __atomic builtins not supported by the compiler." echo "Use newer version. For gcc > 4.7.0" exit -1) + +AC_CONFIG_FILES([platform/linux-generic/test/Makefile]) diff --git a/platform/linux-generic/test/Makefile.am b/platform/linux-generic/test/Makefile.am new file mode 100644 index 0000000..91e361c --- /dev/null +++ b/platform/linux-generic/test/Makefile.am @@ -0,0 +1 @@ +dist_bin_SCRIPTS = $(srcdir)/pktio_env diff --git a/platform/linux-generic/test/pktio_env b/platform/linux-generic/test/pktio_env new file mode 100644 index 0000000..5e547e4 --- /dev/null +++ b/platform/linux-generic/test/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=pktio-p0-p1 +IF1=pktio-p1-p0 +IF2=pktio-p2-p3 +IF3=pktio-p3-p2 + +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/test/validation/odp_pktio_run b/test/validation/odp_pktio_run index b725a5f..a2a7556 100755 --- a/test/validation/odp_pktio_run +++ b/test/validation/odp_pktio_run @@ -1,104 +1,27 @@ #!/bin/sh # -# Test script wrapper for running ODP pktio tests on linux-generic. +# Copyright (c) 2015, Linaro Limited +# All rights reserved. # -# For platforms other than linux-generic this script does nothing other -# than running the odp_pktio binary, odp_pktio will then attempt to -# open and use the special device named "loop" for testing. +# SPDX-License-Identifier: BSD-3-Clause # -# For linux-generic the default behaviour is to create a pair of -# virtual Ethernet interfaces and provide the names of these via -# environment variables to odp_pktio, 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 test will be skipped. -# -# The evironment variable ODP_PLATFORM is used to determine the -# platform under test, when this script is invoked via 'make check' -# this variable is set automatically. -# -# It's also possible to split up the steps, which makes it easier when -# debugging, for example; -# -# export ODP_PLATFORM=linux-generic -# odp_pktio_run setup -# wireshark -i pktio-p0 -k & -# odp_pktio_run -# (repeat running test multiple times..) -# odp_pktio_run cleanup -# -TEST_DIR="${TEST_DIR:-$(dirname $0)}" -IF0=pktio-p0 -IF1=pktio-p1 + +TEST_DIR=$(dirname $0) # exit codes expected by automake for skipped tests TEST_SKIPPED=77 -# 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 [ $? != 0 ]; then - break - elif [ "$operstate" = "up" ]; then - return 0 - fi - - sleep 0.1 - cnt=`expr $cnt + 1` - done - - return 1 -} - -setup_env1() -{ - ip link show $IF0 2> /dev/null - if [ $? = 0 ]; then - ip link show $IF1 2> /dev/null - if [ $? = 0 ]; then - echo "pktio: interfaces $IF0 and $IF1 already exist" - return - fi +# Use installed pktio env or for make check take it from platform directory +if [ -f "./pktio_env" ]; then + . ./pktio_env +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/X/test." + exit 1 fi - - echo "pktio: setting up test interfaces $IF0 and $IF1" - - if [ "$1" = "clean" ]; then - trap cleanup_env1 EXIT - fi - - ip link add $IF0 type veth peer name $IF1 - if [ $? != 0 ]; then - echo "pktio: error: unable to create veth pair" - exit $TEST_SKIPPED - fi - ip link set $IF0 mtu 9216 up - ip link set $IF1 mtu 9216 up - ifconfig $IF0 -arp - ifconfig $IF1 -arp - - # check that the interface has come up before starting the test - for iface in $IF0 $IF1; do - wait_for_iface_up $iface - if [ $? != 0 ]; then - echo "pktio: interface $iface failed to come up" - exit 1 - fi - done -} - -cleanup_env1() -{ - echo "pktio: removing test interfaces $IF0 and $IF1" - ip link del $IF0 2> /dev/null - ip link del $IF1 2> /dev/null -} +fi run_test() { @@ -116,12 +39,12 @@ run_test() export ODP_PKTIO_DISABLE_SOCKET_${distype}=y fi $TEST_DIR/odp_pktio - if [ $? != 0 ]; then + if [ $? -ne 0 ]; then ret=1 fi done - if [ $ret != 0 ]; then + if [ $ret -ne 0 ]; then echo "!!! FAILED !!!" fi @@ -138,7 +61,7 @@ run() if [ "$ODP_PKTIO_IF0" = "" ]; then # no interfaces specified on linux-generic, use defaults - setup_env1 clean + setup_pktio_env clean export ODP_PKTIO_IF0=$IF0 export ODP_PKTIO_IF1=$IF1 fi @@ -146,14 +69,8 @@ run() run_test } -if [ "$ODP_PLATFORM" = "" ]; then - echo "pktio: error: ODP_PLATFORM must be defined" - # not skipped as this should never happen via "make check" - exit 1 -fi - case "$1" in - setup) setup_env1 ;; - cleanup) cleanup_env1 ;; - *) run ;; + setup) setup_pktio_env ;; + cleanup) cleanup_pktio_env ;; + *) run ;; esac