All of lore.kernel.org
 help / color / mirror / Atom feed
From: "De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>
To: "Singh, Jasvinder" <jasvinder.singh@intel.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: "olivier.matz@6wind.com" <olivier.matz@6wind.com>,
	"Doherty, Declan" <declan.doherty@intel.com>
Subject: Re: [PATCH v5 2/2] test/test: add unit test for CRC computation
Date: Tue, 28 Mar 2017 19:23:10 +0000	[thread overview]
Message-ID: <E115CCD9D858EF4F90C690B0DCB4D8974770E043@IRSMSX108.ger.corp.intel.com> (raw)
In-Reply-To: <1490107540-66614-3-git-send-email-jasvinder.singh@intel.com>

Hi Jasvinder,


> -----Original Message-----
> From: Singh, Jasvinder
> Sent: Tuesday, March 21, 2017 2:46 PM
> To: dev@dpdk.org
> Cc: olivier.matz@6wind.com; Doherty, Declan; De Lara Guarch, Pablo
> Subject: [PATCH v5 2/2] test/test: add unit test for CRC computation
> 
> This patch provides a set of tests for verifying the functional
> correctness of 16-bit and 32-bit CRC APIs.
> 
> Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
> ---
>  test/test/Makefile   |   2 +
>  test/test/test_crc.c | 223
> +++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 225 insertions(+)
>  create mode 100644 test/test/test_crc.c
> 

> diff --git a/test/test/test_crc.c b/test/test/test_crc.c
> new file mode 100644
> index 0000000..2eb0bff
> --- /dev/null
> +++ b/test/test/test_crc.c
> @@ -0,0 +1,223 @@


> +
> +#include "test.h"
> +
> +#define CRC_VEC_LEN				32

Unnecessary extra tab.

> +#define CRC32_VEC_LEN1			1512
> +#define CRC32_VEC_LEN2			348
> +#define CRC16_VEC_LEN1			12
> +#define CRC16_VEC_LEN2			2
> +#define LINE_LEN 75

I would align this to the other values above.

...

> +
> +/* 16-bit CRC test vector 1*/

Extra space before "*/".

> +static const uint8_t crc16_vec1[CRC16_VEC_LEN1] = {
> +	0x0D, 0x01, 0x01, 0x23, 0x45, 0x67,
> +	0x89, 0x01, 0x23, 0x45, 0x00, 0x01,
> +};
> +
> +/* 16-bit CRC test vector 2*/

Same here.

> +static const uint8_t crc16_vec2[CRC16_VEC_LEN2] = {
> +	0x03, 0x3f,
> +};
> +/** CRC results */
> +uint32_t crc32_vec_res, crc32_vec1_res, crc32_vec2_res;
> +uint32_t crc16_vec_res, crc16_vec1_res, crc16_vec2_res;
> +
> +static int
> +crc_calc(const uint8_t *vec,
> +	uint32_t vec_len,
> +	enum rte_net_crc_type type)
> +{
> +	/* compute CRC */
> +	uint32_t ret = rte_net_crc_calc(vec, vec_len, type);
> +
> +	/* dump data on console*/

Same here.

> +	rte_hexdump(stdout, NULL, vec, vec_len);

I would use TEST_HEXDUMP, which dumps the stream only if debug is enabled (to avoid too much output).

> +
> +	return  ret;
> +}
> +
> +static void
> +crc_calc_scalar(void)
> +{
> +	uint32_t i;
> +	enum rte_net_crc_type type;
> +	uint8_t *test_data;
> +
> +	/* 32-bit ethernet CRC: scalar result */
> +	type = RTE_NET_CRC32_ETH;
> +	crc32_vec_res = crc_calc(crc_vec,
> +						CRC_VEC_LEN,
> +						type);

Remove unnecessary tabs (more of this in the rest of the file).

> +
> +	/* 32-bit ethernet CRC scalar result*/
> +	test_data = rte_zmalloc(NULL, CRC32_VEC_LEN1, 0);
> +
> +	for (i = 0; i < CRC32_VEC_LEN1; i += 12)
> +	rte_memcpy(&test_data[i], crc32_vec1, 12);

Wrong indentation (more of this in the rest of the file).
Also, why not just one memcpy call, with CRC32_VEC_LEN1.
A comment would be good to explain why.

...

> +static int
> +test_crc(void) {

Looks strange to start the parameters in a new line.
I would say you can start in the same line as the function name.

> +	uint32_t i;
> +	enum rte_net_crc_type type;
> +	uint8_t *test_data;
> +	uint32_t ret;
> +
> +	/* set crc scalar mode */

Probably the references of "crc" in comments should be uppercase "CRC".

> +	rte_net_crc_set_alg(RTE_NET_CRC_SCALAR);
> +	crc_calc_scalar();
> +
> +	/* set crc sse4.2 mode */
> +	rte_net_crc_set_alg(RTE_NET_CRC_SSE42);
> +
> +	/* 32-bit ethernet CRC: Test 1 */
> +	type = RTE_NET_CRC32_ETH;
> +
> +	ret = crc_calc(crc_vec,
> +		CRC_VEC_LEN,
> +		type);
> +	if (ret != crc32_vec_res) {
> +		printf("test_crc(32-bit): test1 failed !\n");

Extra space before "!" (keep consistency with the other printfs).

> +		return -1;
> +	}
> +
> +	/* 32-bit ethernet CRC: Test 2 */
> +	test_data = rte_zmalloc(NULL, CRC32_VEC_LEN1, 0);

Free the memory after the test (also for other calls).

  reply	other threads:[~2017-03-28 19:23 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-24 20:54 [PATCH 0/2] librte_net: add crc computation support Jasvinder Singh
2017-02-24 20:54 ` [PATCH 1/2] librte_net: add crc init and compute APIs Jasvinder Singh
2017-02-28 12:08   ` [PATCH v2 0/2] librte_net: add crc computation support Jasvinder Singh
2017-02-28 12:08     ` [PATCH v2 1/2] librte_net: add crc init and compute APIs Jasvinder Singh
2017-02-28 12:15       ` Jerin Jacob
2017-03-01 18:46       ` Thomas Monjalon
2017-03-02 13:03         ` Singh, Jasvinder
2017-03-06 15:27           ` Thomas Monjalon
2017-03-08 11:08             ` De Lara Guarch, Pablo
2017-03-15 17:35               ` Thomas Monjalon
2017-03-15 19:03                 ` Dumitrescu, Cristian
2017-03-15 20:15                   ` Thomas Monjalon
2017-03-15 21:11                     ` Dumitrescu, Cristian
2017-03-15 19:09                 ` Dumitrescu, Cristian
2017-03-12 21:33       ` [PATCH v3 0/2] librte_net: add crc computation support Jasvinder Singh
2017-03-12 21:33         ` [PATCH v3 1/2] librte_net: add crc compute APIs Jasvinder Singh
2017-03-13  3:06           ` Ananyev, Konstantin
2017-03-13  9:05             ` Singh, Jasvinder
2017-03-20 19:29           ` [PATCH v4 0/2] librte_net: add crc computation support Jasvinder Singh
2017-03-20 19:29             ` [PATCH v4 1/2] librte_net: add crc compute APIs Jasvinder Singh
2017-03-21 14:45               ` [PATCH v5 0/2] librte_net: add crc computation support Jasvinder Singh
2017-03-21 14:45                 ` [PATCH v5 1/2] librte_net: add crc compute APIs Jasvinder Singh
2017-03-28 18:04                   ` De Lara Guarch, Pablo
2017-03-28 18:07                     ` De Lara Guarch, Pablo
2017-03-28 19:21                     ` Singh, Jasvinder
2017-03-29 12:42                   ` [PATCH v6 0/2] librte_net: add crc computation support Jasvinder Singh
2017-03-29 12:42                     ` [PATCH v6 1/2] librte_net: add crc compute APIs Jasvinder Singh
2017-03-29 16:14                       ` De Lara Guarch, Pablo
2017-03-29 17:15                       ` [PATCH v7 0/2] librte_net: add crc computation support Jasvinder Singh
2017-03-29 17:15                         ` [PATCH v7 1/2] librte_net: add crc compute APIs Jasvinder Singh
2017-03-30 11:30                           ` [PATCH v8 0/2] librte_net: add crc computation support Jasvinder Singh
2017-03-30 11:30                             ` [PATCH v8 1/2] librte_net: add crc compute APIs Jasvinder Singh
2017-03-30 11:31                               ` Ananyev, Konstantin
2017-03-30 12:06                                 ` Singh, Jasvinder
2017-03-30 14:40                                 ` Olivier Matz
2017-03-30 15:14                                   ` Singh, Jasvinder
2017-03-30 16:15                               ` [PATCH v9 0/3] librte_net: add crc computation support Jasvinder Singh
2017-03-30 16:15                                 ` [PATCH v9 1/3] librte_net: add crc compute APIs Jasvinder Singh
2017-04-04 20:00                                   ` Thomas Monjalon
2017-04-05 14:58                                   ` [PATCH v10 0/2] librte_net: add crc computation support Jasvinder Singh
2017-04-05 14:58                                     ` [PATCH v10 1/2] librte_net: add crc compute APIs Jasvinder Singh
2017-04-05 17:49                                       ` Thomas Monjalon
2017-04-05 19:22                                         ` Singh, Jasvinder
2017-04-05 20:49                                       ` [PATCH v11 0/2] librte_net: add crc computation support Jasvinder Singh
2017-04-05 20:49                                         ` [PATCH v11 1/2] librte_net: add crc compute APIs Jasvinder Singh
2017-04-05 20:49                                         ` [PATCH v11 2/2] test/test: add unit test for CRC computation Jasvinder Singh
2017-04-05 20:59                                           ` Thomas Monjalon
2017-04-05 21:00                                         ` [PATCH v11 0/2] librte_net: add crc computation support Thomas Monjalon
2017-04-05 14:58                                     ` [PATCH v10 2/2] test/test: add unit test for CRC computation Jasvinder Singh
2017-03-30 16:15                                 ` [PATCH v9 2/3] " Jasvinder Singh
2017-03-30 16:15                                 ` [PATCH v9 3/3] maintainers: add packet crc section and claim maintainership Jasvinder Singh
2017-04-04 19:55                                   ` Thomas Monjalon
2017-04-04 20:02                                 ` [PATCH v9 0/3] librte_net: add crc computation support Thomas Monjalon
2017-04-05  8:34                                   ` Singh, Jasvinder
2017-04-05  9:01                                     ` Thomas Monjalon
2017-04-05  9:37                                       ` Richardson, Bruce
2017-04-05 12:52                                         ` Singh, Jasvinder
2017-03-30 11:30                             ` [PATCH v8 2/2] test/test: add unit test for CRC computation Jasvinder Singh
2017-03-29 17:15                         ` [PATCH v7 " Jasvinder Singh
2017-03-29 12:42                     ` [PATCH v6 " Jasvinder Singh
2017-03-29 16:12                       ` De Lara Guarch, Pablo
2017-03-21 14:45                 ` [PATCH v5 " Jasvinder Singh
2017-03-28 19:23                   ` De Lara Guarch, Pablo [this message]
2017-03-28 19:27                     ` Singh, Jasvinder
2017-03-20 19:29             ` [PATCH v4 2/2] app/test: " Jasvinder Singh
2017-03-21  7:14               ` Peng, Yuan
2017-03-12 21:33         ` [PATCH v3 " Jasvinder Singh
2017-02-28 12:08     ` [PATCH v2 " Jasvinder Singh
2017-02-24 20:54 ` [PATCH " Jasvinder Singh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E115CCD9D858EF4F90C690B0DCB4D8974770E043@IRSMSX108.ger.corp.intel.com \
    --to=pablo.de.lara.guarch@intel.com \
    --cc=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    --cc=jasvinder.singh@intel.com \
    --cc=olivier.matz@6wind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.