From: Remy Horton <remy.horton@intel.com>
To: Hari kumar Vemula <hari.kumarx.vemula@intel.com>
Cc: reshma.pattan@intel.com, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] test: add unit tests for metrics library
Date: Thu, 5 Jul 2018 15:05:43 +0100 [thread overview]
Message-ID: <92bd80fd-e1cc-4928-72e8-015dd218517d@intel.com> (raw)
In-Reply-To: <1530776231-17707-1-git-send-email-hari.kumarx.vemula@intel.com>
'noon,
See inline comments.
On 05/07/2018 08:37, Hari kumar Vemula wrote:
> Unit Testcases are added for metrics library.
[..]
> +/* Test case to validate registering a list of valid metric names */
> +static int
> +test_metrics_reg_names(void)
> +{
> + int err = 0;
> + const char * const mnames[] = {
> + "mean_bits_in", "mean_bits_out",
> + "peak_bits_in", "peak_bits_out",
> + };
> +
> +
> + /* Success Test: valid array and count size */
> + err = rte_metrics_reg_names(&mnames[0], ARRAY_SIZE(mnames));
> + TEST_ASSERT(err >= 0, "%s, %d", __func__, __LINE__);
> +
> + /* Failure Test: valid array and higher count size than array size*/
> + err = rte_metrics_reg_names(&mnames[0], ARRAY_SIZE(mnames) + 2);
> + TEST_ASSERT(err < 0, "%s, %d", __func__, __LINE__);
rte_metrics_reg_names() relies on cnt_names being truthful about the
size of *names. If it is overstated there is nothing to prevent an array
overrun and in most cases a core-dump.
> +
> + /* Failure Test: valid array and count size lessthan 1*/
> + err = rte_metrics_reg_names(&mnames[0], 0);
> + TEST_ASSERT(err == -EINVAL, "%s, %d", __func__, __LINE__);
> +
> + /* Failure Test: valid array and count exceeds max count */
> + err = rte_metrics_reg_names(&mnames[0], INVALID_COUNT);
> + TEST_ASSERT(err == -ENOMEM, "%s, %d", __func__, __LINE__);
See previous comment.
> +
> + /* Failure Test: Invalid array and valid count size */
> + err = rte_metrics_reg_names(NULL, ARRAY_SIZE(mnames) + 2);
> + TEST_ASSERT(err == -EINVAL, "%s, %d", __func__, __LINE__);
> +
> + /* Failure Test: Valid array and Invalid count size */
> + err = rte_metrics_reg_names(&mnames[0], INVAL_METRIC_COUNT);
> + TEST_ASSERT(err < 0, "%s, %d", __func__, __LINE__);
Ditto.
> +
> + return TEST_SUCCESS;
> +}
> +
[..]
> +/* Test case to validate update a list of metrics */
> +static int
> +test_metrics_update_values(void)
> +{
> + int err = 0;
> + const uint64_t value[REG_METRIC_COUNT] = {1, 2, 3, 4, 5, 6};
> +
> + /* Success Test: valid data */
> + err = rte_metrics_update_values(RTE_METRICS_GLOBAL,
> + KEY, &value[0], ARRAY_SIZE(value));
> + TEST_ASSERT(err >= 0, "%s, %d", __func__, __LINE__);
Updates cannot overlap more than one metric set. A successful test would be:
/* Success Test: valid data */
err = rte_metrics_update_values(RTE_METRICS_GLOBAL, 0,
&value[0], 1);
TEST_ASSERT(err >= 0, "%s, %d", __func__, __LINE__);
err = rte_metrics_update_values(RTE_METRICS_GLOBAL, 1,
&value[1], 1);
TEST_ASSERT(err >= 0, "%s, %d", __func__, __LINE__);
err = rte_metrics_update_values(RTE_METRICS_GLOBAL, 2,
&value[2], 4);
TEST_ASSERT(err >= 0, "%s, %d", __func__, __LINE__);
I am wondering whether this constraint should be removed.
> + /* Failed Test: Invalid count size */
> + err = rte_metrics_update_values(RTE_METRICS_GLOBAL,
> + KEY, &value[0], 0);
> + TEST_ASSERT(err < 0, "%s, %d", __func__, __LINE__);
Good catch. Will update library code.
> +
> + /* Success Test: valid data with lower count stats size */
> + err = rte_metrics_update_values(RTE_METRICS_GLOBAL,
> + KEY, &value[0], ARRAY_SIZE(value) - 3);
> + TEST_ASSERT(err >= 0, "%s, %d", __func__, __LINE__);
KEY should be 2, which is where the set of size four starts. The set
starting at KEY (i.e 1) is of size one.
> +
> + /* Failed Test: Invalid port_id(lower value) and valid data */
> + err = rte_metrics_update_values(-2, KEY, &value[0], ARRAY_SIZE(value));
> + TEST_ASSERT(err == -EINVAL, "%s, %d", __func__, __LINE__);
> +
> + /* Failed Test: Invalid port_id(higher value) and valid data */
> + err = rte_metrics_update_values(39, 1, &value[0], ARRAY_SIZE(value));
> + TEST_ASSERT(err == -EINVAL, "%s, %d", __func__, __LINE__);
Testcases Ok.
> +
> + /* Failed Test: higher count size */
> + err = rte_metrics_update_values(RTE_METRICS_GLOBAL,
> + KEY, &value[0], ARRAY_SIZE(value) + 5);
> + TEST_ASSERT(err == -ERANGE, "%s, %d", __func__, __LINE__);
Array sizes should not be overstated.
> +
> + /* Failed Test: Invalid array */
> + err = rte_metrics_update_values(RTE_METRICS_GLOBAL,
> + KEY, NULL, ARRAY_SIZE(value));
> + TEST_ASSERT(err == -EINVAL, "%s, %d", __func__, __LINE__);
> +
> + return TEST_SUCCESS;
> +}
> +
> +/* Test to validate get metric name-key lookup table */
> +static int
> +test_metrics_get_names(void)
> +{
[..]
> +
> + /* Failure Test: Invalid array list, Correct Count Stats same as
> + * memzone stats
> + */
> + err = rte_metrics_get_names(metrics, REG_METRIC_COUNT);
> + TEST_ASSERT(err < 0, "%s, %d", __func__, __LINE__);
Overstated array size.
> +
> + /* Failure Test: Invalid array list, Increased Count Stats */
> + err = rte_metrics_get_names(metrics, REG_METRIC_COUNT+9);
> + TEST_ASSERT(err < 0, "%s, %d", __func__, __LINE__);
Overstated array size.
> +
> + return TEST_SUCCESS;
> +}
> +
> +/* Test to validate get list of metric values */
..Remy
next prev parent reply other threads:[~2018-07-05 14:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-05 7:37 Hari kumar Vemula
2018-07-05 14:05 ` Remy Horton [this message]
2018-07-21 14:26 ` [dpdk-dev] [PATCH v2] " Hari kumar Vemula
2018-07-24 14:53 ` Remy Horton
2018-08-03 14:33 ` [dpdk-dev] [PATCH v3 0/3] add unit test " Hari Kumar Vemula
2018-08-03 14:33 ` [dpdk-dev] [PATCH v3 1/3] test: add unit tests " Hari Kumar Vemula
2018-08-15 9:29 ` Pattan, Reshma
2018-08-03 14:33 ` [dpdk-dev] [PATCH v3 2/3] autotest: add new unit tests to autotest list Hari Kumar Vemula
2018-08-03 14:33 ` [dpdk-dev] [PATCH v3 3/3] maintainers: add metrics test Hari Kumar Vemula
2018-08-24 12:56 ` [dpdk-dev] [PATCH v4] test: add unit tests for metrics library Hari Kumar Vemula
2018-10-08 13:01 ` [dpdk-dev] [PATCH v5] " Hari Kumar Vemula
2018-10-29 3:01 ` Thomas Monjalon
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=92bd80fd-e1cc-4928-72e8-015dd218517d@intel.com \
--to=remy.horton@intel.com \
--cc=dev@dpdk.org \
--cc=hari.kumarx.vemula@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).