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

Message ID 20231103095325.47843-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 Nov. 3, 2023, 9:53 a.m. UTC
  Introduce unit test suite framework for test_kvargs.c.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test/test_kvargs.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
  

Patch

diff --git a/app/test/test_kvargs.c b/app/test/test_kvargs.c
index 7a60cac4c1..9aeb9aa0aa 100644
--- a/app/test/test_kvargs.c
+++ b/app/test/test_kvargs.c
@@ -1,5 +1,6 @@ 
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright 2014 6WIND S.A.
+ * Copyright(c) 2023 HiSilicon Limited
  */
 
 #include <stdlib.h>
@@ -280,16 +281,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);