@@ -1292,6 +1292,44 @@ void packet_test_copydata(void)
odp_packet_free(pkt);
}
+static
+void packet_test_zerodata_pkt(odp_packet_t pkt)
+{
+ 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);
+
+ for (i = 0; i < pkt_len; i++)
+ data_buf[i] = (uint8_t)i;
+
+ CU_ASSERT(!odp_packet_copy_from_mem(pkt, 0, pkt_len, data_buf));
+ CU_ASSERT(!odp_packet_zero_data(pkt, 0, pkt_len));
+ memset(data_buf, 0xff, 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] != 0) {
+ correct_memory = 0;
+ break;
+ }
+ CU_ASSERT(correct_memory);
+
+ free(data_buf);
+}
+
+void packet_test_zerodata(void)
+{
+ packet_test_zerodata_pkt(test_packet);
+ packet_test_zerodata_pkt(segmented_test_packet);
+}
+
void packet_test_concatsplit(void)
{
odp_packet_t pkt, pkt2;
@@ -2412,6 +2450,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_zerodata),
ODP_TEST_INFO(packet_test_concatsplit),
ODP_TEST_INFO(packet_test_concat_small),
ODP_TEST_INFO(packet_test_concat_extend_trunc),
@@ -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_zerodata(void);
void packet_test_concatsplit(void);
void packet_test_concat_small(void);
void packet_test_concat_extend_trunc(void);