From: Naga Suresh Somarowthu <naga.sureshx.somarowthu@intel.com>
To: dev@dpdk.org
Cc: remy.horton@intel.com, reshma.pattan@intel.com,
Naga Suresh Somarowthu <naga.sureshx.somarowthu@intel.com>
Subject: [dpdk-dev] [PATCH v5 3/4] test: add unit tests for latencystats library
Date: Tue, 24 Jul 2018 11:54:30 +0100 [thread overview]
Message-ID: <1532429671-1606-4-git-send-email-naga.sureshx.somarowthu@intel.com> (raw)
In-Reply-To: <1532429671-1606-1-git-send-email-naga.sureshx.somarowthu@intel.com>
Unit Test Cases added for latencystats library.
Signed-off-by: Naga Suresh Somarowthu <naga.sureshx.somarowthu@intel.com>
Reviewed-by: Reshma Pattan <reshma.pattan@intel.com>
---
test/test/Makefile | 1 +
test/test/autotest_data.py | 6 ++
test/test/test_latencystats.c | 216 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 223 insertions(+)
create mode 100644 test/test/test_latencystats.c
diff --git a/test/test/Makefile b/test/test/Makefile
index 8407ae36e..1c08b906a 100644
--- a/test/test/Makefile
+++ b/test/test/Makefile
@@ -167,6 +167,7 @@ SRCS-y += virtual_pmd.c
SRCS-y += packet_burst_generator.c
SRCS-y += sample_packet_forward.c
SRCS-$(CONFIG_RTE_LIBRTE_BITRATE) += test_bitratestats.c
+SRCS-$(CONFIG_RTE_LIBRTE_LATENCY_STATS) += test_latencystats.c
SRCS-$(CONFIG_RTE_LIBRTE_ACL) += test_acl.c
ifeq ($(CONFIG_RTE_LIBRTE_PMD_RING),y)
diff --git a/test/test/autotest_data.py b/test/test/autotest_data.py
index 419520342..3eccc4e1a 100644
--- a/test/test/autotest_data.py
+++ b/test/test/autotest_data.py
@@ -299,6 +299,12 @@ def per_sockets(num):
"Report": None,
},
{
+ "Name": "Latencystats autotest",
+ "Command": "latencystats_autotest",
+ "Func": default_autotest,
+ "Report": None,
+ },
+ {
"Name": "PMD ring autotest",
"Command": "ring_pmd_autotest",
"Func": default_autotest,
diff --git a/test/test/test_latencystats.c b/test/test/test_latencystats.c
new file mode 100644
index 000000000..8fdc0c8b0
--- /dev/null
+++ b/test/test/test_latencystats.c
@@ -0,0 +1,216 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Intel Corporation
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <time.h>
+
+#include <rte_common.h>
+#include <rte_metrics.h>
+#include <rte_latencystats.h>
+#include <rte_eth_ring.h>
+#include <rte_ethdev.h>
+#include <rte_mbuf.h>
+#include "test.h"
+#include "sample_packet_forward.h"
+#define NUM_STATS 4
+#define LATENCY_NUM_PACKETS 10
+#define QUEUE_ID 0
+
+uint16_t portid;
+struct rte_ring *ring[NUM_RINGS];
+
+struct rte_metric_name lat_stats_strings[] = {
+ {"min_latency_ns"},
+ {"avg_latency_ns"},
+ {"max_latency_ns"},
+ {"jitter_ns"},
+};
+
+/* Test case for latency init with metrics init */
+static int test_latency_init(void)
+{
+ int ret = 0;
+
+ /* Metrics Initialization */
+ rte_metrics_init(rte_socket_id());
+
+ ret = rte_latencystats_init(1, NULL);
+ TEST_ASSERT(ret >= 0, "Test Failed: rte_latencystats_init failed");
+
+ return TEST_SUCCESS;
+}
+
+/* Test case to update the latency stats */
+static int test_latency_update(void)
+{
+ int ret = 0;
+
+ ret = rte_latencystats_update();
+ TEST_ASSERT(ret >= 0, "Test Failed: rte_latencystats_update failed");
+
+ return TEST_SUCCESS;
+}
+
+/* Test case to uninit latency stats */
+static int test_latency_uninit(void)
+{
+ int ret = 0;
+
+ ret = rte_latencystats_uninit();
+ TEST_ASSERT(ret >= 0, "Test Failed: rte_latencystats_uninit failed");
+
+ return TEST_SUCCESS;
+}
+
+/* Test case to get names of latency stats */
+static int test_latencystats_get_names(void)
+{
+ int ret = 0;
+ int size = 0;
+ struct rte_metric_name names[NUM_STATS] = { 0 };
+ struct rte_metric_name wrongnames[NUM_STATS - 2] = { 0 };
+
+ /* Success Test: Valid names and size */
+ size = NUM_STATS;
+ ret = rte_latencystats_get_names(names, size);
+ for (int i = 0; i <= NUM_STATS; i++) {
+ if (strcmp(lat_stats_strings[i].name, names[i].name) == 0)
+ printf(" %s\n", names[i].name);
+ else
+ printf("Failed: Names are not matched\n");
+ }
+ TEST_ASSERT((ret == NUM_STATS), "Test Failed to get metrics names");
+
+ /* Failure Test: Invalid names and valid size */
+ ret = rte_latencystats_get_names(NULL, size);
+ TEST_ASSERT((ret == NUM_STATS), "Test Failed to get the metrics count,"
+ "Actual: %d Expected: %d", ret, NUM_STATS);
+
+ /* Failure Test: Valid names and invalid size */
+ size = 0;
+ ret = rte_latencystats_get_names(names, size);
+ TEST_ASSERT((ret == NUM_STATS), "Test Failed to get the metrics count,"
+ "Actual: %d Expected: %d", ret, NUM_STATS);
+
+ /* Failure Test: Invalid names (array size lesser than size) */
+ size = NUM_STATS + 1;
+ ret = rte_latencystats_get_names(wrongnames, size);
+ TEST_ASSERT((ret == NUM_STATS), "Test Failed to get metrics names");
+ return TEST_SUCCESS;
+}
+
+/* Test case to get latency stats values */
+static int test_latencystats_get(void)
+{
+ int ret = 0;
+ int size = 0;
+ struct rte_metric_value values[NUM_STATS] = { 0 };
+ struct rte_metric_value wrongvalues[NUM_STATS - 2] = { 0 };
+
+ /* Success Test: Valid values and valid size */
+ size = NUM_STATS;
+ ret = rte_latencystats_get(values, size);
+ TEST_ASSERT((ret == NUM_STATS), "Test Failed to get latency metrics"
+ " values");
+ for (int i = 0; i < NUM_STATS; i++)
+ printf("values: %ld\n", values[i].value);
+
+ /* Failure Test: Invalid values and valid size */
+ ret = rte_latencystats_get(NULL, size);
+ TEST_ASSERT((ret == NUM_STATS), "Test Failed to get the stats count,"
+ "Actual: %d Expected: %d", ret, NUM_STATS);
+
+ /* Failure Test: Valid values and invalid size */
+ size = 0;
+ ret = rte_latencystats_get(values, size);
+ TEST_ASSERT((ret == NUM_STATS), "Test Failed to get the stats count,"
+ "Actual: %d Expected: %d", ret, NUM_STATS);
+
+ /* Failure Test: Invalid values(array size lesser than size)
+ * and invalid size
+ */
+ size = NUM_STATS + 2;
+ ret = rte_latencystats_get(wrongvalues, size);
+ TEST_ASSERT(ret == NUM_STATS, "Test Failed to get latency metrics"
+ " values");
+
+ return TEST_SUCCESS;
+}
+
+static int test_latency_ring_setup(void)
+{
+ test_ring_setup(ring, &portid);
+
+ return TEST_SUCCESS;
+}
+
+static void test_latency_ring_free(void)
+{
+ test_ring_free(ring[0]);
+ test_vdev_uninit("net_ring_net_ringa");
+}
+
+static int test_latency_packet_forward(void)
+{
+ int ret;
+ struct rte_mbuf *pbuf[LATENCY_NUM_PACKETS] = { };
+ struct rte_mempool *mp;
+ char poolname[] = "mbuf_pool";
+
+ ret = test_get_mbuf_from_pool(&mp, pbuf, poolname);
+ if (ret < 0) {
+ printf("allocate mbuf pool Failed\n");
+ return TEST_FAILED;
+ }
+ ret = test_packet_forward(pbuf, portid, QUEUE_ID);
+ if (ret < 0)
+ printf("send pkts Failed\n");
+ test_put_mbuf_to_pool(mp, pbuf);
+
+ return TEST_SUCCESS;
+}
+
+static struct
+unit_test_suite latencystats_testsuite = {
+ .suite_name = "Latency Stats Unit Test Suite",
+ .setup = test_latency_ring_setup,
+ .teardown = test_latency_ring_free,
+ .unit_test_cases = {
+
+ /* Test Case 1: To check latency init with
+ * metrics init
+ */
+ TEST_CASE_ST(NULL, NULL, test_latency_init),
+
+ /* Test Case 2: Do packet forwarding for metrics
+ * calculation and check the latency metrics values
+ * are updated
+ */
+ TEST_CASE_ST(test_latency_packet_forward, NULL,
+ test_latency_update),
+ /* Test Case 3: To check whether latency stats names
+ * are retrieved
+ */
+ TEST_CASE_ST(NULL, NULL, test_latencystats_get_names),
+
+ /* Test Case 4: To check whether latency stats
+ * values are retrieved
+ */
+ TEST_CASE_ST(NULL, NULL, test_latencystats_get),
+
+ /* Test Case 5: To check uninit of latency test */
+ TEST_CASE_ST(NULL, NULL, test_latency_uninit),
+
+ TEST_CASES_END()
+ }
+};
+
+static int test_latencystats(void)
+{
+ return unit_test_suite_runner(&latencystats_testsuite);
+}
+
+REGISTER_TEST_COMMAND(latencystats_autotest, test_latencystats);
--
2.13.6
next prev parent reply other threads:[~2018-07-24 10:55 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-06 17:07 [dpdk-dev] [PATCH] add sample functions for packet forwarding Jananee Parthasarathy
2018-07-10 9:53 ` Pattan, Reshma
2018-07-12 8:53 ` [dpdk-dev] [PATCH v2] " Jananee Parthasarathy
2018-07-12 16:00 ` Pattan, Reshma
2018-07-16 16:00 ` [dpdk-dev] [PATCH v3] test: " Jananee Parthasarathy
2018-07-17 8:15 ` Pattan, Reshma
2018-07-17 10:00 ` [dpdk-dev] [PATCH v4] " Jananee Parthasarathy
2018-07-17 10:22 ` Burakov, Anatoly
2018-07-24 10:54 ` [dpdk-dev] [PATCH v5 0/4] add unit tests for bitrate, latency and pdump libraries Naga Suresh Somarowthu
2018-07-24 10:54 ` [dpdk-dev] [PATCH v5 1/4] test: add ring pmd based packet rx/tx for UT Naga Suresh Somarowthu
2018-07-24 11:21 ` Burakov, Anatoly
2018-07-24 10:54 ` [dpdk-dev] [PATCH v5 2/4] test: add unit tests for bitrate library Naga Suresh Somarowthu
2018-07-24 10:54 ` Naga Suresh Somarowthu [this message]
2018-07-24 10:54 ` [dpdk-dev] [PATCH v5 4/4] test: add unit test for pdump library Naga Suresh Somarowthu
2018-07-24 12:27 ` Burakov, Anatoly
2018-07-25 17:05 ` [dpdk-dev] [PATCH v6 0/4] add unit tests for bitrate, latency and pdump libraries Naga Suresh Somarowthu
2018-07-25 17:05 ` [dpdk-dev] [PATCH v6 1/4] test: add ring pmd based packet rx/tx for UT Naga Suresh Somarowthu
2018-07-26 9:59 ` Burakov, Anatoly
2018-07-25 17:05 ` [dpdk-dev] [PATCH v6 2/4] test: add unit tests for bitrate library Naga Suresh Somarowthu
2018-07-25 17:05 ` [dpdk-dev] [PATCH v6 3/4] test: add unit tests for latencystats library Naga Suresh Somarowthu
2018-07-25 17:06 ` [dpdk-dev] [PATCH v6 4/4] test: add unit test for pdump library Naga Suresh Somarowthu
2018-07-26 10:02 ` Burakov, Anatoly
2018-07-26 12:50 ` [dpdk-dev] [PATCH v7 0/4] add unit tests for bitrate, latency and pdump libraries Naga Suresh Somarowthu
2018-07-26 12:50 ` [dpdk-dev] [PATCH v7 1/4] test: add ring pmd based packet rx/tx for UT Naga Suresh Somarowthu
2018-07-26 16:43 ` Pattan, Reshma
2018-07-27 7:40 ` Burakov, Anatoly
2018-07-26 12:50 ` [dpdk-dev] [PATCH v7 2/4] test: add unit tests for bitrate library Naga Suresh Somarowthu
2018-07-26 12:50 ` [dpdk-dev] [PATCH v7 3/4] test: add unit tests for latencystats library Naga Suresh Somarowthu
2018-07-26 12:50 ` [dpdk-dev] [PATCH v7 4/4] test: add unit test for pdump library Naga Suresh Somarowthu
2018-07-26 16:04 ` [dpdk-dev] [PATCH v7 0/4] add unit tests for bitrate, latency and pdump libraries Pattan, Reshma
2018-07-27 14:26 ` [dpdk-dev] [PATCH v8 " Naga Suresh Somarowthu
2018-07-27 14:26 ` [dpdk-dev] [PATCH v8 1/4] test: add helper functions for tests using ring-PMD Rx/Tx Naga Suresh Somarowthu
2018-07-27 14:26 ` [dpdk-dev] [PATCH v8 2/4] test: add unit tests for bitrate library Naga Suresh Somarowthu
2018-07-27 14:26 ` [dpdk-dev] [PATCH v8 3/4] test: add unit tests for latencystats library Naga Suresh Somarowthu
2018-07-27 14:26 ` [dpdk-dev] [PATCH v8 4/4] test: add unit test for pdump library Naga Suresh Somarowthu
2018-07-31 14:57 ` [dpdk-dev] [PATCH v8 0/4] add unit tests for bitrate, latency and pdump libraries Thomas Monjalon
2018-07-31 16:43 ` Pattan, Reshma
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=1532429671-1606-4-git-send-email-naga.sureshx.somarowthu@intel.com \
--to=naga.sureshx.somarowthu@intel.com \
--cc=dev@dpdk.org \
--cc=remy.horton@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).