Skip to content

Commit

Permalink
validation: event: add tests for odp_event_pool()
Browse files Browse the repository at this point in the history
Add validation tests for new odp_event_pool() API.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
  • Loading branch information
MatiasElo authored and psavol committed Dec 19, 2023
1 parent 695cccb commit 026f78e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 9 deletions.
2 changes: 2 additions & 0 deletions test/validation/api/buffer/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ static void test_pool_alloc_free(const odp_pool_param_t *param)
odp_buffer_from_event_multi(&buf, &ev, 1);
CU_ASSERT(buf == buffer[i]);

CU_ASSERT(odp_event_pool(ev) == pool);

if (odp_event_type(ev) != ODP_EVENT_BUFFER)
wrong_type = true;
if (odp_event_subtype(ev) != ODP_EVENT_NO_SUBTYPE)
Expand Down
6 changes: 6 additions & 0 deletions test/validation/api/dma/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ static void test_dma_compl_pool(void)
odp_pool_t pool;
odp_pool_info_t pool_info;
odp_dma_compl_t compl[global.dma_capa.max_transfers];
odp_event_t ev;
uint64_t u64;
int ret;
uint32_t i, j;
Expand Down Expand Up @@ -359,6 +360,11 @@ static void test_dma_compl_pool(void)
if (compl[i] == ODP_DMA_COMPL_INVALID)
break;

/* No source pool for DMA completion events */
ev = odp_dma_compl_to_event(compl[i]);
CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID);
CU_ASSERT(odp_event_pool(ev) == ODP_POOL_INVALID);

printf("\n DMA compl handle: 0x%" PRIx64 "\n", u64);
odp_dma_compl_print(compl[i]);
}
Expand Down
4 changes: 3 additions & 1 deletion test/validation/api/ipsec/ipsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,13 @@ static void ipsec_status_event_handle(odp_event_t ev_status,
CU_ASSERT_EQUAL(1, odp_event_is_valid(ev_status));
CU_ASSERT_EQUAL_FATAL(ODP_EVENT_IPSEC_STATUS, odp_event_type(ev_status));

/* No user area for IPsec status events */
/* No user area or source pool for IPsec status events */
CU_ASSERT(odp_event_user_area(ev_status) == NULL);
CU_ASSERT(odp_event_user_area_and_flag(ev_status, &flag) == NULL);
CU_ASSERT(flag < 0);

CU_ASSERT(odp_event_pool(ev_status) == ODP_POOL_INVALID);

CU_ASSERT_EQUAL(0, odp_ipsec_status(&status, ev_status));
CU_ASSERT_EQUAL(ODP_IPSEC_STATUS_WARN, status.id);
CU_ASSERT_EQUAL(sa, status.sa);
Expand Down
19 changes: 13 additions & 6 deletions test/validation/api/packet/packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ static void packet_test_alloc_free(void)
odp_packet_t packet;
odp_pool_param_t params;
odp_event_subtype_t subtype;
odp_event_t ev;

odp_pool_param_init(&params);

Expand All @@ -418,13 +419,15 @@ static void packet_test_alloc_free(void)
packet = odp_packet_alloc(pool, packet_len);
CU_ASSERT_FATAL(packet != ODP_PACKET_INVALID);
CU_ASSERT(odp_packet_len(packet) == packet_len);
CU_ASSERT(odp_event_type(odp_packet_to_event(packet)) ==
ODP_EVENT_PACKET);
CU_ASSERT(odp_event_subtype(odp_packet_to_event(packet)) ==
ODP_EVENT_PACKET_BASIC);
CU_ASSERT(odp_event_types(odp_packet_to_event(packet), &subtype) ==
ODP_EVENT_PACKET);

ev = odp_packet_to_event(packet);
CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID);
CU_ASSERT(odp_event_type(ev) == ODP_EVENT_PACKET);
CU_ASSERT(odp_event_subtype(ev) == ODP_EVENT_PACKET_BASIC);
CU_ASSERT(odp_event_types(ev, &subtype) == ODP_EVENT_PACKET);
CU_ASSERT(subtype == ODP_EVENT_PACKET_BASIC);
CU_ASSERT(odp_event_pool(ev) == pool);

CU_ASSERT(odp_packet_subtype(packet) == ODP_EVENT_PACKET_BASIC);
CU_ASSERT(odp_packet_to_u64(packet) !=
odp_packet_to_u64(ODP_PACKET_INVALID));
Expand Down Expand Up @@ -3205,6 +3208,7 @@ static void packet_vector_basic_test(void)
odp_pool_capability_t capa;
uint32_t i, num;
uint32_t max_size = PKT_VEC_PACKET_NUM;
odp_event_t ev;

CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
if (capa.vector.max_size < max_size)
Expand All @@ -3215,6 +3219,9 @@ static void packet_vector_basic_test(void)

/* Making sure default vector packet is from default vector pool */
CU_ASSERT(odp_packet_vector_pool(pktv_default) == vector_default_pool)
ev = odp_packet_vector_to_event(pktv_default);
CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID);
CU_ASSERT(odp_event_pool(ev) == vector_default_pool);

/* Get packet vector table */
num = odp_packet_vector_tbl(pktv_default, &pkt_tbl);
Expand Down
8 changes: 6 additions & 2 deletions test/validation/api/pktio/pktio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3648,11 +3648,13 @@ static void pktio_test_pktout_compl_event(bool use_plain_queue)
CU_ASSERT(odp_packet_tx_compl_user_ptr(tx_compl) ==
(const void *)&pkt_seq[i]);

/* No user area for TX completion events */
/* No user area or source pool for TX completion events */
CU_ASSERT(odp_event_user_area(ev) == NULL);
CU_ASSERT(odp_event_user_area_and_flag(ev, &flag) == NULL);
CU_ASSERT(flag < 0);

CU_ASSERT(odp_event_pool(ev) == ODP_POOL_INVALID);

/* Alternatively call event free / compl free */
if (i % 2)
odp_packet_tx_compl_free(tx_compl);
Expand Down Expand Up @@ -3688,11 +3690,13 @@ static void pktio_test_pktout_compl_event(bool use_plain_queue)
}
}

/* No user area for TX completion events */
/* No user area or source pool for TX completion events */
CU_ASSERT(odp_event_user_area(ev) == NULL);
CU_ASSERT(odp_event_user_area_and_flag(ev, &flag) == NULL);
CU_ASSERT(flag < 0);

CU_ASSERT(odp_event_pool(ev) == ODP_POOL_INVALID);

/* Check that sequence number is found */
CU_ASSERT(j < TX_BATCH_LEN);

Expand Down
3 changes: 3 additions & 0 deletions test/validation/api/timer/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@ static void timer_test_timeout_pool_alloc(void)
wrong_type = true;
if (subtype != ODP_EVENT_NO_SUBTYPE)
wrong_subtype = true;

/* No source pool for timeout events */
CU_ASSERT(odp_event_pool(ev) == ODP_POOL_INVALID);
}

/* Check that the pool had at least num items */
Expand Down

0 comments on commit 026f78e

Please sign in to comment.