Use null device to exercise ethdev start/stop in secondary process. Signed-off-by: Stephen Hemminger <step...@networkplumber.org> --- app/test/meson.build | 2 +- app/test/test_mp_secondary.c | 50 +++++++++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/app/test/meson.build b/app/test/meson.build index ae947c4cbd..f3ea3e2b74 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -132,7 +132,7 @@ source_file_deps = { 'test_memzone.c': [], 'test_meter.c': ['meter'], 'test_metrics.c': ['metrics'], - 'test_mp_secondary.c': ['hash'], + 'test_mp_secondary.c': ['ethdev','hash'], 'test_net_ether.c': ['net'], 'test_net_ip6.c': ['net'], 'test_pcapng.c': ['ethdev', 'net', 'pcapng', 'bus_vdev'], diff --git a/app/test/test_mp_secondary.c b/app/test/test_mp_secondary.c index f3694530a8..d6604b326d 100644 --- a/app/test/test_mp_secondary.c +++ b/app/test/test_mp_secondary.c @@ -42,6 +42,8 @@ test_mp_secondary(void) #include <rte_debug.h> #include <rte_log.h> #include <rte_mempool.h> +#include <rte_ethdev.h> +#include <rte_bus_vdev.h> #ifdef RTE_LIB_HASH #include <rte_hash.h> @@ -204,6 +206,44 @@ run_object_creation_tests(void) return 0; } +static int +run_ethdev_tests(void) +{ + static const char vdev_name[] = "net_null"; + struct rte_eth_conf dev_conf = { 0 }; + uint16_t port; + int ret; + + printf("### Testing hotplug and ethdev start/stop\n"); + + /* use hotplug to make a null vdev */ + ret = rte_eal_hotplug_add("vdev", vdev_name, ""); + TEST_ASSERT(ret == 0, "Hotplug add of '%s' failed", vdev_name); + + printf("# Checked hotplug_add OK\n"); + + ret = rte_eth_dev_get_port_by_name(vdev_name, &port); + TEST_ASSERT(ret == 0, "Lookup vdev '%s' failed", vdev_name); + + ret = rte_eth_dev_configure(port, 1, 1, &dev_conf); + TEST_ASSERT(ret == 0, "Configure port %u failed", port); + + ret = rte_eth_dev_start(port); + TEST_ASSERT(ret == 0, "Start port %u failed", port); + + printf("# Checked rte_eth_dev_start\n"); + + ret = rte_eth_dev_stop(port); + TEST_ASSERT(ret == 0, "Stop port %u failed", port); + + printf("# Checked rte_eth_dev_stop\n"); + + rte_eal_hotplug_remove("vdev", vdev_name); + + printf("# Checked hotplug_remove OK\n"); + return 0; +} + /* if called in a primary process, just spawns off a secondary process to * run validation tests - which brings us right back here again... * if called in a secondary process, this runs a series of API tests to check @@ -212,15 +252,19 @@ run_object_creation_tests(void) int test_mp_secondary(void) { - if (rte_eal_process_type() == RTE_PROC_PRIMARY) { + int ret; + + if (rte_eal_process_type() == RTE_PROC_PRIMARY) return run_secondary_instances(); - } printf("IN SECONDARY PROCESS\n"); + ret = run_ethdev_tests(); + if (ret != 0) + return ret; return run_object_creation_tests(); } #endif /* !RTE_EXEC_ENV_WINDOWS */ -REGISTER_FAST_TEST(multiprocess_autotest, false, false, test_mp_secondary); +REGISTER_FAST_TEST(multiprocess_autotest, true, true, test_mp_secondary); -- 2.47.2