From cbbabd8147feabebfaa28ca5237c943076ffb504 Mon Sep 17 00:00:00 2001 From: Matias Elo Date: Fri, 10 Nov 2023 15:59:47 +0200 Subject: [PATCH] validation: event: add tests for odp_event_pool() Add validation tests for new odp_event_pool() API. Signed-off-by: Matias Elo --- test/validation/api/buffer/buffer.c | 2 ++ test/validation/api/dma/dma.c | 6 ++++++ test/validation/api/ipsec/ipsec.c | 4 +++- test/validation/api/packet/packet.c | 19 +++++++++++++------ test/validation/api/pktio/pktio.c | 8 ++++++-- test/validation/api/timer/timer.c | 3 +++ 6 files changed, 33 insertions(+), 9 deletions(-) diff --git a/test/validation/api/buffer/buffer.c b/test/validation/api/buffer/buffer.c index 909608ed815..91cfbfb5f58 100644 --- a/test/validation/api/buffer/buffer.c +++ b/test/validation/api/buffer/buffer.c @@ -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) diff --git a/test/validation/api/dma/dma.c b/test/validation/api/dma/dma.c index 787f719a7ac..4f454168d18 100644 --- a/test/validation/api/dma/dma.c +++ b/test/validation/api/dma/dma.c @@ -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; @@ -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]); } diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c index da60c77b310..9849a44b51e 100644 --- a/test/validation/api/ipsec/ipsec.c +++ b/test/validation/api/ipsec/ipsec.c @@ -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); diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index 40cfc148101..79b8fbe5030 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -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(¶ms); @@ -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)); @@ -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) @@ -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); diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c index 5feeea4c0a9..3abf2dd0e08 100644 --- a/test/validation/api/pktio/pktio.c +++ b/test/validation/api/pktio/pktio.c @@ -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); @@ -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); diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index db66b366462..f40bd8d6890 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -449,6 +449,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 */