diff options
author | Matias Elo <matias.elo@nokia.com> | 2015-10-23 16:01:25 +0300 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2015-10-26 15:06:57 +0300 |
commit | 3d9ef62a01f5345ad121ca43f35d1aa5651bebe4 (patch) | |
tree | 6dc1573200ea228405790f27bd69ed7325d12f35 /test/performance | |
parent | fd9825679fcc76813da6d6c9489f4f84b70e15fe (diff) |
test: l2fwd: fix crash when accuracy is set to 0
Application crashes if accuracy option is set to zero
(division by zero). Disable statistics printing if accuracy
<= 0.
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'test/performance')
-rw-r--r-- | test/performance/odp_l2fwd.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c index c50ca2034..b49a27167 100644 --- a/test/performance/odp_l2fwd.c +++ b/test/performance/odp_l2fwd.c @@ -346,12 +346,22 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool) * */ static int print_speed_stats(int num_workers, stats_t **thr_stats, - int duration, int timeout) + int duration, int timeout) { - uint64_t pkts, pkts_prev = 0, pps, drops, maximum_pps = 0; - int i, elapsed = 0; + uint64_t pkts = 0; + uint64_t pkts_prev = 0; + uint64_t pps; + uint64_t drops; + uint64_t maximum_pps = 0; + int i; + int elapsed = 0; + int stats_enabled = 1; int loop_forever = (duration == 0); + if (timeout <= 0) + stats_enabled = 0; + timeout = 1; + /* Wait for all threads to be ready*/ odp_barrier_wait(&barrier); @@ -365,20 +375,23 @@ static int print_speed_stats(int num_workers, stats_t **thr_stats, pkts += thr_stats[i]->packets; drops += thr_stats[i]->drops; } - pps = (pkts - pkts_prev) / timeout; - if (pps > maximum_pps) - maximum_pps = pps; - printf("%" PRIu64 " pps, %" PRIu64 " max pps, ", pps, - maximum_pps); + if (stats_enabled) { + pps = (pkts - pkts_prev) / timeout; + if (pps > maximum_pps) + maximum_pps = pps; + printf("%" PRIu64 " pps, %" PRIu64 " max pps, ", pps, + maximum_pps); - printf(" %" PRIu64 " total drops\n", drops); + printf(" %" PRIu64 " total drops\n", drops); + pkts_prev = pkts; + } elapsed += timeout; - pkts_prev = pkts; } while (loop_forever || (elapsed < duration)); - printf("TEST RESULT: %" PRIu64 " maximum packets per second.\n", - maximum_pps); + if (stats_enabled) + printf("TEST RESULT: %" PRIu64 " maximum packets per second.\n", + maximum_pps); return pkts > 100 ? 0 : -1; } |