diff mbox

[dpdk-dev,2/5] test: check for mbuf alloc failure

Message ID 1418742233-16776-3-git-send-email-bruce.richardson@intel.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Bruce Richardson Dec. 16, 2014, 3:03 p.m. UTC
If mbuf allocation failed for whatever reason, we would get a NULL
pointer exception in test_table_acl.c:test_pipeline_single_filter test
We fix this by causing an early break out of the application loop. If we
quit the test immediately we would leak any existing allocated mbufs,
but by breaking instead, we allow the test to continue and clean up the
mbufs already in the pipeline, while still having a test failure as the
mbuf counts should not match.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
 app/test/test_table_acl.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox


diff --git a/app/test/test_table_acl.c b/app/test/test_table_acl.c
index 0f2b57e..e4e9b9c 100644
--- a/app/test/test_table_acl.c
+++ b/app/test/test_table_acl.c
@@ -513,6 +513,11 @@  test_pipeline_single_filter(int expected_count)
 			struct rte_mbuf *mbuf;
 			mbuf = rte_pktmbuf_alloc(pool);
+			if (mbuf == NULL)
+				/* this will cause test failure after cleanup
+				 * of already enqueued mbufs, as the mbuf
+				 * counts won't match */
+				break;
 			memset(rte_pktmbuf_mtod(mbuf, char *), 0x00,
 				sizeof(struct ipv4_5tuple));