diff mbox series

[API-NEXT,v1,4/4] validation: packet: add parse result test

Message ID 1533906007-732-5-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v1,1/4] api: packet: add parse result call | expand

Commit Message

Github ODP bot Aug. 10, 2018, 1 p.m. UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


Test new parse result functions.

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

---
/** Email created from pull request 672 (psavol:next-packet-metadata)
 ** https://github.com/Linaro/odp/pull/672
 ** Patch: https://github.com/Linaro/odp/pull/672.patch
 ** Base sha: 9b2b5a9695ad66977c964c83691cd2fef4c45b85
 ** Merge commit sha: 2f50c6c282fb183ddbc4628815da441de53deea0
 **/
 test/validation/api/packet/packet.c | 109 ++++++++++++++++++++++++++++
 1 file changed, 109 insertions(+)
diff mbox series

Patch

diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c
index 4594260cf..29581fc8d 100644
--- a/test/validation/api/packet/packet.c
+++ b/test/validation/api/packet/packet.c
@@ -3303,6 +3303,114 @@  static void parse_eth_ipv4_rr_nop_icmp(void)
 	odp_packet_free_multi(pkt, num_pkt);
 }
 
+static void parse_result(void)
+{
+	odp_packet_parse_param_t parse;
+	int i;
+	int num_pkt = PARSE_TEST_NUM_PKT;
+	odp_packet_t pkt[num_pkt];
+	odp_packet_parse_result_t result[num_pkt];
+	odp_packet_parse_result_t *result_ptr[num_pkt];
+
+	/* Ethernet/VLAN/IPv6/UDP */
+	parse_test_alloc(pkt, test_packet_vlan_ipv6_udp,
+			 sizeof(test_packet_vlan_ipv6_udp), num_pkt);
+
+	parse.proto = ODP_PROTO_ETH;
+	parse.last_layer = ODP_PROTO_LAYER_ALL;
+	parse.chksums.all_chksum = 0;
+
+	CU_ASSERT(odp_packet_parse(pkt[0], 0, &parse) == 0);
+	CU_ASSERT(odp_packet_parse_multi(&pkt[1], parse_test.offset_zero,
+					 num_pkt - 1, &parse) == (num_pkt - 1));
+
+	for (i = 0; i < num_pkt; i++) {
+		result_ptr[i] = &result[i];
+		memset(&result[i], 0, sizeof(odp_packet_parse_result_t));
+	}
+
+	odp_packet_parse_result(pkt[0], result_ptr[0]);
+	odp_packet_parse_result_multi(&pkt[1], &result_ptr[1], num_pkt - 1);
+
+	for (i = 0; i < num_pkt; i++) {
+		CU_ASSERT(odp_packet_has_eth(pkt[i]));
+		CU_ASSERT(odp_packet_has_vlan(pkt[i]));
+		CU_ASSERT(odp_packet_has_ipv6(pkt[i]));
+		CU_ASSERT(odp_packet_has_udp(pkt[i]));
+		CU_ASSERT(!odp_packet_has_ipv4(pkt[i]));
+		CU_ASSERT(!odp_packet_has_tcp(pkt[i]));
+		CU_ASSERT(odp_packet_l2_type(pkt[i]) == ODP_PROTO_L2_TYPE_ETH);
+		CU_ASSERT(odp_packet_l3_type(pkt[i]) == ODP_PROTO_L3_TYPE_IPV6);
+		CU_ASSERT(odp_packet_l4_type(pkt[i]) == ODP_PROTO_L4_TYPE_UDP);
+
+		CU_ASSERT(result[i].flag.all != 0);
+		CU_ASSERT(result[i].flag.has_error ==
+			  odp_packet_has_error(pkt[i]));
+		CU_ASSERT(result[i].flag.has_l2_error ==
+			  odp_packet_has_l2_error(pkt[i]));
+		CU_ASSERT(result[i].flag.has_l3_error ==
+			  odp_packet_has_l3_error(pkt[i]));
+		CU_ASSERT(result[i].flag.has_l4_error ==
+			  odp_packet_has_l4_error(pkt[i]));
+		CU_ASSERT(result[i].flag.has_l2 ==
+			  odp_packet_has_l2(pkt[i]));
+		CU_ASSERT(result[i].flag.has_l3 ==
+			  odp_packet_has_l3(pkt[i]));
+		CU_ASSERT(result[i].flag.has_l4 ==
+			  odp_packet_has_l4(pkt[i]));
+		CU_ASSERT(result[i].flag.has_eth ==
+			  odp_packet_has_eth(pkt[i]));
+		CU_ASSERT(result[i].flag.has_eth_bcast ==
+			  odp_packet_has_eth_bcast(pkt[i]));
+		CU_ASSERT(result[i].flag.has_eth_mcast ==
+			  odp_packet_has_eth_mcast(pkt[i]));
+		CU_ASSERT(result[i].flag.has_jumbo ==
+			  odp_packet_has_jumbo(pkt[i]));
+		CU_ASSERT(result[i].flag.has_vlan ==
+			  odp_packet_has_vlan(pkt[i]));
+		CU_ASSERT(result[i].flag.has_vlan_qinq ==
+			  odp_packet_has_vlan_qinq(pkt[i]));
+		CU_ASSERT(result[i].flag.has_arp ==
+			  odp_packet_has_arp(pkt[i]));
+		CU_ASSERT(result[i].flag.has_ipv4 ==
+			  odp_packet_has_ipv4(pkt[i]));
+		CU_ASSERT(result[i].flag.has_ipv6 ==
+			  odp_packet_has_ipv6(pkt[i]));
+		CU_ASSERT(result[i].flag.has_ip_bcast ==
+			  odp_packet_has_ip_bcast(pkt[i]));
+		CU_ASSERT(result[i].flag.has_ip_mcast ==
+			  odp_packet_has_ip_mcast(pkt[i]));
+		CU_ASSERT(result[i].flag.has_ipfrag ==
+			  odp_packet_has_ipfrag(pkt[i]));
+		CU_ASSERT(result[i].flag.has_ipopt ==
+			  odp_packet_has_ipopt(pkt[i]));
+		CU_ASSERT(result[i].flag.has_ipsec ==
+			  odp_packet_has_ipsec(pkt[i]));
+		CU_ASSERT(result[i].flag.has_udp ==
+			  odp_packet_has_udp(pkt[i]));
+		CU_ASSERT(result[i].flag.has_tcp ==
+			  odp_packet_has_tcp(pkt[i]));
+		CU_ASSERT(result[i].flag.has_sctp ==
+			  odp_packet_has_sctp(pkt[i]));
+		CU_ASSERT(result[i].flag.has_icmp ==
+			  odp_packet_has_icmp(pkt[i]));
+
+		CU_ASSERT(result[i].packet_len == odp_packet_len(pkt[i]));
+		CU_ASSERT(result[i].l2_offset == odp_packet_l2_offset(pkt[i]));
+		CU_ASSERT(result[i].l3_offset == odp_packet_l3_offset(pkt[i]));
+		CU_ASSERT(result[i].l4_offset == odp_packet_l4_offset(pkt[i]));
+		CU_ASSERT(result[i].l3_chksum_status ==
+			  odp_packet_l3_chksum_status(pkt[i]));
+		CU_ASSERT(result[i].l4_chksum_status ==
+			  odp_packet_l4_chksum_status(pkt[i]));
+		CU_ASSERT(result[i].l2_type == odp_packet_l2_type(pkt[i]));
+		CU_ASSERT(result[i].l3_type == odp_packet_l3_type(pkt[i]));
+		CU_ASSERT(result[i].l4_type == odp_packet_l4_type(pkt[i]));
+	}
+
+	odp_packet_free_multi(pkt, num_pkt);
+}
+
 odp_testinfo_t packet_suite[] = {
 	ODP_TEST_INFO(packet_test_alloc_free),
 	ODP_TEST_INFO(packet_test_alloc_free_multi),
@@ -3360,6 +3468,7 @@  odp_testinfo_t packet_parse_suite[] = {
 	ODP_TEST_INFO(parse_eth_ipv4_udp_first_frag),
 	ODP_TEST_INFO(parse_eth_ipv4_udp_last_frag),
 	ODP_TEST_INFO(parse_eth_ipv4_rr_nop_icmp),
+	ODP_TEST_INFO(parse_result),
 	ODP_TEST_INFO_NULL,
 };