diff mbox

[PATCHv3] validation: implement platform env and add performance/odp_example_l2fwd_run

Message ID 1427103989-17859-1-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov March 23, 2015, 9:46 a.m. UTC
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.
As prof of validation that it works l2fwd is added to make check.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 This patch depends on: [PATCHv4] example: l2fwd print packets per second

 I named it as v3, previous patch version was: "tests: performance add l2fwd to run script"

 Best regards,
 Maxim.


 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   |  98 +++++++++++++++++++++++++
 test/performance/Makefile.am            |   4 +-
 test/performance/odp_example_l2fwd_run  |  35 +++++++++
 test/validation/odp_pktio_run           | 122 ++++----------------------------
 7 files changed, 155 insertions(+), 109 deletions(-)
 create mode 100644 platform/linux-generic/test/Makefile.am
 create mode 100755 platform/linux-generic/test/pktio_env
 create mode 100755 test/performance/odp_example_l2fwd_run

Comments

Mike Holmes March 24, 2015, 4 p.m. UTC | #1
Should this be structure for per platform test and example specifics be
structure 1 or 2 ?

   1. platform/linux-generic/test
   2. test/platform/linux-generic/test

I had imagined that we dont complicate the ODP API implementation with
the test and example support and work with structure 2.

Mike


On 23 March 2015 at 05:46, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> 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.
> As prof of validation that it works l2fwd is added to make check.
>
> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
> ---
>  This patch depends on: [PATCHv4] example: l2fwd print packets per second
>
>  I named it as v3, previous patch version was: "tests: performance add
> l2fwd to run script"
>
>  Best regards,
>  Maxim.
>
>
>  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   |  98 +++++++++++++++++++++++++
>  test/performance/Makefile.am            |   4 +-
>  test/performance/odp_example_l2fwd_run  |  35 +++++++++
>  test/validation/odp_pktio_run           | 122
> ++++----------------------------
>  7 files changed, 155 insertions(+), 109 deletions(-)
>  create mode 100644 platform/linux-generic/test/Makefile.am
>  create mode 100755 platform/linux-generic/test/pktio_env
>  create mode 100755 test/performance/odp_example_l2fwd_run
>
> diff --git a/platform/linux-generic/Makefile.am
> b/platform/linux-generic/Makefile.am
> index 9aed113..08349cd 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 100755
> index 0000000..97a2230
> --- /dev/null
> +++ b/platform/linux-generic/test/pktio_env
> @@ -0,0 +1,98 @@
> +#!/bin/sh
> +#
> +# Test script wrapper for running ODP pktio tests on linux-generic.
> +#
> +# For linux-generic the default behaviour is to create two pairs of
> +# virtual Ethernet interfaces and provide the names of these via
> +# environment variables to pktio test, 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.
> +#
> +TEST_DIR=$(dirname $0)
> +# Network set up
> +# IF0 <---> IF1
> +# IF2 <---> IF3
> +IF0=pktio-p0-p1
> +IF1=pktio-p1-p0
> +IF2=pktio-p2-p3
> +IF3=pktio-p3-p2
> +
> +# 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 [ $? -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."
> +
> +       for iface in $IF0 $IF1 $IF2 $IF3; do
> +               echo "ip link show $iface"
> +               #ip link show $iface 2> /dev/null
> +               ip link show $iface
> +               if [ $? -eq 0 ]; then
> +                       echo "pktio: interface $iface already exist $?"
> +                       return
> +               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"
> +               exit $TEST_SKIPPED
> +       fi
> +       ip link add $IF2 type veth peer name $IF3
> +       if [ $? -ne 0 ]; then
> +               echo "pktio: error: unable to create veth pair"
> +               exit $TEST_SKIPPED
> +       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"
> +                       exit 1
> +               fi
> +       done
> +}
> +
> +cleanup_pktio_env()
> +{
> +       echo "pktio: removing test interfaces $IF0 - $IF3"
> +
> +       for iface in $IF0 $IF1 $IF2 $IF3; do
> +               ip link del $iface 2> /dev/null
> +       done
> +}
> diff --git a/test/performance/Makefile.am b/test/performance/Makefile.am
> index 3be3721..4f480c3 100644
> --- a/test/performance/Makefile.am
> +++ b/test/performance/Makefile.am
> @@ -1,10 +1,12 @@
>  include $(top_srcdir)/test/Makefile.inc
>
> +TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform}
> +
>  EXECUTABLES =
>
>  COMPILE_ONLY = odp_scheduling
>
> -TESTSCRIPTS = odp_scheduling_run
> +TESTSCRIPTS = odp_scheduling_run odp_example_l2fwd_run
>
>  if test_perf
>  TESTS = $(EXECUTABLES) $(TESTSCRIPTS)
> diff --git a/test/performance/odp_example_l2fwd_run
> b/test/performance/odp_example_l2fwd_run
> new file mode 100755
> index 0000000..c300055
> --- /dev/null
> +++ b/test/performance/odp_example_l2fwd_run
> @@ -0,0 +1,35 @@
> +#!/bin/sh
> +
> +TEST_DIR=$(dirname $0)
> +
> +# 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 "unable to find pktio_env"
> +                       exit 1
> +               fi
> +fi
> +
> +run_l2fwd_example()
> +{
> +       setup_pktio_env
> +       #@todo: limit odp_generator to cores
> +       ($TEST_DIR/../../example/generator/odp_generator -I $IF0 \
> +                       --srcmac fe:0f:97:c9:e0:44  --dstmac
> 32:cb:9b:27:2f:1a \
> +                       --srcip 192.168.0.1 --dstip 192.168.0.2 -m u 2>&1
> > /dev/null) \
> +                       2>&1 > /dev/null &
> +
> +       echo "Run $TEST_DIR/../../example/l2fwd/odp_l2fwd -i $IF1,$IF2 -m
> 0 -t 60 -c 2"
> +       $TEST_DIR/../../example/l2fwd/odp_l2fwd -i $IF1,$IF2 -m 0 -t 60 -c
> 2
> +       cleanup_pktio_env
> +       exit 0
> +}
> +
> +case "$1" in
> +       setup)   setup_pktio_env   ;;
> +       cleanup) cleanup_pktio_env ;;
> +       *)       run_l2fwd_example ;;
> +esac
> diff --git a/test/validation/odp_pktio_run b/test/validation/odp_pktio_run
> index 204b440..74cec27 100755
> --- a/test/validation/odp_pktio_run
> +++ b/test/validation/odp_pktio_run
> @@ -1,104 +1,16 @@
>  #!/bin/sh
> -#
> -# Test script wrapper for running ODP pktio tests on linux-generic.
> -#
> -# 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.
> -#
> -# 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=$(dirname $0)
> -IF0=pktio-p0
> -IF1=pktio-p1
>
> -# 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
> -       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"
> +# 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 "unable to find pktio_env"
>                         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 +28,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 +50,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 +58,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
> --
> 1.9.1
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Maxim Uvarov March 24, 2015, 4:07 p.m. UTC | #2
On 03/24/15 19:00, Mike Holmes wrote:
> Should this be structure for per platform test and example specifics 
> be structure 1 or 2 ?
>
>  1. platform/linux-generic/test
>  2. test/platform/linux-generic/test
>
> I had imagined that we dont complicate the ODP API implementation with 
> the test and example support and work with structure 2.
>
> Mike
>
We spoke about that with Anders and finally decided go with 1. Our 
arguments are: platform implementations
should not touch test/ directory. But each platform can provide it's own 
set ups and env for running examples and tests. When you build .deb (or 
.ipk) platfrom specific env will be packaged to directory with example 
binaries. Because one .deb has only one odp platfrom, there will be only 
one env specific for that platform.

Best regards,
Maxim.


>
> On 23 March 2015 at 05:46, Maxim Uvarov <maxim.uvarov@linaro.org 
> <mailto:maxim.uvarov@linaro.org>> wrote:
>
>     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.
>     As prof of validation that it works l2fwd is added to make check.
>
>     Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org
>     <mailto:maxim.uvarov@linaro.org>>
>     ---
>      This patch depends on: [PATCHv4] example: l2fwd print packets per
>     second
>
>      I named it as v3, previous patch version was: "tests: performance
>     add l2fwd to run script"
>
>      Best regards,
>      Maxim.
>
>
>      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   |  98
>     +++++++++++++++++++++++++
>      test/performance/Makefile.am            |   4 +-
>      test/performance/odp_example_l2fwd_run  |  35 +++++++++
>      test/validation/odp_pktio_run           | 122
>     ++++----------------------------
>      7 files changed, 155 insertions(+), 109 deletions(-)
>      create mode 100644 platform/linux-generic/test/Makefile.am
>      create mode 100755 platform/linux-generic/test/pktio_env
>      create mode 100755 test/performance/odp_example_l2fwd_run
>
>     diff --git a/platform/linux-generic/Makefile.am
>     b/platform/linux-generic/Makefile.am
>     index 9aed113..08349cd 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 100755
>     index 0000000..97a2230
>     --- /dev/null
>     +++ b/platform/linux-generic/test/pktio_env
>     @@ -0,0 +1,98 @@
>     +#!/bin/sh
>     +#
>     +# Test script wrapper for running ODP pktio tests on linux-generic.
>     +#
>     +# For linux-generic the default behaviour is to create two pairs of
>     +# virtual Ethernet interfaces and provide the names of these via
>     +# environment variables to pktio test, 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.
>     +#
>     +TEST_DIR=$(dirname $0)
>     +# Network set up
>     +# IF0 <---> IF1
>     +# IF2 <---> IF3
>     +IF0=pktio-p0-p1
>     +IF1=pktio-p1-p0
>     +IF2=pktio-p2-p3
>     +IF3=pktio-p3-p2
>     +
>     +# 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 [ $? -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."
>     +
>     +       for iface in $IF0 $IF1 $IF2 $IF3; do
>     +               echo "ip link show $iface"
>     +               #ip link show $iface 2> /dev/null
>     +               ip link show $iface
>     +               if [ $? -eq 0 ]; then
>     +                       echo "pktio: interface $iface already
>     exist $?"
>     +                       return
>     +               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"
>     +               exit $TEST_SKIPPED
>     +       fi
>     +       ip link add $IF2 type veth peer name $IF3
>     +       if [ $? -ne 0 ]; then
>     +               echo "pktio: error: unable to create veth pair"
>     +               exit $TEST_SKIPPED
>     +       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"
>     +                       exit 1
>     +               fi
>     +       done
>     +}
>     +
>     +cleanup_pktio_env()
>     +{
>     +       echo "pktio: removing test interfaces $IF0 - $IF3"
>     +
>     +       for iface in $IF0 $IF1 $IF2 $IF3; do
>     +               ip link del $iface 2> /dev/null
>     +       done
>     +}
>     diff --git a/test/performance/Makefile.am
>     b/test/performance/Makefile.am
>     index 3be3721..4f480c3 100644
>     --- a/test/performance/Makefile.am
>     +++ b/test/performance/Makefile.am
>     @@ -1,10 +1,12 @@
>      include $(top_srcdir)/test/Makefile.inc
>
>     +TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform}
>     +
>      EXECUTABLES =
>
>      COMPILE_ONLY = odp_scheduling
>
>     -TESTSCRIPTS = odp_scheduling_run
>     +TESTSCRIPTS = odp_scheduling_run odp_example_l2fwd_run
>
>      if test_perf
>      TESTS = $(EXECUTABLES) $(TESTSCRIPTS)
>     diff --git a/test/performance/odp_example_l2fwd_run
>     b/test/performance/odp_example_l2fwd_run
>     new file mode 100755
>     index 0000000..c300055
>     --- /dev/null
>     +++ b/test/performance/odp_example_l2fwd_run
>     @@ -0,0 +1,35 @@
>     +#!/bin/sh
>     +
>     +TEST_DIR=$(dirname $0)
>     +
>     +# 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 "unable to find pktio_env"
>     +                       exit 1
>     +               fi
>     +fi
>     +
>     +run_l2fwd_example()
>     +{
>     +       setup_pktio_env
>     +       #@todo: limit odp_generator to cores
>     +       ($TEST_DIR/../../example/generator/odp_generator -I $IF0 \
>     +                       --srcmac fe:0f:97:c9:e0:44  --dstmac
>     32:cb:9b:27:2f:1a \
>     +                       --srcip 192.168.0.1 --dstip 192.168.0.2 -m
>     u 2>&1 > /dev/null) \
>     +                       2>&1 > /dev/null &
>     +
>     +       echo "Run $TEST_DIR/../../example/l2fwd/odp_l2fwd -i
>     $IF1,$IF2 -m 0 -t 60 -c 2"
>     +       $TEST_DIR/../../example/l2fwd/odp_l2fwd -i $IF1,$IF2 -m 0
>     -t 60 -c 2
>     +       cleanup_pktio_env
>     +       exit 0
>     +}
>     +
>     +case "$1" in
>     +       setup)   setup_pktio_env   ;;
>     +       cleanup) cleanup_pktio_env ;;
>     +       *)       run_l2fwd_example ;;
>     +esac
>     diff --git a/test/validation/odp_pktio_run
>     b/test/validation/odp_pktio_run
>     index 204b440..74cec27 100755
>     --- a/test/validation/odp_pktio_run
>     +++ b/test/validation/odp_pktio_run
>     @@ -1,104 +1,16 @@
>      #!/bin/sh
>     -#
>     -# Test script wrapper for running ODP pktio tests on linux-generic.
>     -#
>     -# 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.
>     -#
>     -# 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=$(dirname $0)
>     -IF0=pktio-p0
>     -IF1=pktio-p1
>
>     -# 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
>     -       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"
>     +# 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 "unable to find pktio_env"
>                             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 +28,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 +50,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 +58,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
>     --
>     1.9.1
>
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>
> -- 
> Mike Holmes
> Technical Manager - Linaro Networking Group
> Linaro.org <http://www.linaro.org/>***│ *Open source software for ARM SoCs
>
diff mbox

Patch

diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index 9aed113..08349cd 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 100755
index 0000000..97a2230
--- /dev/null
+++ b/platform/linux-generic/test/pktio_env
@@ -0,0 +1,98 @@ 
+#!/bin/sh
+#
+# Test script wrapper for running ODP pktio tests on linux-generic.
+#
+# For linux-generic the default behaviour is to create two pairs of
+# virtual Ethernet interfaces and provide the names of these via
+# environment variables to pktio test, 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.
+#
+TEST_DIR=$(dirname $0)
+# Network set up
+# IF0 <---> IF1
+# IF2 <---> IF3
+IF0=pktio-p0-p1
+IF1=pktio-p1-p0
+IF2=pktio-p2-p3
+IF3=pktio-p3-p2
+
+# 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 [ $? -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."
+
+	for iface in $IF0 $IF1 $IF2 $IF3; do
+		echo "ip link show $iface"
+		#ip link show $iface 2> /dev/null
+		ip link show $iface
+		if [ $? -eq 0 ]; then
+			echo "pktio: interface $iface already exist $?"
+			return
+		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"
+		exit $TEST_SKIPPED
+	fi
+	ip link add $IF2 type veth peer name $IF3
+	if [ $? -ne 0 ]; then
+		echo "pktio: error: unable to create veth pair"
+		exit $TEST_SKIPPED
+	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"
+			exit 1
+		fi
+	done
+}
+
+cleanup_pktio_env()
+{
+	echo "pktio: removing test interfaces $IF0 - $IF3"
+
+	for iface in $IF0 $IF1 $IF2 $IF3; do
+		ip link del $iface 2> /dev/null
+	done
+}
diff --git a/test/performance/Makefile.am b/test/performance/Makefile.am
index 3be3721..4f480c3 100644
--- a/test/performance/Makefile.am
+++ b/test/performance/Makefile.am
@@ -1,10 +1,12 @@ 
 include $(top_srcdir)/test/Makefile.inc
 
+TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform}
+
 EXECUTABLES =
 
 COMPILE_ONLY = odp_scheduling
 
-TESTSCRIPTS = odp_scheduling_run
+TESTSCRIPTS = odp_scheduling_run odp_example_l2fwd_run
 
 if test_perf
 TESTS = $(EXECUTABLES) $(TESTSCRIPTS)
diff --git a/test/performance/odp_example_l2fwd_run b/test/performance/odp_example_l2fwd_run
new file mode 100755
index 0000000..c300055
--- /dev/null
+++ b/test/performance/odp_example_l2fwd_run
@@ -0,0 +1,35 @@ 
+#!/bin/sh
+
+TEST_DIR=$(dirname $0)
+
+# 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 "unable to find pktio_env"
+			exit 1
+		fi
+fi
+
+run_l2fwd_example()
+{
+	setup_pktio_env
+	#@todo: limit odp_generator to cores
+	($TEST_DIR/../../example/generator/odp_generator -I $IF0 \
+			--srcmac fe:0f:97:c9:e0:44  --dstmac 32:cb:9b:27:2f:1a \
+			--srcip 192.168.0.1 --dstip 192.168.0.2 -m u 2>&1 > /dev/null) \
+			2>&1 > /dev/null &
+
+	echo "Run $TEST_DIR/../../example/l2fwd/odp_l2fwd -i $IF1,$IF2 -m 0 -t 60 -c 2"
+	$TEST_DIR/../../example/l2fwd/odp_l2fwd -i $IF1,$IF2 -m 0 -t 60 -c 2
+	cleanup_pktio_env
+	exit 0
+}
+
+case "$1" in
+	setup)   setup_pktio_env   ;;
+	cleanup) cleanup_pktio_env ;;
+	*)       run_l2fwd_example ;;
+esac
diff --git a/test/validation/odp_pktio_run b/test/validation/odp_pktio_run
index 204b440..74cec27 100755
--- a/test/validation/odp_pktio_run
+++ b/test/validation/odp_pktio_run
@@ -1,104 +1,16 @@ 
 #!/bin/sh
-#
-# Test script wrapper for running ODP pktio tests on linux-generic.
-#
-# 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.
-#
-# 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=$(dirname $0)
-IF0=pktio-p0
-IF1=pktio-p1
 
-# 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
-	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"
+# 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 "unable to find pktio_env"
 			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 +28,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 +50,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 +58,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