Message ID | 1426259027-14083-3-git-send-email-maxim.uvarov@linaro.org |
---|---|
State | New |
Headers | show |
On Fri, Mar 13, 2015 at 06:03:47PM +0300, Maxim Uvarov wrote: > Move common pktio linux-generic functions to setup virtual net to > linux-generic folder and add running l2fwd test for make check. > > Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> > --- > platform/linux-generic/test/pktio_env | 90 ++++++++++++++++++++++++++++++++++ > test/performance/Makefile.am | 4 +- > test/performance/odp_example_l2fwd_run | 31 ++++++++++++ > test/validation/odp_pktio_run | 83 +++---------------------------- > 4 files changed, 132 insertions(+), 76 deletions(-) > create mode 100755 platform/linux-generic/test/pktio_env > create mode 100755 test/performance/odp_example_l2fwd_run > > diff --git a/platform/linux-generic/test/pktio_env b/platform/linux-generic/test/pktio_env > new file mode 100755 > index 0000000..a6d0597 > --- /dev/null > +++ b/platform/linux-generic/test/pktio_env > @@ -0,0 +1,90 @@ > +#!/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. This comment and some others below aren't valid now. > +# > +# 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) > +# 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 > + > +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" What about the other 2 interfaces? > + return > + fi > + fi > + > + echo "pktio: setting up test interfaces $IF0, $IF1, $IF2, $IF3." > + > + 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 add $IF2 type veth peer name $IF3 > + 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 > + ip link set $IF2 mtu 9216 up > + ip link set $IF3 mtu 9216 up > + ifconfig $IF0 -arp > + ifconfig $IF1 -arp > + ifconfig $IF2 -arp > + ifconfig $IF3 -arp > + > + # network needs a little time to come up > + sleep 1 > +} > + > +cleanup_env1() > +{ > + echo "pktio: removing test interfaces $IF0 - $IF3" > + ip link del $IF0 2> /dev/null > + ip link del $IF1 2> /dev/null > + ip link del $IF2 2> /dev/null > + ip link del $IF3 2> /dev/null > +} > 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..69784f9 > --- /dev/null > +++ b/test/performance/odp_example_l2fwd_run > @@ -0,0 +1,31 @@ > +#!/bin/sh > + > +TEST_DIR=$(dirname $0) > + > +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 > + > +if [ "$ODP_PLATFORM" = "linux-generic" ]; then > +echo "source ${TEST_DIR}/../../platform/linux-generic/test/pktio_env" > +. ${TEST_DIR}/../../platform/linux-generic/test/pktio_env This won't work when you're cross-building and then running the tests on the target as a separate step. > +fi > + > +run_l2fwd_example() > +{ > + setup_env1 > + #ping is too slow, needed to replace it with odp generator As this isn't an RFC I'd think it's better just to state for now that it's testing basic functionality, performance testing can be added later. > + (ping -w 65 -I $IF0 -f 1.1.1.1 2>&1 > /dev/null) & > + echo "Run $TEST_DIR/../../example/l2fwd/odp_l2fwd -i $IF1,$IF2 -m 0 -t 60" If ODP_PLATFORM != linux-generic this code still runs, but the interfaces almost certainly won't exist. How would this test be run on platforms other than linux-generic? > + $TEST_DIR/../../example/l2fwd/odp_l2fwd -i $IF1,$IF2 -m 0 -t 60 You need to limit the cores on which l2fwd runs to prevent the traffic generation interfering with the forwarding (though not much of a problem with just the ping). > + cleanup_env1 > + exit 0 > +} > + > +case "$1" in > + setup) setup_env1 ;; > + cleanup) cleanup_env1 ;; > + *) run_l2fwd_example ;; > +esac > diff --git a/test/validation/odp_pktio_run b/test/validation/odp_pktio_run > index 6177caa..37b775f 100755 > --- a/test/validation/odp_pktio_run > +++ b/test/validation/odp_pktio_run > @@ -1,76 +1,15 @@ > #!/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 > +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 > > -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 > - > - # network needs a little time to come up > - sleep 1 > -} > - > -cleanup_env1() > -{ > - echo "pktio: removing test interfaces $IF0 and $IF1" > - ip link del $IF0 2> /dev/null > - ip link del $IF1 2> /dev/null > -} > +if [ "$ODP_PLATFORM" = "linux-generic" ]; then > +. ${TEST_DIR}/../../platform/linux-generic/test/pktio_env > +fi As earlier, won't work in a cross-build-test environment. > > run_test() > { Not shown in this patch, but there's a bunch of other stuff in odp_pktio_run that is linux-generic specific so it makes sense to move that up to platform/linux-generic too. > @@ -118,12 +57,6 @@ 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 ;; > -- > 1.9.1 >
On 03/16/15 14:09, Stuart Haslam wrote: > On Fri, Mar 13, 2015 at 06:03:47PM +0300, Maxim Uvarov wrote: >> Move common pktio linux-generic functions to setup virtual net to >> linux-generic folder and add running l2fwd test for make check. >> >> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> >> --- >> platform/linux-generic/test/pktio_env | 90 ++++++++++++++++++++++++++++++++++ >> test/performance/Makefile.am | 4 +- >> test/performance/odp_example_l2fwd_run | 31 ++++++++++++ >> test/validation/odp_pktio_run | 83 +++---------------------------- >> 4 files changed, 132 insertions(+), 76 deletions(-) >> create mode 100755 platform/linux-generic/test/pktio_env >> create mode 100755 test/performance/odp_example_l2fwd_run >> >> diff --git a/platform/linux-generic/test/pktio_env b/platform/linux-generic/test/pktio_env >> new file mode 100755 >> index 0000000..a6d0597 >> --- /dev/null >> +++ b/platform/linux-generic/test/pktio_env >> @@ -0,0 +1,90 @@ >> +#!/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. > This comment and some others below aren't valid now. Ah, yes. Not sure what is better move in one patch and fix in second patch. Or move and fix in one patch. >> +# >> +# 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) >> +# 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 >> + >> +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" > What about the other 2 interfaces? good catch. And more likely that cascading if's are not needed here. >> + return >> + fi >> + fi >> + >> + echo "pktio: setting up test interfaces $IF0, $IF1, $IF2, $IF3." >> + >> + 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 add $IF2 type veth peer name $IF3 >> + 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 >> + ip link set $IF2 mtu 9216 up >> + ip link set $IF3 mtu 9216 up >> + ifconfig $IF0 -arp >> + ifconfig $IF1 -arp >> + ifconfig $IF2 -arp >> + ifconfig $IF3 -arp >> + >> + # network needs a little time to come up >> + sleep 1 >> +} >> + >> +cleanup_env1() >> +{ >> + echo "pktio: removing test interfaces $IF0 - $IF3" >> + ip link del $IF0 2> /dev/null >> + ip link del $IF1 2> /dev/null >> + ip link del $IF2 2> /dev/null >> + ip link del $IF3 2> /dev/null >> +} >> 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..69784f9 >> --- /dev/null >> +++ b/test/performance/odp_example_l2fwd_run >> @@ -0,0 +1,31 @@ >> +#!/bin/sh >> + >> +TEST_DIR=$(dirname $0) >> + >> +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 >> + >> +if [ "$ODP_PLATFORM" = "linux-generic" ]; then >> +echo "source ${TEST_DIR}/../../platform/linux-generic/test/pktio_env" >> +. ${TEST_DIR}/../../platform/linux-generic/test/pktio_env > This won't work when you're cross-building and then running the tests on > the target as a separate step. I think to make 'make check' happy it will be enough to do: TEST_DIR="${TEST_DIR:-$(dirname $0)}" >> +fi >> + >> +run_l2fwd_example() >> +{ >> + setup_env1 >> + #ping is too slow, needed to replace it with odp generator > As this isn't an RFC I'd think it's better just to state for now that > it's testing basic functionality, performance testing can be added later. Yes, that is a plan. >> + (ping -w 65 -I $IF0 -f 1.1.1.1 2>&1 > /dev/null) & >> + echo "Run $TEST_DIR/../../example/l2fwd/odp_l2fwd -i $IF1,$IF2 -m 0 -t 60" > If ODP_PLATFORM != linux-generic this code still runs, but the interfaces > almost certainly won't exist. How would this test be run on platforms > other than linux-generic? > >> + $TEST_DIR/../../example/l2fwd/odp_l2fwd -i $IF1,$IF2 -m 0 -t 60 > You need to limit the cores on which l2fwd runs to prevent the traffic > generation interfering with the forwarding (though not much of a problem > with just the ping). generation is done on IF0, while l2fwd uses IF1 and IF2. But for better results it might be reasonable to limit cores. > >> + cleanup_env1 >> + exit 0 >> +} >> + >> +case "$1" in >> + setup) setup_env1 ;; >> + cleanup) cleanup_env1 ;; >> + *) run_l2fwd_example ;; >> +esac >> diff --git a/test/validation/odp_pktio_run b/test/validation/odp_pktio_run >> index 6177caa..37b775f 100755 >> --- a/test/validation/odp_pktio_run >> +++ b/test/validation/odp_pktio_run >> @@ -1,76 +1,15 @@ >> #!/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 >> +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 >> >> -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 >> - >> - # network needs a little time to come up >> - sleep 1 >> -} >> - >> -cleanup_env1() >> -{ >> - echo "pktio: removing test interfaces $IF0 and $IF1" >> - ip link del $IF0 2> /dev/null >> - ip link del $IF1 2> /dev/null >> -} >> +if [ "$ODP_PLATFORM" = "linux-generic" ]; then >> +. ${TEST_DIR}/../../platform/linux-generic/test/pktio_env >> +fi > As earlier, won't work in a cross-build-test environment. we do not run make check for cross build - test. That is intended to be run manually or from 'make check' >> >> run_test() >> { > Not shown in this patch, but there's a bunch of other stuff in > odp_pktio_run that is linux-generic specific so it makes sense to > move that up to platform/linux-generic too. yes. >> @@ -118,12 +57,6 @@ 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 ;; >> -- >> 1.9.1 >>
On Mon, Mar 16, 2015 at 06:56:19PM +0300, Maxim Uvarov wrote: > On 03/16/15 14:09, Stuart Haslam wrote: > >On Fri, Mar 13, 2015 at 06:03:47PM +0300, Maxim Uvarov wrote: > >>Move common pktio linux-generic functions to setup virtual net to > >>linux-generic folder and add running l2fwd test for make check. > >> > >>Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> > >>--- > >> platform/linux-generic/test/pktio_env | 90 ++++++++++++++++++++++++++++++++++ > >> test/performance/Makefile.am | 4 +- > >> test/performance/odp_example_l2fwd_run | 31 ++++++++++++ > >> test/validation/odp_pktio_run | 83 +++---------------------------- > >> 4 files changed, 132 insertions(+), 76 deletions(-) > >> create mode 100755 platform/linux-generic/test/pktio_env > >> create mode 100755 test/performance/odp_example_l2fwd_run > >> > >>diff --git a/platform/linux-generic/test/pktio_env b/platform/linux-generic/test/pktio_env > >>new file mode 100755 > >>index 0000000..a6d0597 > >>--- /dev/null > >>+++ b/platform/linux-generic/test/pktio_env > >>@@ -0,0 +1,90 @@ > >>+#!/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. > >This comment and some others below aren't valid now. > > Ah, yes. Not sure what is better move in one patch and fix in second > patch. Or move and fix in one patch. > I think it's best to fix up the comments with the initial move, otherwise it's confusing in the interim. > > >>+# > >>+# 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) > >>+# 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 > >>+ > >>+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" > >What about the other 2 interfaces? > good catch. And more likely that cascading if's are not needed here. > > >>+ return > >>+ fi > >>+ fi > >>+ > >>+ echo "pktio: setting up test interfaces $IF0, $IF1, $IF2, $IF3." > >>+ > >>+ 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 add $IF2 type veth peer name $IF3 > >>+ 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 > >>+ ip link set $IF2 mtu 9216 up > >>+ ip link set $IF3 mtu 9216 up > >>+ ifconfig $IF0 -arp > >>+ ifconfig $IF1 -arp > >>+ ifconfig $IF2 -arp > >>+ ifconfig $IF3 -arp > >>+ > >>+ # network needs a little time to come up > >>+ sleep 1 > >>+} > >>+ > >>+cleanup_env1() > >>+{ > >>+ echo "pktio: removing test interfaces $IF0 - $IF3" > >>+ ip link del $IF0 2> /dev/null > >>+ ip link del $IF1 2> /dev/null > >>+ ip link del $IF2 2> /dev/null > >>+ ip link del $IF3 2> /dev/null > >>+} > >>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..69784f9 > >>--- /dev/null > >>+++ b/test/performance/odp_example_l2fwd_run > >>@@ -0,0 +1,31 @@ > >>+#!/bin/sh > >>+ > >>+TEST_DIR=$(dirname $0) > >>+ > >>+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 > >>+ > >>+if [ "$ODP_PLATFORM" = "linux-generic" ]; then > >>+echo "source ${TEST_DIR}/../../platform/linux-generic/test/pktio_env" > >>+. ${TEST_DIR}/../../platform/linux-generic/test/pktio_env > >This won't work when you're cross-building and then running the tests on > >the target as a separate step. > I think to make 'make check' happy it will be enough to do: > TEST_DIR="${TEST_DIR:-$(dirname $0)}" That'll fix the make check, but the other problem is that the pktio_env script doesn't get installed. We're working on getting the "make check" tests running on the platforms in the LAVA lab, this means everything required to run the tests needs installed and packaged. > >>+fi > >>+ > >>+run_l2fwd_example() > >>+{ > >>+ setup_env1 > >>+ #ping is too slow, needed to replace it with odp generator > >As this isn't an RFC I'd think it's better just to state for now that > >it's testing basic functionality, performance testing can be added later. > Yes, that is a plan. > >>+ (ping -w 65 -I $IF0 -f 1.1.1.1 2>&1 > /dev/null) & > >>+ echo "Run $TEST_DIR/../../example/l2fwd/odp_l2fwd -i $IF1,$IF2 -m 0 -t 60" > >If ODP_PLATFORM != linux-generic this code still runs, but the interfaces > >almost certainly won't exist. How would this test be run on platforms > >other than linux-generic? > > Still interested in this as I'm not sure how this would work on other platforms. I think it's useful to have but if it only works on linux-generic then it (at least the automatic execution via "make check") needs to be conditioned on that, and perhaps moved up to platform/linux-generic. > >>+ $TEST_DIR/../../example/l2fwd/odp_l2fwd -i $IF1,$IF2 -m 0 -t 60 > >You need to limit the cores on which l2fwd runs to prevent the traffic > >generation interfering with the forwarding (though not much of a problem > >with just the ping). > generation is done on IF0, while l2fwd uses IF1 and IF2. But for better > results it might be reasonable to limit cores. Yeah I was referring to CPU load. > > > >>+ cleanup_env1 > >>+ exit 0 > >>+} > >>+ > >>+case "$1" in > >>+ setup) setup_env1 ;; > >>+ cleanup) cleanup_env1 ;; > >>+ *) run_l2fwd_example ;; > >>+esac > >>diff --git a/test/validation/odp_pktio_run b/test/validation/odp_pktio_run > >>index 6177caa..37b775f 100755 > >>--- a/test/validation/odp_pktio_run > >>+++ b/test/validation/odp_pktio_run > >>@@ -1,76 +1,15 @@ > >> #!/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 > >>+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 > >>-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 > >>- > >>- # network needs a little time to come up > >>- sleep 1 > >>-} > >>- > >>-cleanup_env1() > >>-{ > >>- echo "pktio: removing test interfaces $IF0 and $IF1" > >>- ip link del $IF0 2> /dev/null > >>- ip link del $IF1 2> /dev/null > >>-} > >>+if [ "$ODP_PLATFORM" = "linux-generic" ]; then > >>+. ${TEST_DIR}/../../platform/linux-generic/test/pktio_env > >>+fi > >As earlier, won't work in a cross-build-test environment. > we do not run make check for cross build - test. Not yet, but we should.
diff --git a/platform/linux-generic/test/pktio_env b/platform/linux-generic/test/pktio_env new file mode 100755 index 0000000..a6d0597 --- /dev/null +++ b/platform/linux-generic/test/pktio_env @@ -0,0 +1,90 @@ +#!/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) +# 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 + +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, $IF1, $IF2, $IF3." + + 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 add $IF2 type veth peer name $IF3 + 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 + ip link set $IF2 mtu 9216 up + ip link set $IF3 mtu 9216 up + ifconfig $IF0 -arp + ifconfig $IF1 -arp + ifconfig $IF2 -arp + ifconfig $IF3 -arp + + # network needs a little time to come up + sleep 1 +} + +cleanup_env1() +{ + echo "pktio: removing test interfaces $IF0 - $IF3" + ip link del $IF0 2> /dev/null + ip link del $IF1 2> /dev/null + ip link del $IF2 2> /dev/null + ip link del $IF3 2> /dev/null +} 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..69784f9 --- /dev/null +++ b/test/performance/odp_example_l2fwd_run @@ -0,0 +1,31 @@ +#!/bin/sh + +TEST_DIR=$(dirname $0) + +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 + +if [ "$ODP_PLATFORM" = "linux-generic" ]; then +echo "source ${TEST_DIR}/../../platform/linux-generic/test/pktio_env" +. ${TEST_DIR}/../../platform/linux-generic/test/pktio_env +fi + +run_l2fwd_example() +{ + setup_env1 + #ping is too slow, needed to replace it with odp generator + (ping -w 65 -I $IF0 -f 1.1.1.1 2>&1 > /dev/null) & + echo "Run $TEST_DIR/../../example/l2fwd/odp_l2fwd -i $IF1,$IF2 -m 0 -t 60" + $TEST_DIR/../../example/l2fwd/odp_l2fwd -i $IF1,$IF2 -m 0 -t 60 + cleanup_env1 + exit 0 +} + +case "$1" in + setup) setup_env1 ;; + cleanup) cleanup_env1 ;; + *) run_l2fwd_example ;; +esac diff --git a/test/validation/odp_pktio_run b/test/validation/odp_pktio_run index 6177caa..37b775f 100755 --- a/test/validation/odp_pktio_run +++ b/test/validation/odp_pktio_run @@ -1,76 +1,15 @@ #!/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 +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 -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 - - # network needs a little time to come up - sleep 1 -} - -cleanup_env1() -{ - echo "pktio: removing test interfaces $IF0 and $IF1" - ip link del $IF0 2> /dev/null - ip link del $IF1 2> /dev/null -} +if [ "$ODP_PLATFORM" = "linux-generic" ]; then +. ${TEST_DIR}/../../platform/linux-generic/test/pktio_env +fi run_test() { @@ -118,12 +57,6 @@ 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 ;;
Move common pktio linux-generic functions to setup virtual net to linux-generic folder and add running l2fwd test for make check. Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> --- platform/linux-generic/test/pktio_env | 90 ++++++++++++++++++++++++++++++++++ test/performance/Makefile.am | 4 +- test/performance/odp_example_l2fwd_run | 31 ++++++++++++ test/validation/odp_pktio_run | 83 +++---------------------------- 4 files changed, 132 insertions(+), 76 deletions(-) create mode 100755 platform/linux-generic/test/pktio_env create mode 100755 test/performance/odp_example_l2fwd_run