[API-NEXT,v3,3/6] validation: packet: add tests for o_p_set_data and o_p_cmp_data

Message ID 1501552809-14585-4-git-send-email-odpbot@yandex.ru
State New
Headers show
Series
  • Add support for AES-192 and AES-256 keys
Related show

Commit Message

Github ODP bot Aug. 1, 2017, 2 a.m.
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 94 (lumag:crypto-long-keys)
 ** https://github.com/Linaro/odp/pull/94
 ** Patch: https://github.com/Linaro/odp/pull/94.patch
 ** Base sha: c16f1363303cd5fc11324acbc4dfebe0a9680a41
 ** Merge commit sha: 97de0c6543391f0a758ac472f48e0b407ad1d800
 **/
 test/common_plat/validation/api/packet/packet.c | 35 +++++++++++++++++++++++++
 test/common_plat/validation/api/packet/packet.h |  1 +
 2 files changed, 36 insertions(+)

Patch hide | download patch | download mbox

diff --git a/test/common_plat/validation/api/packet/packet.c b/test/common_plat/validation/api/packet/packet.c
index fa6f4afd..27ef701d 100644
--- a/test/common_plat/validation/api/packet/packet.c
+++ b/test/common_plat/validation/api/packet/packet.c
@@ -1311,6 +1311,40 @@  void packet_test_copydata(void)
 	odp_packet_free(pkt);
 }
 
+void packet_test_setcmpdata(void)
+{
+	odp_packet_t pkt = test_packet;
+	uint32_t pkt_len = odp_packet_len(pkt);
+	uint8_t *data_buf;
+	uint32_t i;
+	int correct_memory;
+
+	CU_ASSERT_FATAL(pkt_len > 0);
+
+	data_buf = malloc(pkt_len);
+	CU_ASSERT_PTR_NOT_NULL_FATAL(data_buf);
+
+	CU_ASSERT(!odp_packet_set_data(pkt, 0, 0xa5, pkt_len));
+	memset(data_buf, 0, pkt_len);
+	CU_ASSERT(!odp_packet_copy_to_mem(pkt, 0, pkt_len, data_buf));
+
+	correct_memory = 1;
+	for (i = 0; i < pkt_len; i++)
+		if (data_buf[i] != 0xa5) {
+			correct_memory = 0;
+			break;
+		}
+	CU_ASSERT(correct_memory);
+
+	CU_ASSERT(!odp_packet_cmp_mem(pkt, 0, data_buf, pkt_len));
+
+	data_buf[pkt_len - 1] = 0x5a;
+
+	CU_ASSERT(odp_packet_cmp_mem(pkt, 0, data_buf, pkt_len));
+
+	free(data_buf);
+}
+
 void packet_test_concatsplit(void)
 {
 	odp_packet_t pkt, pkt2;
@@ -2431,6 +2465,7 @@  odp_testinfo_t packet_suite[] = {
 	ODP_TEST_INFO(packet_test_add_rem_data),
 	ODP_TEST_INFO(packet_test_copy),
 	ODP_TEST_INFO(packet_test_copydata),
+	ODP_TEST_INFO(packet_test_setcmpdata),
 	ODP_TEST_INFO(packet_test_concatsplit),
 	ODP_TEST_INFO(packet_test_concat_small),
 	ODP_TEST_INFO(packet_test_concat_extend_trunc),
diff --git a/test/common_plat/validation/api/packet/packet.h b/test/common_plat/validation/api/packet/packet.h
index 783b7a11..2080544b 100644
--- a/test/common_plat/validation/api/packet/packet.h
+++ b/test/common_plat/validation/api/packet/packet.h
@@ -29,6 +29,7 @@  void packet_test_error_flags(void);
 void packet_test_add_rem_data(void);
 void packet_test_copy(void);
 void packet_test_copydata(void);
+void packet_test_setcmpdata(void);
 void packet_test_concatsplit(void);
 void packet_test_concat_small(void);
 void packet_test_concat_extend_trunc(void);