Skip to contentSkip to conversation

test: add unit tests for latencystats library

PATCH In review Naga Suresh Somarowthu 2 participants 6 messages Oct 8, 2018 – Jan 18, 2019 1 message not in the archive Arm/Amlogic Meson SoC support

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 1535115087-2442-1

#1 lore raw

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

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

---
 MAINTAINERS                       |   5 ++
 test/test/Makefile                |   1 +
 test/test/meson.build             |   1 +
 test/test/sample_packet_forward.c | 114 ++++++++++++++++++++++++++++++++++++++
 test/test/sample_packet_forward.h |  46 +++++++++++++++
 5 files changed, 167 insertions(+)
 create mode 100644 test/test/sample_packet_forward.c
 create mode 100644 test/test/sample_packet_forward.h
MAINTAINERS +5 -0
index 84b9ff786..c00081cd8 100644
@@ -1188,6 +1188,11 @@ F: test/test/test_resource.c
 F: test/test/virtual_pmd.c
 F: test/test/virtual_pmd.h
 
+Sample packet helper functions for unit test
+M: Reshma Pattan <[email protected]>
+F: test/test/sample_packet_forward.c
+F: test/test/sample_packet_forward.h
+
 Driver testing tool
 M: Wenzhuo Lu <[email protected]>
 M: Jingjing Wu <[email protected]>
test/test/Makefile +1 -0
index dcea4410d..66e98066f 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/meson.build +1 -0
index bacb5b144..087ffdb91 100644
@@ -3,6 +3,7 @@
 
 test_sources = files('commands.c',
 	'packet_burst_generator.c',
+	'sample_packet_forward.c',
 	'test.c',
 	'test_acl.c',
 	'test_alarm.c',
test/test/sample_packet_forward.c new file +114 -0

114 lines not on this page · raw message

test/test/sample_packet_forward.h new file +46 -0

46 lines not on this page · raw message

Signature · 1 line
2.13.6
#2 lore raw

PATCH v14 2/4 test: add unit tests for bitrate library

In reply to a message not in the archive

Unit Test Cases for BitRate library.

---
 MAINTAINERS                   |   1 +
 test/test/Makefile            |   1 +
 test/test/autotest_data.py    |   6 ++
 test/test/meson.build         |   4 +
 test/test/test_bitratestats.c | 226 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 238 insertions(+)
 create mode 100644 test/test/test_bitratestats.c
MAINTAINERS +1 -0
index c00081cd8..4798fb258 100644
@@ -1156,6 +1156,7 @@ F: lib/librte_metrics/
 Bit-rate statistics
 M: Remy Horton <[email protected]>
 F: lib/librte_bitratestats/
+F: test/test/test_bitratestats.c
 
 Latency statistics
 M: Reshma Pattan <[email protected]>
test/test/Makefile +1 -0
index 66e98066f..c030ab111 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/autotest_data.py +6 -0
index f68d9b111..b253bf8f0 100644
@@ -482,6 +482,12 @@
         "Func":    default_autotest,
         "Report":  None,
     },
+    {
+        "Name":    "Bitratestats autotest",
+        "Command": "bitratestats_autotest",
+        "Func":    default_autotest,
+        "Report":  None,
+    },
     #
     #Please always keep all dump tests at the end and together!
     #
test/test/meson.build +4 -0
index 087ffdb91..f40a28f27 100644
@@ -9,6 +9,7 @@ test_sources = files('commands.c',
 	'test_alarm.c',
 	'test_atomic.c',
 	'test_barrier.c',
+	'test_bitratestats.c',
 	'test_bpf.c',
 	'test_byteorder.c',
 	'test_cmdline.c',
@@ -104,6 +105,7 @@ test_sources = files('commands.c',
 )
 
 test_deps = ['acl',
+	'bitratestats',
 	'bpf',
 	'cfgfile',
 	'cmdline',
@@ -116,6 +118,7 @@ test_deps = ['acl',
 	'hash',
 	'lpm',
 	'member',
+	'metrics',
 	'pipeline',
 	'port',
 	'reorder',
@@ -128,6 +131,7 @@ test_names = [
 	'alarm_autotest',
 	'atomic_autotest',
 	'barrier_autotest',
+	'bitratestats_autotest',
 	'byteorder_autotest',
 	'cmdline_autotest',
 	'common_autotest',
test/test/test_bitratestats.c new file +226 -0

226 lines not on this page · raw message

Signature · 1 line
2.13.6
#3 lore raw

PATCH v14 3/4 test: add unit tests for latencystats library

In reply to a message not in the archive

Unit Test Cases added for latencystats library.

---
 MAINTAINERS                   |   1 +
 test/test/Makefile            |   1 +
 test/test/autotest_data.py    |   6 ++
 test/test/meson.build         |   3 +
 test/test/test_latencystats.c | 224 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 235 insertions(+)
 create mode 100644 test/test/test_latencystats.c
MAINTAINERS +1 -0
index 4798fb258..5eee72956 100644
@@ -1161,6 +1161,7 @@ F: test/test/test_bitratestats.c
 Latency statistics
 M: Reshma Pattan <[email protected]>
 F: lib/librte_latencystats/
+F: test/test/test_latencystats.c
 
 BPF - EXPERIMENTAL
 M: Konstantin Ananyev <[email protected]>
test/test/Makefile +1 -0
index c030ab111..5729638a4 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/autotest_data.py +6 -0
index b253bf8f0..f44e31d33 100644
@@ -488,6 +488,12 @@
         "Func":    default_autotest,
         "Report":  None,
     },
+    {
+        "Name":    "Latencystats autotest",
+        "Command": "latencystats_autotest",
+        "Func":    default_autotest,
+        "Report":  None,
+    },
     #
     #Please always keep all dump tests at the end and together!
     #
test/test/meson.build +3 -0
index f40a28f27..e31e24096 100644
@@ -51,6 +51,7 @@ test_sources = files('commands.c',
 	'test_interrupts.c',
 	'test_kni.c',
 	'test_kvargs.c',
+	'test_latencystats.c',
 	'test_link_bonding.c',
 	'test_link_bonding_mode4.c',
 	'test_logs.c',
@@ -116,6 +117,7 @@ test_deps = ['acl',
 	'eventdev',
 	'flow_classify',
 	'hash',
+	'latencystats',
 	'lpm',
 	'member',
 	'metrics',
@@ -179,6 +181,7 @@ test_names = [
 	'interrupt_autotest',
 	'kni_autotest',
 	'kvargs_autotest',
+	'latencystats_autotest',
 	'link_bonding_autotest',
 	'link_bonding_mode4_autotest',
 	'logs_autotest',
test/test/test_latencystats.c new file +224 -0

224 lines not on this page · raw message

Signature · 1 line
2.13.6
#4 lore raw

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

In reply to a message not in the archive

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

Patches 2/4, 3/4 and 4/4 depends on 1/4

---
v14 :rebased
v13: added required changes for meson build
updated respective patches
updated the headers as per IWYU
v12: corrected commit message for pdump unit test
v11: fixed compilation issue in centos and 32bit arch
removed memzone free as per fix in the latency library
and updated the maintainers file
v10: fixed clang compiler issues and freed latency stats memzone in latency stats unit tests.
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

 MAINTAINERS                       |  10 +-
 test/test/Makefile                |   9 ++
 test/test/autotest_data.py        |  18 +++
 test/test/meson.build             |  10 ++
 test/test/process.h               |  13 +++
 test/test/sample_packet_forward.c | 114 +++++++++++++++++++
 test/test/sample_packet_forward.h |  46 ++++++++
 test/test/test.c                  |   2 +
 test/test/test_bitratestats.c     | 226 ++++++++++++++++++++++++++++++++++++++
 test/test/test_latencystats.c     | 224 +++++++++++++++++++++++++++++++++++++
 test/test/test_pdump.c            | 219 ++++++++++++++++++++++++++++++++++++
 test/test/test_pdump.h            |  31 ++++++
 12 files changed, 921 insertions(+), 1 deletion(-)
 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.13.6
#5 lore raw

Re: [PATCH v14 0/4] add unit tests for bitrate, latency and pdump libraries

08/10/2018 14:12, Naga Suresh Somarowthu:

Quoted 28 lines

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

Patches 2/4, 3/4 and 4/4 depends on 1/4

---
v14 :rebased
v13: added required changes for meson build
updated respective patches
updated the headers as per IWYU
v12: corrected commit message for pdump unit test
v11: fixed compilation issue in centos and 32bit arch
removed memzone free as per fix in the latency library
and updated the maintainers file
v10: fixed clang compiler issues and freed latency stats memzone in latency stats unit tests.
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
---

Quoted 5 lines

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

Rebased and applied, thanks

#6 lore raw

PATCH v14 4/4 test: add unit test for pdump library

In reply to a message not in the archive

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.

---
 MAINTAINERS                |   3 +-
 test/test/Makefile         |   6 ++
 test/test/autotest_data.py |   6 ++
 test/test/meson.build      |   2 +
 test/test/process.h        |  13 +++
 test/test/test.c           |   2 +
 test/test/test_pdump.c     | 219 +++++++++++++++++++++++++++++++++++++++++++++
 test/test/test_pdump.h     |  31 +++++++
 8 files changed, 281 insertions(+), 1 deletion(-)
 create mode 100644 test/test/test_pdump.c
 create mode 100644 test/test/test_pdump.h
MAINTAINERS +2 -1
index 5eee72956..7160c92cd 100644
@@ -1030,7 +1030,8 @@ F: lib/librte_pdump/
 F: doc/guides/prog_guide/pdump_lib.rst
 F: app/pdump/
 F: doc/guides/tools/pdump.rst
-
+F: test/test/test_pdump.c
+F: test/test/test_pdump.h
 
 Packet Framework
 ----------------
test/test/Makefile +6 -0
index 5729638a4..129acb330 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
@@ -215,6 +216,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/autotest_data.py +6 -0
index f44e31d33..9a54d0c04 100644
@@ -494,6 +494,12 @@
         "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!
     #
test/test/meson.build +2 -0
index e31e24096..4fd383c00 100644
@@ -71,6 +71,7 @@ test_sources = files('commands.c',
 	'test_memzone.c',
 	'test_meter.c',
 	'test_mp_secondary.c',
+	'test_pdump.c',
 	'test_per_lcore.c',
 	'test_pmd_perf.c',
 	'test_pmd_ring.c',
@@ -201,6 +202,7 @@ test_names = [
 	'memzone_autotest',
 	'meter_autotest',
 	'multiprocess_autotest',
+	'pdump_autotest',
 	'per_lcore_autotest',
 	'pmd_perf_autotest',
 	'power_acpi_cpufreq_autotest',
test/test/process.h +13 -0
index ba3a18502..7f62f644f 100644
@@ -9,6 +9,7 @@
 #include <libgen.h> /* basename et al */
 #include <stdlib.h> /* NULL */
 #include <unistd.h> /* readlink */
+#include <sys/wait.h>
 
 #ifdef RTE_EXEC_ENV_BSDAPP
 #define self "curproc"
@@ -18,6 +19,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 +36,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 +67,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 +219 -0

219 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.13.6