[PATCH v8 09/10] test: use unit test runner for eal flags

Stephen Hemminger
2025-11-28T22:45:17Z

Make the sub tests in eal flags suite into a group
so that they are not individual tests.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
app/test/test_eal_flags.c | 75 ++++++++++++++++++---------------------
1 file changed, 34 insertions(+), 41 deletions(-)

diff --git a/app/test/test_eal_flags.c b/app/test/test_eal_flags.c
index fbdc972240..faace5c866 100644
--- a/app/test/test_eal_flags.c
+++ b/app/test/test_eal_flags.c
@@ -32,13 +32,6 @@ test_invalid_n_flag(void)
return TEST_SKIPPED;
}

-static int
-test_no_hpet_flag(void)
-{
- printf("no_hpet_flag not supported on Windows, skipping test\n");
- return TEST_SKIPPED;
-}
-
static int
test_no_huge_flag(void)
{
@@ -81,13 +74,6 @@ test_memory_flags(void)
return TEST_SKIPPED;
}

-static int
-test_file_prefix(void)
-{
- printf("file_prefix not supported on Windows, skipping test\n");
- return TEST_SKIPPED;
-}
-
static int
test_misc_flags(void)
{
@@ -730,15 +716,13 @@ test_invalid_n_flag(void)
return 0;
}

+#ifdef RTE_EXEC_ENV_LINUX
/*
* Test that the app runs with HPET, and without HPET
*/
static int
test_no_hpet_flag(void)
{
-#ifdef RTE_EXEC_ENV_FREEBSD
- return 0;
-#else
const char *prefix = file_prefix_arg();
if (prefix == NULL)
return -1;
@@ -756,9 +740,9 @@ test_no_hpet_flag(void)
printf("Error - process did not run ok without --no-hpet flag\n");
return -1;
}
-#
return 0;
}
+#endif

/*
* Test that the app runs with --no-huge and doesn't run when --socket-mem are
@@ -826,7 +810,7 @@ test_no_huge_flag(void)
printf("Error - process run ok with --no-huge and --huge-worker-stack=size flags");
return -1;
}
-#endif
+
return 0;
}

@@ -1140,16 +1124,7 @@ test_misc_flags(void)
return -1;
}

-#ifdef RTE_EXEC_ENV_FREEBSD
-
-static int
-test_file_prefix(void)
-{
- printf("file_prefix not supported on FreeBSD, skipping test\n");
- return TEST_SKIPPED;
-}
-
-#else
+#ifdef RTE_EXEC_ENV_LINUX

static int
test_file_prefix(void)
@@ -1611,15 +1586,33 @@ test_memory_flags(void)

#endif /* !RTE_EXEC_ENV_WINDOWS */

-REGISTER_FAST_TEST(eal_flags_c_opt_autotest, false, false, test_missing_c_flag);
-REGISTER_FAST_TEST(eal_flags_main_opt_autotest, false, false, test_main_lcore_flag);
-REGISTER_FAST_TEST(eal_flags_n_opt_autotest, false, false, test_invalid_n_flag);
-REGISTER_FAST_TEST(eal_flags_hpet_autotest, false, false, test_no_hpet_flag);
-REGISTER_FAST_TEST(eal_flags_no_huge_autotest, false, false, test_no_huge_flag);
-REGISTER_FAST_TEST(eal_flags_a_opt_autotest, false, false, test_allow_flag);
-REGISTER_FAST_TEST(eal_flags_b_opt_autotest, false, false, test_invalid_b_flag);
-REGISTER_FAST_TEST(eal_flags_vdev_opt_autotest, false, false, test_invalid_vdev_flag);
-REGISTER_FAST_TEST(eal_flags_r_opt_autotest, false, false, test_invalid_r_flag);
-REGISTER_FAST_TEST(eal_flags_mem_autotest, false, false, test_memory_flags);
-REGISTER_FAST_TEST(eal_flags_file_prefix_autotest, false, false, test_file_prefix);
-REGISTER_FAST_TEST(eal_flags_misc_autotest, false, false, test_misc_flags);
+static struct unit_test_suite eal_flags_test_suite = {
+ .suite_name = "EAL flags unit test suite",
+ .unit_test_cases = {
+ TEST_CASE(test_missing_c_flag),
+ TEST_CASE(test_main_lcore_flag),
+ TEST_CASE(test_invalid_n_flag),
+#ifdef RTE_EXEC_ENV_LINUX
+ TEST_CASE(test_no_hpet_flag),
+#endif
+ TEST_CASE(test_no_huge_flag),
+ TEST_CASE(test_allow_flag),
+ TEST_CASE(test_invalid_b_flag),
+ TEST_CASE(test_invalid_vdev_flag),
+ TEST_CASE(test_invalid_r_flag),
+ TEST_CASE(test_memory_flags),
+#ifdef RTE_EXEC_ENV_LINUX
+ TEST_CASE(test_file_prefix),
+#endif
+ TEST_CASE(test_misc_flags),
+ TEST_CASES_END()
+ }
+};
+
+static int
+test_eal_flags(void)
+{
+ return unit_test_suite_runner(&eal_flags_test_suite);
+}
+
+REGISTER_FAST_TEST(eal_flags_autotest, false, false, test_eal_flags);
--
2.51.0