diff mbox

[1/2] validation: pktio: fix statistics test

Message ID 1459862441-28467-1-git-send-email-matias.elo@nokia.com
State Accepted
Commit d608a318f64b00de13b345065868b8d74ddde892
Headers show

Commit Message

Elo, Matias (Nokia - FI/Espoo) April 5, 2016, 1:20 p.m. UTC
Stop trying to schedule new packets if all sent packets have
already been received.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
---
 test/validation/pktio/pktio.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Maxim Uvarov April 6, 2016, 2:06 p.m. UTC | #1
Merged this 1/2 patch.

(trivial enhancements).

Maxim.

On 04/05/16 16:20, Matias Elo wrote:
> Stop trying to schedule new packets if all sent packets have
> already been received.
>
> Signed-off-by: Matias Elo <matias.elo@nokia.com>
> ---
>   test/validation/pktio/pktio.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
> index cb403a6..d52a520 100644
> --- a/test/validation/pktio/pktio.c
> +++ b/test/validation/pktio/pktio.c
> @@ -1173,7 +1173,7 @@ void pktio_test_statistics_counters(void)
>   	odp_packet_t pkt;
>   	odp_packet_t tx_pkt[1000];
>   	odp_event_t ev;
> -	int i, pkts, ret, alloc = 0;
> +	int i, pkts, tx_pkts, ret, alloc = 0;
>   	odp_pktout_queue_t pktout;
>   	uint64_t wait = odp_schedule_wait_time(ODP_TIME_MSEC_IN_NS);
>   	odp_pktio_stats_t stats[2];
> @@ -1233,9 +1233,10 @@ void pktio_test_statistics_counters(void)
>   		}
>   		pkts += ret;
>   	}
> +	tx_pkts = pkts;
>   
>   	/* get */
> -	for (i = 0, pkts = 0; i < 1000; i++) {
> +	for (i = 0, pkts = 0; i < 1000 && pkts != tx_pkts; i++) {
>   		ev = odp_schedule(NULL, wait);
>   		if (ev != ODP_EVENT_INVALID) {
>   			if (odp_event_type(ev) == ODP_EVENT_PACKET) {
> @@ -1247,6 +1248,8 @@ void pktio_test_statistics_counters(void)
>   		}
>   	}
>   
> +	CU_ASSERT(pkts == tx_pkts);
> +
>   	ret = odp_pktio_stats(pktio_tx, &stats[0]);
>   	CU_ASSERT(ret == 0);
>   
> @@ -1268,7 +1271,6 @@ void pktio_test_statistics_counters(void)
>   			  (PKT_LEN_NORMAL * (uint64_t)pkts)));
>   	}
>   
> -	CU_ASSERT(pkts == alloc);
>   	CU_ASSERT(0 == stats[0].in_discards);
>   	CU_ASSERT(0 == stats[0].in_errors);
>   	CU_ASSERT(0 == stats[0].in_unknown_protos);
diff mbox

Patch

diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index cb403a6..d52a520 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -1173,7 +1173,7 @@  void pktio_test_statistics_counters(void)
 	odp_packet_t pkt;
 	odp_packet_t tx_pkt[1000];
 	odp_event_t ev;
-	int i, pkts, ret, alloc = 0;
+	int i, pkts, tx_pkts, ret, alloc = 0;
 	odp_pktout_queue_t pktout;
 	uint64_t wait = odp_schedule_wait_time(ODP_TIME_MSEC_IN_NS);
 	odp_pktio_stats_t stats[2];
@@ -1233,9 +1233,10 @@  void pktio_test_statistics_counters(void)
 		}
 		pkts += ret;
 	}
+	tx_pkts = pkts;
 
 	/* get */
-	for (i = 0, pkts = 0; i < 1000; i++) {
+	for (i = 0, pkts = 0; i < 1000 && pkts != tx_pkts; i++) {
 		ev = odp_schedule(NULL, wait);
 		if (ev != ODP_EVENT_INVALID) {
 			if (odp_event_type(ev) == ODP_EVENT_PACKET) {
@@ -1247,6 +1248,8 @@  void pktio_test_statistics_counters(void)
 		}
 	}
 
+	CU_ASSERT(pkts == tx_pkts);
+
 	ret = odp_pktio_stats(pktio_tx, &stats[0]);
 	CU_ASSERT(ret == 0);
 
@@ -1268,7 +1271,6 @@  void pktio_test_statistics_counters(void)
 			  (PKT_LEN_NORMAL * (uint64_t)pkts)));
 	}
 
-	CU_ASSERT(pkts == alloc);
 	CU_ASSERT(0 == stats[0].in_discards);
 	CU_ASSERT(0 == stats[0].in_errors);
 	CU_ASSERT(0 == stats[0].in_unknown_protos);