event/sw: fix selftest enqueue return value checks

Message ID 20190327184546.89483-1-harry.van.haaren@intel.com
State Accepted, archived
Delegated to: Jerin Jacob
Headers show
Series
  • event/sw: fix selftest enqueue return value checks
Related show

Checks

Context Check Description
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing fail Performance Testing issues
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Van Haaren, Harry March 27, 2019, 6:45 p.m.
This patch fixes a number of instances of the same return
value mis-check, where previously we checked for a negative
return value as error, however the API returns an unsigned
integer, so these return value checks are invalid.

The rte_event_enqueue_burst() API returns the number of
events enqueued, so in order to identify the error case,
we must check for != the number of intended enqueues.

Fixes: cd1a9e3eab55 ("test/eventdev: add SW tests for load balancing")

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>

---

Given this commit only changes the test-suite, and not production
code I don't see value in backporting it to stable releases.

These issues were flagged by the LGTM static analysis tool.

---
 drivers/event/sw/sw_evdev_selftest.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Comments

Jerin Jacob Kollanukkaran March 30, 2019, 3:26 p.m. | #1
On Wed, 2019-03-27 at 18:45 +0000, Harry van Haaren wrote:
> -------------------------------------------------------------------
> ---
> This patch fixes a number of instances of the same return
> value mis-check, where previously we checked for a negative
> return value as error, however the API returns an unsigned
> integer, so these return value checks are invalid.
> 
> The rte_event_enqueue_burst() API returns the number of
> events enqueued, so in order to identify the error case,
> we must check for != the number of intended enqueues.
> 
> Fixes: cd1a9e3eab55 ("test/eventdev: add SW tests for load
> balancing")

Cc: stable@dpdk.org


> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>

Applied to dpdk-next-eventdev/master. Thanks.

Patch

diff --git a/drivers/event/sw/sw_evdev_selftest.c b/drivers/event/sw/sw_evdev_selftest.c
index d00d5de61..38c21fa0f 100644
--- a/drivers/event/sw/sw_evdev_selftest.c
+++ b/drivers/event/sw/sw_evdev_selftest.c
@@ -385,7 +385,7 @@  run_prio_packet_test(struct test *t)
 			.mbuf = arp
 		};
 		err = rte_event_enqueue_burst(evdev, t->port[0], &ev, 1);
-		if (err < 0) {
+		if (err != 1) {
 			printf("%d: error failed to enqueue\n", __LINE__);
 			return -1;
 		}
@@ -477,7 +477,7 @@  test_single_directed_packet(struct test *t)
 
 	/* generate pkt and enqueue */
 	err = rte_event_enqueue_burst(evdev, rx_enq, &ev, 1);
-	if (err < 0) {
+	if (err != 1) {
 		printf("%d: error failed to enqueue\n", __LINE__);
 		return -1;
 	}
@@ -546,7 +546,7 @@  test_directed_forward_credits(struct test *t)
 
 	for (i = 0; i < 1000; i++) {
 		err = rte_event_enqueue_burst(evdev, 0, &ev, 1);
-		if (err < 0) {
+		if (err != 1) {
 			printf("%d: error failed to enqueue\n", __LINE__);
 			return -1;
 		}
@@ -707,7 +707,7 @@  burst_packets(struct test *t)
 		};
 		/* generate pkt and enqueue */
 		err = rte_event_enqueue_burst(evdev, t->port[rx_port], &ev, 1);
-		if (err < 0) {
+		if (err != 1) {
 			printf("%d: Failed to enqueue\n", __LINE__);
 			return -1;
 		}
@@ -795,7 +795,7 @@  abuse_inflights(struct test *t)
 
 	/* Enqueue op only */
 	err = rte_event_enqueue_burst(evdev, t->port[rx_enq], &release_ev, 1);
-	if (err < 0) {
+	if (err != 1) {
 		printf("%d: Failed to enqueue\n", __LINE__);
 		return -1;
 	}
@@ -2026,7 +2026,7 @@  load_balancing(struct test *t)
 		};
 		/* generate pkt and enqueue */
 		err = rte_event_enqueue_burst(evdev, t->port[rx_enq], &ev, 1);
-		if (err < 0) {
+		if (err != 1) {
 			printf("%d: Failed to enqueue\n", __LINE__);
 			return -1;
 		}
@@ -2125,7 +2125,7 @@  load_balancing_history(struct test *t)
 		}
 		arp->hash.rss = flows1[i];
 		err = rte_event_enqueue_burst(evdev, t->port[rx_enq], &ev, 1);
-		if (err < 0) {
+		if (err != 1) {
 			printf("%d: Failed to enqueue\n", __LINE__);
 			return -1;
 		}
@@ -2175,7 +2175,7 @@  load_balancing_history(struct test *t)
 		arp->hash.rss = flows2[i];
 
 		err = rte_event_enqueue_burst(evdev, t->port[rx_enq], &ev, 1);
-		if (err < 0) {
+		if (err != 1) {
 			printf("%d: Failed to enqueue\n", __LINE__);
 			return -1;
 		}
@@ -2285,7 +2285,7 @@  invalid_qid(struct test *t)
 		};
 		/* generate pkt and enqueue */
 		err = rte_event_enqueue_burst(evdev, t->port[rx_enq], &ev, 1);
-		if (err < 0) {
+		if (err != 1) {
 			printf("%d: Failed to enqueue\n", __LINE__);
 			return -1;
 		}
@@ -2372,7 +2372,7 @@  single_packet(struct test *t)
 	arp->seqn = MAGIC_SEQN;
 
 	err = rte_event_enqueue_burst(evdev, t->port[rx_enq], &ev, 1);
-	if (err < 0) {
+	if (err != 1) {
 		printf("%d: Failed to enqueue\n", __LINE__);
 		return -1;
 	}
@@ -2416,7 +2416,7 @@  single_packet(struct test *t)
 
 	rte_pktmbuf_free(ev.mbuf);
 	err = rte_event_enqueue_burst(evdev, t->port[wrk_enq], &release_ev, 1);
-	if (err < 0) {
+	if (err != 1) {
 		printf("%d: Failed to enqueue\n", __LINE__);
 		return -1;
 	}