From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 5612C8E90 for ; Mon, 23 Nov 2015 12:46:18 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 23 Nov 2015 03:46:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,336,1444719600"; d="scan'208";a="857528400" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 23 Nov 2015 03:46:06 -0800 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id tANBk5uQ000890; Mon, 23 Nov 2015 11:46:05 GMT Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id tANBk5Z2014323; Mon, 23 Nov 2015 11:46:05 GMT Received: (from dhunt5@localhost) by sivswdev02.ir.intel.com with id tANBk5cY014319; Mon, 23 Nov 2015 11:46:05 GMT From: David Hunt To: dev@dpdk.org Date: Mon, 23 Nov 2015 11:45:48 +0000 Message-Id: <1448279148-14283-1-git-send-email-david.hunt@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] test: fix crash in pmd_perf_test X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Nov 2015 11:46:18 -0000 Fix crash in pmd_perf_test autotest (div by 0) when no packets received Also fixes the fact that the test passes even if exec_burst fails To repeat the issue: The system must be incorrectly set up so that all packets will be lost, i.e. no loopback cable, etc. This is an edge case, but still the test should not crash or pass when failing. run the test app RTE>> set_rxtx_sc poll_before_xmit RTE>> pmd_perf_autotest --snip-- > Generate 4096 packets @socket 1 > start to receive total expect 4096 > 4096 packets lost, IDLE 10000 times > Floating point exception (core dumped) Signed-off-by: David Hunt --- app/test/test_pmd_perf.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c index 8f55640..25b4d09 100644 --- a/app/test/test_pmd_perf.c +++ b/app/test/test_pmd_perf.c @@ -626,7 +626,10 @@ timeout: rte_free(pkts_burst); - return diff_tsc / total; + if (total > 0) + return diff_tsc / total; + else + return -1; } static int @@ -673,8 +676,10 @@ exec_burst(uint32_t flags, int lcore) /* wait for polling finished */ diff_tsc = rte_eal_wait_lcore(lcore); - if (diff_tsc < 0) + if (diff_tsc < 0) { + printf("exec_burst: Failed to measure cycles per packet\n"); return -1; + } printf("Result: %d cycles per packet\n", diff_tsc); @@ -811,7 +816,8 @@ test_pmd_perf(void) return -1; } else if (sc_flag == SC_BURST_POLL_FIRST || sc_flag == SC_BURST_XMIT_FIRST) - exec_burst(sc_flag, slave_id); + if (exec_burst(sc_flag, slave_id) < 0) + return -1; /* port tear down */ for (portid = 0; portid < nb_ports; portid++) { -- 2.1.0