mbox series

[bpf-next,v2,0/4] selftests/bpf: xsk improvements and new stats tests

Message ID 20210223103507.10465-1-ciara.loftus@intel.com
Headers show
Series selftests/bpf: xsk improvements and new stats tests | expand

Message

Loftus, Ciara Feb. 23, 2021, 10:35 a.m. UTC
This series attempts to improve the xsk selftest framework by:
1. making the default output less verbose
2. adding an optional verbose flag to both the test_xsk.sh script and xdpxceiver app.
3. renaming the debug option in the app to to 'dump-pkts' and add a flag to the test_xsk.sh
script which enables the flag in the app.
4. changing how tests are launched - now they are launched from the xdpxceiver app
instead of the script.

Once the improvements are made, a new set of tests are added which test the xsk
statistics.

The output of the test script now looks like:

./test_xsk.sh
PREREQUISITES: [ PASS ]
1..10
ok 1 PASS: SKB NOPOLL 
ok 2 PASS: SKB POLL 
ok 3 PASS: SKB NOPOLL Socket Teardown
ok 4 PASS: SKB NOPOLL Bi-directional Sockets
ok 5 PASS: SKB NOPOLL Stats
ok 6 PASS: DRV NOPOLL 
ok 7 PASS: DRV POLL 
ok 8 PASS: DRV NOPOLL Socket Teardown
ok 9 PASS: DRV NOPOLL Bi-directional Sockets
ok 10 PASS: DRV NOPOLL Stats
# Totals: pass:10 fail:0 xfail:0 xpass:0 skip:0 error:0
XSK KSELFTESTS: [ PASS ]

v1->v2:
* Changed '-d' flag in the shell script to '-D' to be consistent with the xdpxceiver app.
* Renamed debug mode to 'dump-pkts' which better reflects the behaviour.
* Use libpf APIs instead of calls to ss for configuring xdp on the links
* Remove mutex init & destroy for each stats test
* Added a description for each of the new statistics tests
* Distinguish between exiting due to initialisation failure vs test failure

This series applies on commit d310ec03a34e92a77302edb804f7d68ee4f01ba0

Ciara Loftus (3):
  selftests/bpf: expose and rename debug argument
  selftests/bpf: restructure xsk selftests
  selftests/bpf: introduce xsk statistics tests

Magnus Karlsson (1):
  selftest/bpf: make xsk tests less verbose

 tools/testing/selftests/bpf/test_xsk.sh    | 129 ++-----
 tools/testing/selftests/bpf/xdpxceiver.c   | 380 +++++++++++++++------
 tools/testing/selftests/bpf/xdpxceiver.h   |  57 +++-
 tools/testing/selftests/bpf/xsk_prereqs.sh |  30 +-
 4 files changed, 336 insertions(+), 260 deletions(-)

Comments

Loftus, Ciara Feb. 23, 2021, 3:01 p.m. UTC | #1
> 
> On Tue, Feb 23, 2021 at 10:35:05AM +0000, Ciara Loftus wrote:
> > Launching xdpxceiver with -D enables what was formerly know as 'debug'
> > mode. Rename this mode to 'dump-pkts' as it better describes the
> > behavior enabled by the option. New usage:
> >
> > ./xdpxceiver .. -D
> > or
> > ./xdpxceiver .. --dump-pkts
> >
> > Also make it possible to pass this flag to the app via the test_xsk.sh
> > shell script like so:
> >
> > ./test_xsk.sh -D
> 
> This doesn't work for me. Not a shell programming expert, but seems like
> my shell doesn't understand that dump-pkts is a variable.
> 
> $ sudo ./test_xsk.sh -D
> ./test_xsk.sh: line 82: dump-pkts=1: command not found
> 
> If I do:
> 
> diff --git a/tools/testing/selftests/bpf/test_xsk.sh
> b/tools/testing/selftests/bpf/test_xsk.sh
> index cb8a9e5c34ff..378720e22877 100755
> --- a/tools/testing/selftests/bpf/test_xsk.sh
> +++ b/tools/testing/selftests/bpf/test_xsk.sh
> @@ -79,7 +79,7 @@ do
>         case "${flag}" in
>                 c) colorconsole=1;;
>                 v) verbose=1;;
> -               D) dump-pkts=1;;
> +               D) dump_pkts=1;;
>         esac
>  done
> 
> @@ -136,7 +136,7 @@ if [[ $verbose -eq 1 ]]; then
>         VERBOSE_ARG="-v"
>  fi
> 
> -if [[ $dump-pkts -eq 1 ]]; then
> +if [[ $dump_pkts -eq 1 ]]; then
>         DUMP_PKTS_ARG="-D"
>  fi
> 
> Then it's fine.

Thanks for catching this Maciej. My shell didn't complain like yours, however with this naming the flag wasn't propagating to the app for me.
Switching to 'dump_pkts' as you suggested solves both problems, so I'll update that in the v3.

> 
> >
> > Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
> > ---
> >  tools/testing/selftests/bpf/test_xsk.sh    | 7 ++++++-
> >  tools/testing/selftests/bpf/xdpxceiver.c   | 6 +++---
> >  tools/testing/selftests/bpf/xsk_prereqs.sh | 3 ++-
> >  3 files changed, 11 insertions(+), 5 deletions(-)
> >
> > diff --git a/tools/testing/selftests/bpf/test_xsk.sh
> b/tools/testing/selftests/bpf/test_xsk.sh
> > index 91127a5be90d..870ae3f38818 100755
> > --- a/tools/testing/selftests/bpf/test_xsk.sh
> > +++ b/tools/testing/selftests/bpf/test_xsk.sh
> > @@ -74,11 +74,12 @@
> >
> >  . xsk_prereqs.sh
> >
> > -while getopts "cv" flag
> > +while getopts "cvD" flag
> >  do
> >  	case "${flag}" in
> >  		c) colorconsole=1;;
> >  		v) verbose=1;;
> > +		D) dump-pkts=1;;
> >  	esac
> >  done
> >
> > @@ -135,6 +136,10 @@ if [[ $verbose -eq 1 ]]; then
> >  	VERBOSE_ARG="-v"
> >  fi
> >
> > +if [[ $dump-pkts -eq 1 ]]; then
> > +	DUMP_PKTS_ARG="-D"
> > +fi
> > +
> >  test_status $retval "${TEST_NAME}"
> >
> >  ## START TESTS
> > diff --git a/tools/testing/selftests/bpf/xdpxceiver.c
> b/tools/testing/selftests/bpf/xdpxceiver.c
> > index 8af746c9a6b6..506423201197 100644
> > --- a/tools/testing/selftests/bpf/xdpxceiver.c
> > +++ b/tools/testing/selftests/bpf/xdpxceiver.c
> > @@ -58,7 +58,7 @@
> >   * - Rx thread verifies if all 10k packets were received and delivered in-
> order,
> >   *   and have the right content
> >   *
> > - * Enable/disable debug mode:
> > + * Enable/disable packet dump mode:
> >   * --------------------------
> >   * To enable L2 - L4 headers and payload dump of each packet on STDOUT,
> add
> >   * parameter -D to params array in test_xsk.sh, i.e. params=("-S" "-D")
> > @@ -340,7 +340,7 @@ static struct option long_options[] = {
> >  	{"copy", no_argument, 0, 'c'},
> >  	{"tear-down", no_argument, 0, 'T'},
> >  	{"bidi", optional_argument, 0, 'B'},
> > -	{"debug", optional_argument, 0, 'D'},
> > +	{"dump-pkts", optional_argument, 0, 'D'},
> >  	{"verbose", no_argument, 0, 'v'},
> >  	{"tx-pkt-count", optional_argument, 0, 'C'},
> >  	{0, 0, 0, 0}
> > @@ -359,7 +359,7 @@ static void usage(const char *prog)
> >  	    "  -c, --copy           Force copy mode\n"
> >  	    "  -T, --tear-down      Tear down sockets by repeatedly recreating
> them\n"
> >  	    "  -B, --bidi           Bi-directional sockets test\n"
> > -	    "  -D, --debug          Debug mode - dump packets L2 - L5\n"
> > +	    "  -D, --dump-pkts      Dump packets L2 - L5\n"
> >  	    "  -v, --verbose        Verbose output\n"
> >  	    "  -C, --tx-pkt-count=n Number of packets to send\n";
> >  	ksft_print_msg(str, prog);
> > diff --git a/tools/testing/selftests/bpf/xsk_prereqs.sh
> b/tools/testing/selftests/bpf/xsk_prereqs.sh
> > index ef8c5b31f4b6..da93575d757a 100755
> > --- a/tools/testing/selftests/bpf/xsk_prereqs.sh
> > +++ b/tools/testing/selftests/bpf/xsk_prereqs.sh
> > @@ -128,5 +128,6 @@ execxdpxceiver()
> >  			copy[$index]=${!current}
> >  		done
> >
> > -	./${XSKOBJ} -i ${VETH0} -i ${VETH1},${NS1} ${copy[*]} -C
> ${NUMPKTS} ${VERBOSE_ARG}
> > +	./${XSKOBJ} -i ${VETH0} -i ${VETH1},${NS1} ${copy[*]} -C
> ${NUMPKTS} ${VERBOSE_ARG} \
> > +		${DUMP_PKTS_ARG}
> >  }
> > --
> > 2.17.1
> >