[v2,2/3] app/test: change rawdev autotest to run selftest on all devs

Message ID 20200910164716.1011901-3-bruce.richardson@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series simplify unit-testing of rawdevs |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Bruce Richardson Sept. 10, 2020, 4:47 p.m. UTC
  Rather than having each rawdev provide its own autotest command, we can
instead just use the generic rawdev_autotest to test any and all available
rawdevs.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/test/test_rawdev.c                 | 34 ++++++++++++++++++++++++--
 doc/guides/rel_notes/release_20_11.rst |  5 ++++
 2 files changed, 37 insertions(+), 2 deletions(-)
  

Comments

Kevin Laatz Sept. 14, 2020, 12:28 p.m. UTC | #1
On 10/09/2020 17:47, Bruce Richardson wrote:
> Rather than having each rawdev provide its own autotest command, we can
> instead just use the generic rawdev_autotest to test any and all available
> rawdevs.
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>   app/test/test_rawdev.c                 | 34 ++++++++++++++++++++++++--
>   doc/guides/rel_notes/release_20_11.rst |  5 ++++
>   2 files changed, 37 insertions(+), 2 deletions(-)
[...]

Reviewed-by: Kevin Laatz <kevin.laatz@intel.com>
  

Patch

diff --git a/app/test/test_rawdev.c b/app/test/test_rawdev.c
index d8d9595be1..7e2fb2cf27 100644
--- a/app/test/test_rawdev.c
+++ b/app/test/test_rawdev.c
@@ -14,8 +14,13 @@ 
 static int
 test_rawdev_selftest_impl(const char *pmd, const char *opts)
 {
+	int ret;
+
+	printf("\n### Test rawdev infrastructure using skeleton driver\n");
 	rte_vdev_init(pmd, opts);
-	return rte_rawdev_selftest(rte_rawdev_get_dev_id(pmd));
+	ret = rte_rawdev_selftest(rte_rawdev_get_dev_id(pmd));
+	rte_vdev_uninit(pmd);
+	return ret;
 }
 
 static int
@@ -24,7 +29,32 @@  test_rawdev_selftest_skeleton(void)
 	return test_rawdev_selftest_impl("rawdev_skeleton", "");
 }
 
-REGISTER_TEST_COMMAND(rawdev_autotest, test_rawdev_selftest_skeleton);
+static int
+test_rawdev_selftests(void)
+{
+	const int count = rte_rawdev_count();
+	int ret = 0;
+	int i;
+
+	/* basic sanity on rawdev infrastructure */
+	if (test_rawdev_selftest_skeleton() < 0)
+		return -1;
+
+	/* now run self-test on all rawdevs */
+	if (count > 0)
+		printf("\n### Run selftest on each available rawdev\n");
+	for (i = 0; i < count; i++) {
+		int result = rte_rawdev_selftest(i);
+		printf("Rawdev %u (%s) selftest: %s\n", i,
+				rte_rawdevs[i].name,
+				result == 0 ? "Passed" : "Failed");
+		ret |=  result;
+	}
+
+	return ret;
+}
+
+REGISTER_TEST_COMMAND(rawdev_autotest, test_rawdev_selftests);
 
 static int
 test_rawdev_selftest_ioat(void)
diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst
index 667e3d54ad..2ac7dca9a0 100644
--- a/doc/guides/rel_notes/release_20_11.rst
+++ b/doc/guides/rel_notes/release_20_11.rst
@@ -93,6 +93,11 @@  API Changes
   and the function ``rte_rawdev_queue_conf_get()``
   from ``void`` to ``int`` allowing the return of error codes from drivers.
 
+* rawdev: The running of a drivers ``selftest()`` function can now be done
+  using the ``rawdev_autotest`` command in the ``dpdk-test`` binary. This
+  command now calls the self-test function for each rawdev found on the
+  system, and does not require a specific command per device type.
+
 
 ABI Changes
 -----------