[v4,1/7] app/test: introduce UT suite framework for kvargs

Message ID 20241030085450.56864-2-fengchengwen@huawei.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series refactor kvargs test |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chengwen Feng Oct. 30, 2024, 8:54 a.m. UTC
Introduce unit test suite framework for test_kvargs.c.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_kvargs.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
  

Patch

diff --git a/app/test/test_kvargs.c b/app/test/test_kvargs.c
index 7a60cac4c1..1c46fbcaab 100644
--- a/app/test/test_kvargs.c
+++ b/app/test/test_kvargs.c
@@ -280,16 +280,21 @@  static int test_invalid_kvargs(void)
 	return -1;
 }
 
+static struct unit_test_suite kvargs_test_suite  = {
+	.suite_name = "Kvargs Unit Test Suite",
+	.setup = NULL,
+	.teardown = NULL,
+	.unit_test_cases = {
+		TEST_CASE(test_valid_kvargs),
+		TEST_CASE(test_invalid_kvargs),
+		TEST_CASES_END() /**< NULL terminate unit test array */
+	}
+};
+
 static int
 test_kvargs(void)
 {
-	printf("== test valid case ==\n");
-	if (test_valid_kvargs() < 0)
-		return -1;
-	printf("== test invalid case ==\n");
-	if (test_invalid_kvargs() < 0)
-		return -1;
-	return 0;
+	return unit_test_suite_runner(&kvargs_test_suite);
 }
 
 REGISTER_FAST_TEST(kvargs_autotest, true, true, test_kvargs);