app/test:add NIC parameter exception handling

Message ID 20230713051716.2579821-1-kaisenx.you@intel.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series app/test:add NIC parameter exception handling |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-aarch-unit-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

Kaisen You July 13, 2023, 5:17 a.m. UTC
  Add NIC exception parameter handling to dpdk_test process,
program exits when carrying unbound vfio NIC parameters.

Fixes: 50247fe03fe0 ("test/timer: exercise new APIs in secondary process")
Cc: stable@dpdk.org

Signed-off-by: Kaisen You <kaisenx.you@intel.com>
---
 app/test/test.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
  

Patch

diff --git a/app/test/test.c b/app/test/test.c
index fb073ff795..c927adba81 100644
--- a/app/test/test.c
+++ b/app/test/test.c
@@ -20,6 +20,7 @@  extern cmdline_parse_ctx_t main_ctx[];
 #endif
 
 #include <rte_memory.h>
+#include <rte_ethdev.h>
 #include <rte_eal.h>
 #include <rte_cycles.h>
 #include <rte_log.h>
@@ -111,6 +112,9 @@  main(int argc, char **argv)
 	char *tests[argc]; /* store an array of tests to run */
 	int test_count = 0;
 	int i;
+	uint16_t count;
+	uint16_t port_id;
+	uint16_t nb_ports;
 #endif
 	char *extra_args;
 	int ret;
@@ -157,6 +161,20 @@  main(int argc, char **argv)
 
 	prgname = argv[0];
 
+	count = 0;
+	RTE_ETH_FOREACH_DEV(port_id) {
+		count++;
+	}
+	nb_ports = count;
+	if (nb_ports == 0) {
+		if (rte_errno == EBUSY)
+			printf("Requested device cannot be used: %d\n", rte_errno);
+		else
+			printf("No probed ethernet devices: %d\n", rte_errno);
+		ret = 0;
+		goto out;
+	}
+
 #ifdef RTE_LIB_TIMER
 	ret = rte_timer_subsystem_init();
 	if (ret < 0 && ret != -EALREADY) {