Skip to contentSkip to conversation

add unit tests for bitrate, latency and pdump libraries

PATCH Superseded Reshma Pattan 2 participants 8 messages Jul 31, 2018

v9 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v9 cover add unit tests for bitrate, latency and pdump libraries

From: Reshma Pattan <[email protected]>

1/5: add helper functions for tests using ring-PMD Rx/Tx 2/5: unit test cases added for bitrate library 3/5: unit test cases added for latencystats library 4/5: unit test cases added for pdump library 5/5: added new unit tests to autotest list

Patches 2/5,3/5 depends on 1/5
Patch 4/5 depends on 1/5 and the below patch
http://patches.dpdk.org/patch/43354/

---
v9: rebased ontop of latest autotest changes and added new tests to the autotest list
v8: renamed commit headline and freed the metrics memzone for bitrate ut
v7: removed unused macros and corrected the comment
v6: updated ring variable appropriately
v5: rebased, freed pools and rings, created common patch set
---
Naga Suresh Somarowthu (4):
test: add helper functions for tests using ring-PMD Rx/Tx
test: add unit tests for bitrate library
test: add unit tests for latencystats library
test: add unit test for pdump library

Reshma Pattan (1):
autotest: add new unit tests to autotest list

 test/test/Makefile                |   9 ++
 test/test/autotest_data.py        |  18 +++
 test/test/process.h               |  12 ++
 test/test/sample_packet_forward.c | 115 +++++++++++++++++++
 test/test/sample_packet_forward.h |  40 +++++++
 test/test/test.c                  |   2 +
 test/test/test_bitratestats.c     | 229 +++++++++++++++++++++++++++++++++++++
 test/test/test_latencystats.c     | 216 +++++++++++++++++++++++++++++++++++
 test/test/test_pdump.c            | 232 ++++++++++++++++++++++++++++++++++++++
 test/test/test_pdump.h            |  31 +++++
 10 files changed, 904 insertions(+)
 create mode 100644 test/test/sample_packet_forward.c
 create mode 100644 test/test/sample_packet_forward.h
 create mode 100644 test/test/test_bitratestats.c
 create mode 100644 test/test/test_latencystats.c
 create mode 100644 test/test/test_pdump.c
 create mode 100644 test/test/test_pdump.h
Signature · 1 line
2.14.4
#1 lore raw

PATCH v9 1/5 test: add helper functions for tests using ring-PMD Rx/Tx

From: Naga Suresh Somarowthu <[email protected]>

Added ring pmd based packet rx/tx helper functions for verifying Latency, Bitrate and pdump lib UTs.

---
 test/test/Makefile                |   1 +
 test/test/sample_packet_forward.c | 115 ++++++++++++++++++++++++++++++++++++++
 test/test/sample_packet_forward.h |  40 +++++++++++++
 3 files changed, 156 insertions(+)
 create mode 100644 test/test/sample_packet_forward.c
 create mode 100644 test/test/sample_packet_forward.h
test/test/Makefile +1 -0
index e6967bab6..9f7d398e4 100644
@@ -165,6 +165,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_REORDER) += test_reorder.c
 
 SRCS-y += virtual_pmd.c
 SRCS-y += packet_burst_generator.c
+SRCS-y += sample_packet_forward.c
 SRCS-$(CONFIG_RTE_LIBRTE_ACL) += test_acl.c
 
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_RING),y)
test/test/sample_packet_forward.c new file +115 -0

115 lines not on this page · raw message

test/test/sample_packet_forward.h new file +40 -0
new file mode 100644
index 000000000..433bd3ba2
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Intel Corporation
+ */
+
+#ifndef _SAMPLE_PACKET_FORWARD_H_
+#define _SAMPLE_PACKET_FORWARD_H_
+
+/* MACROS to support virtual ring creation */
+#define RING_SIZE 256
+#define NUM_QUEUES 1
+#define NB_MBUF 512
+
+#define NUM_PACKETS 10
+
+/* Sample test to create virtual rings and tx,rx portid from rings */
+int test_ring_setup(struct rte_ring **ring, uint16_t *portid);
+
+/* Sample test to free the virtual rings */
+void test_ring_free(struct rte_ring *rxtx);
+
+/* Sample test to forward packet using virtual port id */
+int test_packet_forward(struct rte_mbuf **pbuf, uint16_t portid,
+		uint16_t queue_id);
+
+/* sample test to allocate buffer for pkts */
+int test_get_mbuf_from_pool(struct rte_mempool **mp, struct rte_mbuf **pbuf,
+		char *poolname);
+
+/* Sample test to create the mempool */
+int test_get_mempool(struct rte_mempool **mp, char *poolname);
+
+/* sample test to deallocate the allocated buffers and mempool */
+void test_put_mbuf_to_pool(struct rte_mempool *mp, struct rte_mbuf **pbuf);
+
+/* Sample test to free the mempool */
+void test_mp_free(struct rte_mempool *mp);
+
+/* Sample test to release the vdev */
+void test_vdev_uninit(const char *vdev);
+#endif				/* _SAMPLE_PACKET_FORWARD_H_ */
Signature · 1 line
2.14.4
#2 lore raw

PATCH v9 2/5 test: add unit tests for bitrate library

In reply to Reshma Pattan

From: Naga Suresh Somarowthu <[email protected]>

Unit Test Cases for BitRate library.

---
 test/test/Makefile            |   1 +
 test/test/test_bitratestats.c | 229 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 230 insertions(+)
 create mode 100644 test/test/test_bitratestats.c
test/test/Makefile +1 -0
index 9f7d398e4..c619877f0 100644
@@ -183,6 +183,7 @@ 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_CRYPTODEV) += test_cryptodev_asym.c
+SRCS-$(CONFIG_RTE_LIBRTE_BITRATE) += test_bitratestats.c
 
 ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_COMPRESSDEV) += test_compressdev.c
test/test/test_bitratestats.c new file +229 -0

229 lines not on this page · raw message

Signature · 1 line
2.14.4
#3 lore raw

PATCH v9 3/5 test: add unit tests for latencystats library

In reply to Reshma Pattan

From: Naga Suresh Somarowthu <[email protected]>

Unit Test Cases added for latencystats library.

---
 test/test/Makefile            |   1 +
 test/test/test_latencystats.c | 216 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 217 insertions(+)
 create mode 100644 test/test/test_latencystats.c
test/test/Makefile +1 -0
index c619877f0..bba3be1be 100644
@@ -184,6 +184,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_blockcipher.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_asym.c
 SRCS-$(CONFIG_RTE_LIBRTE_BITRATE) += test_bitratestats.c
+SRCS-$(CONFIG_RTE_LIBRTE_LATENCY_STATS) += test_latencystats.c
 
 ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_COMPRESSDEV) += test_compressdev.c
test/test/test_latencystats.c new file +216 -0

216 lines not on this page · raw message

Signature · 1 line
2.14.4
#6 lore raw

PATCH v9 4/5 test: add unit test for pdump library

In reply to Reshma Pattan

From: Naga Suresh Somarowthu <[email protected]>

Unit test cases are added for pdump library.
Primary process will act as server, forks a child secondary process. Secondary process acts as client.
Server will do pdump init to serve any pdump client requests. Server will create a vdev, send/receive packets continuously in a separate thread.
Client will create virtual rings to receive the packet dump. Client sends pdump enable/disable requests using either port/device id. Packet flow direction can be tx/rx/tx&rx.
In Server, appropriate pdump callbacks are triggered,
when packets are transmitted/received.
Pdump packet is copied to client rings.

---
 test/test/Makefile     |   6 ++
 test/test/process.h    |  12 +++
 test/test/test.c       |   2 +
 test/test/test_pdump.c | 232 +++++++++++++++++++++++++++++++++++++++++++++++++
 test/test/test_pdump.h |  31 +++++++
 5 files changed, 283 insertions(+)
 create mode 100644 test/test/test_pdump.c
 create mode 100644 test/test/test_pdump.h
test/test/Makefile +6 -0
index bba3be1be..3e7baef76 100644
@@ -185,6 +185,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_asym.c
 SRCS-$(CONFIG_RTE_LIBRTE_BITRATE) += test_bitratestats.c
 SRCS-$(CONFIG_RTE_LIBRTE_LATENCY_STATS) += test_latencystats.c
+SRCS-$(CONFIG_RTE_LIBRTE_PDUMP) += test_pdump.c
 
 ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_COMPRESSDEV) += test_compressdev.c
@@ -214,6 +215,11 @@ CFLAGS += $(WERROR_FLAGS)
 CFLAGS += -D_GNU_SOURCE
 
 LDLIBS += -lm
+
+ifeq ($(CONFIG_RTE_LIBRTE_PDUMP),y)
+LDLIBS += -lpthread
+endif
+
 ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)
 ifeq ($(CONFIG_RTE_LIBRTE_COMPRESSDEV),y)
 LDLIBS += -lz
test/test/process.h +12 -0
index ba3a18502..c015c9030 100644
@@ -18,6 +18,10 @@
 #define exe "exe"
 #endif
 
+#include <pthread.h>
+extern void *send_pkts(void *empty);
+extern uint16_t flag_for_send_pkts;
+
 /*
  * launches a second copy of the test process using the given argv parameters,
  * which should include argv[0] as the process name. To identify in the
@@ -31,6 +35,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
 	char *argv_cpy[numargs + 1];
 	int i, fd, status;
 	char path[32];
+	pthread_t thread;
 
 	pid_t pid = fork();
 	if (pid < 0)
@@ -61,8 +66,15 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
 			rte_panic("Cannot exec\n");
 	}
 	/* parent process does a wait */
+	if ((strcmp(env_value, "run_pdump_server_tests") == 0))
+		pthread_create(&thread, NULL, &send_pkts, NULL);
+
 	while (wait(&status) != pid)
 		;
+	if ((strcmp(env_value, "run_pdump_server_tests") == 0)) {
+		flag_for_send_pkts = 0;
+		pthread_join(thread, NULL);
+	}
 	return status;
 }
 
test/test/test.c +2 -0
index 44dfe20ef..a54b0d142 100644
@@ -30,6 +30,7 @@ extern cmdline_parse_ctx_t main_ctx[];
 #endif
 
 #include "test.h"
+#include "test_pdump.h"
 
 #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1
 
@@ -49,6 +50,7 @@ do_recursive_call(void)
 		int (*action_fn)(void);
 	} actions[] =  {
 			{ "run_secondary_instances", test_mp_secondary },
+			{ "run_pdump_server_tests", test_pdump },
 			{ "test_missing_c_flag", no_action },
 			{ "test_master_lcore_flag", no_action },
 			{ "test_invalid_n_flag", no_action },
test/test/test_pdump.c new file +232 -0

232 lines not on this page · raw message

test/test/test_pdump.h new file +31 -0
new file mode 100644
index 000000000..abef9a85e
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Intel Corporation
+ */
+
+#ifndef _TEST_PDUMP_H_
+#define _TEST_PDUMP_H_
+
+#define QUEUE_ID 0
+#define NUM_ITR 3
+
+/* sample test to send packets to the pdump client recursively */
+void *send_pkts(void *port);
+
+/* Sample test to create setup for the pdump server tests */
+int test_pdump_init(void);
+
+/* Sample test to teardown the pdump server setup */
+int test_pdump_uninit(void);
+
+/* Sample test to run the pdump client tests */
+int run_pdump_client_tests(void);
+
+/* Sample test to run the pdump server tests */
+int run_pdump_server_tests(void);
+
+/* Sample test to run the pdump client and server tests based on
+ * the process type
+ */
+int test_pdump(void);
+
+#endif /* _TEST_PDUMP_H_ */
Signature · 1 line
2.14.4
#7 lore raw

PATCH v9 5/5 autotest: add new unit tests to autotest list

In reply to Reshma Pattan

From: Reshma Pattan <[email protected]>

added bitrate, latency and pdump lib unit tests to autotest list.

---
 test/test/autotest_data.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
test/test/autotest_data.py +18 -0
index 3f856ff57..2f7a2aa43 100644
@@ -476,6 +476,24 @@
         "Func":    default_autotest,
         "Report":  None,
     },
+    {
+        "Name":    "Bitratestats autotest",
+        "Command": "bitratestats_autotest",
+        "Func":    default_autotest,
+        "Report":  None,
+    }
+    {
+        "Name":    "Latencystats autotest",
+        "Command": "latencystats_autotest",
+        "Func":    default_autotest,
+        "Report":  None,
+    }
+    {
+        "Name":    "Pdump autotest",
+        "Comamnd": "pdump_autotest",
+        "Func":    default_autotest,
+        "Report":  None,
+    }
     #
     #Please always keep all dump tests at the end and together!
     #
Signature · 1 line
2.14.4
#4 lore raw

Re: [PATCH v9 3/5] test: add unit tests for latencystats library

In reply to Reshma Pattan

31/07/2018 18:40, Reshma Pattan:

Quoted 7 lines

From: Naga Suresh Somarowthu <[email protected]>

Unit Test Cases added for latencystats library.

---

Compilation error with clang:

test/test/test_latencystats.c line 73

Quoted 1 line
test/test/test_latencystats.c new file +1 -0
+	struct rte_metric_name names[NUM_STATS] = { 0 };

test_latencystats.c:73:46: fatal error:
suggest braces around initialization of subobject [-Wmissing-braces]

test/test/test_latencystats.c line 74

Quoted 1 line
test/test/test_latencystats.c new file +1 -0
+	struct rte_metric_name wrongnames[NUM_STATS - 2] = { 0 };

Usually, it is recommended to use memset for initializations of structs.

#5 lore raw

Re: [PATCH v9 3/5] test: add unit tests for latencystats library

Hi,

Quoted 22 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Tuesday, July 31, 2018 6:06 PM
To: Pattan, Reshma <[email protected]>; Somarowthu, Naga SureshX <[email protected]>
Cc: [email protected]; Burakov, Anatoly <[email protected]>; Parthasarathy, JananeeX M <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v9 3/5] test: add unit tests for latencystats library

31/07/2018 18:40, Reshma Pattan:

Quoted 5 lines

From: Naga Suresh Somarowthu <[email protected]>

Unit Test Cases added for latencystats library.

Signed-off-by Naga Suresh Somarowthu

<[email protected]>

Quoted 2 lines

---

Compilation error with clang:

Quoted 9 lines

test/test/test_latencystats.c line 73

Quoted 1 line
test/test/test_latencystats.c new file +1 -0
+	struct rte_metric_name names[NUM_STATS] = { 0 };

test_latencystats.c:73:46: fatal error:
suggest braces around initialization of subobject [-Wmissing-braces]

test/test/test_latencystats.c line 74

Quoted 1 line
test/test/test_latencystats.c new file +1 -0
+	struct rte_metric_name wrongnames[NUM_STATS - 2] = { 0 };

Usually, it is recommended to use memset for initializations of structs.

Fixed in v10 .

Thanks,
Reshma