From: Bruce Richardson Subject: [PATCH 3/3] ring: autotest for using ring as ethdev Date: Fri, 16 May 2014 19:15:14 +0100 Message-ID: <1400264114-28455-4-git-send-email-bruce.richardson@intel.com> References: <1400264114-28455-1-git-send-email-bruce.richardson@intel.com> To: dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: <1400264114-28455-1-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 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 --- 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 #include #include +#include #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