diff mbox series

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

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

Commit Message

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


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: b2330885d3eb101d2b618264e0bc830f93ba54e7
 **/
 test/common_plat/validation/api/pktio/pktio.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 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..e9f4a2aa2 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,27 @@  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) {
+		printf("\n mac address set not supported for %s!\n",
+		       iface_name[0]);
+		ret = odp_pktio_close(pktio);
+		CU_ASSERT(ret == 0);
+		return;
+	}
+
+	/* 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);
+
 	ret = odp_pktio_close(pktio);
 	CU_ASSERT(0 == ret);
 }