From: Xueming Li <xuemingl@nvidia.com>
To: <dev@dpdk.org>, Gaetan Rivet <grive@u256.net>
Cc: <xuemingl@nvidia.com>, Thomas Monjalon <thomas@monjalon.net>,
"Lior Margalit" <lmargalit@nvidia.com>
Subject: [dpdk-dev] [PATCH v2 3/3] test/devargs: add devargs test cases
Date: Wed, 20 Oct 2021 15:31:51 +0800 [thread overview]
Message-ID: <20211020073151.2374674-4-xuemingl@nvidia.com> (raw)
In-Reply-To: <20211020073151.2374674-1-xuemingl@nvidia.com>
Initial version to test Global devargs syntax.
Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
app/test/autotest_data.py | 803 ++++++++++++++++++++++++++++++++++++++
app/test/meson.build | 2 +
app/test/test_devargs.c | 184 +++++++++
3 files changed, 989 insertions(+)
create mode 100644 app/test/autotest_data.py
create mode 100644 app/test/test_devargs.c
diff --git a/app/test/autotest_data.py b/app/test/autotest_data.py
new file mode 100644
index 00000000000..3b841e71918
--- /dev/null
+++ b/app/test/autotest_data.py
@@ -0,0 +1,803 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2010-2014 Intel Corporation
+
+# Test data for autotests
+
+from autotest_test_funcs import *
+
+# groups of tests that can be run in parallel
+# the grouping has been found largely empirically
+parallel_test_list = [
+ {
+ "Name": "Timer autotest",
+ "Command": "timer_autotest",
+ "Func": timer_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Debug autotest",
+ "Command": "debug_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Errno autotest",
+ "Command": "errno_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Meter autotest",
+ "Command": "meter_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Common autotest",
+ "Command": "common_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Resource autotest",
+ "Command": "resource_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Memory autotest",
+ "Command": "memory_autotest",
+ "Func": memory_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Read/write lock autotest",
+ "Command": "rwlock_autotest",
+ "Func": rwlock_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Lcores autotest",
+ "Command": "lcores_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Logs autotest",
+ "Command": "logs_autotest",
+ "Func": logs_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "CPU flags autotest",
+ "Command": "cpuflags_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Version autotest",
+ "Command": "version_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "EAL filesystem autotest",
+ "Command": "eal_fs_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "EAL flags autotest",
+ "Command": "eal_flags_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Hash autotest",
+ "Command": "hash_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "LPM autotest",
+ "Command": "lpm_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "LPM6 autotest",
+ "Command": "lpm6_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "RIB autotest",
+ "Command": "rib_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "RIB slow autotest",
+ "Command": "rib_slow_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "RIB6 autotest",
+ "Command": "rib6_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "RIB6 slow autotest",
+ "Command": "rib6_slow_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "FIB autotest",
+ "Command": "fib_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "FIB slow autotest",
+ "Command": "fib_slow_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "FIB6 autotest",
+ "Command": "fib6_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "FIB6 slow autotest",
+ "Command": "fib6_slow_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Memcpy autotest",
+ "Command": "memcpy_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Memzone autotest",
+ "Command": "memzone_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "String autotest",
+ "Command": "string_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Malloc autotest",
+ "Command": "malloc_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Multi-process autotest",
+ "Command": "multiprocess_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Mbuf autotest",
+ "Command": "mbuf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Per-lcore autotest",
+ "Command": "per_lcore_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Ring autotest",
+ "Command": "ring_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Spinlock autotest",
+ "Command": "spinlock_autotest",
+ "Func": spinlock_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Ticketlock autotest",
+ "Command": "ticketlock_autotest",
+ "Func": ticketlock_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "MCSlock autotest",
+ "Command": "mcslock_autotest",
+ "Func": mcslock_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Byte order autotest",
+ "Command": "byteorder_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "TAILQ autotest",
+ "Command": "tailq_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Command-line autotest",
+ "Command": "cmdline_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Interrupts autotest",
+ "Command": "interrupt_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Function reentrancy autotest",
+ "Command": "func_reentrancy_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Mempool autotest",
+ "Command": "mempool_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Atomics autotest",
+ "Command": "atomic_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Prefetch autotest",
+ "Command": "prefetch_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Red autotest",
+ "Command": "red_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "PMD ring autotest",
+ "Command": "ring_pmd_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Access list control autotest",
+ "Command": "acl_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Sched autotest",
+ "Command": "sched_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Eventdev selftest octeontx",
+ "Command": "eventdev_selftest_octeontx",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Event ring autotest",
+ "Command": "event_ring_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Table autotest",
+ "Command": "table_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Flow classify autotest",
+ "Command": "flow_classify_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Event eth rx adapter autotest",
+ "Command": "event_eth_rx_adapter_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "User delay",
+ "Command": "user_delay_us",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Rawdev autotest",
+ "Command": "rawdev_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Kvargs autotest",
+ "Command": "kvargs_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Link bonding autotest",
+ "Command": "link_bonding_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Link bonding mode4 autotest",
+ "Command": "link_bonding_mode4_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Link bonding rssconf autotest",
+ "Command": "link_bonding_rssconf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Crc autotest",
+ "Command": "crc_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Distributor autotest",
+ "Command": "distributor_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Reorder autotest",
+ "Command": "reorder_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Barrier autotest",
+ "Command": "barrier_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Bitmap test",
+ "Command": "bitmap_test",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Bitops test",
+ "Command": "bitops_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Hash multiwriter autotest",
+ "Command": "hash_multiwriter_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Service autotest",
+ "Command": "service_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Timer racecond autotest",
+ "Command": "timer_racecond_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Member autotest",
+ "Command": "member_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Efd_autotest",
+ "Command": "efd_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Thash autotest",
+ "Command": "thash_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Hash function autotest",
+ "Command": "hash_functions_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Cryptodev sw mvsam autotest",
+ "Command": "cryptodev_sw_mvsam_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Cryptodev dpaa2 sec autotest",
+ "Command": "cryptodev_dpaa2_sec_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Cryptodev dpaa sec autotest",
+ "Command": "cryptodev_dpaa_sec_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Cryptodev qat autotest",
+ "Command": "cryptodev_qat_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Cryptodev aesni mb autotest",
+ "Command": "cryptodev_aesni_mb_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Cryptodev openssl autotest",
+ "Command": "cryptodev_openssl_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Cryptodev scheduler autotest",
+ "Command": "cryptodev_scheduler_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Cryptodev aesni gcm autotest",
+ "Command": "cryptodev_aesni_gcm_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Cryptodev null autotest",
+ "Command": "cryptodev_null_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Cryptodev sw snow3g autotest",
+ "Command": "cryptodev_sw_snow3g_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Cryptodev sw kasumi autotest",
+ "Command": "cryptodev_sw_kasumi_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Cryptodev_sw_zuc_autotest",
+ "Command": "cryptodev_sw_zuc_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Reciprocal division",
+ "Command": "reciprocal_division",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Red all",
+ "Command": "red_all",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Fbarray autotest",
+ "Command": "fbarray_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "External memory autotest",
+ "Command": "external_mem_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Metrics autotest",
+ "Command": "metrics_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Bitratestats autotest",
+ "Command": "bitratestats_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Latencystats autotest",
+ "Command": "latencystats_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Pdump autotest",
+ "Command": "pdump_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "IPsec_SAD",
+ "Command": "ipsec_sad_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Checksum autotest",
+ "Command": "cksum_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ #
+ #Please always keep all dump tests at the end and together!
+ #
+ {
+ "Name": "Dump physmem",
+ "Command": "dump_physmem",
+ "Func": dump_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Dump memzone",
+ "Command": "dump_memzone",
+ "Func": dump_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Dump struct sizes",
+ "Command": "dump_struct_sizes",
+ "Func": dump_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Dump mempool",
+ "Command": "dump_mempool",
+ "Func": dump_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Dump malloc stats",
+ "Command": "dump_malloc_stats",
+ "Func": dump_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Dump devargs",
+ "Command": "dump_devargs",
+ "Func": dump_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Dump log types",
+ "Command": "dump_log_types",
+ "Func": dump_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Dump_ring",
+ "Command": "dump_ring",
+ "Func": dump_autotest,
+ "Report": None,
+ },
+]
+
+# tests that should not be run when any other tests are running
+non_parallel_test_list = [
+ {
+ "Name": "Eventdev common autotest",
+ "Command": "eventdev_common_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Eventdev selftest sw",
+ "Command": "eventdev_selftest_sw",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "KNI autotest",
+ "Command": "kni_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Mempool performance autotest",
+ "Command": "mempool_perf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Memcpy performance autotest",
+ "Command": "memcpy_perf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Hash performance autotest",
+ "Command": "hash_perf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Hash read-write concurrency functional autotest",
+ "Command": "hash_readwrite_func_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Hash read-write concurrency perf autotest",
+ "Command": "hash_readwrite_perf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Hash read-write lock-free concurrency perf autotest",
+ "Command": "hash_readwrite_lf_perf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Power autotest",
+ "Command": "power_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Power cpufreq autotest",
+ "Command": "power_cpufreq_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Power KVM VM autotest",
+ "Command": "power_kvm_vm_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Timer performance autotest",
+ "Command": "timer_perf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+
+ "Name": "Pmd perf autotest",
+ "Command": "pmd_perf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Ring pmd perf autotest",
+ "Command": "ring_pmd_perf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Distributor perf autotest",
+ "Command": "distributor_perf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Red_perf",
+ "Command": "red_perf",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Lpm6 perf autotest",
+ "Command": "lpm6_perf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Lpm perf autotest",
+ "Command": "lpm_perf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "FIB perf autotest",
+ "Command": "fib_perf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "FIB6 perf autotest",
+ "Command": "fib6_perf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Efd perf autotest",
+ "Command": "efd_perf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Member perf autotest",
+ "Command": "member_perf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "Reciprocal division perf",
+ "Command": "reciprocal_division_perf",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "RCU QSBR autotest",
+ "Command": "rcu_qsbr_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
+ "Name": "RCU QSBR performance autotest",
+ "Command": "rcu_qsbr_perf_autotest",
+ "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!
+ #
+ {
+ "Name": "Ring performance autotest",
+ "Command": "ring_perf_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+]
diff --git a/app/test/meson.build b/app/test/meson.build
index a16374b7a10..842388b0d32 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_dmadev.c',
@@ -204,6 +205,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..13e95f052b0
--- /dev/null
+++ b/app/test/test_devargs.c
@@ -0,0 +1,184 @@
+/* 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 <rte_bus.h>
+#include <rte_class.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;
+ const char *bus;
+ const char *name;
+ const char *class;
+ } list[] = {
+ /* Global devargs syntax: */
+ { "bus=pci",
+ 1, 0, 0, "pci", NULL, NULL},
+ { "class=eth",
+ 0, 1, 0, NULL, NULL, "eth" },
+ { "bus=pci,addr=1:2.3/class=eth/driver=abc,k0=v0",
+ 2, 1, 2, "pci", "0000:01:02.3", "eth" },
+ { "bus=vdev,name=/dev/file/name/class=eth",
+ 2, 1, 0, "vdev", "/dev/file/name", "eth" },
+ { "bus=vdev,name=/class/bus/path/class=eth",
+ 2, 1, 0, "vdev", "/class/bus/path", "eth" },
+ { "bus=vdev,name=///dblslsh/class=eth",
+ 2, 1, 0, "vdev", "///dblslsh", "eth" },
+ /* Legacy devargs syntax: */
+ { "1:2.3", 0, 0, 0,
+ "pci", "1:2.3", NULL },
+ { "pci:1:2.3,k0=v0",
+ 0, 0, 1, "pci", "1:2.3", NULL },
+ { "net_virtio_user0,iface=test,path=/dev/vhost-net,queues=1",
+ 0, 0, 3, "vdev", "net_virtio_user0", NULL },
+ { "net_virtio_user0,iface=test,path=/class/bus/,queues=1",
+ 0, 0, 3, "vdev", "net_virtio_user0", NULL },
+ };
+ struct rte_devargs da;
+ uint32_t i;
+ int ret;
+ int fail = 0;
+
+ for (i = 0; i < RTE_DIM(list); i++) {
+ memset(&da, 0, sizeof(da));
+ ret = rte_devargs_parse(&da, list[i].devargs);
+ if (ret < 0) {
+ printf("rte_devargs_parse(%s) returned %d (but should not)\n",
+ list[i].devargs, ret);
+ goto fail;
+ }
+ if ((list[i].bus_kv > 0 || list[i].bus != NULL) &&
+ da.bus == NULL) {
+ printf("rte_devargs_parse(%s) bus not parsed\n",
+ list[i].devargs);
+ goto fail;
+ }
+ if (test_args(list[i].devargs, "bus", da.bus_str,
+ list[i].bus_kv) != 0)
+ goto fail;
+ if (list[i].bus != NULL &&
+ strcmp(da.bus->name, list[i].bus) != 0) {
+ printf("rte_devargs_parse(%s) bus name (%s) not expected (%s)\n",
+ list[i].devargs, da.bus->name, list[i].bus);
+ goto fail;
+ }
+ if ((list[i].class_kv > 0 || list[i].class != NULL) &&
+ da.cls == NULL) {
+ printf("rte_devargs_parse(%s) class not parsed\n",
+ list[i].devargs);
+ goto fail;
+ }
+ if (test_args(list[i].devargs, "class", da.cls_str,
+ list[i].class_kv) != 0)
+ goto fail;
+ if (list[i].class != NULL &&
+ strcmp(da.cls->name, list[i].class) != 0) {
+ printf("rte_devargs_parse(%s) class name (%s) not expected (%s)\n",
+ list[i].devargs, da.cls->name, list[i].class);
+ goto fail;
+ }
+ if (test_args(list[i].devargs, "driver", da.drv_str,
+ list[i].driver_kv) != 0)
+ goto fail;
+ if (list[i].name != NULL &&
+ strcmp(da.name, list[i].name) != 0) {
+ printf("rte_devargs_parse(%s) device name (%s) not expected (%s)\n",
+ list[i].devargs, da.name, list[i].name);
+ goto fail;
+ }
+ goto cleanup;
+fail:
+ fail = -1;
+cleanup:
+ rte_devargs_reset(&da);
+ }
+ return fail;
+}
+
+/* Test several invalid cases */
+static int
+test_invalid_devargs(void)
+{
+ static const char * const list[] = {
+ "bus=wrong-bus",
+ "class=wrong-class"};
+ struct rte_devargs da;
+ uint32_t i;
+ int ret;
+ int fail = 0;
+
+ for (i = 0; i < RTE_DIM(list); i++) {
+ ret = rte_devargs_parse(&da, list[i]);
+ if (ret >= 0) {
+ printf("rte_devargs_parse(%s) returned %d (but should not)\n",
+ list[i], ret);
+ fail = ret;
+ }
+ rte_devargs_reset(&da);
+ }
+ return fail;
+}
+
+static int
+test_devargs(void)
+{
+ printf("== test valid case ==\n");
+ if (test_valid_devargs() < 0)
+ return -1;
+ printf("== test invalid case ==\n");
+ if (test_invalid_devargs() < 0)
+ return -1;
+ return 0;
+}
+
+REGISTER_TEST_COMMAND(devargs_autotest, test_devargs);
--
2.33.0
next prev parent reply other threads:[~2021-10-20 7:32 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
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 ` Xueming Li [this message]
2021-10-20 7:38 ` [dpdk-dev] [PATCH v2 3/3] test/devargs: add devargs test cases 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=20211020073151.2374674-4-xuemingl@nvidia.com \
--to=xuemingl@nvidia.com \
--cc=dev@dpdk.org \
--cc=grive@u256.net \
--cc=lmargalit@nvidia.com \
--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).