diff mbox

[PATCHv4,11/11] cunit: pktio use CU_register_suites

Message ID 1417450537-7640-12-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov Dec. 1, 2014, 4:15 p.m. UTC
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 test/validation/odp_pktio.c | 50 ++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 26 deletions(-)

Comments

Anders Roxell Dec. 1, 2014, 11 p.m. UTC | #1
On 2014-12-01 19:15, Maxim Uvarov wrote:
> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
> ---
>  test/validation/odp_pktio.c | 50 ++++++++++++++++++++++-----------------------
>  1 file changed, 24 insertions(+), 26 deletions(-)
> 
> diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c
> index 67dd8d0..cfdf3f8 100644
> --- a/test/validation/odp_pktio.c
> +++ b/test/validation/odp_pktio.c
> @@ -108,14 +108,34 @@ static void test_pktio_promisc(void)
>  	return;
>  }
>  
> +static CU_TestInfo test_mac[] = {
> +	{"mac", test_pktio_mac },
> +	CU_TEST_INFO_NULL,
> +};
> +
> +static CU_TestInfo test_mtu[] = {
> +	{"mtu", test_pktio_mtu },
> +	CU_TEST_INFO_NULL,
> +};
> +
> +static CU_TestInfo test_promisc[] = {
> +	{"promisc", test_pktio_promisc },
> +	CU_TEST_INFO_NULL,
> +};
> +
> +CU_SuiteInfo suites[] = {
> +	{ "MAC" , NULL, NULL, NULL, NULL, test_mac },
> +	{ "MTU" , NULL, NULL, NULL, NULL, test_mtu },
> +	{ "PROMISC" , NULL, NULL, NULL, NULL, test_promisc },
> +	CU_SUITE_INFO_NULL,
> +};

I think you should change the above to this:
and then squash this patch into patch 4/11.

CU_TestInfo test_odp_shm[] = {
	{"mac", test_pktio_mac },
	{"mtu", test_pktio_mtu },
	{"promisc", test_pktio_promisc },
	CU_TEST_INFO_NULL,
};

CU_SuiteInfo odp_testsuites[] = {
	{"Packet I/O", NULL, NULL, NULL, NULL, test_odp_pktio},
	CU_SUITE_INFO_NULL,
};

Cheers,
Anders

[1] http://lists.linaro.org/pipermail/lng-odp/2014-December/005710.html
Anders Roxell Dec. 1, 2014, 11:15 p.m. UTC | #2
On 2 December 2014 at 00:00, Anders Roxell <anders.roxell@linaro.org> wrote:
> On 2014-12-01 19:15, Maxim Uvarov wrote:
>> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
>> ---
>>  test/validation/odp_pktio.c | 50 ++++++++++++++++++++++-----------------------
>>  1 file changed, 24 insertions(+), 26 deletions(-)
>>
>> diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c
>> index 67dd8d0..cfdf3f8 100644
>> --- a/test/validation/odp_pktio.c
>> +++ b/test/validation/odp_pktio.c
>> @@ -108,14 +108,34 @@ static void test_pktio_promisc(void)
>>       return;
>>  }
>>
>> +static CU_TestInfo test_mac[] = {
>> +     {"mac", test_pktio_mac },
>> +     CU_TEST_INFO_NULL,
>> +};
>> +
>> +static CU_TestInfo test_mtu[] = {
>> +     {"mtu", test_pktio_mtu },
>> +     CU_TEST_INFO_NULL,
>> +};
>> +
>> +static CU_TestInfo test_promisc[] = {
>> +     {"promisc", test_pktio_promisc },
>> +     CU_TEST_INFO_NULL,
>> +};
>> +
>> +CU_SuiteInfo suites[] = {
>> +     { "MAC" , NULL, NULL, NULL, NULL, test_mac },
>> +     { "MTU" , NULL, NULL, NULL, NULL, test_mtu },
>> +     { "PROMISC" , NULL, NULL, NULL, NULL, test_promisc },
>> +     CU_SUITE_INFO_NULL,
>> +};
>
> I think you should change the above to this:
> and then squash this patch into patch 4/11.
>
> CU_TestInfo test_odp_shm[] = {

I failed to make this test correct change shm to pktio =)

>         {"mac", test_pktio_mac },
>         {"mtu", test_pktio_mtu },
>         {"promisc", test_pktio_promisc },
>         CU_TEST_INFO_NULL,
> };
>
> CU_SuiteInfo odp_testsuites[] = {
>         {"Packet I/O", NULL, NULL, NULL, NULL, test_odp_pktio},
>         CU_SUITE_INFO_NULL,
> };
>
> Cheers,
> Anders
>
> [1] http://lists.linaro.org/pipermail/lng-odp/2014-December/005710.html
Maxim Uvarov Dec. 2, 2014, 11:56 a.m. UTC | #3
On 12/02/2014 02:15 AM, Anders Roxell wrote:
> On 2 December 2014 at 00:00, Anders Roxell <anders.roxell@linaro.org> wrote:
>> On 2014-12-01 19:15, Maxim Uvarov wrote:
>>> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
>>> ---
>>>   test/validation/odp_pktio.c | 50 ++++++++++++++++++++++-----------------------
>>>   1 file changed, 24 insertions(+), 26 deletions(-)
>>>
>>> diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c
>>> index 67dd8d0..cfdf3f8 100644
>>> --- a/test/validation/odp_pktio.c
>>> +++ b/test/validation/odp_pktio.c
>>> @@ -108,14 +108,34 @@ static void test_pktio_promisc(void)
>>>        return;
>>>   }
>>>
>>> +static CU_TestInfo test_mac[] = {
>>> +     {"mac", test_pktio_mac },
>>> +     CU_TEST_INFO_NULL,
>>> +};
>>> +
>>> +static CU_TestInfo test_mtu[] = {
>>> +     {"mtu", test_pktio_mtu },
>>> +     CU_TEST_INFO_NULL,
>>> +};
>>> +
>>> +static CU_TestInfo test_promisc[] = {
>>> +     {"promisc", test_pktio_promisc },
>>> +     CU_TEST_INFO_NULL,
>>> +};
>>> +
>>> +CU_SuiteInfo suites[] = {
>>> +     { "MAC" , NULL, NULL, NULL, NULL, test_mac },
>>> +     { "MTU" , NULL, NULL, NULL, NULL, test_mtu },
>>> +     { "PROMISC" , NULL, NULL, NULL, NULL, test_promisc },
>>> +     CU_SUITE_INFO_NULL,
>>> +};
>> I think you should change the above to this:
>> and then squash this patch into patch 4/11.
>>
>> CU_TestInfo test_odp_shm[] = {
> I failed to make this test correct change shm to pktio =)
>
>>          {"mac", test_pktio_mac },
>>          {"mtu", test_pktio_mtu },
>>          {"promisc", test_pktio_promisc },
>>          CU_TEST_INFO_NULL,
>> };
>>
>> CU_SuiteInfo odp_testsuites[] = {
>>          {"Packet I/O", NULL, NULL, NULL, NULL, test_odp_pktio},
>>          CU_SUITE_INFO_NULL,
>> };
>>
>> Cheers,
>> Anders

Yes, I did a squash and it's looks logical.

But I still not sure about what we name suites and tests. I did initial 
version which might be does not test all positive and negative cases.
After some time tests can be extended. I think current file should have 
several suites and several tests. Not just one suite and
number of tests.

So we have binary:
tests/validation/odp_<layer>.c
which has features as "suites"
and tests as different tests for that features.

That might be already documented somewhere.

Maxim.

>>
>> [1] http://lists.linaro.org/pipermail/lng-odp/2014-December/005710.html
diff mbox

Patch

diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c
index 67dd8d0..cfdf3f8 100644
--- a/test/validation/odp_pktio.c
+++ b/test/validation/odp_pktio.c
@@ -108,14 +108,34 @@  static void test_pktio_promisc(void)
 	return;
 }
 
+static CU_TestInfo test_mac[] = {
+	{"mac", test_pktio_mac },
+	CU_TEST_INFO_NULL,
+};
+
+static CU_TestInfo test_mtu[] = {
+	{"mtu", test_pktio_mtu },
+	CU_TEST_INFO_NULL,
+};
+
+static CU_TestInfo test_promisc[] = {
+	{"promisc", test_pktio_promisc },
+	CU_TEST_INFO_NULL,
+};
+
+CU_SuiteInfo suites[] = {
+	{ "MAC" , NULL, NULL, NULL, NULL, test_mac },
+	{ "MTU" , NULL, NULL, NULL, NULL, test_mtu },
+	{ "PROMISC" , NULL, NULL, NULL, NULL, test_promisc },
+	CU_SUITE_INFO_NULL,
+};
+
 int main(void)
 {
 	odp_shm_t shm;
 	void *pool_base;
 	odp_buffer_pool_t pool;
 	odp_queue_t out_queue;
-	CU_pSuite ptr_suite;
-	CU_pTest ptest;
 
 	if (odp_init_global(NULL, NULL)) {
 		printf("ODP global init failed.\n");
@@ -180,30 +200,8 @@  int main(void)
 	if (CUE_SUCCESS != CU_initialize_registry())
 		return CU_get_error();
 
-	/* add a suite to the registry */
-	ptr_suite = CU_add_suite(__FILE__, NULL, NULL);
-	if (NULL == ptr_suite) {
-		CU_cleanup_registry();
-		return CU_get_error();
-	}
-
-	ptest = CU_ADD_TEST(ptr_suite, test_pktio_mtu);
-	if (NULL == ptest) {
-		CU_cleanup_registry();
-		return CU_get_error();
-	}
-
-	ptest = CU_ADD_TEST(ptr_suite, test_pktio_promisc);
-	if (NULL == ptest) {
-		CU_cleanup_registry();
-		return CU_get_error();
-	}
-
-	ptest = CU_ADD_TEST(ptr_suite, test_pktio_mac);
-	if (NULL == ptest) {
-		CU_cleanup_registry();
-		return CU_get_error();
-	}
+	/* register suites */
+	CU_register_suites(suites);
 
 	/* Run all tests using the CUnit Basic interface */
 	CU_basic_set_mode(CU_BRM_VERBOSE);