DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] test/test: allow taking extra arguments from environment
@ 2018-10-12 15:34 Bruce Richardson
  2018-10-12 17:42 ` Luca Boccassi
  0 siblings, 1 reply; 3+ messages in thread
From: Bruce Richardson @ 2018-10-12 15:34 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson

When running unit tests automatically, either via script, from meson,
or otherwise, the same set of options may be used for each run, for
example to set a standard coremask to be used for all tests.

To facilitate this, this patch adds support for the test binary taking
additional EAL parameters from the environment and appending them to the
argc/argv list passed to eal init. This allows parameter modification
without having to edit test scripts etc.

There are now two environment variables which can be used for running
tests:
 * DPDK_TEST - (added previously) passes the test name to be run
               automatically rather than running the app interactively.
               Used by "meson test" when running tests individually or
               as part of a suite.

 * DPDK_TEST_PARAMS - new parameter to specify the commandline arguments
               to use with the test binary. For example to run a test,
               or tests, on only 16 lcores, and to skip pci scan we can
               set this to "-l 0-15 --no-pci".

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 doc/guides/rel_notes/release_18_11.rst |  8 ++++++
 test/test/test.c                       | 34 +++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/doc/guides/rel_notes/release_18_11.rst b/doc/guides/rel_notes/release_18_11.rst
index 436b20e2b..b5ac61e55 100644
--- a/doc/guides/rel_notes/release_18_11.rst
+++ b/doc/guides/rel_notes/release_18_11.rst
@@ -159,6 +159,14 @@ New Features
   this application doesn't need to launch dedicated worker threads for vhost
   enqueue/dequeue operations.
 
+* **Allow Unit Test Binary to take Parameters from the environment**
+
+  The unit test "test", or "dpdk-test", binary is often called from scripts,
+  which can make passing additional parameters, such as a coremask, to it more
+  awkward. Support has been added to the application to allow it to take
+  additional command-line parameter values from the "DPDK_TEST_PARAMS"
+  environment variable to make this application easier to use.
+
 
 API Changes
 -----------
diff --git a/test/test/test.c b/test/test/test.c
index 44dfe20ef..d49700d7f 100644
--- a/test/test/test.c
+++ b/test/test/test.c
@@ -75,15 +75,47 @@ do_recursive_call(void)
 
 int last_test_result;
 
+#define MAX_EXTRA_ARGS 32
+
 int
 main(int argc, char **argv)
 {
 #ifdef RTE_LIBRTE_CMDLINE
 	struct cmdline *cl;
 #endif
+	char *extra_args;
 	int ret;
 
-	ret = rte_eal_init(argc, argv);
+	extra_args = getenv("DPDK_TEST_PARAMS");
+	if (extra_args != NULL && strlen(extra_args) > 0) {
+		char **all_argv;
+		char *eargv[MAX_EXTRA_ARGS];
+		int all_argc;
+		int eargc;
+		int i;
+
+		RTE_LOG(INFO, APP, "Using additional DPDK_TEST_PARAMS: '%s'\n",
+				extra_args);
+		eargc = rte_strsplit(extra_args, strlen(extra_args),
+				eargv, MAX_EXTRA_ARGS, ' ');
+
+		/* merge argc/argv and the environment args */
+		all_argc = argc + eargc;
+		all_argv = malloc(sizeof(*all_argv) * (all_argc + 1));
+		if (all_argv == NULL)
+			return -1;
+
+		for (i = 0; i < argc; i++)
+			all_argv[i] = argv[i];
+		for (i = 0; i < eargc; i++)
+			all_argv[argc + i] = eargv[i];
+		all_argv[all_argc] = NULL;
+
+		/* call eal_init with combined args */
+		ret = rte_eal_init(all_argc, all_argv);
+		free(all_argv);
+	} else
+		ret = rte_eal_init(argc, argv);
 	if (ret < 0)
 		return -1;
 
-- 
2.17.2

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] test/test: allow taking extra arguments from environment
  2018-10-12 15:34 [dpdk-dev] [PATCH] test/test: allow taking extra arguments from environment Bruce Richardson
@ 2018-10-12 17:42 ` Luca Boccassi
  2018-11-06  1:59   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Luca Boccassi @ 2018-10-12 17:42 UTC (permalink / raw)
  To: Bruce Richardson, dev

On Fri, 2018-10-12 at 16:34 +0100, Bruce Richardson wrote:
> When running unit tests automatically, either via script, from meson,
> or otherwise, the same set of options may be used for each run, for
> example to set a standard coremask to be used for all tests.
> 
> To facilitate this, this patch adds support for the test binary
> taking
> additional EAL parameters from the environment and appending them to
> the
> argc/argv list passed to eal init. This allows parameter modification
> without having to edit test scripts etc.
> 
> There are now two environment variables which can be used for running
> tests:
>  * DPDK_TEST - (added previously) passes the test name to be run
>                automatically rather than running the app
> interactively.
>                Used by "meson test" when running tests individually
> or
>                as part of a suite.
> 
>  * DPDK_TEST_PARAMS - new parameter to specify the commandline
> arguments
>                to use with the test binary. For example to run a
> test,
>                or tests, on only 16 lcores, and to skip pci scan we
> can
>                set this to "-l 0-15 --no-pci".
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  doc/guides/rel_notes/release_18_11.rst |  8 ++++++
>  test/test/test.c                       | 34
> +++++++++++++++++++++++++-
>  2 files changed, 41 insertions(+), 1 deletion(-)

Was just thinking that something like this would be useful!

Tested-by: Luca Boccassi <bluca@debian.org>

-- 
Kind regards,
Luca Boccassi

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] test/test: allow taking extra arguments from environment
  2018-10-12 17:42 ` Luca Boccassi
@ 2018-11-06  1:59   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2018-11-06  1:59 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Luca Boccassi

12/10/2018 19:42, Luca Boccassi:
> On Fri, 2018-10-12 at 16:34 +0100, Bruce Richardson wrote:
> > When running unit tests automatically, either via script, from meson,
> > or otherwise, the same set of options may be used for each run, for
> > example to set a standard coremask to be used for all tests.
> > 
> > To facilitate this, this patch adds support for the test binary
> > taking
> > additional EAL parameters from the environment and appending them to
> > the
> > argc/argv list passed to eal init. This allows parameter modification
> > without having to edit test scripts etc.
> > 
> > There are now two environment variables which can be used for running
> > tests:
> >  * DPDK_TEST - (added previously) passes the test name to be run
> >                automatically rather than running the app
> > interactively.
> >                Used by "meson test" when running tests individually
> > or
> >                as part of a suite.
> > 
> >  * DPDK_TEST_PARAMS - new parameter to specify the commandline
> > arguments
> >                to use with the test binary. For example to run a
> > test,
> >                or tests, on only 16 lcores, and to skip pci scan we
> > can
> >                set this to "-l 0-15 --no-pci".
> > 
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > ---
> >  doc/guides/rel_notes/release_18_11.rst |  8 ++++++
> >  test/test/test.c                       | 34
> > +++++++++++++++++++++++++-
> >  2 files changed, 41 insertions(+), 1 deletion(-)
> 
> Was just thinking that something like this would be useful!
> 
> Tested-by: Luca Boccassi <bluca@debian.org>

Applied, thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-06  1:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-12 15:34 [dpdk-dev] [PATCH] test/test: allow taking extra arguments from environment Bruce Richardson
2018-10-12 17:42 ` Luca Boccassi
2018-11-06  1:59   ` Thomas Monjalon

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).