diff mbox series

[API-NEXT,v4,3/3] validation: packet: add call to ones complement

Message ID 1510228830-21766-4-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v4,1/3] api: packet: ones complement sum | expand

Commit Message

Github ODP bot Nov. 9, 2017, noon UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


Call ones complement function. Actual validation of
correctness of the sum is to be done, when an implementation
exist which sets the sum on packet input.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
/** Email created from pull request 242 (psavol:next-checksum-metadata)
 ** https://github.com/Linaro/odp/pull/242
 ** Patch: https://github.com/Linaro/odp/pull/242.patch
 ** Base sha: d22c949cc466bf28de559855a1cb525740578137
 ** Merge commit sha: 02aa905e6f9d4be66e19ccdb577e40a293be2902
 **/
 test/validation/api/packet/packet.c |  6 ++++++
 test/validation/api/pktio/pktio.c   | 25 +++++++++++++++++++++----
 2 files changed, 27 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c
index 37550a2f5..dc99395c5 100644
--- a/test/validation/api/packet/packet.c
+++ b/test/validation/api/packet/packet.c
@@ -503,6 +503,7 @@  void packet_test_basic_metadata(void)
 {
 	odp_packet_t pkt = test_packet;
 	odp_time_t ts;
+	odp_packet_data_range_t range;
 
 	CU_ASSERT_PTR_NOT_NULL(odp_packet_head(pkt));
 	CU_ASSERT_PTR_NOT_NULL(odp_packet_data(pkt));
@@ -512,6 +513,11 @@  void packet_test_basic_metadata(void)
 	CU_ASSERT(odp_packet_input(pkt) == ODP_PKTIO_INVALID);
 	CU_ASSERT(odp_packet_input_index(pkt) < 0);
 
+	/* Packet was not received from a packet IO, shouldn't have ones
+	 * complement calculated. */
+	odp_packet_ones_comp(pkt, &range);
+	CU_ASSERT(range.length == 0);
+
 	odp_packet_flow_hash_set(pkt, UINT32_MAX);
 	CU_ASSERT(odp_packet_has_flow_hash(pkt));
 	CU_ASSERT(odp_packet_flow_hash(pkt) == UINT32_MAX);
diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c
index 720707358..004379cd8 100644
--- a/test/validation/api/pktio/pktio.c
+++ b/test/validation/api/pktio/pktio.c
@@ -48,6 +48,9 @@  static int num_ifaces;
     interface that just become up.*/
 static bool wait_for_network;
 
+/* Dummy global variable to avoid compiler optimizing out API calls */
+static volatile uint64_t test_pktio_dummy_u64;
+
 /** local container for pktio attributes */
 typedef struct {
 	const char *name;
@@ -661,10 +664,24 @@  static void pktio_txrx_multi(pktio_info_t *pktio_a, pktio_info_t *pktio_b,
 	CU_ASSERT(num_rx == num_pkts);
 
 	for (i = 0; i < num_rx; ++i) {
-		CU_ASSERT_FATAL(rx_pkt[i] != ODP_PACKET_INVALID);
-		CU_ASSERT(odp_packet_input(rx_pkt[i]) == pktio_b->id);
-		CU_ASSERT(odp_packet_has_error(rx_pkt[i]) == 0);
-		odp_packet_free(rx_pkt[i]);
+		odp_packet_data_range_t range;
+		uint16_t sum;
+		odp_packet_t pkt = rx_pkt[i];
+
+		CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+		CU_ASSERT(odp_packet_input(pkt) == pktio_b->id);
+		CU_ASSERT(odp_packet_has_error(pkt) == 0);
+
+		/* Dummy read to ones complement in case pktio has set it */
+		sum = odp_packet_ones_comp(pkt, &range);
+		if (range.length > 0)
+			test_pktio_dummy_u64 += sum;
+
+		/* Dummy read to flow hash in case pktio has set it */
+		if (odp_packet_has_flow_hash(pkt))
+			test_pktio_dummy_u64 += odp_packet_flow_hash(pkt);
+
+		odp_packet_free(pkt);
 	}
 }