diff mbox series

[API-NEXT,v5,3/3] test: validation: pktio: validate MAC address set function

Message ID 1507626011-15870-4-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v5,1/3] api: packet_io: add MAC address set function | expand

Commit Message

Github ODP bot Oct. 10, 2017, 9 a.m. UTC
From: Bogdan Pricope <bogdan.pricope@linaro.org>


Add validation tests for MAC address set API.

Signed-off-by: Bogdan Pricope <bogdan.pricope@linaro.org>

---
/** Email created from pull request 203 (bogdanPricope:set_mac_pr)
 ** https://github.com/Linaro/odp/pull/203
 ** Patch: https://github.com/Linaro/odp/pull/203.patch
 ** Base sha: bf803098eb1518dfb9e719071256fe22700b8c72
 ** Merge commit sha: 9741b2bb193f1cb28f8dd4bf382bc598e1dbd5ef
 **/
 test/common_plat/validation/api/pktio/pktio.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/test/common_plat/validation/api/pktio/pktio.c b/test/common_plat/validation/api/pktio/pktio.c
index 6a085729b..720707358 100644
--- a/test/common_plat/validation/api/pktio/pktio.c
+++ b/test/common_plat/validation/api/pktio/pktio.c
@@ -1065,9 +1065,12 @@  void pktio_test_promisc(void)
 void pktio_test_mac(void)
 {
 	unsigned char mac_addr[ODP_PKTIO_MACADDR_MAXSIZE];
+	unsigned char mac_addr_ref[ODP_PKTIO_MACADDR_MAXSIZE] =	{
+		0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0};
 	int mac_len;
 	int ret;
 	odp_pktio_t pktio;
+	odp_pktio_capability_t capa;
 
 	pktio = create_pktio(0, ODP_PKTIN_MODE_SCHED,
 			     ODP_PKTOUT_MODE_DIRECT);
@@ -1088,6 +1091,26 @@  void pktio_test_mac(void)
 	mac_len = odp_pktio_mac_addr(pktio, mac_addr, 2);
 	CU_ASSERT(mac_len < 0);
 
+	CU_ASSERT_FATAL(odp_pktio_capability(pktio, &capa) == 0);
+	if (capa.set_op.op.mac_addr) {
+		/* Fail case: wrong addr_size. Expected <0. */
+		ret = odp_pktio_mac_addr_set(pktio, mac_addr_ref, 2);
+		CU_ASSERT_FATAL(ret < 0);
+
+		ret = odp_pktio_mac_addr_set(pktio, mac_addr_ref,
+					     ODPH_ETHADDR_LEN);
+		CU_ASSERT_FATAL(ret == 0);
+
+		mac_len = odp_pktio_mac_addr(pktio, mac_addr,
+					     ODPH_ETHADDR_LEN);
+		CU_ASSERT(ODPH_ETHADDR_LEN == mac_len);
+
+		CU_ASSERT(odp_memcmp(mac_addr_ref, mac_addr,
+				     ODPH_ETHADDR_LEN) == 0);
+	} else
+		printf("\n mac address set not supported for %s!\n",
+		       iface_name[0]);
+
 	ret = odp_pktio_close(pktio);
 	CU_ASSERT(0 == ret);
 }