diff mbox series

[API-NEXT,v1,3/4] validation: packet: add num_pkt parameter to parse_test_alloc

Message ID 1533906007-732-4-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>


It's more robust to use a parameter instead of assuming that
a fixed number of packets are allocated.

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 | 47 ++++++++++++++---------------
 1 file changed, 23 insertions(+), 24 deletions(-)
diff mbox series

Patch

diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c
index a564c0028..4594260cf 100644
--- a/test/validation/api/packet/packet.c
+++ b/test/validation/api/packet/packet.c
@@ -2558,10 +2558,9 @@  static int packet_parse_suite_term(void)
 }
 
 static void parse_test_alloc(odp_packet_t pkt[], const uint8_t test_packet[],
-			     uint32_t len)
+			     uint32_t len, int num_pkt)
 {
 	int ret, i;
-	int num_pkt = PARSE_TEST_NUM_PKT;
 
 	ret = odp_packet_alloc_multi(parse_test.pool, len, pkt, num_pkt);
 	CU_ASSERT_FATAL(ret == num_pkt);
@@ -2582,7 +2581,7 @@  static void parse_eth_ipv4_udp(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_ipv4_udp,
-			 sizeof(test_packet_ipv4_udp));
+			 sizeof(test_packet_ipv4_udp), num_pkt);
 
 	for (i = 0; i < num_pkt; i++) {
 		chksum_status = odp_packet_l3_chksum_status(pkt[i]);
@@ -2626,7 +2625,7 @@  static void parse_ipv4_udp(void)
 	uint32_t offset[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_ipv4_udp,
-			 sizeof(test_packet_ipv4_udp));
+			 sizeof(test_packet_ipv4_udp), num_pkt);
 
 	for (i = 0; i < num_pkt; i++)
 		offset[i] = 14;
@@ -2662,7 +2661,7 @@  static void parse_eth_ipv4_tcp(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_ipv4_tcp,
-			 sizeof(test_packet_ipv4_tcp));
+			 sizeof(test_packet_ipv4_tcp), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -2698,7 +2697,7 @@  static void parse_eth_ipv6_udp(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_ipv6_udp,
-			 sizeof(test_packet_ipv6_udp));
+			 sizeof(test_packet_ipv6_udp), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -2728,7 +2727,7 @@  static void parse_eth_ipv6_tcp(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_ipv6_tcp,
-			 sizeof(test_packet_ipv6_tcp));
+			 sizeof(test_packet_ipv6_tcp), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_ALL;
@@ -2758,7 +2757,7 @@  static void parse_eth_vlan_ipv4_udp(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_vlan_ipv4_udp,
-			 sizeof(test_packet_vlan_ipv4_udp));
+			 sizeof(test_packet_vlan_ipv4_udp), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -2789,7 +2788,7 @@  static void parse_eth_vlan_ipv6_udp(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_vlan_ipv6_udp,
-			 sizeof(test_packet_vlan_ipv6_udp));
+			 sizeof(test_packet_vlan_ipv6_udp), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -2826,7 +2825,7 @@  static void parse_eth_vlan_qinq_ipv4_udp(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_vlan_qinq_ipv4_udp,
-			 sizeof(test_packet_vlan_qinq_ipv4_udp));
+			 sizeof(test_packet_vlan_qinq_ipv4_udp), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -2858,7 +2857,7 @@  static void parse_eth_arp(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_arp,
-			 sizeof(test_packet_arp));
+			 sizeof(test_packet_arp), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -2890,7 +2889,7 @@  static void parse_eth_ipv4_icmp(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_ipv4_icmp,
-			 sizeof(test_packet_ipv4_icmp));
+			 sizeof(test_packet_ipv4_icmp), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -2921,7 +2920,7 @@  static void parse_eth_ipv6_icmp(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_ipv6_icmp,
-			 sizeof(test_packet_ipv6_icmp));
+			 sizeof(test_packet_ipv6_icmp), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -2952,7 +2951,7 @@  static void parse_eth_ipv4_sctp(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_ipv4_sctp,
-			 sizeof(test_packet_ipv4_sctp));
+			 sizeof(test_packet_ipv4_sctp), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -2983,7 +2982,7 @@  static void parse_eth_ipv4_ipsec_ah(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_ipv4_ipsec_ah,
-			 sizeof(test_packet_ipv4_ipsec_ah));
+			 sizeof(test_packet_ipv4_ipsec_ah), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -3014,7 +3013,7 @@  static void parse_eth_ipv4_ipsec_esp(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_ipv4_ipsec_esp,
-			 sizeof(test_packet_ipv4_ipsec_esp));
+			 sizeof(test_packet_ipv4_ipsec_esp), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -3045,7 +3044,7 @@  static void parse_eth_ipv6_ipsec_ah(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_ipv6_ipsec_ah,
-			 sizeof(test_packet_ipv6_ipsec_ah));
+			 sizeof(test_packet_ipv6_ipsec_ah), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -3082,7 +3081,7 @@  static void parse_eth_ipv6_ipsec_esp(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_ipv6_ipsec_esp,
-			 sizeof(test_packet_ipv6_ipsec_esp));
+			 sizeof(test_packet_ipv6_ipsec_esp), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -3113,7 +3112,7 @@  static void parse_mcast_eth_ipv4_udp(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_mcast_eth_ipv4_udp,
-			 sizeof(test_packet_mcast_eth_ipv4_udp));
+			 sizeof(test_packet_mcast_eth_ipv4_udp), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -3147,7 +3146,7 @@  static void parse_bcast_eth_ipv4_udp(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_bcast_eth_ipv4_udp,
-			 sizeof(test_packet_bcast_eth_ipv4_udp));
+			 sizeof(test_packet_bcast_eth_ipv4_udp), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -3182,7 +3181,7 @@  static void parse_mcast_eth_ipv6_udp(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_mcast_eth_ipv6_udp,
-			 sizeof(test_packet_mcast_eth_ipv6_udp));
+			 sizeof(test_packet_mcast_eth_ipv6_udp), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -3216,7 +3215,7 @@  static void parse_eth_ipv4_udp_first_frag(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_ipv4_udp_first_frag,
-			 sizeof(test_packet_ipv4_udp_first_frag));
+			 sizeof(test_packet_ipv4_udp_first_frag), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -3248,7 +3247,7 @@  static void parse_eth_ipv4_udp_last_frag(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_ipv4_udp_last_frag,
-			 sizeof(test_packet_ipv4_udp_last_frag));
+			 sizeof(test_packet_ipv4_udp_last_frag), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;
@@ -3280,7 +3279,7 @@  static void parse_eth_ipv4_rr_nop_icmp(void)
 	odp_packet_t pkt[num_pkt];
 
 	parse_test_alloc(pkt, test_packet_ipv4_rr_nop_icmp,
-			 sizeof(test_packet_ipv4_rr_nop_icmp));
+			 sizeof(test_packet_ipv4_rr_nop_icmp), num_pkt);
 
 	parse.proto = ODP_PROTO_ETH;
 	parse.last_layer = ODP_PROTO_LAYER_L4;