This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, master has been updated via 6ea9400bfcc7497ea8f9d2fd8cc3b77936c71d0b (commit) via 18462171eb83f9b6f867812629f7e89998bc6e1a (commit) via c976a3146724bd0d09bcad2bd83810c300bf8ad5 (commit) via 9805209384a5f40210b5f57c1f7a67e83f07fb99 (commit) via 67b1d6ed0e5a318f6913f96f9d427df5799317e9 (commit) via 22866cc9df76230750b8ce5504d948ed78a727a2 (commit) via ab78f2924a353d4e0e45deea73201e6da10a7664 (commit) from 41b3fa2cd994a7ef68290a07dcde5564e4640847 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit 6ea9400bfcc7497ea8f9d2fd8cc3b77936c71d0b Author: Petri Savolainen petri.savolainen@linaro.org Date: Tue Feb 13 14:00:54 2018 +0200
validation: packet: add IP multicast tests
Added test cases for Ethernet/IP multi- and broadcasts.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/common/test_packet_parser.h b/test/common/test_packet_parser.h index b7d02113..d0a0582a 100644 --- a/test/common/test_packet_parser.h +++ b/test/common/test_packet_parser.h @@ -333,6 +333,62 @@ static const uint8_t test_packet_ipv6_ipsec_esp[] = { 0x88, 0x37, 0x65, 0xab, 0x0d, 0xe9, 0x95, 0x3b };
+static const uint8_t test_packet_mcast_eth_ipv4_udp[] = { + 0x03, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x02, 0x00, + 0x00, 0x03, 0x04, 0x05, 0x08, 0x00, 0x45, 0x00, + 0x00, 0x63, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11, + 0xC8, 0xDB, 0xC0, 0xA8, 0x00, 0x01, 0xEF, 0x01, + 0x02, 0x03, 0x04, 0xD2, 0x16, 0x2E, 0x00, 0x4F, + 0x25, 0x61, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, + 0x73, 0x20, 0x6D, 0x79, 0x20, 0x64, 0x75, 0x6D, + 0x6D, 0x79, 0x20, 0x70, 0x61, 0x79, 0x6C, 0x6F, + 0x61, 0x64, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6E, + 0x67, 0x2E, 0x20, 0x54, 0x68, 0x65, 0x20, 0x6C, + 0x65, 0x6E, 0x67, 0x74, 0x68, 0x20, 0x6F, 0x66, + 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x73, 0x74, + 0x72, 0x69, 0x6E, 0x67, 0x20, 0x69, 0x73, 0x20, + 0x37, 0x31, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, + 0x2E +}; + +static const uint8_t test_packet_bcast_eth_ipv4_udp[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x02, 0x00, + 0x00, 0x03, 0x04, 0x05, 0x08, 0x00, 0x45, 0x00, + 0x00, 0x63, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11, + 0xB9, 0xE0, 0xC0, 0xA8, 0x00, 0x01, 0xFF, 0xFF, + 0xFF, 0xFF, 0x04, 0xD2, 0x16, 0x2E, 0x00, 0x4F, + 0x16, 0x66, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, + 0x73, 0x20, 0x6D, 0x79, 0x20, 0x64, 0x75, 0x6D, + 0x6D, 0x79, 0x20, 0x70, 0x61, 0x79, 0x6C, 0x6F, + 0x61, 0x64, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6E, + 0x67, 0x2E, 0x20, 0x54, 0x68, 0x65, 0x20, 0x6C, + 0x65, 0x6E, 0x67, 0x74, 0x68, 0x20, 0x6F, 0x66, + 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x73, 0x74, + 0x72, 0x69, 0x6E, 0x67, 0x20, 0x69, 0x73, 0x20, + 0x37, 0x31, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, + 0x2E +}; + +static const uint8_t test_packet_mcast_eth_ipv6_udp[] = { + 0x33, 0x33, 0x01, 0x02, 0x03, 0x04, 0x02, 0x00, + 0x00, 0x03, 0x04, 0x05, 0x86, 0xDD, 0x60, 0x00, + 0x00, 0x00, 0x00, 0x4F, 0x11, 0x40, 0xFE, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xFF, 0xFE, 0x03, 0x04, 0x05, 0xFF, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x04, 0xD2, + 0x16, 0x2E, 0x00, 0x4F, 0xD6, 0x79, 0x54, 0x68, + 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x6D, 0x79, + 0x20, 0x64, 0x75, 0x6D, 0x6D, 0x79, 0x20, 0x70, + 0x61, 0x79, 0x6C, 0x6F, 0x61, 0x64, 0x20, 0x73, + 0x74, 0x72, 0x69, 0x6E, 0x67, 0x2E, 0x20, 0x54, + 0x68, 0x65, 0x20, 0x6C, 0x65, 0x6E, 0x67, 0x74, + 0x68, 0x20, 0x6F, 0x66, 0x20, 0x74, 0x68, 0x69, + 0x73, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, + 0x20, 0x69, 0x73, 0x20, 0x37, 0x31, 0x20, 0x62, + 0x79, 0x74, 0x65, 0x73, 0x2E +}; + #ifdef __cplusplus } #endif diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index ccfe6e51..db3a47cf 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -65,7 +65,10 @@ static uint32_t parse_test_pkt_len[] = { sizeof(test_packet_ipv4_ipsec_ah), sizeof(test_packet_ipv4_ipsec_esp), sizeof(test_packet_ipv6_ipsec_ah), - sizeof(test_packet_ipv6_ipsec_esp) + sizeof(test_packet_ipv6_ipsec_esp), + sizeof(test_packet_mcast_eth_ipv4_udp), + sizeof(test_packet_bcast_eth_ipv4_udp), + sizeof(test_packet_mcast_eth_ipv6_udp) };
#define packet_compare_offset(pkt1, off1, pkt2, off2, len) \ @@ -3051,6 +3054,109 @@ static void parse_eth_ipv6_ipsec_esp(void) odp_packet_free_multi(pkt, num_pkt); }
+/* Ethernet mcast/IPv4 mcast/UDP */ +static void parse_mcast_eth_ipv4_udp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + + parse_test_alloc(pkt, test_packet_mcast_eth_ipv4_udp, + sizeof(test_packet_mcast_eth_ipv4_udp)); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_L4; + 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++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_eth_mcast(pkt[i])); + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_ip_mcast(pkt[i])); + CU_ASSERT(odp_packet_has_udp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_eth_bcast(pkt[i])); + CU_ASSERT(!odp_packet_has_ip_bcast(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + +/* Ethernet bcast/IPv4 bcast/UDP */ +static void parse_bcast_eth_ipv4_udp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + + parse_test_alloc(pkt, test_packet_bcast_eth_ipv4_udp, + sizeof(test_packet_bcast_eth_ipv4_udp)); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_L4; + 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++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_eth_bcast(pkt[i])); + /* API specifies that Ethernet broadcast is also multicast */ + CU_ASSERT(odp_packet_has_eth_mcast(pkt[i])); + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_ip_bcast(pkt[i])); + CU_ASSERT(odp_packet_has_udp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_ip_mcast(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + +/* Ethernet mcast/IPv6 mcast/UDP */ +static void parse_mcast_eth_ipv6_udp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + + parse_test_alloc(pkt, test_packet_mcast_eth_ipv6_udp, + sizeof(test_packet_mcast_eth_ipv6_udp)); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_L4; + 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++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_eth_mcast(pkt[i])); + CU_ASSERT(odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(odp_packet_has_ip_mcast(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_has_eth_bcast(pkt[i])); + CU_ASSERT(!odp_packet_has_ip_bcast(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), @@ -3102,6 +3208,9 @@ odp_testinfo_t packet_parse_suite[] = { ODP_TEST_INFO(parse_eth_ipv4_ipsec_esp), ODP_TEST_INFO(parse_eth_ipv6_ipsec_ah), ODP_TEST_INFO(parse_eth_ipv6_ipsec_esp), + ODP_TEST_INFO(parse_mcast_eth_ipv4_udp), + ODP_TEST_INFO(parse_bcast_eth_ipv4_udp), + ODP_TEST_INFO(parse_mcast_eth_ipv6_udp), ODP_TEST_INFO_NULL, };
commit 18462171eb83f9b6f867812629f7e89998bc6e1a Author: Petri Savolainen petri.savolainen@linaro.org Date: Tue Feb 13 14:02:14 2018 +0200
linux-gen: packet: fix IP multicast parse
IPv4 multicast address range is between 224.0.0.0 and 239.255.255.255. So, first four bits are always 0xe (1110).
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index b2a22903..05b8c485 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -2028,7 +2028,7 @@ static inline uint8_t parse_ipv4(packet_parser_t *prs, const uint8_t **parseptr, if (odp_unlikely(dstaddr == 0xffffffff)) prs->input_flags.ip_bcast = 1;
- if (odp_unlikely((dstaddr >> 28) == 0xd)) + if (odp_unlikely((dstaddr >> 28) == 0xe)) prs->input_flags.ip_mcast = 1;
return ipv4->proto;
commit c976a3146724bd0d09bcad2bd83810c300bf8ad5 Author: Petri Savolainen petri.savolainen@linaro.org Date: Tue Feb 13 11:03:27 2018 +0200
validation: packet: add IPSEC parse test
Added test cases for IPSEC. AH and ESP headers with both IP versions.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/common/test_packet_parser.h b/test/common/test_packet_parser.h index 22c7e6c5..b7d02113 100644 --- a/test/common/test_packet_parser.h +++ b/test/common/test_packet_parser.h @@ -168,6 +168,171 @@ static const uint8_t test_packet_ipv4_sctp[] = { 0x79, 0x74, 0x65, 0x73, 0x2E };
+static const uint8_t test_packet_ipv4_ipsec_ah[] = { + /* ETH */ + 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, + 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x08, 0x00, + + /* IPv4 */ + 0x45, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x33, 0xab, 0xd9, 0xc0, 0xa8, 0x6f, 0x02, + 0xc0, 0xa8, 0xde, 0x02, + + /* AH */ + 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, + 0x00, 0x00, 0x00, 0x01, + 0x6c, 0x2e, 0xf7, 0x1f, 0x7c, 0x70, 0x39, 0xa3, + 0x4a, 0x77, 0x01, 0x47, 0x9e, 0x45, 0x73, 0x51, + + /* ICMP */ + 0x08, 0x00, 0xfb, 0x37, 0x12, 0x34, 0x00, 0x00, + 0xba, 0xbe, 0x01, 0x23, 0x45, 0x67, 0xca, 0xfe, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b +}; + +static const uint8_t test_packet_ipv4_ipsec_esp[] = { + /* ETH */ + 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, + 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x08, 0x00, + + /* IPv4 */ + 0x45, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x32, 0x19, 0x18, 0x0a, 0x00, 0x6f, 0x02, + 0x0a, 0x00, 0xde, 0x02, + + /* ESP */ + 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x01, + + /* IPv4 */ + 0x45, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x01, 0xac, 0x27, 0xc0, 0xa8, 0x6f, 0x02, + 0xc0, 0xa8, 0xde, 0x02, + + /* ICMP */ + 0x08, 0x00, 0xfb, 0x37, 0x12, 0x34, 0x00, 0x00, + 0xba, 0xbe, 0x01, 0x23, 0x45, 0x67, 0xca, 0xfe, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, + + /* ESP TRL */ + 0x01, 0x02, 0x02, 0x04, + + /* ICV */ + 0x73, 0x8d, 0xf6, 0x9a, 0x26, 0x06, 0x4d, 0xa1, + 0x88, 0x37, 0x65, 0xab, 0x0d, 0xe9, 0x95, 0x3b +}; + +static const uint8_t test_packet_ipv6_ipsec_ah[] = { + /* ETH */ + 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, + 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x86, 0xdd, + + /* IPv6 */ + 0x60, 0x00, 0x00, 0x00, 0x00, 0xbc, 0x33, 0x40, + 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x11, 0x43, 0xff, 0xfe, 0x4a, 0xd7, 0x0a, + 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, + + /* AH */ + 0x29, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, + 0x00, 0x00, 0x00, 0x01, + 0x62, 0x96, 0x2b, 0x40, 0x3e, 0x53, 0x76, 0x4a, + 0x4d, 0x7f, 0xf6, 0x22, 0x35, 0x3c, 0x74, 0xe2, + 0x00, 0x00, 0x00, 0x00, + + /* IPv6 */ + 0x60, 0x00, 0x00, 0x00, 0x00, 0x74, 0x00, 0x40, + 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x11, 0x43, 0xff, 0xfe, 0x4a, 0xd7, 0x0a, + 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, + + /* Hop-by-Hop */ + 0x3a, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, + + /* ICMP */ + 0x08, 0x00, 0xfb, 0x37, 0x12, 0x34, 0x00, 0x00, + 0xba, 0xbe, 0x01, 0x23, 0x45, 0x67, 0xca, 0xfe, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b +}; + +static const uint8_t test_packet_ipv6_ipsec_esp[] = { + /* ETH */ + 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, + 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x86, 0xdd, + + /* IPv6 */ + 0x60, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x32, 0x40, + 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x11, 0x43, 0xff, 0xfe, 0x4a, 0xd7, 0x0a, + 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, + + /* ESP */ + 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x01, + + /* IPv4 */ + 0x45, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x01, 0xac, 0x27, 0xc0, 0xa8, 0x6f, 0x02, + 0xc0, 0xa8, 0xde, 0x02, + + /* ICMP */ + 0x08, 0x00, 0xfb, 0x37, 0x12, 0x34, 0x00, 0x00, + 0xba, 0xbe, 0x01, 0x23, 0x45, 0x67, 0xca, 0xfe, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, + + /* ESP TRL */ + 0x01, 0x02, 0x02, 0x04, + + /* ICV */ + 0x73, 0x8d, 0xf6, 0x9a, 0x26, 0x06, 0x4d, 0xa1, + 0x88, 0x37, 0x65, 0xab, 0x0d, 0xe9, 0x95, 0x3b +}; + #ifdef __cplusplus } #endif diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index ad552040..ccfe6e51 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -61,7 +61,11 @@ static uint32_t parse_test_pkt_len[] = { sizeof(test_packet_ipv6_tcp), sizeof(test_packet_ipv6_udp), sizeof(test_packet_vlan_ipv6_udp), - sizeof(test_packet_ipv4_sctp) + sizeof(test_packet_ipv4_sctp), + sizeof(test_packet_ipv4_ipsec_ah), + sizeof(test_packet_ipv4_ipsec_esp), + sizeof(test_packet_ipv6_ipsec_ah), + sizeof(test_packet_ipv6_ipsec_esp) };
#define packet_compare_offset(pkt1, off1, pkt2, off2, len) \ @@ -2923,6 +2927,130 @@ static void parse_eth_ipv4_sctp(void) odp_packet_free_multi(pkt, num_pkt); }
+/* Ethernet/IPv4/IPSEC AH*/ +static void parse_eth_ipv4_ipsec_ah(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + + parse_test_alloc(pkt, test_packet_ipv4_ipsec_ah, + sizeof(test_packet_ipv4_ipsec_ah)); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_L4; + 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++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_ipsec(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_udp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + +/* Ethernet/IPv4/IPSEC ESP*/ +static void parse_eth_ipv4_ipsec_esp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + + parse_test_alloc(pkt, test_packet_ipv4_ipsec_esp, + sizeof(test_packet_ipv4_ipsec_esp)); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_L4; + 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++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_ipsec(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_udp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + +/* Ethernet/IPv6/IPSEC AH*/ +static void parse_eth_ipv6_ipsec_ah(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + + parse_test_alloc(pkt, test_packet_ipv6_ipsec_ah, + sizeof(test_packet_ipv6_ipsec_ah)); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_L4; + 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++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(odp_packet_has_ipsec(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_udp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + +/* Ethernet/IPv6/IPSEC ESP*/ +static void parse_eth_ipv6_ipsec_esp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + + parse_test_alloc(pkt, test_packet_ipv6_ipsec_esp, + sizeof(test_packet_ipv6_ipsec_esp)); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_L4; + 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++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(odp_packet_has_ipsec(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_udp(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), @@ -2970,6 +3098,10 @@ odp_testinfo_t packet_parse_suite[] = { ODP_TEST_INFO(parse_eth_ipv4_icmp), ODP_TEST_INFO(parse_eth_ipv6_icmp), ODP_TEST_INFO(parse_eth_ipv4_sctp), + ODP_TEST_INFO(parse_eth_ipv4_ipsec_ah), + ODP_TEST_INFO(parse_eth_ipv4_ipsec_esp), + ODP_TEST_INFO(parse_eth_ipv6_ipsec_ah), + ODP_TEST_INFO(parse_eth_ipv6_ipsec_esp), ODP_TEST_INFO_NULL, };
commit 9805209384a5f40210b5f57c1f7a67e83f07fb99 Author: Petri Savolainen petri.savolainen@linaro.org Date: Mon Feb 12 15:32:16 2018 +0200
validation: packet: add IPv4 SCTP parse test
Added test for IPv4 / SCTP packet with payload data chunk type.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/common/test_packet_parser.h b/test/common/test_packet_parser.h index 918e0ad6..22c7e6c5 100644 --- a/test/common/test_packet_parser.h +++ b/test/common/test_packet_parser.h @@ -4,12 +4,6 @@ * SPDX-License-Identifier: BSD-3-Clause */
-/** - * @file - * - * Test packets for parser tests - */ - #ifndef TEST_PACKET_PARSER_H_ #define TEST_PACKET_PARSER_H_
@@ -21,9 +15,7 @@ extern "C" {
/* Test packets without CRC */
-/** - * ARP request - */ +/* ARP request */ static const uint8_t test_packet_arp[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x09, 0x00, 0x04, 0x00, 0x08, 0x06, 0x00, 0x01, @@ -35,9 +27,7 @@ static const uint8_t test_packet_arp[] = { 0x0E, 0x0F, 0x10, 0x11 };
-/** - * ICMPv4 echo reply - */ +/* ICMPv4 echo reply */ static const uint8_t test_packet_ipv4_icmp[] = { 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x00, 0x04, 0x00, 0x08, 0x00, 0x45, 0x00, @@ -49,9 +39,7 @@ static const uint8_t test_packet_ipv4_icmp[] = { 0x0E, 0x0F, 0x10, 0x11 };
-/** - * IPv4 TCP - */ +/* IPv4 TCP */ static const uint8_t test_packet_ipv4_tcp[] = { 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x00, 0x04, 0x00, 0x08, 0x00, 0x45, 0x00, @@ -63,9 +51,7 @@ static const uint8_t test_packet_ipv4_tcp[] = { 0x02, 0x03, 0x04, 0x05 };
-/** - * IPv4 UDP - */ +/* IPv4 UDP */ static const uint8_t test_packet_ipv4_udp[] = { 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x00, 0x04, 0x00, 0x08, 0x00, 0x45, 0x00, @@ -77,9 +63,8 @@ static const uint8_t test_packet_ipv4_udp[] = { 0x0E, 0x0F, 0x10, 0x11 };
-/** - * VLAN IPv4 UDP - * - ID: 23 +/* VLAN IPv4 UDP + * - type 0x8100, tag 23 */ static const uint8_t test_packet_vlan_ipv4_udp[] = { 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, @@ -92,10 +77,9 @@ static const uint8_t test_packet_vlan_ipv4_udp[] = { 0x0A, 0x0B, 0x0C, 0x0D };
-/** - * VLAN Q-in-Q IPv4 UDP - * - Outer: Tag Protocol ID 0x88a8, VLAN ID 1 - * - Inner: Tag Protocol ID 0x8100, VLAN ID 2 +/* VLAN Q-in-Q IPv4 UDP + * - Outer: type 0x88a8, tag 1 + * - Inner: type 0x8100, tag 2 */ static const uint8_t test_packet_vlan_qinq_ipv4_udp[] = { 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, @@ -108,9 +92,7 @@ static const uint8_t test_packet_vlan_qinq_ipv4_udp[] = { 0x06, 0x07, 0x08, 0x09 };
-/** - * ICMPv6 echo request - */ +/* ICMPv6 echo request */ static const uint8_t test_packet_ipv6_icmp[] = { 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x00, 0x04, 0x00, 0x86, 0xDD, 0x60, 0x30, @@ -122,9 +104,7 @@ static const uint8_t test_packet_ipv6_icmp[] = { 0x1B, 0xC2, 0x00, 0x01, 0x00, 0x02 };
-/** - * IPv6 TCP - */ +/* IPv6 TCP */ static const uint8_t test_packet_ipv6_tcp[] = { 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x00, 0x04, 0x00, 0x86, 0xDD, 0x60, 0x30, @@ -138,9 +118,7 @@ static const uint8_t test_packet_ipv6_tcp[] = { 0x00, 0x00 };
-/** - * IPv6 UDP - */ +/* IPv6 UDP */ static const uint8_t test_packet_ipv6_udp[] = { 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x00, 0x04, 0x00, 0x86, 0xDD, 0x60, 0x30, @@ -152,9 +130,8 @@ static const uint8_t test_packet_ipv6_udp[] = { 0x00, 0x3F, 0x00, 0x08, 0x9B, 0x68 };
-/** - * VLAN IPv6 - * - ID: 23 +/* VLAN IPv6 + * - type 0x8100, tag 23 */ static const uint8_t test_packet_vlan_ipv6_udp[] = { 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, @@ -168,6 +145,29 @@ static const uint8_t test_packet_vlan_ipv6_udp[] = { 0x9B, 0x68 };
+/* IPv4 SCTP + * - chunk type: payload data + */ +static const uint8_t test_packet_ipv4_sctp[] = { + 0x00, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x00, 0x01, + 0x02, 0x03, 0x04, 0x05, 0x08, 0x00, 0x45, 0x00, + 0x00, 0x77, 0x00, 0x01, 0x00, 0x00, 0x40, 0x84, + 0xF8, 0xAE, 0xC0, 0xA8, 0x00, 0x01, 0xC0, 0xA8, + 0x00, 0x02, 0x04, 0xD2, 0x16, 0x2E, 0xDE, 0xAD, + 0xBE, 0xEF, 0x31, 0x44, 0xE3, 0xFE, 0x00, 0x00, + 0x00, 0x57, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x68, + 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x6D, 0x79, + 0x20, 0x64, 0x75, 0x6D, 0x6D, 0x79, 0x20, 0x70, + 0x61, 0x79, 0x6C, 0x6F, 0x61, 0x64, 0x20, 0x73, + 0x74, 0x72, 0x69, 0x6E, 0x67, 0x2E, 0x20, 0x54, + 0x68, 0x65, 0x20, 0x6C, 0x65, 0x6E, 0x67, 0x74, + 0x68, 0x20, 0x6F, 0x66, 0x20, 0x74, 0x68, 0x69, + 0x73, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, + 0x20, 0x69, 0x73, 0x20, 0x37, 0x31, 0x20, 0x62, + 0x79, 0x74, 0x65, 0x73, 0x2E +}; + #ifdef __cplusplus } #endif diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index ea7e89b2..ad552040 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -60,7 +60,8 @@ static uint32_t parse_test_pkt_len[] = { sizeof(test_packet_ipv6_icmp), sizeof(test_packet_ipv6_tcp), sizeof(test_packet_ipv6_udp), - sizeof(test_packet_vlan_ipv6_udp) + sizeof(test_packet_vlan_ipv6_udp), + sizeof(test_packet_ipv4_sctp) };
#define packet_compare_offset(pkt1, off1, pkt2, off2, len) \ @@ -2891,6 +2892,37 @@ static void parse_eth_ipv6_icmp(void) odp_packet_free_multi(pkt, num_pkt); }
+/* Ethernet/IPv4/SCTP */ +static void parse_eth_ipv4_sctp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + + parse_test_alloc(pkt, test_packet_ipv4_sctp, + sizeof(test_packet_ipv4_sctp)); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_L4; + 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++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_sctp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_udp(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), @@ -2937,6 +2969,7 @@ odp_testinfo_t packet_parse_suite[] = { ODP_TEST_INFO(parse_eth_arp), ODP_TEST_INFO(parse_eth_ipv4_icmp), ODP_TEST_INFO(parse_eth_ipv6_icmp), + ODP_TEST_INFO(parse_eth_ipv4_sctp), ODP_TEST_INFO_NULL, };
commit 67b1d6ed0e5a318f6913f96f9d427df5799317e9 Author: Petri Savolainen petri.savolainen@linaro.org Date: Mon Feb 12 14:52:37 2018 +0200
validation: packet: add parser test cases
Add remaining test cases for packet formats already defined in test_packet_parser.h file.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index 05ec2b55..ea7e89b2 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -2633,6 +2633,7 @@ static void parse_eth_ipv4_tcp(void) num_pkt - 1, &parse) == (num_pkt - 1));
for (i = 0; i < num_pkt; i++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); CU_ASSERT(odp_packet_has_ipv4(pkt[i])); CU_ASSERT(odp_packet_has_tcp(pkt[i])); CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); @@ -2702,6 +2703,194 @@ static void parse_eth_ipv6_tcp(void) odp_packet_free_multi(pkt, num_pkt); }
+/* Ethernet/VLAN/IPv4/UDP */ +static void parse_eth_vlan_ipv4_udp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + + parse_test_alloc(pkt, test_packet_vlan_ipv4_udp, + sizeof(test_packet_vlan_ipv4_udp)); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_L4; + 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++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_vlan(pkt[i])); + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_udp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + +/* Ethernet/VLAN/IPv6/UDP */ +static void parse_eth_vlan_ipv6_udp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + + parse_test_alloc(pkt, test_packet_vlan_ipv6_udp, + sizeof(test_packet_vlan_ipv6_udp)); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_L4; + 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++) { + 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])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + +/* Ethernet/VLAN/VLAN/IPv4/UDP */ +static void parse_eth_vlan_qinq_ipv4_udp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + + parse_test_alloc(pkt, test_packet_vlan_qinq_ipv4_udp, + sizeof(test_packet_vlan_qinq_ipv4_udp)); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_L4; + 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++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_vlan(pkt[i])); + CU_ASSERT(odp_packet_has_vlan_qinq(pkt[i])); + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_udp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + +/* Ethernet/ARP */ +static void parse_eth_arp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + + parse_test_alloc(pkt, test_packet_arp, + sizeof(test_packet_arp)); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_L4; + 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++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_eth_bcast(pkt[i])); + CU_ASSERT(odp_packet_has_arp(pkt[i])); + CU_ASSERT(!odp_packet_has_vlan(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_udp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + +/* Ethernet/IPv4/ICMP */ +static void parse_eth_ipv4_icmp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + + parse_test_alloc(pkt, test_packet_ipv4_icmp, + sizeof(test_packet_ipv4_icmp)); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_L4; + 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++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_icmp(pkt[i])); + CU_ASSERT(!odp_packet_has_eth_bcast(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + +/* Ethernet/IPv6/ICMP */ +static void parse_eth_ipv6_icmp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + + parse_test_alloc(pkt, test_packet_ipv6_icmp, + sizeof(test_packet_ipv6_icmp)); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_L4; + 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++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(odp_packet_has_icmp(pkt[i])); + CU_ASSERT(!odp_packet_has_eth_bcast(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(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), @@ -2742,6 +2931,12 @@ odp_testinfo_t packet_parse_suite[] = { ODP_TEST_INFO(parse_eth_ipv4_tcp), ODP_TEST_INFO(parse_eth_ipv6_udp), ODP_TEST_INFO(parse_eth_ipv6_tcp), + ODP_TEST_INFO(parse_eth_vlan_ipv4_udp), + ODP_TEST_INFO(parse_eth_vlan_ipv6_udp), + ODP_TEST_INFO(parse_eth_vlan_qinq_ipv4_udp), + ODP_TEST_INFO(parse_eth_arp), + ODP_TEST_INFO(parse_eth_ipv4_icmp), + ODP_TEST_INFO(parse_eth_ipv6_icmp), ODP_TEST_INFO_NULL, };
commit 22866cc9df76230750b8ce5504d948ed78a727a2 Author: Petri Savolainen petri.savolainen@linaro.org Date: Mon Feb 12 14:19:55 2018 +0200
validation: packet: create parse test suite
Move parse tests into own suite before adding new test cases. There will be many parse test cases as there are many combinations of good and bad packet formats.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index 1188c683..05ec2b55 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -23,6 +23,9 @@ ODP_STATIC_ASSERT(PACKET_POOL_NUM_SEG > 1 && PACKET_POOL_NUM_SEG < PACKET_POOL_NUM, "Invalid PACKET_POOL_NUM_SEG value");
+/* Number of packets in parse test */ +#define PARSE_TEST_NUM_PKT 10 + static odp_pool_t packet_pool, packet_pool_no_uarea, packet_pool_double_uarea; static uint32_t packet_len;
@@ -41,6 +44,25 @@ static struct udata_struct { "abcdefg", };
+static struct { + odp_pool_t pool; + odp_proto_chksums_t all_chksums; + uint32_t offset_zero[PARSE_TEST_NUM_PKT]; +} parse_test; + +static uint32_t parse_test_pkt_len[] = { + sizeof(test_packet_arp), + sizeof(test_packet_ipv4_icmp), + sizeof(test_packet_ipv4_tcp), + sizeof(test_packet_ipv4_udp), + sizeof(test_packet_vlan_ipv4_udp), + sizeof(test_packet_vlan_qinq_ipv4_udp), + sizeof(test_packet_ipv6_icmp), + sizeof(test_packet_ipv6_tcp), + sizeof(test_packet_ipv6_udp), + sizeof(test_packet_vlan_ipv6_udp) +}; + #define packet_compare_offset(pkt1, off1, pkt2, off2, len) \ _packet_compare_offset((pkt1), (off1), (pkt2), (off2), (len), __LINE__)
@@ -2459,41 +2481,18 @@ void packet_test_ref(void) odp_packet_free(ref_pkt[1]); }
-void packet_test_parse(void) +static int packet_parse_suite_init(void) { - odp_pool_t pool; + int num_test_pkt, i; + uint32_t max_len; odp_pool_param_t param; - odp_packet_parse_param_t parse; - int ret, num_test_pkt, i; - uint32_t len, max_len; - odp_packet_chksum_status_t chksum_status; - odp_proto_chksums_t all_chksums; - int num_pkt = 10; - odp_packet_t pkt[num_pkt]; - uint32_t offset[num_pkt]; - uint32_t test_pkt_len[] = {sizeof(test_packet_arp), - sizeof(test_packet_ipv4_icmp), - sizeof(test_packet_ipv4_tcp), - sizeof(test_packet_ipv4_udp), - sizeof(test_packet_vlan_ipv4_udp), - sizeof(test_packet_vlan_qinq_ipv4_udp), - sizeof(test_packet_ipv6_icmp), - sizeof(test_packet_ipv6_tcp), - sizeof(test_packet_ipv6_udp), - sizeof(test_packet_vlan_ipv6_udp) }; - - all_chksums.all_chksum = 0; - all_chksums.chksum.ipv4 = 1; - all_chksums.chksum.udp = 1; - all_chksums.chksum.tcp = 1; - all_chksums.chksum.sctp = 1; - - num_test_pkt = sizeof(test_pkt_len) / sizeof(uint32_t); + + num_test_pkt = sizeof(parse_test_pkt_len) / sizeof(uint32_t); max_len = 0;
for (i = 0; i < num_test_pkt; i++) { - if (max_len < test_pkt_len[i]) - max_len = test_pkt_len[i]; + if (max_len < parse_test_pkt_len[i]) + max_len = parse_test_pkt_len[i]; }
odp_pool_param_init(¶m); @@ -2503,21 +2502,59 @@ void packet_test_parse(void) param.pkt.len = max_len; param.pkt.num = 100;
- pool = odp_pool_create("test_parse_pool", ¶m); - CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + parse_test.pool = odp_pool_create("parse_test_pool", ¶m); + + if (parse_test.pool == ODP_POOL_INVALID) + return -1; + + parse_test.all_chksums.all_chksum = 0; + parse_test.all_chksums.chksum.ipv4 = 1; + parse_test.all_chksums.chksum.udp = 1; + parse_test.all_chksums.chksum.tcp = 1; + parse_test.all_chksums.chksum.sctp = 1; + + for (i = 0; i < PARSE_TEST_NUM_PKT; i++) + parse_test.offset_zero[i] = 0; + + return 0; +} + +static int packet_parse_suite_term(void) +{ + if (odp_pool_destroy(parse_test.pool)) + return -1;
- /* Ethernet/IPv4/UDP */ - len = sizeof(test_packet_ipv4_udp); - ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); + return 0; +} + +static void parse_test_alloc(odp_packet_t pkt[], const uint8_t test_packet[], + uint32_t len) +{ + 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);
for (i = 0; i < num_pkt; i++) { - ret = odp_packet_copy_from_mem(pkt[i], 0, len, - test_packet_ipv4_udp); - CU_ASSERT(ret == 0); + ret = odp_packet_copy_from_mem(pkt[i], 0, len, test_packet); + CU_ASSERT_FATAL(ret == 0); + } +}
- offset[i] = 0; +/* Ethernet/IPv4/UDP */ +static void parse_eth_ipv4_udp(void) +{ + odp_packet_parse_param_t parse; + int i; + odp_packet_chksum_status_t chksum_status; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + + parse_test_alloc(pkt, test_packet_ipv4_udp, + sizeof(test_packet_ipv4_udp));
+ for (i = 0; i < num_pkt; i++) { chksum_status = odp_packet_l3_chksum_status(pkt[i]); CU_ASSERT(chksum_status == ODP_PACKET_CHKSUM_UNKNOWN); chksum_status = odp_packet_l4_chksum_status(pkt[i]); @@ -2526,10 +2563,10 @@ void packet_test_parse(void)
parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_ALL; - parse.chksums = all_chksums; + parse.chksums = parse_test.all_chksums;
- CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); - CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], + 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++) { @@ -2541,19 +2578,22 @@ void packet_test_parse(void) }
odp_packet_free_multi(pkt, num_pkt); +}
- /* IPv4/UDP */ - len = sizeof(test_packet_ipv4_udp); - ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); - CU_ASSERT_FATAL(ret == num_pkt); +/* IPv4/UDP */ +static void parse_ipv4_udp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + uint32_t offset[num_pkt];
- for (i = 0; i < num_pkt; i++) { - ret = odp_packet_copy_from_mem(pkt[i], 0, len, - test_packet_ipv4_udp); - CU_ASSERT(ret == 0); + parse_test_alloc(pkt, test_packet_ipv4_udp, + sizeof(test_packet_ipv4_udp));
+ for (i = 0; i < num_pkt; i++) offset[i] = 14; - }
parse.proto = ODP_PROTO_IPV4; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -2571,26 +2611,25 @@ void packet_test_parse(void) }
odp_packet_free_multi(pkt, num_pkt); +}
- /* Ethernet/IPv4/TCP */ - len = sizeof(test_packet_ipv4_tcp); - ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); - CU_ASSERT_FATAL(ret == num_pkt); - - for (i = 0; i < num_pkt; i++) { - ret = odp_packet_copy_from_mem(pkt[i], 0, len, - test_packet_ipv4_tcp); - CU_ASSERT(ret == 0); +/* Ethernet/IPv4/TCP */ +static void parse_eth_ipv4_tcp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt];
- offset[i] = 0; - } + parse_test_alloc(pkt, test_packet_ipv4_tcp, + sizeof(test_packet_ipv4_tcp));
parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; parse.chksums.all_chksum = 0;
- CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); - CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], + 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++) { @@ -2601,26 +2640,25 @@ void packet_test_parse(void) }
odp_packet_free_multi(pkt, num_pkt); +}
- /* Ethernet/IPv6/UDP */ - len = sizeof(test_packet_ipv6_udp); - ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); - CU_ASSERT_FATAL(ret == num_pkt); - - for (i = 0; i < num_pkt; i++) { - ret = odp_packet_copy_from_mem(pkt[i], 0, len, - test_packet_ipv6_udp); - CU_ASSERT(ret == 0); +/* Ethernet/IPv6/UDP */ +static void parse_eth_ipv6_udp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt];
- offset[i] = 0; - } + parse_test_alloc(pkt, test_packet_ipv6_udp, + sizeof(test_packet_ipv6_udp));
parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; parse.chksums.all_chksum = 0;
- CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); - CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], + 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++) { @@ -2632,26 +2670,25 @@ void packet_test_parse(void) }
odp_packet_free_multi(pkt, num_pkt); +}
- /* Ethernet/IPv6/TCP */ - len = sizeof(test_packet_ipv6_tcp); - ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); - CU_ASSERT_FATAL(ret == num_pkt); - - for (i = 0; i < num_pkt; i++) { - ret = odp_packet_copy_from_mem(pkt[i], 0, len, - test_packet_ipv6_tcp); - CU_ASSERT(ret == 0); +/* Ethernet/IPv6/TCP */ +static void parse_eth_ipv6_tcp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt];
- offset[i] = 0; - } + parse_test_alloc(pkt, test_packet_ipv6_tcp, + sizeof(test_packet_ipv6_tcp));
parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_ALL; parse.chksums.all_chksum = 0;
- CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); - CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], + 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++) { @@ -2663,8 +2700,6 @@ void packet_test_parse(void) }
odp_packet_free_multi(pkt, num_pkt); - - odp_pool_destroy(pool); }
odp_testinfo_t packet_suite[] = { @@ -2698,7 +2733,15 @@ odp_testinfo_t packet_suite[] = { ODP_TEST_INFO(packet_test_align), ODP_TEST_INFO(packet_test_offset), ODP_TEST_INFO(packet_test_ref), - ODP_TEST_INFO(packet_test_parse), + ODP_TEST_INFO_NULL, +}; + +odp_testinfo_t packet_parse_suite[] = { + ODP_TEST_INFO(parse_eth_ipv4_udp), + ODP_TEST_INFO(parse_ipv4_udp), + ODP_TEST_INFO(parse_eth_ipv4_tcp), + ODP_TEST_INFO(parse_eth_ipv6_udp), + ODP_TEST_INFO(parse_eth_ipv6_tcp), ODP_TEST_INFO_NULL, };
@@ -2708,6 +2751,11 @@ odp_suiteinfo_t packet_suites[] = { .init_func = packet_suite_init, .term_func = packet_suite_term, }, + { .name = "packet parse tests", + .testinfo_tbl = packet_parse_suite, + .init_func = packet_parse_suite_init, + .term_func = packet_parse_suite_term, + }, ODP_SUITE_INFO_NULL, };
diff --git a/test/validation/api/packet/packet.h b/test/validation/api/packet/packet.h index 1d9947af..798b272b 100644 --- a/test/validation/api/packet/packet.h +++ b/test/validation/api/packet/packet.h @@ -40,7 +40,6 @@ void packet_test_extend_ref(void); void packet_test_align(void); void packet_test_offset(void); void packet_test_ref(void); -void packet_test_parse(void);
/* test arrays: */ extern odp_testinfo_t packet_suite[];
commit ab78f2924a353d4e0e45deea73201e6da10a7664 Author: Petri Savolainen petri.savolainen@linaro.org Date: Mon Feb 12 13:12:31 2018 +0200
validation: common: remove camel case names
Rename struct fields to not use camel case names.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/common/odp_cunit_common.c b/test/common/odp_cunit_common.c index 6e51388f..d8a17a75 100644 --- a/test/common/odp_cunit_common.c +++ b/test/common/odp_cunit_common.c @@ -126,8 +126,8 @@ static odp_suiteinfo_t *cunit_get_suite_info(const char *suite_name) { odp_suiteinfo_t *sinfo;
- for (sinfo = global_testsuites; sinfo->pName; sinfo++) - if (strcmp(sinfo->pName, suite_name) == 0) + for (sinfo = global_testsuites; sinfo->name; sinfo++) + if (strcmp(sinfo->name, suite_name) == 0) return sinfo;
return NULL; @@ -138,8 +138,8 @@ static odp_testinfo_t *cunit_get_test_info(odp_suiteinfo_t *sinfo, { odp_testinfo_t *tinfo;
- for (tinfo = sinfo->pTests; tinfo->pName; tinfo++) - if (strcmp(tinfo->pName, test_name) == 0) + for (tinfo = sinfo->testinfo_tbl; tinfo->name; tinfo++) + if (strcmp(tinfo->name, test_name) == 0) return tinfo;
return NULL; @@ -167,14 +167,14 @@ static int _cunit_suite_init(void) return -1;
/* execute its init function */ - if (sinfo->pInitFunc) { - ret = sinfo->pInitFunc(); + if (sinfo->init_func) { + ret = sinfo->init_func(); if (ret) return ret; }
/* run any configured conditional checks and mark inactive tests */ - for (tinfo = sinfo->pTests; tinfo->pName; tinfo++) { + for (tinfo = sinfo->testinfo_tbl; tinfo->name; tinfo++) { CU_pTest ptest; CU_ErrorCode err;
@@ -182,7 +182,7 @@ static int _cunit_suite_init(void) continue;
/* test is inactive, mark it as such */ - ptest = CU_get_test_by_name(tinfo->pName, cur_suite); + ptest = CU_get_test_by_name(tinfo->name, cur_suite); if (ptest) err = CU_set_test_active(ptest, CU_FALSE); else @@ -190,7 +190,7 @@ static int _cunit_suite_init(void)
if (err != CUE_SUCCESS) { fprintf(stderr, "%s: failed to set test %s inactive\n", - __func__, tinfo->pName); + __func__, tinfo->name); return -1; } } @@ -211,15 +211,15 @@ static int cunit_register_suites(odp_suiteinfo_t testsuites[]) CU_pSuite suite; CU_pTest test;
- for (sinfo = testsuites; sinfo->pName; sinfo++) { - suite = CU_add_suite(sinfo->pName, - _cunit_suite_init, sinfo->pCleanupFunc); + for (sinfo = testsuites; sinfo->name; sinfo++) { + suite = CU_add_suite(sinfo->name, + _cunit_suite_init, sinfo->term_func); if (!suite) return CU_get_error();
- for (tinfo = sinfo->pTests; tinfo->pName; tinfo++) { - test = CU_add_test(suite, tinfo->pName, - tinfo->pTestFunc); + for (tinfo = sinfo->testinfo_tbl; tinfo->name; tinfo++) { + test = CU_add_test(suite, tinfo->name, + tinfo->test_func); if (!test) return CU_get_error(); } @@ -235,7 +235,7 @@ static int cunit_update_test(CU_pSuite suite, CU_pTest test = NULL; CU_ErrorCode err; odp_testinfo_t *tinfo; - const char *test_name = updated_tinfo->pName; + const char *test_name = updated_tinfo->name;
tinfo = cunit_get_test_info(sinfo, test_name); if (tinfo) @@ -247,7 +247,7 @@ static int cunit_update_test(CU_pSuite suite, return -1; }
- err = CU_set_test_func(test, updated_tinfo->pTestFunc); + err = CU_set_test_func(test, updated_tinfo->test_func); if (err != CUE_SUCCESS) { fprintf(stderr, "%s: failed to update test func for %s\n", __func__, test_name); @@ -267,31 +267,31 @@ static int cunit_update_suite(odp_suiteinfo_t *updated_sinfo) odp_testinfo_t *tinfo;
/* find previously registered suite with matching name */ - sinfo = cunit_get_suite_info(updated_sinfo->pName); + sinfo = cunit_get_suite_info(updated_sinfo->name);
if (sinfo) { /* lookup the associated CUnit suite */ - suite = CU_get_suite_by_name(updated_sinfo->pName, + suite = CU_get_suite_by_name(updated_sinfo->name, CU_get_registry()); }
if (!sinfo || !suite) { fprintf(stderr, "%s: unable to find existing suite named %s\n", - __func__, updated_sinfo->pName); + __func__, updated_sinfo->name); return -1; }
- sinfo->pInitFunc = updated_sinfo->pInitFunc; - sinfo->pCleanupFunc = updated_sinfo->pCleanupFunc; + sinfo->init_func = updated_sinfo->init_func; + sinfo->term_func = updated_sinfo->term_func;
- err = CU_set_suite_cleanupfunc(suite, updated_sinfo->pCleanupFunc); + err = CU_set_suite_cleanupfunc(suite, updated_sinfo->term_func); if (err != CUE_SUCCESS) { fprintf(stderr, "%s: failed to update cleanup func for %s\n", - __func__, updated_sinfo->pName); + __func__, updated_sinfo->name); return -1; }
- for (tinfo = updated_sinfo->pTests; tinfo->pName; tinfo++) { + for (tinfo = updated_sinfo->testinfo_tbl; tinfo->name; tinfo++) { int ret;
ret = cunit_update_test(suite, sinfo, tinfo); @@ -345,7 +345,7 @@ int odp_cunit_update(odp_suiteinfo_t testsuites[]) int ret = 0; odp_suiteinfo_t *sinfo;
- for (sinfo = testsuites; sinfo->pName && ret == 0; sinfo++) + for (sinfo = testsuites; sinfo->name && ret == 0; sinfo++) ret = cunit_update_suite(sinfo);
return ret; diff --git a/test/common/odp_cunit_common.h b/test/common/odp_cunit_common.h index 390e8f57..f6d38432 100644 --- a/test/common/odp_cunit_common.h +++ b/test/common/odp_cunit_common.h @@ -23,16 +23,16 @@ typedef int (*cunit_test_check_active)(void);
typedef struct { - const char *pName; - CU_TestFunc pTestFunc; + const char *name; + CU_TestFunc test_func; cunit_test_check_active check_active; } odp_testinfo_t;
typedef struct { - const char *pName; - CU_InitializeFunc pInitFunc; - CU_CleanupFunc pCleanupFunc; - odp_testinfo_t *pTests; + const char *name; + CU_InitializeFunc init_func; + CU_CleanupFunc term_func; + odp_testinfo_t *testinfo_tbl; } odp_suiteinfo_t;
static inline int odp_cunit_test_inactive(void) { return 0; } diff --git a/test/validation/api/classification/classification.c b/test/validation/api/classification/classification.c index a0d290ec..ef621f72 100644 --- a/test/validation/api/classification/classification.c +++ b/test/validation/api/classification/classification.c @@ -12,18 +12,18 @@ #include "classification.h"
odp_suiteinfo_t classification_suites[] = { - { .pName = "classification basic", - .pTests = classification_suite_basic, + { .name = "classification basic", + .testinfo_tbl = classification_suite_basic, }, - { .pName = "classification pmr tests", - .pTests = classification_suite_pmr, - .pInitFunc = classification_suite_pmr_init, - .pCleanupFunc = classification_suite_pmr_term, + { .name = "classification pmr tests", + .testinfo_tbl = classification_suite_pmr, + .init_func = classification_suite_pmr_init, + .term_func = classification_suite_pmr_term, }, - { .pName = "classification tests", - .pTests = classification_suite, - .pInitFunc = classification_suite_init, - .pCleanupFunc = classification_suite_term, + { .name = "classification tests", + .testinfo_tbl = classification_suite, + .init_func = classification_suite_init, + .term_func = classification_suite_term, }, ODP_SUITE_INFO_NULL, }; diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c index ad9784a6..df1c7b6f 100644 --- a/test/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/validation/api/crypto/odp_crypto_test_inp.c @@ -1230,14 +1230,14 @@ int crypto_suite_term(void) int i; int first = 1;
- for (i = 0; crypto_suite[i].pName; i++) { + for (i = 0; crypto_suite[i].name; i++) { if (crypto_suite[i].check_active && crypto_suite[i].check_active() == ODP_TEST_INACTIVE) { if (first) { first = 0; printf("\n\n Inactive tests:\n"); } - printf(" %s\n", crypto_suite[i].pName); + printf(" %s\n", crypto_suite[i].name); } } return 0; diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c index ea3cff05..b16f84ac 100644 --- a/test/validation/api/ipsec/ipsec.c +++ b/test/validation/api/ipsec/ipsec.c @@ -789,14 +789,14 @@ static int ipsec_suite_term(odp_testinfo_t *suite) if (suite_context.pktio != ODP_PKTIO_INVALID) pktio_stop(suite_context.pktio);
- for (i = 0; suite[i].pName; i++) { + for (i = 0; suite[i].name; i++) { if (suite[i].check_active && suite[i].check_active() == ODP_TEST_INACTIVE) { if (first) { first = 0; printf("\n\n Inactive tests:\n"); } - printf(" %s\n", suite[i].pName); + printf(" %s\n", suite[i].name); } }
diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index 78ccbeae..1188c683 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -2703,10 +2703,10 @@ odp_testinfo_t packet_suite[] = { };
odp_suiteinfo_t packet_suites[] = { - { .pName = "packet tests", - .pTests = packet_suite, - .pInitFunc = packet_suite_init, - .pCleanupFunc = packet_suite_term, + { .name = "packet tests", + .testinfo_tbl = packet_suite, + .init_func = packet_suite_init, + .term_func = packet_suite_term, }, ODP_SUITE_INFO_NULL, }; diff --git a/test/validation/api/pool/pool.c b/test/validation/api/pool/pool.c index 84c17720..3a2c7412 100644 --- a/test/validation/api/pool/pool.c +++ b/test/validation/api/pool/pool.c @@ -230,8 +230,8 @@ odp_testinfo_t pool_suite[] = { };
odp_suiteinfo_t pool_suites[] = { - { .pName = "Pool tests", - .pTests = pool_suite, + { .name = "Pool tests", + .testinfo_tbl = pool_suite, }, ODP_SUITE_INFO_NULL, };
-----------------------------------------------------------------------
Summary of changes: platform/linux-generic/odp_packet.c | 2 +- test/common/odp_cunit_common.c | 52 +- test/common/odp_cunit_common.h | 12 +- test/common/test_packet_parser.h | 295 +++++++-- .../validation/api/classification/classification.c | 20 +- test/validation/api/crypto/odp_crypto_test_inp.c | 4 +- test/validation/api/ipsec/ipsec.c | 4 +- test/validation/api/packet/packet.c | 701 ++++++++++++++++++--- test/validation/api/packet/packet.h | 1 - test/validation/api/pool/pool.c | 4 +- 10 files changed, 916 insertions(+), 179 deletions(-)
hooks/post-receive