[1/7] app/test: introduce UT suite framework for kvargs
Checks
Commit Message
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(-)
Comments
On Fri, 3 Nov 2023 09:53:19 +0000
Chengwen Feng <fengchengwen@huawei.com> wrote:
> 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(-)
>
> 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
> */
The test changes look good and it is always better to have more tests.
IANAL but starting the precedent of allowing adding copyright whenever a file
is touched just leads to lots of meaningless fluff.
On 2024/10/11 10:08, Stephen Hemminger wrote:
> On Fri, 3 Nov 2023 09:53:19 +0000
> Chengwen Feng <fengchengwen@huawei.com> wrote:
>
>> 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(-)
>>
>> 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
>> */
>
> The test changes look good and it is always better to have more tests.
>
> IANAL but starting the precedent of allowing adding copyright whenever a file
> is touched just leads to lots of meaningless fluff.
OK, I sent v2 which remove this line.
@@ -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);