DPDK patches and discussions
 help / color / mirror / Atom feed
From: Olivier Matz <olivier.matz@6wind.com>
To: Lavanya Govindarajan <lavanyax.govindarajan@intel.com>
Cc: dev@dpdk.org, reshma.pattan@intel.com,
	bruce.richardson@intel.com, pallantlax.poornima@intel.com
Subject: Re: [dpdk-dev] [PATCH v4 2/2] app/test: add unit test cases to mbuf
Date: Mon, 26 Aug 2019 11:09:19 +0200	[thread overview]
Message-ID: <20190826090919.xicdbb7p63iwiwgr@platinum> (raw)
In-Reply-To: <1565271260-10295-3-git-send-email-lavanyax.govindarajan@intel.com>

On Thu, Aug 08, 2019 at 02:34:20PM +0100, Lavanya Govindarajan wrote:
> From: Pallantla Poornima <pallantlax.poornima@intel.com@intel.com>
> 
> Added UT for the below four functions in test_mbuf.c
> rte_get_rx_ol_flag_list
> rte_get_tx_ol_flag_list
> rte_get_rx_ol_flag_name
> rte_get_tx_ol_flag_name
> 
> Signed-off-by: Pallantla Poornima <pallantlax.poornima@intel.com@intel.com>

I suggest to change the patch title from
"app/test: add unit test cases to mbuf"
to
"app/test: add unit test for mbuf flag names"

> ---
>  app/test/test_mbuf.c | 260 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 260 insertions(+)
> 
> diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c
> index 28f3216c0..1a943518d 100644
> --- a/app/test/test_mbuf.c
> +++ b/app/test/test_mbuf.c
> @@ -42,6 +42,7 @@
>  #define MBUF_TEST_DATA_LEN3     256
>  #define MBUF_TEST_HDR1_LEN      20
>  #define MBUF_TEST_HDR2_LEN      30
> +#define MBUF_TEST_LEN           250
>  #define MBUF_TEST_ALL_HDRS_LEN  (MBUF_TEST_HDR1_LEN+MBUF_TEST_HDR2_LEN)
>  #define MBUF_TEST_SEG_SIZE      64
>  #define MBUF_TEST_BURST         8
> @@ -1132,6 +1133,245 @@ test_tx_offload(void)
>  	return (v1 == v2) ? 0 : -EINVAL;
>  }
>  
> +
> +static int
> +test_get_rx_ol_flag_list(void)
> +{
> +	int len, ret = 0;
> +	char buf[256] = "";
> +	int buflen = 0;
> +
> +	/* Test case to check with null buffer */
> +	ret = rte_get_rx_ol_flag_list(0, NULL, 0);
> +	if (ret != -1)
> +		GOTO_FAIL("%s expected: -1, received = %d\n", __func__, ret);
> +
> +	/* Test case to check with zero buffer len */
> +	ret = rte_get_rx_ol_flag_list(PKT_RX_L4_CKSUM_MASK, buf, 0);
> +	if (ret != -1)
> +		GOTO_FAIL("%s expected: -1, received = %d\n", __func__, ret);
> +
> +	buflen = strlen(buf);
> +	if (buflen != 0)
> +		GOTO_FAIL("%s buffer should be empty, received = %d\n",
> +				__func__, buflen);
> +
> +	/* Test case to check with reduced buffer len */
> +	len = sizeof(buf) - MBUF_TEST_LEN;
> +	ret = rte_get_rx_ol_flag_list(0, buf, len);

Why using a #define for MBUF_TEST_LEN and not for char buf[256]?
Also, MBUF_TEST_LEN is not a very clear name.

So, I'd prefer to have an hardcoded value:

	len = 5;
	ret = rte_get_rx_ol_flag_list(0, buf, len);


> +	if (ret != -1)
> +		GOTO_FAIL("%s expected: -1, received = %d\n", __func__, ret);
> +
> +	buflen = strlen(buf);
> +	if (buflen != (len - 1))
> +		GOTO_FAIL("%s invalid buffer length retrieved, expected: %d,"
> +				"received = %d\n", __func__,
> +				(len - 1), buflen);
> +
> +	/* Test case to check with zero mask value */
> +	ret = rte_get_rx_ol_flag_list(0, buf, sizeof(buf));
> +	if (ret != 0)
> +		GOTO_FAIL("%s expected: 0, received = %d\n", __func__, ret);
> +
> +	buflen = strlen(buf);
> +	if (buflen == 0)
> +		GOTO_FAIL("%s expected: %s, received length = 0\n", __func__,
> +				"non-zero, buffer should not be empty");
> +
> +	/* Test case to check with valid mask value */
> +	ret = rte_get_rx_ol_flag_list(PKT_RX_SEC_OFFLOAD, buf, sizeof(buf));
> +	if (ret != 0)
> +		GOTO_FAIL("%s expected: 0, received = %d\n", __func__, ret);
> +
> +	buflen = strlen(buf);
> +	if (buflen == 0)
> +		GOTO_FAIL("%s expected: %s, received length = 0\n", __func__,
> +				"non-zero, buffer should not be empty");
> +
> +
> +	return 0;
> +fail:
> +	return -1;
> +}
> +
> +static int
> +test_get_tx_ol_flag_list(void)
> +{

Same comment as rx.

[...]

> +struct flag_name {
> +	uint64_t flag;
> +	const char *name;
> +};
> +
> +static int
> +test_get_rx_ol_flag_name(void)
> +{
> +	uint16_t i;
> +	const char *flag_str = NULL;
> +	const struct flag_name rx_flags[] = {
> +		{ PKT_RX_VLAN, "PKT_RX_VLAN" },
> +		{ PKT_RX_RSS_HASH, "PKT_RX_RSS_HASH" },
> +		{ PKT_RX_FDIR, "PKT_RX_FDIR"},
> +		{ PKT_RX_L4_CKSUM_BAD, "PKT_RX_L4_CKSUM_BAD"},
> +		{ PKT_RX_L4_CKSUM_GOOD, "PKT_RX_L4_CKSUM_GOOD"},
> +		{ PKT_RX_L4_CKSUM_NONE, "PKT_RX_L4_CKSUM_NONE"},
> +		{ PKT_RX_IP_CKSUM_BAD, "PKT_RX_IP_CKSUM_BAD"},
> +		{ PKT_RX_IP_CKSUM_GOOD, "PKT_RX_IP_CKSUM_GOOD"},
> +		{ PKT_RX_IP_CKSUM_NONE, "PKT_RX_IP_CKSUM_NONE"},
> +		{ PKT_RX_EIP_CKSUM_BAD, "PKT_RX_EIP_CKSUM_BAD" },
> +		{ PKT_RX_VLAN_STRIPPED, "PKT_RX_VLAN_STRIPPED" },
> +		{ PKT_RX_IEEE1588_PTP, "PKT_RX_IEEE1588_PTP"},
> +		{ PKT_RX_IEEE1588_TMST, "PKT_RX_IEEE1588_TMST"},
> +		{ PKT_RX_FDIR_ID, "PKT_RX_FDIR_ID"},
> +		{ PKT_RX_FDIR_FLX, "PKT_RX_FDIR_FLX"},
> +		{ PKT_RX_QINQ_STRIPPED, "PKT_RX_QINQ_STRIPPED" },
> +		{ PKT_RX_LRO, "PKT_RX_LRO" },
> +		{ PKT_RX_TIMESTAMP, "PKT_RX_TIMESTAMP"},
> +		{ PKT_RX_SEC_OFFLOAD, "PKT_RX_SEC_OFFLOAD" },
> +		{ PKT_RX_SEC_OFFLOAD_FAILED, "PKT_RX_SEC_OFFLOAD_FAILED" },
> +		{ PKT_RX_OUTER_L4_CKSUM_BAD, "PKT_RX_OUTER_L4_CKSUM_BAD" },
> +		{ PKT_RX_OUTER_L4_CKSUM_GOOD, "PKT_RX_OUTER_L4_CKSUM_GOOD"},
> +		{ PKT_RX_OUTER_L4_CKSUM_INVALID,
> +			"PKT_RX_OUTER_L4_CKSUM_INVALID" },
> +	};

Since flag value and name are the same, why not using a #define
to ensure there is no typo? Something like this:

#define VAL_NAME(flag) { flag, #flag }
	const struct flag_name rx_flags[] = {
		VAL_NAME(PKT_RX_VLAN),
		VAL_NAME(PKT_RX_RSS_HASH),
		...

It makes me think that the same thing could be done in rte_mbuf.c
instead... in this case the test would become overkill.

[...]

> +static int
> +test_get_tx_ol_flag_name(void)
> +{

Same comment as rx.

Thanks,
Olivier

  reply	other threads:[~2019-08-26  9:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-15 12:40 [dpdk-dev] [PATCH] app/test: add unit test cases for mbuf library APIs Lavanya Govindarajan
2019-04-15 12:40 ` Lavanya Govindarajan
2019-05-31 10:45 ` Pattan, Reshma
2019-06-03  8:39 ` Olivier Matz
2019-07-22 13:32   ` Govindarajan, LavanyaX
2019-08-13 10:26     ` Govindarajan, LavanyaX
2019-08-22 11:21       ` Govindarajan, LavanyaX
2019-07-22 13:42 ` [dpdk-dev] [PATCH v2 0/2] add unit test cases for mbuf library Lavanya Govindarajan
2019-07-22 13:42 ` [dpdk-dev] [PATCH v2 1/2] app/test: add unit test cases for mbuf library APIs Lavanya Govindarajan
2019-07-22 13:42 ` [dpdk-dev] [PATCH v2 2/2] app/test: add unit test cases to mbuf Lavanya Govindarajan
2019-07-23 12:14   ` [dpdk-dev] [PATCH v3 0/2] add unit test cases for mbuf library Lavanya Govindarajan
2019-07-23 12:14   ` [dpdk-dev] [PATCH v3 1/2] app/test: add unit test cases for mbuf library APIs Lavanya Govindarajan
2019-08-08 13:34     ` [dpdk-dev] [PATCH v4 0/2] add unit test cases for mbuf library Lavanya Govindarajan
2019-08-08 13:34     ` [dpdk-dev] [PATCH v4 1/2] app/test: add unit test cases for mbuf library APIs Lavanya Govindarajan
2019-08-26  8:47       ` Olivier Matz
2019-08-30 14:13       ` [dpdk-dev] [PATCH v5 0/2] add unit test cases for mbuf library Lavanya Govindarajan
2019-10-24  7:54         ` David Marchand
2019-08-30 14:13       ` [dpdk-dev] [PATCH v5 1/2] app/test: add unit test cases for mbuf library APIs Lavanya Govindarajan
2019-08-30 14:13       ` [dpdk-dev] [PATCH v5 2/2] app/test: add unit test for mbuf flag names Lavanya Govindarajan
2019-08-08 13:34     ` [dpdk-dev] [PATCH v4 2/2] app/test: add unit test cases to mbuf Lavanya Govindarajan
2019-08-26  9:09       ` Olivier Matz [this message]
2019-07-23 12:14   ` [dpdk-dev] [PATCH v3 " Lavanya Govindarajan

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=20190826090919.xicdbb7p63iwiwgr@platinum \
    --to=olivier.matz@6wind.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=lavanyax.govindarajan@intel.com \
    --cc=pallantlax.poornima@intel.com \
    --cc=reshma.pattan@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).