diff mbox series

[API-NEXT,v2,3/3] validation: packet: add calls to ones complement

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

Commit Message

Github ODP bot Oct. 23, 2017, 10 a.m. UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


Call ones complement functions. 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: ec6510b33e8b96d6d6670efb9dc3c9101baed6c6
 ** Merge commit sha: 19351e51472213736d5301c666500b459ccabff7
 **/
 test/validation/api/packet/packet.c | 13 +++++++++++++
 test/validation/api/pktio/pktio.c   | 22 ++++++++++++++++++----
 2 files changed, 31 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c
index 431444cf3..340b81159 100644
--- a/test/validation/api/packet/packet.c
+++ b/test/validation/api/packet/packet.c
@@ -30,6 +30,9 @@  static odp_bool_t segmentation_supported = true;
 
 odp_packet_t test_packet, segmented_test_packet;
 
+/* Dummy global variable to avoid compiler optimizing out API calls */
+uint64_t odp_valid_test_packet_u64;
+
 static struct udata_struct {
 	uint64_t u64;
 	uint32_t u32;
@@ -512,6 +515,15 @@  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. */
+	CU_ASSERT(odp_packet_has_ones_comp(pkt) == 0);
+
+	/* Usually odp_packet_ones_comp() is not called here. This ensures that
+	 * the function exists. */
+	if (odp_packet_has_ones_comp(pkt))
+		odp_valid_test_packet_u64 += odp_packet_ones_comp(pkt);
+
 	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);
@@ -1112,6 +1124,7 @@  static void _packet_compare_inflags(odp_packet_t pkt1, odp_packet_t pkt2)
 	COMPARE_HAS_INFLAG(pkt1, pkt2, tcp);
 	COMPARE_HAS_INFLAG(pkt1, pkt2, sctp);
 	COMPARE_HAS_INFLAG(pkt1, pkt2, icmp);
+	COMPARE_HAS_INFLAG(pkt1, pkt2, ones_comp);
 	COMPARE_HAS_INFLAG(pkt1, pkt2, flow_hash);
 	COMPARE_HAS_INFLAG(pkt1, pkt2, ts);
 
diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c
index 720707358..e3f9ab22a 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 */
+uint64_t odp_valid_test_pktio_u64;
+
 /** local container for pktio attributes */
 typedef struct {
 	const char *name;
@@ -661,10 +664,21 @@  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_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 */
+		if (odp_packet_has_ones_comp(pkt))
+			odp_valid_test_pktio_u64 += odp_packet_ones_comp(pkt);
+
+		/* Dummy read to flow hash in case pktio has set it */
+		if (odp_packet_has_flow_hash(pkt))
+			odp_valid_test_pktio_u64 += odp_packet_flow_hash(pkt);
+
+		odp_packet_free(pkt);
 	}
 }