DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] app/test: rework command registration
@ 2016-07-13 21:24 Thomas Monjalon
  2016-07-13 21:24 ` [dpdk-dev] [PATCH 2/2] app/test: filter out unavailable tests Thomas Monjalon
  2016-07-14 17:25 ` [dpdk-dev] [dpdk-dev, 1/2] app/test: rework command registration viktorin
  0 siblings, 2 replies; 6+ messages in thread
From: Thomas Monjalon @ 2016-07-13 21:24 UTC (permalink / raw)
  To: dev

The tests are registered with their command name by adding a structure
to a list. The structure of each test was declared in each test file
and passed to the register macro.
This rework generate the structure inside the register macro.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
 app/test/test.h                      | 17 +++++++++------
 app/test/test_acl.c                  |  6 +-----
 app/test/test_alarm.c                |  6 +-----
 app/test/test_atomic.c               |  6 +-----
 app/test/test_byteorder.c            |  6 +-----
 app/test/test_cmdline.c              |  6 +-----
 app/test/test_common.c               |  6 +-----
 app/test/test_cpuflags.c             |  6 +-----
 app/test/test_cryptodev.c            | 41 ++++++------------------------------
 app/test/test_cryptodev_perf.c       | 28 ++++--------------------
 app/test/test_cycles.c               |  6 +-----
 app/test/test_debug.c                |  6 +-----
 app/test/test_devargs.c              |  6 +-----
 app/test/test_distributor.c          |  6 +-----
 app/test/test_distributor_perf.c     |  6 +-----
 app/test/test_eal_flags.c            |  6 +-----
 app/test/test_eal_fs.c               |  6 +-----
 app/test/test_errno.c                |  6 +-----
 app/test/test_func_reentrancy.c      |  6 +-----
 app/test/test_hash.c                 |  6 +-----
 app/test/test_hash_functions.c       |  6 +-----
 app/test/test_hash_multiwriter.c     |  8 +------
 app/test/test_hash_perf.c            |  6 +-----
 app/test/test_hash_scaling.c         |  7 +-----
 app/test/test_interrupts.c           |  6 +-----
 app/test/test_ivshmem.c              |  6 +-----
 app/test/test_kni.c                  |  6 +-----
 app/test/test_kvargs.c               |  6 +-----
 app/test/test_link_bonding.c         |  6 +-----
 app/test/test_link_bonding_mode4.c   |  7 +-----
 app/test/test_link_bonding_rssconf.c |  7 +-----
 app/test/test_logs.c                 |  6 +-----
 app/test/test_lpm.c                  |  6 +-----
 app/test/test_lpm6.c                 |  6 +-----
 app/test/test_lpm6_perf.c            |  6 +-----
 app/test/test_lpm_perf.c             |  6 +-----
 app/test/test_malloc.c               |  6 +-----
 app/test/test_mbuf.c                 |  6 +-----
 app/test/test_memcpy.c               |  6 +-----
 app/test/test_memcpy_perf.c          |  6 +-----
 app/test/test_memory.c               |  6 +-----
 app/test/test_mempool.c              |  6 +-----
 app/test/test_mempool_perf.c         |  6 +-----
 app/test/test_memzone.c              |  6 +-----
 app/test/test_meter.c                |  6 +-----
 app/test/test_mp_secondary.c         |  6 +-----
 app/test/test_pci.c                  |  6 +-----
 app/test/test_per_lcore.c            |  6 +-----
 app/test/test_pmd_perf.c             |  6 +-----
 app/test/test_pmd_ring.c             |  6 +-----
 app/test/test_pmd_ring_perf.c        |  6 +-----
 app/test/test_power.c                |  6 +-----
 app/test/test_power_acpi_cpufreq.c   |  6 +-----
 app/test/test_power_kvm_vm.c         |  6 +-----
 app/test/test_prefetch.c             |  6 +-----
 app/test/test_red.c                  | 20 +++---------------
 app/test/test_reorder.c              |  6 +-----
 app/test/test_resource.c             |  6 +-----
 app/test/test_ring.c                 |  6 +-----
 app/test/test_ring_perf.c            |  6 +-----
 app/test/test_rwlock.c               |  6 +-----
 app/test/test_sched.c                |  6 +-----
 app/test/test_spinlock.c             |  6 +-----
 app/test/test_string_fns.c           |  6 +-----
 app/test/test_table.c                |  6 +-----
 app/test/test_tailq.c                |  6 +-----
 app/test/test_thash.c                |  6 +-----
 app/test/test_timer.c                |  6 +-----
 app/test/test_timer_perf.c           |  6 +-----
 app/test/test_timer_racecond.c       |  6 +-----
 app/test/test_version.c              |  6 +-----
 71 files changed, 91 insertions(+), 422 deletions(-)

diff --git a/app/test/test.h b/app/test/test.h
index 81828be..467b9c0 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -250,11 +250,16 @@ struct test_command {
 
 void add_test_command(struct test_command *t);
 
-#define REGISTER_TEST_COMMAND(t) \
-static void __attribute__((used)) testfn_##t(void);\
-void __attribute__((constructor, used)) testfn_##t(void)\
-{\
-	add_test_command(&t);\
-}
+/* Register a test function with its command string */
+#define REGISTER_TEST_COMMAND(cmd, func) \
+	static struct test_command test_struct_##cmd = { \
+		.command = RTE_STR(cmd), \
+		.callback = func, \
+	}; \
+	static void __attribute__((constructor, used)) \
+	test_register_##cmd(void) \
+	{ \
+		add_test_command(&test_struct_##cmd); \
+	}
 
 #endif
diff --git a/app/test/test_acl.c b/app/test/test_acl.c
index 2b82790..28955f0 100644
--- a/app/test/test_acl.c
+++ b/app/test/test_acl.c
@@ -1682,8 +1682,4 @@ test_acl(void)
 	return 0;
 }
 
-static struct test_command acl_cmd = {
-	.command = "acl_autotest",
-	.callback = test_acl,
-};
-REGISTER_TEST_COMMAND(acl_cmd);
+REGISTER_TEST_COMMAND(acl_autotest, test_acl);
diff --git a/app/test/test_alarm.c b/app/test/test_alarm.c
index d83591c..ecb2f6d 100644
--- a/app/test/test_alarm.c
+++ b/app/test/test_alarm.c
@@ -253,8 +253,4 @@ test_alarm(void)
 	return 0;
 }
 
-static struct test_command alarm_cmd = {
-	.command = "alarm_autotest",
-	.callback = test_alarm,
-};
-REGISTER_TEST_COMMAND(alarm_cmd);
+REGISTER_TEST_COMMAND(alarm_autotest, test_alarm);
diff --git a/app/test/test_atomic.c b/app/test/test_atomic.c
index 588f530..b5e7e1b 100644
--- a/app/test/test_atomic.c
+++ b/app/test/test_atomic.c
@@ -374,8 +374,4 @@ test_atomic(void)
 	return 0;
 }
 
-static struct test_command atomic_cmd = {
-	.command = "atomic_autotest",
-	.callback = test_atomic,
-};
-REGISTER_TEST_COMMAND(atomic_cmd);
+REGISTER_TEST_COMMAND(atomic_autotest, test_atomic);
diff --git a/app/test/test_byteorder.c b/app/test/test_byteorder.c
index a088489..8ae3114 100644
--- a/app/test/test_byteorder.c
+++ b/app/test/test_byteorder.c
@@ -92,8 +92,4 @@ test_byteorder(void)
 	return 0;
 }
 
-static struct test_command byteorder_cmd = {
-	.command = "byteorder_autotest",
-	.callback = test_byteorder,
-};
-REGISTER_TEST_COMMAND(byteorder_cmd);
+REGISTER_TEST_COMMAND(byteorder_autotest, test_byteorder);
diff --git a/app/test/test_cmdline.c b/app/test/test_cmdline.c
index 2b5840f..38c7256 100644
--- a/app/test/test_cmdline.c
+++ b/app/test/test_cmdline.c
@@ -89,8 +89,4 @@ test_cmdline(void)
 	return 0;
 }
 
-static struct test_command cmdline_cmd = {
-	.command = "cmdline_autotest",
-	.callback = test_cmdline,
-};
-REGISTER_TEST_COMMAND(cmdline_cmd);
+REGISTER_TEST_COMMAND(cmdline_autotest, test_cmdline);
diff --git a/app/test/test_common.c b/app/test/test_common.c
index 66e9109..8effa2f 100644
--- a/app/test/test_common.c
+++ b/app/test/test_common.c
@@ -169,8 +169,4 @@ test_common(void)
 	return ret;
 }
 
-static struct test_command common_cmd = {
-	.command = "common_autotest",
-	.callback = test_common,
-};
-REGISTER_TEST_COMMAND(common_cmd);
+REGISTER_TEST_COMMAND(common_autotest, test_common);
diff --git a/app/test/test_cpuflags.c b/app/test/test_cpuflags.c
index d083c86..0e5ebe7 100644
--- a/app/test/test_cpuflags.c
+++ b/app/test/test_cpuflags.c
@@ -199,8 +199,4 @@ test_cpuflags(void)
 	return 0;
 }
 
-static struct test_command cpuflags_cmd = {
-	.command = "cpuflags_autotest",
-	.callback = test_cpuflags,
-};
-REGISTER_TEST_COMMAND(cpuflags_cmd);
+REGISTER_TEST_COMMAND(cpuflags_autotest, test_cpuflags);
diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 33325a8..647787d 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -4164,10 +4164,6 @@ test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
 	gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
 	return unit_test_suite_runner(&cryptodev_qat_testsuite);
 }
-static struct test_command cryptodev_qat_cmd = {
-	.command = "cryptodev_qat_autotest",
-	.callback = test_cryptodev_qat,
-};
 
 static int
 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
@@ -4177,11 +4173,6 @@ test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
 	return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
 }
 
-static struct test_command cryptodev_aesni_mb_cmd = {
-	.command = "cryptodev_aesni_mb_autotest",
-	.callback = test_cryptodev_aesni_mb,
-};
-
 static int
 test_cryptodev_aesni_gcm(void)
 {
@@ -4190,11 +4181,6 @@ test_cryptodev_aesni_gcm(void)
 	return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
 }
 
-static struct test_command cryptodev_aesni_gcm_cmd = {
-	.command = "cryptodev_aesni_gcm_autotest",
-	.callback = test_cryptodev_aesni_gcm,
-};
-
 static int
 test_cryptodev_null(void)
 {
@@ -4203,11 +4189,6 @@ test_cryptodev_null(void)
 	return unit_test_suite_runner(&cryptodev_null_testsuite);
 }
 
-static struct test_command cryptodev_null_cmd = {
-	.command = "cryptodev_null_autotest",
-	.callback = test_cryptodev_null,
-};
-
 static int
 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
 {
@@ -4216,11 +4197,6 @@ test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
 	return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
 }
 
-static struct test_command cryptodev_sw_snow3g_cmd = {
-	.command = "cryptodev_sw_snow3g_autotest",
-	.callback = test_cryptodev_sw_snow3g,
-};
-
 static int
 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
 {
@@ -4229,14 +4205,9 @@ test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
 	return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
 }
 
-static struct test_command cryptodev_sw_kasumi_cmd = {
-	.command = "cryptodev_sw_kasumi_autotest",
-	.callback = test_cryptodev_sw_kasumi,
-};
-
-REGISTER_TEST_COMMAND(cryptodev_qat_cmd);
-REGISTER_TEST_COMMAND(cryptodev_aesni_mb_cmd);
-REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_cmd);
-REGISTER_TEST_COMMAND(cryptodev_null_cmd);
-REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_cmd);
-REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_cmd);
+REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
+REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
+REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
+REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
+REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
+REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
diff --git a/app/test/test_cryptodev_perf.c b/app/test/test_cryptodev_perf.c
index 815c41f..2398d84 100644
--- a/app/test/test_cryptodev_perf.c
+++ b/app/test/test_cryptodev_perf.c
@@ -2919,27 +2919,7 @@ perftest_qat_snow3g_cryptodev(void /*argv __rte_unused, int argc __rte_unused*/)
 	return unit_test_suite_runner(&cryptodev_snow3g_testsuite);
 }
 
-static struct test_command cryptodev_aesni_mb_perf_cmd = {
-	.command = "cryptodev_aesni_mb_perftest",
-	.callback = perftest_aesni_mb_cryptodev,
-};
-
-static struct test_command cryptodev_qat_perf_cmd = {
-	.command = "cryptodev_qat_perftest",
-	.callback = perftest_qat_cryptodev,
-};
-
-static struct test_command cryptodev_sw_snow3g_perf_cmd = {
-	.command = "cryptodev_sw_snow3g_perftest",
-	.callback = perftest_sw_snow3g_cryptodev,
-};
-
-static struct test_command cryptodev_qat_snow3g_perf_cmd = {
-	.command = "cryptodev_qat_snow3g_perftest",
-	.callback = perftest_qat_snow3g_cryptodev,
-};
-
-REGISTER_TEST_COMMAND(cryptodev_aesni_mb_perf_cmd);
-REGISTER_TEST_COMMAND(cryptodev_qat_perf_cmd);
-REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_perf_cmd);
-REGISTER_TEST_COMMAND(cryptodev_qat_snow3g_perf_cmd);
+REGISTER_TEST_COMMAND(cryptodev_aesni_mb_perftest, perftest_aesni_mb_cryptodev);
+REGISTER_TEST_COMMAND(cryptodev_qat_perftest, perftest_qat_cryptodev);
+REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_perftest, perftest_sw_snow3g_cryptodev);
+REGISTER_TEST_COMMAND(cryptodev_qat_snow3g_perftest, perftest_qat_snow3g_cryptodev);
diff --git a/app/test/test_cycles.c b/app/test/test_cycles.c
index d8fa517..f6c043a 100644
--- a/app/test/test_cycles.c
+++ b/app/test/test_cycles.c
@@ -89,8 +89,4 @@ test_cycles(void)
 	return 0;
 }
 
-static struct test_command cycles_cmd = {
-	.command = "cycles_autotest",
-	.callback = test_cycles,
-};
-REGISTER_TEST_COMMAND(cycles_cmd);
+REGISTER_TEST_COMMAND(cycles_autotest, test_cycles);
diff --git a/app/test/test_debug.c b/app/test/test_debug.c
index 7c3ee92..0a3b2c4 100644
--- a/app/test/test_debug.c
+++ b/app/test/test_debug.c
@@ -146,8 +146,4 @@ test_debug(void)
 	return 0;
 }
 
-static struct test_command debug_cmd = {
-	.command = "debug_autotest",
-	.callback = test_debug,
-};
-REGISTER_TEST_COMMAND(debug_cmd);
+REGISTER_TEST_COMMAND(debug_autotest, test_debug);
diff --git a/app/test/test_devargs.c b/app/test/test_devargs.c
index e5a9aa0..151ac2a 100644
--- a/app/test/test_devargs.c
+++ b/app/test/test_devargs.c
@@ -131,8 +131,4 @@ test_devargs(void)
 	return -1;
 }
 
-static struct test_command devargs_cmd = {
-	.command = "devargs_autotest",
-	.callback = test_devargs,
-};
-REGISTER_TEST_COMMAND(devargs_cmd);
+REGISTER_TEST_COMMAND(devargs_autotest, test_devargs);
diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c
index 00b1d41..85cb8f3 100644
--- a/app/test/test_distributor.c
+++ b/app/test/test_distributor.c
@@ -576,8 +576,4 @@ err:
 	return -1;
 }
 
-static struct test_command distributor_cmd = {
-	.command = "distributor_autotest",
-	.callback = test_distributor,
-};
-REGISTER_TEST_COMMAND(distributor_cmd);
+REGISTER_TEST_COMMAND(distributor_autotest, test_distributor);
diff --git a/app/test/test_distributor_perf.c b/app/test/test_distributor_perf.c
index 92b2220..7947fe9 100644
--- a/app/test/test_distributor_perf.c
+++ b/app/test/test_distributor_perf.c
@@ -257,8 +257,4 @@ test_distributor_perf(void)
 	return 0;
 }
 
-static struct test_command distributor_perf_cmd = {
-	.command = "distributor_perf_autotest",
-	.callback = test_distributor_perf,
-};
-REGISTER_TEST_COMMAND(distributor_perf_cmd);
+REGISTER_TEST_COMMAND(distributor_perf_autotest, test_distributor_perf);
diff --git a/app/test/test_eal_flags.c b/app/test/test_eal_flags.c
index 93ae6e7..6202f05 100644
--- a/app/test/test_eal_flags.c
+++ b/app/test/test_eal_flags.c
@@ -1441,8 +1441,4 @@ test_eal_flags(void)
 	return ret;
 }
 
-static struct test_command eal_flags_cmd = {
-	.command = "eal_flags_autotest",
-	.callback = test_eal_flags,
-};
-REGISTER_TEST_COMMAND(eal_flags_cmd);
+REGISTER_TEST_COMMAND(eal_flags_autotest, test_eal_flags);
diff --git a/app/test/test_eal_fs.c b/app/test/test_eal_fs.c
index 1cbcb9d..7897812 100644
--- a/app/test/test_eal_fs.c
+++ b/app/test/test_eal_fs.c
@@ -203,8 +203,4 @@ test_eal_fs(void)
 	return 0;
 }
 
-static struct test_command eal_fs_cmd = {
-	.command = "eal_fs_autotest",
-	.callback = test_eal_fs,
-};
-REGISTER_TEST_COMMAND(eal_fs_cmd);
+REGISTER_TEST_COMMAND(eal_fs_autotest, test_eal_fs);
diff --git a/app/test/test_errno.c b/app/test/test_errno.c
index f221eac..388decb 100644
--- a/app/test/test_errno.c
+++ b/app/test/test_errno.c
@@ -113,8 +113,4 @@ test_errno(void)
 	return 0;
 }
 
-static struct test_command errno_cmd = {
-	.command = "errno_autotest",
-	.callback = test_errno,
-};
-REGISTER_TEST_COMMAND(errno_cmd);
+REGISTER_TEST_COMMAND(errno_autotest, test_errno);
diff --git a/app/test/test_func_reentrancy.c b/app/test/test_func_reentrancy.c
index d6e9dd8..baa01ff 100644
--- a/app/test/test_func_reentrancy.c
+++ b/app/test/test_func_reentrancy.c
@@ -507,8 +507,4 @@ test_func_reentrancy(void)
 	return 0;
 }
 
-static struct test_command func_reentrancy_cmd = {
-	.command = "func_reentrancy_autotest",
-	.callback = test_func_reentrancy,
-};
-REGISTER_TEST_COMMAND(func_reentrancy_cmd);
+REGISTER_TEST_COMMAND(func_reentrancy_autotest, test_func_reentrancy);
diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index 29abcd9..94300e1 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -1514,8 +1514,4 @@ test_hash(void)
 	return 0;
 }
 
-static struct test_command hash_cmd = {
-	.command = "hash_autotest",
-	.callback = test_hash,
-};
-REGISTER_TEST_COMMAND(hash_cmd);
+REGISTER_TEST_COMMAND(hash_autotest, test_hash);
diff --git a/app/test/test_hash_functions.c b/app/test/test_hash_functions.c
index f767a48..9652b04 100644
--- a/app/test/test_hash_functions.c
+++ b/app/test/test_hash_functions.c
@@ -319,8 +319,4 @@ test_hash_functions(void)
 	return 0;
 }
 
-static struct test_command hash_functions_cmd = {
-	.command = "hash_functions_autotest",
-	.callback = test_hash_functions,
-};
-REGISTER_TEST_COMMAND(hash_functions_cmd);
+REGISTER_TEST_COMMAND(hash_functions_autotest, test_hash_functions);
diff --git a/app/test/test_hash_multiwriter.c b/app/test/test_hash_multiwriter.c
index b0f31b0..40af95d 100644
--- a/app/test/test_hash_multiwriter.c
+++ b/app/test/test_hash_multiwriter.c
@@ -278,10 +278,4 @@ test_hash_multiwriter_main(void)
 	return r;
 }
 
-
-static struct test_command hash_scaling_cmd = {
-	.command = "hash_multiwriter_autotest",
-	.callback = test_hash_multiwriter_main,
-};
-
-REGISTER_TEST_COMMAND(hash_scaling_cmd);
+REGISTER_TEST_COMMAND(hash_multiwriter_autotest, test_hash_multiwriter_main);
diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c
index 9d53c14..c0051b2 100644
--- a/app/test/test_hash_perf.c
+++ b/app/test/test_hash_perf.c
@@ -656,8 +656,4 @@ test_hash_perf(void)
 	return 0;
 }
 
-static struct test_command hash_perf_cmd = {
-		.command = "hash_perf_autotest",
-		.callback = test_hash_perf,
-};
-REGISTER_TEST_COMMAND(hash_perf_cmd);
+REGISTER_TEST_COMMAND(hash_perf_autotest, test_hash_perf);
diff --git a/app/test/test_hash_scaling.c b/app/test/test_hash_scaling.c
index 1c4c75d..46c48e5 100644
--- a/app/test/test_hash_scaling.c
+++ b/app/test/test_hash_scaling.c
@@ -217,9 +217,4 @@ test_hash_scaling_main(void)
 	return r;
 }
 
-
-static struct test_command hash_scaling_cmd = {
-	.command = "hash_scaling_autotest",
-	.callback = test_hash_scaling_main,
-};
-REGISTER_TEST_COMMAND(hash_scaling_cmd);
+REGISTER_TEST_COMMAND(hash_scaling_autotest, test_hash_scaling_main);
diff --git a/app/test/test_interrupts.c b/app/test/test_interrupts.c
index df6d261..371101f 100644
--- a/app/test/test_interrupts.c
+++ b/app/test/test_interrupts.c
@@ -548,8 +548,4 @@ out:
 	return ret;
 }
 
-static struct test_command interrupt_cmd = {
-	.command = "interrupt_autotest",
-	.callback = test_interrupt,
-};
-REGISTER_TEST_COMMAND(interrupt_cmd);
+REGISTER_TEST_COMMAND(interrupt_autotest, test_interrupt);
diff --git a/app/test/test_ivshmem.c b/app/test/test_ivshmem.c
index 4e61488..ae9fd6c 100644
--- a/app/test/test_ivshmem.c
+++ b/app/test/test_ivshmem.c
@@ -430,8 +430,4 @@ test_ivshmem(void)
 	return -1;
 }
 
-static struct test_command ivshmem_cmd = {
-	.command = "ivshmem_autotest",
-	.callback = test_ivshmem,
-};
-REGISTER_TEST_COMMAND(ivshmem_cmd);
+REGISTER_TEST_COMMAND(ivshmem_autotest, test_ivshmem);
diff --git a/app/test/test_kni.c b/app/test/test_kni.c
index 7243ade..309741c 100644
--- a/app/test/test_kni.c
+++ b/app/test/test_kni.c
@@ -633,8 +633,4 @@ fail:
 	return ret;
 }
 
-static struct test_command kni_cmd = {
-	.command = "kni_autotest",
-	.callback = test_kni,
-};
-REGISTER_TEST_COMMAND(kni_cmd);
+REGISTER_TEST_COMMAND(kni_autotest, test_kni);
diff --git a/app/test/test_kvargs.c b/app/test/test_kvargs.c
index 6be8512..4d9e805 100644
--- a/app/test/test_kvargs.c
+++ b/app/test/test_kvargs.c
@@ -232,8 +232,4 @@ test_kvargs(void)
 	return 0;
 }
 
-static struct test_command kvargs_cmd = {
-	.command = "kvargs_autotest",
-	.callback = test_kvargs,
-};
-REGISTER_TEST_COMMAND(kvargs_cmd);
+REGISTER_TEST_COMMAND(kvargs_autotest, test_kvargs);
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index eeb1395..3229660 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -5002,8 +5002,4 @@ test_link_bonding(void)
 	return unit_test_suite_runner(&link_bonding_test_suite);
 }
 
-static struct test_command link_bonding_cmd = {
-	.command = "link_bonding_autotest",
-	.callback = test_link_bonding,
-};
-REGISTER_TEST_COMMAND(link_bonding_cmd);
+REGISTER_TEST_COMMAND(link_bonding_autotest, test_link_bonding);
diff --git a/app/test/test_link_bonding_mode4.c b/app/test/test_link_bonding_mode4.c
index a3f1f08..53caa3e 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -1599,9 +1599,4 @@ test_link_bonding_mode4(void)
 	return unit_test_suite_runner(&link_bonding_mode4_test_suite);
 }
 
-static struct test_command link_bonding_cmd = {
-	.command = "link_bonding_mode4_autotest",
-	.callback = test_link_bonding_mode4,
-};
-
-REGISTER_TEST_COMMAND(link_bonding_cmd);
+REGISTER_TEST_COMMAND(link_bonding_mode4_autotest, test_link_bonding_mode4);
diff --git a/app/test/test_link_bonding_rssconf.c b/app/test/test_link_bonding_rssconf.c
index 0a3162e..34f1c16 100644
--- a/app/test/test_link_bonding_rssconf.c
+++ b/app/test/test_link_bonding_rssconf.c
@@ -670,9 +670,4 @@ test_link_bonding_rssconf(void)
 	return unit_test_suite_runner(&link_bonding_rssconf_test_suite);
 }
 
-static struct test_command test_link_bonding_rssconf_cmd = {
-	.command = "link_bonding_rssconf_autotest",
-	.callback = test_link_bonding_rssconf,
-};
-
-REGISTER_TEST_COMMAND(test_link_bonding_rssconf_cmd);
+REGISTER_TEST_COMMAND(link_bonding_rssconf_autotest, test_link_bonding_rssconf);
diff --git a/app/test/test_logs.c b/app/test/test_logs.c
index d0a9962..6985ddd 100644
--- a/app/test/test_logs.c
+++ b/app/test/test_logs.c
@@ -86,8 +86,4 @@ test_logs(void)
 	return 0;
 }
 
-static struct test_command logs_cmd = {
-	.command = "logs_autotest",
-	.callback = test_logs,
-};
-REGISTER_TEST_COMMAND(logs_cmd);
+REGISTER_TEST_COMMAND(logs_autotest, test_logs);
diff --git a/app/test/test_lpm.c b/app/test/test_lpm.c
index f6930fb..b6ad2eb 100644
--- a/app/test/test_lpm.c
+++ b/app/test/test_lpm.c
@@ -1238,8 +1238,4 @@ test_lpm(void)
 	return global_status;
 }
 
-static struct test_command lpm_cmd = {
-	.command = "lpm_autotest",
-	.callback = test_lpm,
-};
-REGISTER_TEST_COMMAND(lpm_cmd);
+REGISTER_TEST_COMMAND(lpm_autotest, test_lpm);
diff --git a/app/test/test_lpm6.c b/app/test/test_lpm6.c
index 458a10b..0fd0ef7 100644
--- a/app/test/test_lpm6.c
+++ b/app/test/test_lpm6.c
@@ -1764,8 +1764,4 @@ test_lpm6(void)
 	return global_status;
 }
 
-static struct test_command lpm6_cmd = {
-	.command = "lpm6_autotest",
-	.callback = test_lpm6,
-};
-REGISTER_TEST_COMMAND(lpm6_cmd);
+REGISTER_TEST_COMMAND(lpm6_autotest, test_lpm6);
diff --git a/app/test/test_lpm6_perf.c b/app/test/test_lpm6_perf.c
index b7d4631..be47d4a 100644
--- a/app/test/test_lpm6_perf.c
+++ b/app/test/test_lpm6_perf.c
@@ -184,8 +184,4 @@ test_lpm6_perf(void)
 	return 0;
 }
 
-static struct test_command lpm6_perf_cmd = {
-	.command = "lpm6_perf_autotest",
-	.callback = test_lpm6_perf,
-};
-REGISTER_TEST_COMMAND(lpm6_perf_cmd);
+REGISTER_TEST_COMMAND(lpm6_perf_autotest, test_lpm6_perf);
diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c
index 41da811..58eb415 100644
--- a/app/test/test_lpm_perf.c
+++ b/app/test/test_lpm_perf.c
@@ -242,8 +242,4 @@ test_lpm_perf(void)
 	return 0;
 }
 
-static struct test_command lpm_perf_cmd = {
-	.command = "lpm_perf_autotest",
-	.callback = test_lpm_perf,
-};
-REGISTER_TEST_COMMAND(lpm_perf_cmd);
+REGISTER_TEST_COMMAND(lpm_perf_autotest, test_lpm_perf);
diff --git a/app/test/test_malloc.c b/app/test/test_malloc.c
index a04a751..0673d85 100644
--- a/app/test/test_malloc.c
+++ b/app/test/test_malloc.c
@@ -959,8 +959,4 @@ test_malloc(void)
 	return 0;
 }
 
-static struct test_command malloc_cmd = {
-	.command = "malloc_autotest",
-	.callback = test_malloc,
-};
-REGISTER_TEST_COMMAND(malloc_cmd);
+REGISTER_TEST_COMMAND(malloc_autotest, test_malloc);
diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c
index 8664885..684ad80 100644
--- a/app/test/test_mbuf.c
+++ b/app/test/test_mbuf.c
@@ -1026,8 +1026,4 @@ test_mbuf(void)
 	return 0;
 }
 
-static struct test_command mbuf_cmd = {
-	.command = "mbuf_autotest",
-	.callback = test_mbuf,
-};
-REGISTER_TEST_COMMAND(mbuf_cmd);
+REGISTER_TEST_COMMAND(mbuf_autotest, test_mbuf);
diff --git a/app/test/test_memcpy.c b/app/test/test_memcpy.c
index 8195e20..1d93dd5 100644
--- a/app/test/test_memcpy.c
+++ b/app/test/test_memcpy.c
@@ -159,8 +159,4 @@ test_memcpy(void)
 	return 0;
 }
 
-static struct test_command memcpy_cmd = {
-	.command = "memcpy_autotest",
-	.callback = test_memcpy,
-};
-REGISTER_TEST_COMMAND(memcpy_cmd);
+REGISTER_TEST_COMMAND(memcpy_autotest, test_memcpy);
diff --git a/app/test/test_memcpy_perf.c b/app/test/test_memcpy_perf.c
index be69ead..ff3aaaa 100644
--- a/app/test/test_memcpy_perf.c
+++ b/app/test/test_memcpy_perf.c
@@ -351,8 +351,4 @@ test_memcpy_perf(void)
 	return 0;
 }
 
-static struct test_command memcpy_perf_cmd = {
-	.command = "memcpy_perf_autotest",
-	.callback = test_memcpy_perf,
-};
-REGISTER_TEST_COMMAND(memcpy_perf_cmd);
+REGISTER_TEST_COMMAND(memcpy_perf_autotest, test_memcpy_perf);
diff --git a/app/test/test_memory.c b/app/test/test_memory.c
index 6816385..921bdc8 100644
--- a/app/test/test_memory.c
+++ b/app/test/test_memory.c
@@ -86,8 +86,4 @@ test_memory(void)
 	return 0;
 }
 
-static struct test_command memory_cmd = {
-	.command = "memory_autotest",
-	.callback = test_memory,
-};
-REGISTER_TEST_COMMAND(memory_cmd);
+REGISTER_TEST_COMMAND(memory_autotest, test_memory);
diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c
index 9ea9831..46ad670 100644
--- a/app/test/test_mempool.c
+++ b/app/test/test_mempool.c
@@ -609,8 +609,4 @@ err:
 	return -1;
 }
 
-static struct test_command mempool_cmd = {
-	.command = "mempool_autotest",
-	.callback = test_mempool,
-};
-REGISTER_TEST_COMMAND(mempool_cmd);
+REGISTER_TEST_COMMAND(mempool_autotest, test_mempool);
diff --git a/app/test/test_mempool_perf.c b/app/test/test_mempool_perf.c
index 4fac04c..c0b3f5c 100644
--- a/app/test/test_mempool_perf.c
+++ b/app/test/test_mempool_perf.c
@@ -381,8 +381,4 @@ test_mempool_perf(void)
 	return 0;
 }
 
-static struct test_command mempool_perf_cmd = {
-	.command = "mempool_perf_autotest",
-	.callback = test_mempool_perf,
-};
-REGISTER_TEST_COMMAND(mempool_perf_cmd);
+REGISTER_TEST_COMMAND(mempool_perf_autotest, test_mempool_perf);
diff --git a/app/test/test_memzone.c b/app/test/test_memzone.c
index cadd86f..7ae31cf 100644
--- a/app/test/test_memzone.c
+++ b/app/test/test_memzone.c
@@ -872,8 +872,4 @@ test_memzone(void)
 	return 0;
 }
 
-static struct test_command memzone_cmd = {
-	.command = "memzone_autotest",
-	.callback = test_memzone,
-};
-REGISTER_TEST_COMMAND(memzone_cmd);
+REGISTER_TEST_COMMAND(memzone_autotest, test_memzone);
diff --git a/app/test/test_meter.c b/app/test/test_meter.c
index bc76391..26b0565 100644
--- a/app/test/test_meter.c
+++ b/app/test/test_meter.c
@@ -494,8 +494,4 @@ test_meter(void)
 
 }
 
-static struct test_command meter_cmd = {
-	.command = "meter_autotest",
-	.callback = test_meter,
-};
-REGISTER_TEST_COMMAND(meter_cmd);
+REGISTER_TEST_COMMAND(meter_autotest, test_meter);
diff --git a/app/test/test_mp_secondary.c b/app/test/test_mp_secondary.c
index f66b68f..26c4afd 100644
--- a/app/test/test_mp_secondary.c
+++ b/app/test/test_mp_secondary.c
@@ -282,8 +282,4 @@ test_mp_secondary(void)
 	return run_object_creation_tests();
 }
 
-static struct test_command multiprocess_cmd = {
-	.command = "multiprocess_autotest",
-	.callback = test_mp_secondary,
-};
-REGISTER_TEST_COMMAND(multiprocess_cmd);
+REGISTER_TEST_COMMAND(multiprocess_autotest, test_mp_secondary);
diff --git a/app/test/test_pci.c b/app/test/test_pci.c
index 354a0ad..69f78d9 100644
--- a/app/test/test_pci.c
+++ b/app/test/test_pci.c
@@ -315,8 +315,4 @@ test_pci(void)
 	return 0;
 }
 
-static struct test_command pci_cmd = {
-	.command = "pci_autotest",
-	.callback = test_pci,
-};
-REGISTER_TEST_COMMAND(pci_cmd);
+REGISTER_TEST_COMMAND(pci_autotest, test_pci);
diff --git a/app/test/test_per_lcore.c b/app/test/test_per_lcore.c
index f452cdb..747513d 100644
--- a/app/test/test_per_lcore.c
+++ b/app/test/test_per_lcore.c
@@ -136,8 +136,4 @@ test_per_lcore(void)
 	return 0;
 }
 
-static struct test_command per_lcore_cmd = {
-	.command = "per_lcore_autotest",
-	.callback = test_per_lcore,
-};
-REGISTER_TEST_COMMAND(per_lcore_cmd);
+REGISTER_TEST_COMMAND(per_lcore_autotest, test_per_lcore);
diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c
index 3d56cd2..e055aa0 100644
--- a/app/test/test_pmd_perf.c
+++ b/app/test/test_pmd_perf.c
@@ -910,8 +910,4 @@ test_set_rxtx_sc(cmdline_fixed_string_t type)
 	return -1;
 }
 
-static struct test_command pmd_perf_cmd = {
-	.command = "pmd_perf_autotest",
-	.callback = test_pmd_perf,
-};
-REGISTER_TEST_COMMAND(pmd_perf_cmd);
+REGISTER_TEST_COMMAND(pmd_perf_autotest, test_pmd_perf);
diff --git a/app/test/test_pmd_ring.c b/app/test/test_pmd_ring.c
index 34fea09..47374db 100644
--- a/app/test/test_pmd_ring.c
+++ b/app/test/test_pmd_ring.c
@@ -526,8 +526,4 @@ test_pmd_ring(void)
 	return 0;
 }
 
-static struct test_command ring_pmd_cmd = {
-	.command = "ring_pmd_autotest",
-	.callback = test_pmd_ring,
-};
-REGISTER_TEST_COMMAND(ring_pmd_cmd);
+REGISTER_TEST_COMMAND(ring_pmd_autotest, test_pmd_ring);
diff --git a/app/test/test_pmd_ring_perf.c b/app/test/test_pmd_ring_perf.c
index 3077dba..af011f7 100644
--- a/app/test/test_pmd_ring_perf.c
+++ b/app/test/test_pmd_ring_perf.c
@@ -181,8 +181,4 @@ test_ring_pmd_perf(void)
 	return 0;
 }
 
-static struct test_command ring_pmd_perf_cmd = {
-	.command = "ring_pmd_perf_autotest",
-	.callback = test_ring_pmd_perf,
-};
-REGISTER_TEST_COMMAND(ring_pmd_perf_cmd);
+REGISTER_TEST_COMMAND(ring_pmd_perf_autotest, test_ring_pmd_perf);
diff --git a/app/test/test_power.c b/app/test/test_power.c
index 64a2305..b2e1344 100644
--- a/app/test/test_power.c
+++ b/app/test/test_power.c
@@ -104,8 +104,4 @@ fail_all:
 	return -1;
 }
 
-static struct test_command power_cmd = {
-	.command = "power_autotest",
-	.callback = test_power,
-};
-REGISTER_TEST_COMMAND(power_cmd);
+REGISTER_TEST_COMMAND(power_autotest, test_power);
diff --git a/app/test/test_power_acpi_cpufreq.c b/app/test/test_power_acpi_cpufreq.c
index 0fb1569..64f5dd5 100644
--- a/app/test/test_power_acpi_cpufreq.c
+++ b/app/test/test_power_acpi_cpufreq.c
@@ -537,8 +537,4 @@ fail_all:
 	return -1;
 }
 
-static struct test_command power_acpi_cpufreq_cmd = {
-	.command = "power_acpi_cpufreq_autotest",
-	.callback = test_power_acpi_cpufreq,
-};
-REGISTER_TEST_COMMAND(power_acpi_cpufreq_cmd);
+REGISTER_TEST_COMMAND(power_acpi_cpufreq_autotest, test_power_acpi_cpufreq);
diff --git a/app/test/test_power_kvm_vm.c b/app/test/test_power_kvm_vm.c
index ff468c1..253a5f8 100644
--- a/app/test/test_power_kvm_vm.c
+++ b/app/test/test_power_kvm_vm.c
@@ -300,8 +300,4 @@ fail_all:
 	return -1;
 }
 
-static struct test_command power_kvm_vm_cmd = {
-	.command = "power_kvm_vm_autotest",
-	.callback = test_power_kvm_vm,
-};
-REGISTER_TEST_COMMAND(power_kvm_vm_cmd);
+REGISTER_TEST_COMMAND(power_kvm_vm_autotest, test_power_kvm_vm);
diff --git a/app/test/test_prefetch.c b/app/test/test_prefetch.c
index f8615e2..80afaaf 100644
--- a/app/test/test_prefetch.c
+++ b/app/test/test_prefetch.c
@@ -58,8 +58,4 @@ test_prefetch(void)
 	return 0;
 }
 
-static struct test_command prefetch_cmd = {
-	.command = "prefetch_autotest",
-	.callback = test_prefetch,
-};
-REGISTER_TEST_COMMAND(prefetch_cmd);
+REGISTER_TEST_COMMAND(prefetch_autotest, test_prefetch);
diff --git a/app/test/test_red.c b/app/test/test_red.c
index 7d1c32c..348075d 100644
--- a/app/test/test_red.c
+++ b/app/test/test_red.c
@@ -1880,20 +1880,6 @@ test_red_all(void)
 	return tell_the_result(num_tests, num_pass);
 }
 
-static struct test_command red_cmd = {
-	.command = "red_autotest",
-	.callback = test_red,
-};
-REGISTER_TEST_COMMAND(red_cmd);
-
-static struct test_command red_cmd_perf = {
-	.command = "red_perf",
-	.callback = test_red_perf,
-};
-REGISTER_TEST_COMMAND(red_cmd_perf);
-
-static struct test_command red_cmd_all = {
-	.command = "red_all",
-	.callback = test_red_all,
-};
-REGISTER_TEST_COMMAND(red_cmd_all);
+REGISTER_TEST_COMMAND(red_autotest, test_red);
+REGISTER_TEST_COMMAND(red_perf, test_red_perf);
+REGISTER_TEST_COMMAND(red_all, test_red_all);
diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c
index 67f3151..e8a0a2f 100644
--- a/app/test/test_reorder.c
+++ b/app/test/test_reorder.c
@@ -383,8 +383,4 @@ test_reorder(void)
 	return unit_test_suite_runner(&reorder_test_suite);
 }
 
-static struct test_command reorder_cmd = {
-	.command = "reorder_autotest",
-	.callback = test_reorder,
-};
-REGISTER_TEST_COMMAND(reorder_cmd);
+REGISTER_TEST_COMMAND(reorder_autotest, test_reorder);
diff --git a/app/test/test_resource.c b/app/test/test_resource.c
index 39a6468..a3a82f1 100644
--- a/app/test/test_resource.c
+++ b/app/test/test_resource.c
@@ -130,8 +130,4 @@ static int test_resource(void)
 	return 0;
 }
 
-static struct test_command resource_cmd = {
-	.command = "resource_autotest",
-	.callback = test_resource,
-};
-REGISTER_TEST_COMMAND(resource_cmd);
+REGISTER_TEST_COMMAND(resource_autotest, test_resource);
diff --git a/app/test/test_ring.c b/app/test/test_ring.c
index 9095e59..ebcb896 100644
--- a/app/test/test_ring.c
+++ b/app/test/test_ring.c
@@ -1378,8 +1378,4 @@ test_ring(void)
 	return 0;
 }
 
-static struct test_command ring_cmd = {
-	.command = "ring_autotest",
-	.callback = test_ring,
-};
-REGISTER_TEST_COMMAND(ring_cmd);
+REGISTER_TEST_COMMAND(ring_autotest, test_ring);
diff --git a/app/test/test_ring_perf.c b/app/test/test_ring_perf.c
index 8c47ccb..320c20c 100644
--- a/app/test/test_ring_perf.c
+++ b/app/test/test_ring_perf.c
@@ -414,8 +414,4 @@ test_ring_perf(void)
 	return 0;
 }
 
-static struct test_command ring_perf_cmd = {
-	.command = "ring_perf_autotest",
-	.callback = test_ring_perf,
-};
-REGISTER_TEST_COMMAND(ring_perf_cmd);
+REGISTER_TEST_COMMAND(ring_perf_autotest, test_ring_perf);
diff --git a/app/test/test_rwlock.c b/app/test/test_rwlock.c
index b383bba..50f58ad 100644
--- a/app/test/test_rwlock.c
+++ b/app/test/test_rwlock.c
@@ -129,8 +129,4 @@ test_rwlock(void)
 	return 0;
 }
 
-static struct test_command rwlock_cmd = {
-	.command = "rwlock_autotest",
-	.callback = test_rwlock,
-};
-REGISTER_TEST_COMMAND(rwlock_cmd);
+REGISTER_TEST_COMMAND(rwlock_autotest, test_rwlock);
diff --git a/app/test/test_sched.c b/app/test/test_sched.c
index 9712f9f..63ab084 100644
--- a/app/test/test_sched.c
+++ b/app/test/test_sched.c
@@ -213,8 +213,4 @@ test_sched(void)
 	return 0;
 }
 
-static struct test_command sched_cmd = {
-	.command = "sched_autotest",
-	.callback = test_sched,
-};
-REGISTER_TEST_COMMAND(sched_cmd);
+REGISTER_TEST_COMMAND(sched_autotest, test_sched);
diff --git a/app/test/test_spinlock.c b/app/test/test_spinlock.c
index 180d6de..2d94eec 100644
--- a/app/test/test_spinlock.c
+++ b/app/test/test_spinlock.c
@@ -333,8 +333,4 @@ test_spinlock(void)
 	return ret;
 }
 
-static struct test_command spinlock_cmd = {
-	.command = "spinlock_autotest",
-	.callback = test_spinlock,
-};
-REGISTER_TEST_COMMAND(spinlock_cmd);
+REGISTER_TEST_COMMAND(spinlock_autotest, test_spinlock);
diff --git a/app/test/test_string_fns.c b/app/test/test_string_fns.c
index 39e6a9d..8b4359a 100644
--- a/app/test/test_string_fns.c
+++ b/app/test/test_string_fns.c
@@ -166,8 +166,4 @@ test_string_fns(void)
 	return 0;
 }
 
-static struct test_command string_cmd = {
-	.command = "string_autotest",
-	.callback = test_string_fns,
-};
-REGISTER_TEST_COMMAND(string_cmd);
+REGISTER_TEST_COMMAND(string_autotest, test_string_fns);
diff --git a/app/test/test_table.c b/app/test/test_table.c
index 676dab2..1faa0a6 100644
--- a/app/test/test_table.c
+++ b/app/test/test_table.c
@@ -199,8 +199,4 @@ test_table(void)
 	return 0;
 }
 
-static struct test_command table_cmd = {
-	.command = "table_autotest",
-	.callback = test_table,
-};
-REGISTER_TEST_COMMAND(table_cmd);
+REGISTER_TEST_COMMAND(table_autotest, test_table);
diff --git a/app/test/test_tailq.c b/app/test/test_tailq.c
index c046a8a..33a3e8a 100644
--- a/app/test/test_tailq.c
+++ b/app/test/test_tailq.c
@@ -154,8 +154,4 @@ test_tailq(void)
 	return ret;
 }
 
-static struct test_command tailq_cmd = {
-	.command = "tailq_autotest",
-	.callback = test_tailq,
-};
-REGISTER_TEST_COMMAND(tailq_cmd);
+REGISTER_TEST_COMMAND(tailq_autotest, test_tailq);
diff --git a/app/test/test_thash.c b/app/test/test_thash.c
index 8e9dca0..61754a9 100644
--- a/app/test/test_thash.c
+++ b/app/test/test_thash.c
@@ -169,8 +169,4 @@ test_thash(void)
 	return 0;
 }
 
-static struct test_command thash_cmd = {
-	.command = "thash_autotest",
-	.callback = test_thash,
-};
-REGISTER_TEST_COMMAND(thash_cmd);
+REGISTER_TEST_COMMAND(thash_autotest, test_thash);
diff --git a/app/test/test_timer.c b/app/test/test_timer.c
index bc07925..2f6525a 100644
--- a/app/test/test_timer.c
+++ b/app/test/test_timer.c
@@ -626,8 +626,4 @@ test_timer(void)
 	return TEST_SUCCESS;
 }
 
-static struct test_command timer_cmd = {
-	.command = "timer_autotest",
-	.callback = test_timer,
-};
-REGISTER_TEST_COMMAND(timer_cmd);
+REGISTER_TEST_COMMAND(timer_autotest, test_timer);
diff --git a/app/test/test_timer_perf.c b/app/test/test_timer_perf.c
index 3f7ddd3..fa77efb 100644
--- a/app/test/test_timer_perf.c
+++ b/app/test/test_timer_perf.c
@@ -158,8 +158,4 @@ test_timer_perf(void)
 	return 0;
 }
 
-static struct test_command timer_perf_cmd = {
-	.command = "timer_perf_autotest",
-	.callback = test_timer_perf,
-};
-REGISTER_TEST_COMMAND(timer_perf_cmd);
+REGISTER_TEST_COMMAND(timer_perf_autotest, test_timer_perf);
diff --git a/app/test/test_timer_racecond.c b/app/test/test_timer_racecond.c
index aef3203..7824ec4 100644
--- a/app/test/test_timer_racecond.c
+++ b/app/test/test_timer_racecond.c
@@ -202,8 +202,4 @@ test_timer_racecond(void)
 	return TEST_SUCCESS;
 }
 
-static struct test_command timer_racecond_cmd = {
-	.command = "timer_racecond_autotest",
-	.callback = test_timer_racecond,
-};
-REGISTER_TEST_COMMAND(timer_racecond_cmd);
+REGISTER_TEST_COMMAND(timer_racecond_autotest, test_timer_racecond);
diff --git a/app/test/test_version.c b/app/test/test_version.c
index f66827d..afc0d0b 100644
--- a/app/test/test_version.c
+++ b/app/test/test_version.c
@@ -54,8 +54,4 @@ test_version(void)
 	return 0;
 }
 
-static struct test_command version_cmd = {
-	.command = "version_autotest",
-	.callback = test_version,
-};
-REGISTER_TEST_COMMAND(version_cmd);
+REGISTER_TEST_COMMAND(version_autotest, test_version);
-- 
2.7.0

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

* [dpdk-dev] [PATCH 2/2] app/test: filter out unavailable tests
  2016-07-13 21:24 [dpdk-dev] [PATCH 1/2] app/test: rework command registration Thomas Monjalon
@ 2016-07-13 21:24 ` Thomas Monjalon
  2016-07-15 14:23   ` David Marchand
  2016-07-14 17:25 ` [dpdk-dev] [dpdk-dev, 1/2] app/test: rework command registration viktorin
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Monjalon @ 2016-07-13 21:24 UTC (permalink / raw)
  To: dev

Some tests can fail to run because they are not compiled.
It has been more visible recently when the PCI test became disabled
in the default configuration because of dependency on libarchive:
    PCI autotest:    Fail [Not found]

The autotest script catch them and do not count them as an error anymore:
    PCI autotest:    Skipped [Not Available]

The commands dump_ring and dump_mempool are removed from the autotest list
because they are some internal commands but not some registered tests.
Thus they cannot be parsed as available test commands.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
 app/test/autotest_data.py   | 12 ------------
 app/test/autotest_runner.py | 12 ++++++++++--
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/app/test/autotest_data.py b/app/test/autotest_data.py
index 1e6b422..c69705e 100644
--- a/app/test/autotest_data.py
+++ b/app/test/autotest_data.py
@@ -99,18 +99,6 @@ parallel_test_group_list = [
 		 "Func" :	default_autotest,
 		 "Report" :	None,
 		},
-		{
-		 "Name" :	"Dump rings",
-		 "Command" :	"dump_ring",
-		 "Func" :	dump_autotest,
-		 "Report" :	None,
-		},
-		{
-		 "Name" :	"Dump mempools",
-		 "Command" :	"dump_mempool",
-		 "Func" :	dump_autotest,
-		 "Report" :	None,
-		},
 	]
 },
 {
diff --git a/app/test/autotest_runner.py b/app/test/autotest_runner.py
index 291a821..bd99e19 100644
--- a/app/test/autotest_runner.py
+++ b/app/test/autotest_runner.py
@@ -33,7 +33,7 @@
 
 # The main logic behind running autotests in parallel
 
-import multiprocessing, sys, pexpect, time, os, StringIO, csv
+import multiprocessing, subprocess, sys, pexpect, re, time, os, StringIO, csv
 
 # wait for prompt
 def wait_prompt(child):
@@ -105,6 +105,11 @@ def run_test_group(cmdline, test_group):
 	results.append((0, "Success", "Start %s" % test_group["Prefix"],
 		time.time() - start_time, startuplog.getvalue(), None))
 
+	# parse the binary for available test commands
+	binary = cmdline.split()[0]
+	symbols = subprocess.check_output(['nm', binary]).decode('utf-8')
+	avail_cmds = re.findall('test_register_(\w+)', symbols)
+
 	# run all tests in test group
 	for test in test_group["Tests"]:
 
@@ -124,7 +129,10 @@ def run_test_group(cmdline, test_group):
 			print >>logfile, "\n%s %s\n" % ("-"*20, test["Name"])
 
 			# run test function associated with the test
-			result = test["Func"](child, test["Command"])
+			if test["Command"] in avail_cmds:
+				result = test["Func"](child, test["Command"])
+			else:
+				result = (0, "Skipped [Not Available]")
 
 			# make a note when the test was finished
 			end_time = time.time()
-- 
2.7.0

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

* Re: [dpdk-dev] [dpdk-dev, 1/2] app/test: rework command registration
  2016-07-13 21:24 [dpdk-dev] [PATCH 1/2] app/test: rework command registration Thomas Monjalon
  2016-07-13 21:24 ` [dpdk-dev] [PATCH 2/2] app/test: filter out unavailable tests Thomas Monjalon
@ 2016-07-14 17:25 ` viktorin
  1 sibling, 0 replies; 6+ messages in thread
From: viktorin @ 2016-07-14 17:25 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Wed, 13 Jul 2016 23:24:09 +0200
Thomas Monjalon <thomas.monjalon@6wind.com> wrote:

> The tests are registered with their command name by adding a structure
> to a list. The structure of each test was declared in each test file
> and passed to the register macro.
> This rework generate the structure inside the register macro.

There is just this little issue:

WARNING:LONG_LINE: line over 80 characters
#335: FILE: app/test/test_cryptodev_perf.c:2924:
+REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_perftest, perftest_sw_snow3g_cryptodev);

WARNING:LONG_LINE: line over 80 characters
#336: FILE: app/test/test_cryptodev_perf.c:2925:
+REGISTER_TEST_COMMAND(cryptodev_qat_snow3g_perftest, perftest_qat_snow3g_cryptodev);

total: 0 errors, 2 warnings, 758 lines checked

Otherwise
Reviewed-by: Jan Viktorin <viktorin@rehivetech.com>

> 
> Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
> 
> ---
> app/test/test.h                      | 17 +++++++++------
>  app/test/test_acl.c                  |  6 +-----
>  app/test/test_alarm.c                |  6 +-----
>  app/test/test_atomic.c               |  6 +-----
>  app/test/test_byteorder.c            |  6 +-----
>  app/test/test_cmdline.c              |  6 +-----
>  app/test/test_common.c               |  6 +-----
>  app/test/test_cpuflags.c             |  6 +-----
>  app/test/test_cryptodev.c            | 41 ++++++------------------------------
>  app/test/test_cryptodev_perf.c       | 28 ++++--------------------
>  app/test/test_cycles.c               |  6 +-----
>  app/test/test_debug.c                |  6 +-----
>  app/test/test_devargs.c              |  6 +-----
>  app/test/test_distributor.c          |  6 +-----
>  app/test/test_distributor_perf.c     |  6 +-----
>  app/test/test_eal_flags.c            |  6 +-----
>  app/test/test_eal_fs.c               |  6 +-----
>  app/test/test_errno.c                |  6 +-----
>  app/test/test_func_reentrancy.c      |  6 +-----
>  app/test/test_hash.c                 |  6 +-----
>  app/test/test_hash_functions.c       |  6 +-----
>  app/test/test_hash_multiwriter.c     |  8 +------
>  app/test/test_hash_perf.c            |  6 +-----
>  app/test/test_hash_scaling.c         |  7 +-----
>  app/test/test_interrupts.c           |  6 +-----
>  app/test/test_ivshmem.c              |  6 +-----
>  app/test/test_kni.c                  |  6 +-----
>  app/test/test_kvargs.c               |  6 +-----
>  app/test/test_link_bonding.c         |  6 +-----
>  app/test/test_link_bonding_mode4.c   |  7 +-----
>  app/test/test_link_bonding_rssconf.c |  7 +-----
>  app/test/test_logs.c                 |  6 +-----
>  app/test/test_lpm.c                  |  6 +-----
>  app/test/test_lpm6.c                 |  6 +-----
>  app/test/test_lpm6_perf.c            |  6 +-----
>  app/test/test_lpm_perf.c             |  6 +-----
>  app/test/test_malloc.c               |  6 +-----
>  app/test/test_mbuf.c                 |  6 +-----
>  app/test/test_memcpy.c               |  6 +-----
>  app/test/test_memcpy_perf.c          |  6 +-----
>  app/test/test_memory.c               |  6 +-----
>  app/test/test_mempool.c              |  6 +-----
>  app/test/test_mempool_perf.c         |  6 +-----
>  app/test/test_memzone.c              |  6 +-----
>  app/test/test_meter.c                |  6 +-----
>  app/test/test_mp_secondary.c         |  6 +-----
>  app/test/test_pci.c                  |  6 +-----
>  app/test/test_per_lcore.c            |  6 +-----
>  app/test/test_pmd_perf.c             |  6 +-----
>  app/test/test_pmd_ring.c             |  6 +-----
>  app/test/test_pmd_ring_perf.c        |  6 +-----
>  app/test/test_power.c                |  6 +-----
>  app/test/test_power_acpi_cpufreq.c   |  6 +-----
>  app/test/test_power_kvm_vm.c         |  6 +-----
>  app/test/test_prefetch.c             |  6 +-----
>  app/test/test_red.c                  | 20 +++---------------
>  app/test/test_reorder.c              |  6 +-----
>  app/test/test_resource.c             |  6 +-----
>  app/test/test_ring.c                 |  6 +-----
>  app/test/test_ring_perf.c            |  6 +-----
>  app/test/test_rwlock.c               |  6 +-----
>  app/test/test_sched.c                |  6 +-----
>  app/test/test_spinlock.c             |  6 +-----
>  app/test/test_string_fns.c           |  6 +-----
>  app/test/test_table.c                |  6 +-----
>  app/test/test_tailq.c                |  6 +-----
>  app/test/test_thash.c                |  6 +-----
>  app/test/test_timer.c                |  6 +-----
>  app/test/test_timer_perf.c           |  6 +-----
>  app/test/test_timer_racecond.c       |  6 +-----
>  app/test/test_version.c              |  6 +-----
>  71 files changed, 91 insertions(+), 422 deletions(-)
> 

[...]

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

* Re: [dpdk-dev] [PATCH 2/2] app/test: filter out unavailable tests
  2016-07-13 21:24 ` [dpdk-dev] [PATCH 2/2] app/test: filter out unavailable tests Thomas Monjalon
@ 2016-07-15 14:23   ` David Marchand
  2016-07-15 14:30     ` Thomas Monjalon
  2016-07-15 15:25     ` Thomas Monjalon
  0 siblings, 2 replies; 6+ messages in thread
From: David Marchand @ 2016-07-15 14:23 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Wed, Jul 13, 2016 at 11:24 PM, Thomas Monjalon
<thomas.monjalon@6wind.com> wrote:
> Some tests can fail to run because they are not compiled.
> It has been more visible recently when the PCI test became disabled
> in the default configuration because of dependency on libarchive:
>     PCI autotest:    Fail [Not found]
>
> The autotest script catch them and do not count them as an error anymore:
>     PCI autotest:    Skipped [Not Available]
>
> The commands dump_ring and dump_mempool are removed from the autotest list
> because they are some internal commands but not some registered tests.
> Thus they cannot be parsed as available test commands.
>
> Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>

Suggested-by: David Marchand <david.marchand@6wind.com>

and I trust you for the python ;-)

-- 
David Marchand

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

* Re: [dpdk-dev] [PATCH 2/2] app/test: filter out unavailable tests
  2016-07-15 14:23   ` David Marchand
@ 2016-07-15 14:30     ` Thomas Monjalon
  2016-07-15 15:25     ` Thomas Monjalon
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2016-07-15 14:30 UTC (permalink / raw)
  To: David Marchand; +Cc: dev

2016-07-15 16:23, David Marchand:
> On Wed, Jul 13, 2016 at 11:24 PM, Thomas Monjalon
> <thomas.monjalon@6wind.com> wrote:
> > Some tests can fail to run because they are not compiled.
> > It has been more visible recently when the PCI test became disabled
> > in the default configuration because of dependency on libarchive:
> >     PCI autotest:    Fail [Not found]
> >
> > The autotest script catch them and do not count them as an error anymore:
> >     PCI autotest:    Skipped [Not Available]
> >
> > The commands dump_ring and dump_mempool are removed from the autotest list
> > because they are some internal commands but not some registered tests.
> > Thus they cannot be parsed as available test commands.
> >
> > Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
> 
> Suggested-by: David Marchand <david.marchand@6wind.com>

Thanks for giving me the idea of the nm trick.

> and I trust you for the python ;-)

You should not ;)

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

* Re: [dpdk-dev] [PATCH 2/2] app/test: filter out unavailable tests
  2016-07-15 14:23   ` David Marchand
  2016-07-15 14:30     ` Thomas Monjalon
@ 2016-07-15 15:25     ` Thomas Monjalon
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2016-07-15 15:25 UTC (permalink / raw)
  To: David Marchand; +Cc: dev

> > Some tests can fail to run because they are not compiled.
> > It has been more visible recently when the PCI test became disabled
> > in the default configuration because of dependency on libarchive:
> >     PCI autotest:    Fail [Not found]
> >
> > The autotest script catch them and do not count them as an error anymore:
> >     PCI autotest:    Skipped [Not Available]
> >
> > The commands dump_ring and dump_mempool are removed from the autotest list
> > because they are some internal commands but not some registered tests.
> > Thus they cannot be parsed as available test commands.
> >
> > Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
> 
> Suggested-by: David Marchand <david.marchand@6wind.com>

Series applied

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

end of thread, other threads:[~2016-07-15 15:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-13 21:24 [dpdk-dev] [PATCH 1/2] app/test: rework command registration Thomas Monjalon
2016-07-13 21:24 ` [dpdk-dev] [PATCH 2/2] app/test: filter out unavailable tests Thomas Monjalon
2016-07-15 14:23   ` David Marchand
2016-07-15 14:30     ` Thomas Monjalon
2016-07-15 15:25     ` Thomas Monjalon
2016-07-14 17:25 ` [dpdk-dev] [dpdk-dev, 1/2] app/test: rework command registration viktorin

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