diff options
Diffstat (limited to 'test/validation/api')
-rw-r--r-- | test/validation/api/buffer/buffer.c | 187 | ||||
-rw-r--r-- | test/validation/api/classification/odp_classification_common.c | 5 | ||||
-rw-r--r-- | test/validation/api/classification/odp_classification_test_pmr.c | 119 | ||||
-rw-r--r-- | test/validation/api/classification/odp_classification_testsuites.h | 3 | ||||
-rw-r--r-- | test/validation/api/crypto/odp_crypto_test_inp.c | 3 | ||||
-rw-r--r-- | test/validation/api/pktio/pktio.c | 1 | ||||
-rw-r--r-- | test/validation/api/scheduler/scheduler.c | 52 | ||||
-rw-r--r-- | test/validation/api/timer/timer.c | 43 |
8 files changed, 366 insertions, 47 deletions
diff --git a/test/validation/api/buffer/buffer.c b/test/validation/api/buffer/buffer.c index 07b671228..19f39e1d3 100644 --- a/test/validation/api/buffer/buffer.c +++ b/test/validation/api/buffer/buffer.c @@ -1,5 +1,6 @@ /* Copyright (c) 2014-2018, Linaro Limited * Copyright (c) 2019, Nokia + * Copyright (c) 2022, Marvell * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -51,7 +52,7 @@ static int buffer_suite_init(void) return 0; } -static void buffer_test_pool_alloc_free(void) +static void test_pool_alloc_free(const odp_pool_param_t *param) { odp_pool_t pool; odp_event_t ev; @@ -59,14 +60,15 @@ static void buffer_test_pool_alloc_free(void) uint32_t num_buf = 0; void *addr; odp_event_subtype_t subtype; - uint32_t num = default_param.buf.num; - uint32_t size = default_param.buf.size; - uint32_t align = default_param.buf.align; + uint32_t num = param->buf.num; + uint32_t size = param->buf.size; + uint32_t align = param->buf.align; + odp_buffer_t buffer[num]; odp_bool_t wrong_type = false, wrong_subtype = false; odp_bool_t wrong_size = false, wrong_align = false; - pool = odp_pool_create("default pool", &default_param); + pool = odp_pool_create("default pool", param); CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); odp_pool_print(pool); @@ -123,7 +125,7 @@ static void buffer_test_pool_alloc_free(void) CU_ASSERT(odp_pool_destroy(pool) == 0); } -static void buffer_test_pool_alloc_free_multi(void) +static void test_pool_alloc_free_multi(const odp_pool_param_t *param) { odp_pool_t pool; uint32_t i, num_buf; @@ -131,14 +133,15 @@ static void buffer_test_pool_alloc_free_multi(void) odp_event_t ev; void *addr; odp_event_subtype_t subtype; - uint32_t num = default_param.buf.num; - uint32_t size = default_param.buf.size; - uint32_t align = default_param.buf.align; + uint32_t num = param->buf.num; + uint32_t size = param->buf.size; + uint32_t align = param->buf.align; + odp_buffer_t buffer[num + BURST]; odp_bool_t wrong_type = false, wrong_subtype = false; odp_bool_t wrong_size = false, wrong_align = false; - pool = odp_pool_create("default pool", &default_param); + pool = odp_pool_create("default pool", param); CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); ret = 0; @@ -203,16 +206,14 @@ static void buffer_test_pool_alloc_free_multi(void) CU_ASSERT(odp_pool_destroy(pool) == 0); } -static void buffer_test_pool_single_pool(void) +static void test_pool_single_pool(odp_pool_param_t *param) { odp_pool_t pool; odp_buffer_t buffer; - odp_pool_param_t param; - memcpy(¶m, &default_param, sizeof(odp_pool_param_t)); - param.buf.num = 1; + param->buf.num = 1; - pool = odp_pool_create("pool 0", ¶m); + pool = odp_pool_create("pool 0", param); CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); odp_pool_print(pool); @@ -246,23 +247,21 @@ static void buffer_test_pool_single_pool(void) CU_ASSERT(odp_pool_destroy(pool) == 0); } -static void buffer_test_pool_two_pools(void) +static void test_pool_two_pools(odp_pool_param_t *param) { odp_pool_t pool0, pool1; odp_buffer_t buf, buffer[2]; - odp_pool_param_t param; int num = 0; if (pool_capa.buf.max_pools < 2) return; - memcpy(¶m, &default_param, sizeof(odp_pool_param_t)); - param.buf.num = 1; + param->buf.num = 1; - pool0 = odp_pool_create("pool 0", ¶m); + pool0 = odp_pool_create("pool 0", param); CU_ASSERT_FATAL(pool0 != ODP_POOL_INVALID); - pool1 = odp_pool_create("pool 1", ¶m); + pool1 = odp_pool_create("pool 1", param); CU_ASSERT_FATAL(pool1 != ODP_POOL_INVALID); buffer[0] = odp_buffer_alloc(pool0); @@ -309,15 +308,14 @@ static void buffer_test_pool_two_pools(void) CU_ASSERT(odp_pool_destroy(pool1) == 0); } -static void buffer_test_pool_max_pools(void) +static void test_pool_max_pools(odp_pool_param_t *param) { - odp_pool_param_t param; uint32_t i, num_pool, num_buf; void *addr; odp_event_t ev; uint32_t max_pools = pool_capa.buf.max_pools; - uint32_t size = default_param.buf.size; - uint32_t align = default_param.buf.align; + uint32_t size = param->buf.size; + uint32_t align = param->buf.align; odp_pool_t pool[max_pools]; odp_buffer_t buffer[max_pools]; @@ -325,11 +323,10 @@ static void buffer_test_pool_max_pools(void) printf("\n Creating %u pools\n", max_pools); - memcpy(¶m, &default_param, sizeof(odp_pool_param_t)); - param.buf.num = 1; + param->buf.num = 1; for (i = 0; i < max_pools; i++) { - pool[i] = odp_pool_create(NULL, ¶m); + pool[i] = odp_pool_create(NULL, param); if (pool[i] == ODP_POOL_INVALID) break; @@ -370,12 +367,146 @@ static void buffer_test_pool_max_pools(void) CU_ASSERT(odp_pool_destroy(pool[i]) == 0); } +static void buffer_test_pool_alloc_free(void) +{ + test_pool_alloc_free(&default_param); +} + +static void buffer_test_pool_alloc_free_min_cache(void) +{ + odp_pool_param_t param; + + memcpy(¶m, &default_param, sizeof(odp_pool_param_t)); + param.buf.cache_size = pool_capa.buf.min_cache_size; + test_pool_alloc_free(¶m); +} + +static void buffer_test_pool_alloc_free_max_cache(void) +{ + odp_pool_param_t param; + + memcpy(¶m, &default_param, sizeof(odp_pool_param_t)); + param.buf.cache_size = pool_capa.buf.max_cache_size; + test_pool_alloc_free(¶m); +} + +static void buffer_test_pool_alloc_free_multi(void) +{ + test_pool_alloc_free_multi(&default_param); +} + +static void buffer_test_pool_alloc_free_multi_min_cache(void) +{ + odp_pool_param_t param; + + memcpy(¶m, &default_param, sizeof(odp_pool_param_t)); + param.buf.cache_size = pool_capa.buf.min_cache_size; + test_pool_alloc_free_multi(¶m); +} + +static void buffer_test_pool_alloc_free_multi_max_cache(void) +{ + odp_pool_param_t param; + + memcpy(¶m, &default_param, sizeof(odp_pool_param_t)); + param.buf.cache_size = pool_capa.buf.max_cache_size; + test_pool_alloc_free_multi(¶m); +} + +static void buffer_test_pool_single_pool(void) +{ + odp_pool_param_t param; + + memcpy(¶m, &default_param, sizeof(odp_pool_param_t)); + test_pool_single_pool(¶m); +} + +static void buffer_test_pool_single_pool_min_cache(void) +{ + odp_pool_param_t param; + + memcpy(¶m, &default_param, sizeof(odp_pool_param_t)); + param.buf.cache_size = pool_capa.buf.min_cache_size; + test_pool_single_pool(¶m); +} + +static void buffer_test_pool_single_pool_max_cache(void) +{ + odp_pool_param_t param; + + memcpy(¶m, &default_param, sizeof(odp_pool_param_t)); + param.buf.cache_size = pool_capa.buf.max_cache_size; + test_pool_single_pool(¶m); +} + +static void buffer_test_pool_two_pools(void) +{ + odp_pool_param_t param; + + memcpy(¶m, &default_param, sizeof(odp_pool_param_t)); + test_pool_two_pools(¶m); +} + +static void buffer_test_pool_two_pools_min_cache(void) +{ + odp_pool_param_t param; + + memcpy(¶m, &default_param, sizeof(odp_pool_param_t)); + param.buf.cache_size = pool_capa.buf.min_cache_size; + test_pool_two_pools(¶m); +} + +static void buffer_test_pool_two_pools_max_cache(void) +{ + odp_pool_param_t param; + + memcpy(¶m, &default_param, sizeof(odp_pool_param_t)); + param.buf.cache_size = pool_capa.buf.max_cache_size; + test_pool_two_pools(¶m); +} + +static void buffer_test_pool_max_pools(void) +{ + odp_pool_param_t param; + + memcpy(¶m, &default_param, sizeof(odp_pool_param_t)); + test_pool_max_pools(¶m); +} + +static void buffer_test_pool_max_pools_min_cache(void) +{ + odp_pool_param_t param; + + memcpy(¶m, &default_param, sizeof(odp_pool_param_t)); + param.buf.cache_size = pool_capa.buf.min_cache_size; + test_pool_max_pools(¶m); +} + +static void buffer_test_pool_max_pools_max_cache(void) +{ + odp_pool_param_t param; + + memcpy(¶m, &default_param, sizeof(odp_pool_param_t)); + param.buf.cache_size = pool_capa.buf.max_cache_size; + test_pool_max_pools(¶m); +} + odp_testinfo_t buffer_suite[] = { ODP_TEST_INFO(buffer_test_pool_alloc_free), + ODP_TEST_INFO(buffer_test_pool_alloc_free_min_cache), + ODP_TEST_INFO(buffer_test_pool_alloc_free_max_cache), ODP_TEST_INFO(buffer_test_pool_alloc_free_multi), + ODP_TEST_INFO(buffer_test_pool_alloc_free_multi_min_cache), + ODP_TEST_INFO(buffer_test_pool_alloc_free_multi_max_cache), ODP_TEST_INFO(buffer_test_pool_single_pool), + ODP_TEST_INFO(buffer_test_pool_single_pool_min_cache), + ODP_TEST_INFO(buffer_test_pool_single_pool_max_cache), ODP_TEST_INFO(buffer_test_pool_two_pools), + ODP_TEST_INFO(buffer_test_pool_two_pools_min_cache), + ODP_TEST_INFO(buffer_test_pool_two_pools_max_cache), ODP_TEST_INFO(buffer_test_pool_max_pools), + ODP_TEST_INFO(buffer_test_pool_max_pools_min_cache), + ODP_TEST_INFO(buffer_test_pool_max_pools_max_cache), ODP_TEST_INFO_NULL, }; diff --git a/test/validation/api/classification/odp_classification_common.c b/test/validation/api/classification/odp_classification_common.c index dd8373b04..8eac41a1e 100644 --- a/test/validation/api/classification/odp_classification_common.c +++ b/test/validation/api/classification/odp_classification_common.c @@ -417,7 +417,7 @@ odp_packet_t create_packet(cls_packet_info_t pkt_info) ip->tot_len = odp_cpu_to_be_16(l3_len); ip->ttl = DEFAULT_TTL; ip->frag_offset = 0; - ip->tos = 0; + ip->tos = pkt_info.dscp << ODPH_IP_TOS_DSCP_SHIFT; odp_packet_has_ipv4_set(pkt, 1); odph_ipv4_csum_update(pkt); } else { @@ -425,7 +425,8 @@ odp_packet_t create_packet(cls_packet_info_t pkt_info) odp_packet_has_ipv6_set(pkt, 1); ipv6 = (odph_ipv6hdr_t *)odp_packet_l3_ptr(pkt, NULL); version = ODPH_IPV6 << ODPH_IPV6HDR_VERSION_SHIFT; - tc = DEFAULT_TOS << ODPH_IPV6HDR_TC_SHIFT; + tc = pkt_info.dscp << ODPH_IP_TOS_DSCP_SHIFT; + tc <<= ODPH_IPV6HDR_TC_SHIFT; flow = seqno << ODPH_IPV6HDR_FLOW_LABEL_SHIFT; ver_tc_flow = version | tc | flow; diff --git a/test/validation/api/classification/odp_classification_test_pmr.c b/test/validation/api/classification/odp_classification_test_pmr.c index 068e2112c..e69f077a2 100644 --- a/test/validation/api/classification/odp_classification_test_pmr.c +++ b/test/validation/api/classification/odp_classification_test_pmr.c @@ -13,6 +13,8 @@ #define MAX_NUM_UDP 4 #define MARK_IP 1 #define MARK_UDP 2 +#define TEST_IPV4 false +#define TEST_IPV6 true static odp_pool_t pkt_pool; /** sequence number of IP packets */ @@ -560,7 +562,7 @@ static void classification_test_pmr_term_udp_sport(void) test_pmr(&pmr_param, pkt, NO_MATCH); } -static void classification_test_pmr_term_ipproto(void) +static void classification_test_pmr_term_proto(odp_bool_t ipv6) { odp_packet_t pkt; uint8_t val; @@ -578,18 +580,73 @@ static void classification_test_pmr_term_ipproto(void) pmr_param.val_sz = sizeof(val); pkt_info = default_pkt_info; + pkt_info.ipv6 = ipv6; pkt_info.l4_type = CLS_PKT_L4_UDP; pkt = create_packet(pkt_info); CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); test_pmr(&pmr_param, pkt, MATCH); - pkt = create_packet(default_pkt_info); + pkt_info.l4_type = CLS_PKT_L4_TCP; + pkt = create_packet(pkt_info); CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); test_pmr(&pmr_param, pkt, NO_MATCH); } +static void classification_test_pmr_term_ipv4_proto(void) +{ + classification_test_pmr_term_proto(TEST_IPV4); +} + +static void classification_test_pmr_term_ipv6_proto(void) +{ + classification_test_pmr_term_proto(TEST_IPV6); +} + +static void classification_test_pmr_term_dscp(odp_bool_t ipv6) +{ + odp_packet_t pkt; + uint8_t val; + uint8_t mask; + odp_pmr_param_t pmr_param; + cls_packet_info_t pkt_info; + + val = DSCP_CLASS4; + mask = 0x3f; + + odp_cls_pmr_param_init(&pmr_param); + pmr_param.term = ODP_PMR_IP_DSCP; + pmr_param.match.value = &val; + pmr_param.match.mask = &mask; + pmr_param.val_sz = sizeof(val); + + pkt_info = default_pkt_info; + pkt_info.ipv6 = ipv6; + pkt_info.l4_type = CLS_PKT_L4_UDP; + pkt_info.dscp = DSCP_CLASS4; + pkt = create_packet(pkt_info); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + + test_pmr(&pmr_param, pkt, MATCH); + + pkt_info.dscp = 0; + pkt = create_packet(pkt_info); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + + test_pmr(&pmr_param, pkt, NO_MATCH); +} + +static void classification_test_pmr_term_ipv4_dscp(void) +{ + classification_test_pmr_term_dscp(TEST_IPV4); +} + +static void classification_test_pmr_term_ipv6_dscp(void) +{ + classification_test_pmr_term_dscp(TEST_IPV6); +} + static void classification_test_pmr_term_dmac(void) { odp_packet_t pkt; @@ -797,6 +854,44 @@ static void classification_test_pmr_term_vlan_id_x(void) test_pmr(&pmr_param, pkt, NO_MATCH); } +static void classification_test_pmr_term_vlan_pcp_0(void) +{ + odp_packet_t pkt; + uint8_t val; + uint8_t mask; + uint16_t tci; + odp_pmr_param_t pmr_param; + odph_ethhdr_t *eth; + odph_vlanhdr_t *vlan_0; + cls_packet_info_t pkt_info; + + val = 5; + mask = 0x7; + tci = ((uint16_t)val) << ODPH_VLANHDR_PCP_SHIFT; + tci |= 0x123; + + odp_cls_pmr_param_init(&pmr_param); + pmr_param.term = ODP_PMR_VLAN_PCP_0; + pmr_param.match.value = &val; + pmr_param.match.mask = &mask; + pmr_param.val_sz = sizeof(val); + + pkt_info = default_pkt_info; + pkt_info.vlan = true; + pkt = create_packet(pkt_info); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL); + vlan_0 = (odph_vlanhdr_t *)(eth + 1); + vlan_0->tci = odp_cpu_to_be_16(tci); + + test_pmr(&pmr_param, pkt, MATCH); + + pkt = create_packet(pkt_info); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + + test_pmr(&pmr_param, pkt, NO_MATCH); +} + static void classification_test_pmr_term_eth_type_0(void) { odp_packet_t pkt; @@ -1803,6 +1898,11 @@ static int check_capa_ip_proto(void) return cls_capa.supported_terms.bit.ip_proto; } +static int check_capa_ip_dscp(void) +{ + return cls_capa.supported_terms.bit.ip_dscp; +} + static int check_capa_dmac(void) { return cls_capa.supported_terms.bit.dmac; @@ -1843,6 +1943,11 @@ static int check_capa_vlan_id_x(void) return cls_capa.supported_terms.bit.vlan_id_x; } +static int check_capa_vlan_pcp_0(void) +{ + return cls_capa.supported_terms.bit.vlan_pcp_0; +} + static int check_capa_ethtype_0(void) { return cls_capa.supported_terms.bit.ethtype_0; @@ -1945,8 +2050,14 @@ odp_testinfo_t classification_suite_pmr[] = { check_capa_icmp_code), ODP_TEST_INFO_CONDITIONAL(classification_test_pmr_term_icmp_id, check_capa_icmp_id), - ODP_TEST_INFO_CONDITIONAL(classification_test_pmr_term_ipproto, + ODP_TEST_INFO_CONDITIONAL(classification_test_pmr_term_ipv4_proto, + check_capa_ip_proto), + ODP_TEST_INFO_CONDITIONAL(classification_test_pmr_term_ipv6_proto, check_capa_ip_proto), + ODP_TEST_INFO_CONDITIONAL(classification_test_pmr_term_ipv4_dscp, + check_capa_ip_dscp), + ODP_TEST_INFO_CONDITIONAL(classification_test_pmr_term_ipv6_dscp, + check_capa_ip_dscp), ODP_TEST_INFO_CONDITIONAL(classification_test_pmr_term_dmac, check_capa_dmac), ODP_TEST_INFO_CONDITIONAL(classification_test_pmr_pool_set, @@ -1967,6 +2078,8 @@ odp_testinfo_t classification_suite_pmr[] = { check_capa_vlan_id_0), ODP_TEST_INFO_CONDITIONAL(classification_test_pmr_term_vlan_id_x, check_capa_vlan_id_x), + ODP_TEST_INFO_CONDITIONAL(classification_test_pmr_term_vlan_pcp_0, + check_capa_vlan_pcp_0), ODP_TEST_INFO_CONDITIONAL(classification_test_pmr_term_eth_type_0, check_capa_ethtype_0), ODP_TEST_INFO_CONDITIONAL(classification_test_pmr_term_eth_type_x, diff --git a/test/validation/api/classification/odp_classification_testsuites.h b/test/validation/api/classification/odp_classification_testsuites.h index 6b00e138b..592f37cd6 100644 --- a/test/validation/api/classification/odp_classification_testsuites.h +++ b/test/validation/api/classification/odp_classification_testsuites.h @@ -27,7 +27,8 @@ typedef struct cls_packet_info { bool vlan_qinq; odp_atomic_u32_t *seq; cls_packet_l4_info l4_type; - bool ipv6; + odp_bool_t ipv6; + uint8_t dscp; uint32_t len; } cls_packet_info_t; diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c index 97f721dd5..e3eff88b9 100644 --- a/test/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/validation/api/crypto/odp_crypto_test_inp.c @@ -353,9 +353,6 @@ static int alg_packet_op(odp_packet_t pkt, return rc; } - if (!result.ok) - CU_ASSERT(odp_packet_has_error(pkt)); - *ok = result.ok; return 0; diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c index f6408c788..d3ce41a2c 100644 --- a/test/validation/api/pktio/pktio.c +++ b/test/validation/api/pktio/pktio.c @@ -3078,6 +3078,7 @@ static void pktio_test_pktin_ts(void) ns1 = 100; ts = odp_pktio_ts_from_ns(pktio_tx, ns1); ns2 = odp_time_to_ns(ts); + CU_ASSERT_FATAL(res != 0); res_ns = ODP_TIME_SEC_IN_NS / res; if (ODP_TIME_SEC_IN_NS % res) res_ns++; diff --git a/test/validation/api/scheduler/scheduler.c b/test/validation/api/scheduler/scheduler.c index 0dc2db360..490ac9fea 100644 --- a/test/validation/api/scheduler/scheduler.c +++ b/test/validation/api/scheduler/scheduler.c @@ -2297,6 +2297,57 @@ static void scheduler_test_ordered_lock(void) CU_ASSERT(odp_queue_destroy(queue) == 0); } +static void enqueue_event(odp_queue_t queue) +{ + odp_pool_t pool; + odp_buffer_t buf; + odp_event_t ev; + int ret; + + pool = odp_pool_lookup(MSG_POOL_NAME); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + buf = odp_buffer_alloc(pool); + CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID); + ev = odp_buffer_to_event(buf); + ret = odp_queue_enq(queue, ev); + CU_ASSERT_FATAL(ret == 0); +} + +static void scheduler_test_order_wait_1_thread(void) +{ + odp_schedule_capability_t sched_capa; + odp_queue_param_t queue_param; + odp_queue_t queue; + odp_event_t ev; + + CU_ASSERT(!odp_schedule_capability(&sched_capa)); + + sched_queue_param_init(&queue_param); + queue_param.sched.sync = ODP_SCHED_SYNC_ORDERED; + queue = odp_queue_create("ordered queue", &queue_param); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + CU_ASSERT_FATAL(odp_queue_type(queue) == ODP_QUEUE_TYPE_SCHED); + CU_ASSERT_FATAL(odp_queue_sched_type(queue) == ODP_SCHED_SYNC_ORDERED); + + /* Set up an ordered scheduling context */ + enqueue_event(queue); + ev = odp_schedule(NULL, ODP_SCHED_WAIT); + CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID); + odp_event_free(ev); + + /* Fail build if the capability field does not exist */ + printf(" (capa=%d) ", sched_capa.order_wait); + /* Check that order wait does not get stuck or crash */ + odp_schedule_order_wait(); + + /* Release the context */ + ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT); + CU_ASSERT(ev == ODP_EVENT_INVALID); + + CU_ASSERT(odp_queue_destroy(queue) == 0); +} + static int sched_and_plain_thread(void *arg) { odp_event_t ev1, ev2; @@ -3226,6 +3277,7 @@ odp_testinfo_t scheduler_basic_suite[] = { ODP_TEST_INFO(scheduler_test_pause_resume), ODP_TEST_INFO(scheduler_test_pause_enqueue), ODP_TEST_INFO(scheduler_test_ordered_lock), + ODP_TEST_INFO(scheduler_test_order_wait_1_thread), ODP_TEST_INFO_CONDITIONAL(scheduler_test_flow_aware, check_flow_aware_support), ODP_TEST_INFO(scheduler_test_parallel), diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index a8af3f4fa..ccfbf5558 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -36,11 +36,12 @@ #define TICK_INVALID (~(uint64_t)0) /* Test case options */ -#define PRIV 1 -#define EXP_RELAX 1 -#define WAIT 0 -#define CANCEL 1 -#define RESTART 1 +#define PRIV 1 +#define EXP_RELAX 1 +#define WAIT 0 +#define CANCEL 1 +#define RESTART 1 +#define FIRST_TICK 1 /* Timer helper structure */ struct test_timer { @@ -2235,7 +2236,7 @@ static void timer_test_sched_all(void) timer_test_all(ODP_QUEUE_TYPE_SCHED); } -static void timer_test_periodic(odp_queue_type_t queue_type) +static void timer_test_periodic(odp_queue_type_t queue_type, int use_first) { odp_timer_capability_t timer_capa; odp_timer_periodic_capability_t periodic_capa; @@ -2369,7 +2370,9 @@ static void timer_test_periodic(odp_queue_type_t queue_type) cur_tick = odp_timer_current_tick(timer_pool); tick = cur_tick + odp_timer_ns_to_tick(timer_pool, period_ns / 2); - start_param.first_tick = tick; + if (use_first) + start_param.first_tick = tick; + start_param.freq_multiplier = multiplier; start_param.tmo_ev = ev; @@ -2424,7 +2427,9 @@ static void timer_test_periodic(odp_queue_type_t queue_type) } CU_ASSERT(num_tmo == num); - CU_ASSERT(diff_ns < 2 * duration_ns); + + /* Allow +-30% error on test duration */ + CU_ASSERT((diff_ns > 0.7 * duration_ns) && (diff_ns < 1.3 * duration_ns)); /* Stop periodic timer */ ret = odp_timer_periodic_cancel(timer); @@ -2465,6 +2470,10 @@ static void timer_test_periodic(odp_queue_type_t queue_type) } } + /* Check that ack() returned 2 on the last event */ + CU_ASSERT(done); + CU_ASSERT(ret == 2); + CU_ASSERT(odp_timer_free(timer) == ODP_EVENT_INVALID); odp_timer_pool_destroy(timer_pool); CU_ASSERT(odp_queue_destroy(queue) == 0); @@ -2473,12 +2482,22 @@ static void timer_test_periodic(odp_queue_type_t queue_type) static void timer_test_periodic_sched(void) { - timer_test_periodic(ODP_QUEUE_TYPE_SCHED); + timer_test_periodic(ODP_QUEUE_TYPE_SCHED, 0); } static void timer_test_periodic_plain(void) { - timer_test_periodic(ODP_QUEUE_TYPE_PLAIN); + timer_test_periodic(ODP_QUEUE_TYPE_PLAIN, 0); +} + +static void timer_test_periodic_sched_first(void) +{ + timer_test_periodic(ODP_QUEUE_TYPE_SCHED, FIRST_TICK); +} + +static void timer_test_periodic_plain_first(void) +{ + timer_test_periodic(ODP_QUEUE_TYPE_PLAIN, FIRST_TICK); } odp_testinfo_t timer_suite[] = { @@ -2553,8 +2572,12 @@ odp_testinfo_t timer_suite[] = { check_sched_queue_support), ODP_TEST_INFO_CONDITIONAL(timer_test_periodic_sched, check_periodic_sched_support), + ODP_TEST_INFO_CONDITIONAL(timer_test_periodic_sched_first, + check_periodic_sched_support), ODP_TEST_INFO_CONDITIONAL(timer_test_periodic_plain, check_periodic_plain_support), + ODP_TEST_INFO_CONDITIONAL(timer_test_periodic_plain_first, + check_periodic_plain_support), ODP_TEST_INFO_NULL, }; |