[dpdk-dev] [PATCH 3/3] ring: autotest for using ring as ethdev

Bruce Richardson bruce.richardson at intel.com
Fri May 16 20:15:14 CEST 2014


An automated unit test for the new API to allow a ring to be used as an
ethdev. Verifies that expected enqueue/dequeue functionality still
works.

Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
---
 app/test/test_ring.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/app/test/test_ring.c b/app/test/test_ring.c
index cfd907f..f2aac24 100644
--- a/app/test/test_ring.c
+++ b/app/test/test_ring.c
@@ -58,6 +58,7 @@
 #include <rte_common.h>
 #include <rte_errno.h>
 #include <rte_hexdump.h>
+#include <rte_ethdev.h>
 
 #include "test.h"
 
@@ -1322,6 +1323,26 @@ fail_test:
 	return ret;
 }
 
+static int
+test_ring_as_eth_dev(void)
+{
+	int ethnum = rte_ring_as_eth_dev(r);
+	struct rte_mbuf *buf = NULL;
+
+	printf("Testing ring as ethdev - port num: %d\n", ethnum);
+	if (rte_eth_tx_burst(ethnum, 0, &buf, 1) != 1)
+		return -1;
+	if (rte_ring_count(r) != 1)
+		return -1;
+	if (rte_eth_rx_burst(ethnum, 0, &buf, 1) != 1)
+		return -1;
+	if (buf != NULL)
+		return -1;
+	printf("Enqueue/dequeue tests ok\n");
+
+	return 0;
+}
+
 int
 test_ring(void)
 {
@@ -1379,6 +1400,10 @@ test_ring(void)
 			else
 				printf ( "Test detected NULL ring lookup \n");
 
+	/* test using the ring as an ethdev */
+	if (test_ring_as_eth_dev() < 0)
+		return -1;
+
 	/* test of creating ring with wrong size */
 	if (test_ring_creation_with_wrong_size() < 0)
 		return -1;
-- 
1.9.0



More information about the dev mailing list