DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] test: add unit tests for latencystats library
@ 2018-07-06 18:00 Jananee Parthasarathy
  2018-07-10 11:55 ` Pattan, Reshma
  2018-07-12 10:13 ` [dpdk-dev] [PATCH v2] " Jananee Parthasarathy
  0 siblings, 2 replies; 4+ messages in thread
From: Jananee Parthasarathy @ 2018-07-06 18:00 UTC (permalink / raw)
  To: dev
  Cc: remy.horton, reshma.pattan, Jananee Parthasarathy,
	Agalya Babu RadhaKrishnan

From: Jananee Parthasarathy <jananeex.m.parthasarathy@intel.com> 

Unit Test Cases added for latencystats library.

Signed-off-by: Agalya Babu RadhaKrishnan <agalyax.babu.radhakrishnan@intel.com>
Reviewed-by: Reshma Pattan <reshma.pattan@intel.com>
---
 test/test/Makefile            |   3 +
 test/test/test_latencystats.c | 178 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 181 insertions(+)
 create mode 100644 test/test/test_latencystats.c

diff --git a/test/test/Makefile b/test/test/Makefile
index eccc8efcf..5b73dab0e 100644
--- a/test/test/Makefile
+++ b/test/test/Makefile
@@ -134,6 +134,7 @@ SRCS-y += test_func_reentrancy.c
 
 SRCS-y += test_service_cores.c
 
+
 SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline.c
 SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_num.c
 SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_etheraddr.c
@@ -180,6 +181,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring_perf.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_blockcipher.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev.c
 
+SRCS-$(CONFIG_RTE_LIBRTE_LATENCY_STATS) += test_latencystats.c
+
 ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_COMPRESSDEV) += test_compressdev.c
 endif
diff --git a/test/test/test_latencystats.c b/test/test/test_latencystats.c
new file mode 100644
index 000000000..6d9809883
--- /dev/null
+++ b/test/test/test_latencystats.c
@@ -0,0 +1,178 @@
+/* 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 "test.h"
+
+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");
+	}
+	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 struct
+unit_test_suite latencystats_testsuite  = {
+	.suite_name = "Latency Stats Unit Test Suite",
+	.setup = test_ring_setup,
+	.teardown = NULL,
+	.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_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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] test: add unit tests for latencystats library
  2018-07-06 18:00 [dpdk-dev] [PATCH] test: add unit tests for latencystats library Jananee Parthasarathy
@ 2018-07-10 11:55 ` Pattan, Reshma
  2018-07-12 10:13 ` [dpdk-dev] [PATCH v2] " Jananee Parthasarathy
  1 sibling, 0 replies; 4+ messages in thread
From: Pattan, Reshma @ 2018-07-10 11:55 UTC (permalink / raw)
  To: Parthasarathy, JananeeX M, dev; +Cc: Horton, Remy, Babu Radhakrishnan, AgalyaX

Hi,

> -----Original Message-----
> From: Parthasarathy, JananeeX M
> Sent: Friday, July 6, 2018 7:01 PM
> To: dev@dpdk.org
> Cc: Horton, Remy <remy.horton@intel.com>; Pattan, Reshma
> <reshma.pattan@intel.com>; Parthasarathy, JananeeX M
> <jananeex.m.parthasarathy@intel.com>; Babu Radhakrishnan, AgalyaX
> <agalyax.babu.radhakrishnan@intel.com>
> Subject: [PATCH] test: add unit tests for latencystats library
> 
> From: Jananee Parthasarathy <jananeex.m.parthasarathy@intel.com>
> 
> Unit Test Cases added for latencystats library.

Need to mention dependency of sample oacket formward functions patch

> diff --git a/test/test/test_latencystats.c b/test/test/test_latencystats.c new file
> mode 100644 index 000000000..6d9809883
> --- /dev/null
> +++ b/test/test/test_latencystats.c
> +
> +/* 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};

NUM_STATS is not defined here nor in sample_packet_forwrd code patch.
Am I missing something here.
 
Include  this test to auto_test suite.

> +			printf("Failed: Names are not matched");
> +	}

Missing \n in printf.

Thanks,
Reshma

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH v2] test: add unit tests for latencystats library
  2018-07-06 18:00 [dpdk-dev] [PATCH] test: add unit tests for latencystats library Jananee Parthasarathy
  2018-07-10 11:55 ` Pattan, Reshma
@ 2018-07-12 10:13 ` Jananee Parthasarathy
  2018-07-12 16:11   ` Pattan, Reshma
  1 sibling, 1 reply; 4+ messages in thread
From: Jananee Parthasarathy @ 2018-07-12 10:13 UTC (permalink / raw)
  To: dev
  Cc: remy.horton, reshma.pattan, Jananee Parthasarathy,
	Agalya Babu RadhaKrishnan

Unit Test Cases added for latencystats library.
Dependency patch is
"add sample functions for packet forwarding"
Patch Link is http://patches.dpdk.org/patch/42946/

Signed-off-by: Agalya Babu RadhaKrishnan <agalyax.babu.radhakrishnan@intel.com>
Reviewed-by: Reshma Pattan <reshma.pattan@intel.com>
---
v2:
  Latency test is added to autotest_data.py.
  NUM_STATS is added to latencystats test file.
---
 test/test/Makefile            |   3 +
 test/test/autotest_data.py    |   6 ++
 test/test/test_latencystats.c | 179 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 188 insertions(+)
 create mode 100644 test/test/test_latencystats.c

diff --git a/test/test/Makefile b/test/test/Makefile
index eccc8efcf..5b73dab0e 100644
--- a/test/test/Makefile
+++ b/test/test/Makefile
@@ -134,6 +134,7 @@ SRCS-y += test_func_reentrancy.c
 
 SRCS-y += test_service_cores.c
 
+
 SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline.c
 SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_num.c
 SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_etheraddr.c
@@ -180,6 +181,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring_perf.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_blockcipher.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev.c
 
+SRCS-$(CONFIG_RTE_LIBRTE_LATENCY_STATS) += test_latencystats.c
+
 ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_COMPRESSDEV) += test_compressdev.c
 endif
diff --git a/test/test/autotest_data.py b/test/test/autotest_data.py
index aacfe0a66..646ca832d 100644
--- a/test/test/autotest_data.py
+++ b/test/test/autotest_data.py
@@ -293,6 +293,12 @@ def per_sockets(num):
         "Tests":
         [
             {
+                "Name":    "Latency Stats 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..39b8b734d
--- /dev/null
+++ b/test/test/test_latencystats.c
@@ -0,0 +1,179 @@
+/* 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 "test.h"
+#include "sample_packet_forward.h"
+#define NUM_STATS 4
+
+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 struct
+unit_test_suite latencystats_testsuite  = {
+	.suite_name = "Latency Stats Unit Test Suite",
+	.setup = test_ring_setup,
+	.teardown = NULL,
+	.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_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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] test: add unit tests for latencystats library
  2018-07-12 10:13 ` [dpdk-dev] [PATCH v2] " Jananee Parthasarathy
@ 2018-07-12 16:11   ` Pattan, Reshma
  0 siblings, 0 replies; 4+ messages in thread
From: Pattan, Reshma @ 2018-07-12 16:11 UTC (permalink / raw)
  To: Parthasarathy, JananeeX M, dev; +Cc: Horton, Remy, Babu Radhakrishnan, AgalyaX

Hi,

> -----Original Message-----
> From: Parthasarathy, JananeeX M
> Sent: Thursday, July 12, 2018 11:14 AM
> To: dev@dpdk.org
> Cc: Horton, Remy <remy.horton@intel.com>; Pattan, Reshma
> <reshma.pattan@intel.com>; Parthasarathy, JananeeX M
> <jananeex.m.parthasarathy@intel.com>; Babu Radhakrishnan, AgalyaX
> <agalyax.babu.radhakrishnan@intel.com>
> Subject: [PATCH v2] test: add unit tests for latencystats library
> 
> Unit Test Cases added for latencystats library.
> Dependency patch is
> "add sample functions for packet forwarding"
> Patch Link is http://patches.dpdk.org/patch/42946/
> 
> Signed-off-by: Agalya Babu RadhaKrishnan
> <agalyax.babu.radhakrishnan@intel.com>
> Reviewed-by: Reshma Pattan <reshma.pattan@intel.com>
> ---
> v2:
>   Latency test is added to autotest_data.py.
>   NUM_STATS is added to latencystats test file.
> ---

Patch doesn't apply 

git apply v2-test-add-unit-tests-for-latencystats-library
error: patch failed: test/test/Makefile:180
error: test/test/Makefile: patch does not apply

rest of the code looks ok,
Acked-by:  Reshma Pattan <reshma.pattan@intel.com>

Thanks,
Reshma

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-12 16:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-06 18:00 [dpdk-dev] [PATCH] test: add unit tests for latencystats library Jananee Parthasarathy
2018-07-10 11:55 ` Pattan, Reshma
2018-07-12 10:13 ` [dpdk-dev] [PATCH v2] " Jananee Parthasarathy
2018-07-12 16:11   ` Pattan, Reshma

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).