From: "Xueming(Steven) Li" <xuemingl@nvidia.com>
To: "dev@dpdk.org" <dev@dpdk.org>, "grive@u256.net" <grive@u256.net>
Cc: NBU-Contact-Thomas Monjalon <thomas@monjalon.net>,
"david.marchand@redhat.com" <david.marchand@redhat.com>
Subject: Re: [dpdk-dev] [PATCH v1 3/3] test/devargs: add devargs test cases
Date: Wed, 20 Oct 2021 07:20:47 +0000 [thread overview]
Message-ID: <fc3acdd6acebd7653c3eef6efb2df3680df51ee7.camel@nvidia.com> (raw)
In-Reply-To: <b4a6ec30-52af-4618-acb4-0cd353159481@www.fastmail.com>
On Tue, 2021-10-19 at 17:07 +0200, Gaëtan Rivet wrote:
> On Tue, Oct 5, 2021, at 17:54, Xueming Li wrote:
> > Initial version to test Global devargs syntax.
> >
> > Signed-off-by: Xueming Li <xuemingl@nvidia.com>
>
> Hi,
>
> The test is a very nice addition, absolutely required.
> I have however two remarks on the coverage and the implementation, below.
>
> > ---
> > app/test/autotest_data.py | 6 ++
> > app/test/meson.build | 2 +
> > app/test/test_devargs.c | 147 ++++++++++++++++++++++++++++++++++++++
> > 3 files changed, 155 insertions(+)
> > create mode 100644 app/test/test_devargs.c
> >
> > diff --git a/app/test/autotest_data.py b/app/test/autotest_data.py
> > index 302d6374c16..3b841e71918 100644
> > --- a/app/test/autotest_data.py
> > +++ b/app/test/autotest_data.py
> > @@ -785,6 +785,12 @@
> > "Func": default_autotest,
> > "Report": None,
> > },
> > + {
> > + "Name": "Devargs autotest",
> > + "Command": "devargs_autotest",
> > + "Func": default_autotest,
> > + "Report": None,
> > + },
> > #
> > # Please always make sure that ring_perf is the last test!
> > #
> > diff --git a/app/test/meson.build b/app/test/meson.build
> > index f144d8b8ed6..de8540f6119 100644
> > --- a/app/test/meson.build
> > +++ b/app/test/meson.build
> > @@ -42,6 +42,7 @@ test_sources = files(
> > 'test_cryptodev_security_pdcp.c',
> > 'test_cycles.c',
> > 'test_debug.c',
> > + 'test_devargs.c',
> > 'test_distributor.c',
> > 'test_distributor_perf.c',
> > 'test_eal_flags.c',
> > @@ -201,6 +202,7 @@ fast_tests = [
> > ['common_autotest', true],
> > ['cpuflags_autotest', true],
> > ['debug_autotest', true],
> > + ['devargs_autotest', true],
> > ['eal_flags_c_opt_autotest', false],
> > ['eal_flags_main_opt_autotest', false],
> > ['eal_flags_n_opt_autotest', false],
> > diff --git a/app/test/test_devargs.c b/app/test/test_devargs.c
> > new file mode 100644
> > index 00000000000..8a173368347
> > --- /dev/null
> > +++ b/app/test/test_devargs.c
> > @@ -0,0 +1,147 @@
> > +/* SPDX-License-Identifier: BSD-3-Clause
> > + * Copyright (c) 2021 NVIDIA Corporation & Affiliates
> > + */
> > +
> > +#include <stdlib.h>
> > +#include <stdio.h>
> > +#include <string.h>
> > +
> > +#include <rte_common.h>
> > +#include <rte_devargs.h>
> > +#include <rte_kvargs.h>
> > +
> > +#include "test.h"
> > +
> > +/* Check layer arguments. */
> > +static int
> > +test_args(const char *devargs, const char *layer, const char *args,
> > const int n)
> > +{
> > + struct rte_kvargs *kvlist;
> > +
> > + if (n == 0) {
> > + if (args != NULL && strlen(args) > 0) {
> > + printf("rte_devargs_parse(%s) %s args parsed (not expected)\n",
> > + devargs, layer);
> > + return -1;
> > + } else {
> > + return 0;
> > + }
> > + }
> > + if (args == NULL) {
> > + printf("rte_devargs_parse(%s) %s args not parsed\n",
> > + devargs, layer);
> > + return -1;
> > + }
> > + kvlist = rte_kvargs_parse(args, NULL);
> > + if (kvlist == NULL) {
> > + printf("rte_devargs_parse(%s) %s_str: %s not parsed\n",
> > + devargs, layer, args);
> > + return -1;
> > + }
> > + if ((int)kvlist->count != n) {
> > + printf("rte_devargs_parse(%s) %s_str: %s kv number %u, not %d\n",
> > + devargs, layer, args, kvlist->count, n);
> > + return -1;
> > + }
> > + return 0;
> > +}
> > +
> > +/* Test several valid cases */
> > +static int
> > +test_valid_devargs(void)
> > +{
> > + static const struct {
> > + const char *devargs;
> > + int bus_kv;
> > + int class_kv;
> > + int driver_kv;
> > + } list[] = {
> > + /* Global devargs syntax: */
> > + { "bus=pci", 1, 0, 0 },
> > + { "class=eth", 0, 1, 0 },
> > + { "bus=pci,addr=1:2.3/class=eth/driver=abc,k0=v0", 2, 1, 2 },
> > + { "bus=vdev,name=/dev/file/name/class=eth", 2, 1, 0 },
> > + /* Legacy devargs syntax: */
> > + { "1:2.3", 0, 0, 0 },
> > + { "pci:1:2.3,k0=v0", 0, 0, 1 },
> > + { "net_virtio_user0,iface=test,path=/dev/vhost-net,queues=1",
> > + 0, 0, 3 },
>
> I would add here cases to verify that edge-case are properly parsed such as:
>
> + { "bus=vdev,name=/class/bus/path/class=eth", 2, 1, 0 },
> [...]
> + { "net_virtio_user0,iface=test,path=/class/bus/,queues=1",
> + 0, 0, 3 },
>
> To check the /class or /bus parts cannot throw off the parser (it does not currently).
>
> Additionally, paths with multiple slashes are correct. Maybe add:
>
> + { "bus=vdev,name=///dblslsh/class=eth", 2, 1, 0 },
>
> as well.
>
> I tested all those cases without issue, it seems the parser is ok.
>
>
> A second point is that the test only verifies that the numbers of kv were found.
> I think this is not robust enough. Instead, I think the 'expect' part of the test
> should describe exactly what each layers should be within the devargs (which bus,
> class and driver are expected to be found, and the associated string).
>
> Right now the parser could mangle part of a key-value list within the string,
> recognize each layers and give incorrect strings to each layer parser.
>
> It might be too much? I don't know. But it seems it could help ensure no error
> is introduced at some point by future changes.
>
Good suggestion, will added them in v2, thanks!
next prev parent reply other threads:[~2021-10-20 7:20 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-05 12:30 [dpdk-dev] [PATCH 1/3] devargs: support path value for global device arguments Xueming Li
2021-10-05 12:30 ` [dpdk-dev] [PATCH 2/3] devargs: make bus key parsing optional Xueming Li
2021-10-05 12:30 ` [dpdk-dev] [PATCH 3/3] test/devargs: add devargs test cases Xueming Li
2021-10-05 14:01 ` David Marchand
2021-10-05 15:56 ` Xueming(Steven) Li
2021-10-05 15:54 ` [dpdk-dev] [PATCH v1 0/3] devargs: support path in global syntax Xueming Li
2021-10-05 15:54 ` [dpdk-dev] [PATCH v1 1/3] devargs: support path value for global device arguments Xueming Li
2021-10-19 14:57 ` Gaëtan Rivet
2021-10-05 15:54 ` [dpdk-dev] [PATCH v1 2/3] devargs: make bus key parsing optional Xueming Li
2021-10-19 15:19 ` Gaëtan Rivet
2021-10-05 15:54 ` [dpdk-dev] [PATCH v1 3/3] test/devargs: add devargs test cases Xueming Li
2021-10-19 15:07 ` Gaëtan Rivet
2021-10-20 7:20 ` Xueming(Steven) Li [this message]
2021-10-20 7:31 ` [dpdk-dev] [PATCH v2 0/3] devargs: support path in global syntax Xueming Li
2021-10-20 7:31 ` [dpdk-dev] [PATCH v2 1/3] devargs: support path value for global device arguments Xueming Li
2021-10-20 7:31 ` [dpdk-dev] [PATCH v2 2/3] devargs: make bus key parsing optional Xueming Li
2021-10-20 7:31 ` [dpdk-dev] [PATCH v2 3/3] test/devargs: add devargs test cases Xueming Li
2021-10-20 7:38 ` David Marchand
2021-10-20 8:23 ` Xueming(Steven) Li
2021-10-20 8:21 ` [dpdk-dev] [PATCH v3 0/3] devargs: support path in global syntax Xueming Li
2021-10-20 8:21 ` [dpdk-dev] [PATCH v3 1/3] devargs: support path value for global device arguments Xueming Li
2021-10-20 8:21 ` [dpdk-dev] [PATCH v3 2/3] devargs: make bus key parsing optional Xueming Li
2021-10-20 8:22 ` [dpdk-dev] [PATCH v3 3/3] test/devargs: add devargs test cases Xueming Li
2021-10-20 9:08 ` David Marchand
2021-10-20 9:40 ` Xueming(Steven) Li
2021-10-20 10:41 ` Bruce Richardson
2021-10-20 11:12 ` [dpdk-dev] [PATCH v4 0/3] devargs: support path in global syntax Xueming Li
2021-10-20 11:12 ` [dpdk-dev] [PATCH v4 1/3] devargs: support path value for global device arguments Xueming Li
2021-10-20 11:12 ` [dpdk-dev] [PATCH v4 2/3] devargs: make bus key parsing optional Xueming Li
2021-10-20 11:12 ` [dpdk-dev] [PATCH v4 3/3] test/devargs: add devargs test cases Xueming Li
2021-10-20 11:55 ` Gaëtan Rivet
2021-10-20 13:53 ` Xueming(Steven) Li
2021-10-20 14:22 ` Gaëtan Rivet
2021-10-20 14:34 ` Bruce Richardson
2021-10-20 15:47 ` [dpdk-dev] [PATCH v5 0/3] devargs: support path in global syntax Xueming Li
2021-10-20 15:47 ` [dpdk-dev] [PATCH v5 1/3] devargs: support path value for global device arguments Xueming Li
2021-10-20 15:47 ` [dpdk-dev] [PATCH v5 2/3] devargs: make bus key parsing optional Xueming Li
2021-10-20 15:47 ` [dpdk-dev] [PATCH v5 3/3] test/devargs: add devargs test cases Xueming Li
2021-10-21 9:03 ` Gaëtan Rivet
2021-10-23 6:17 ` David Marchand
2021-10-23 12:20 ` Xueming(Steven) Li
2021-10-21 9:22 ` [dpdk-dev] [PATCH v5 0/3] devargs: support path in global syntax David Marchand
2021-10-21 10:43 ` Xueming(Steven) Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fc3acdd6acebd7653c3eef6efb2df3680df51ee7.camel@nvidia.com \
--to=xuemingl@nvidia.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=grive@u256.net \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).