diff options
Diffstat (limited to 'test/validation/api/pool/pool.c')
-rw-r--r-- | test/validation/api/pool/pool.c | 97 |
1 files changed, 83 insertions, 14 deletions
diff --git a/test/validation/api/pool/pool.c b/test/validation/api/pool/pool.c index cded05650..b335f194c 100644 --- a/test/validation/api/pool/pool.c +++ b/test/validation/api/pool/pool.c @@ -1098,6 +1098,7 @@ static int pool_check_timeout_pool_statistics(void) static void pool_test_pool_statistics(odp_pool_type_t pool_type) { odp_pool_stats_t stats; + odp_pool_stats_selected_t selected; odp_pool_param_t param; odp_pool_stats_opt_t supported; uint32_t i, j, num_pool, num_obj, cache_size; @@ -1164,8 +1165,8 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type) CU_ASSERT_FATAL(max_pools != 0); /* Extra alloc rounds for testing odp_pool_stats_t.alloc_fails */ - uint32_t num_alloc_rounds = num_obj + 100; - odp_event_t event[max_pools][num_alloc_rounds]; + uint32_t num_allocs = num_obj + 100; + odp_event_t event[max_pools][num_allocs]; uint32_t num_event[max_pools]; odp_pool_t pool[max_pools]; @@ -1187,22 +1188,40 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type) stats.thread.first = first; stats.thread.last = last; CU_ASSERT_FATAL(odp_pool_stats(pool[i], &stats) == 0); + CU_ASSERT_FATAL(odp_pool_stats_selected(pool[i], &selected, &supported) == 0); CU_ASSERT(stats.available <= num_obj); + if (supported.bit.available) + CU_ASSERT(selected.available <= num_obj); CU_ASSERT(stats.alloc_ops == 0); + if (supported.bit.alloc_ops) + CU_ASSERT(selected.alloc_ops == 0); CU_ASSERT(stats.alloc_fails == 0); + if (supported.bit.alloc_fails) + CU_ASSERT(selected.alloc_fails == 0); CU_ASSERT(stats.free_ops == 0); + if (supported.bit.free_ops) + CU_ASSERT(selected.free_ops == 0); CU_ASSERT(stats.total_ops == 0); + if (supported.bit.total_ops) + CU_ASSERT(selected.total_ops == 0); CU_ASSERT(stats.cache_available <= num_obj); + if (supported.bit.cache_available) + CU_ASSERT(selected.cache_available <= num_obj); CU_ASSERT(stats.cache_alloc_ops == 0); + if (supported.bit.cache_alloc_ops) + CU_ASSERT(selected.cache_alloc_ops == 0); CU_ASSERT(stats.cache_free_ops == 0); + if (supported.bit.cache_free_ops) + CU_ASSERT(selected.cache_free_ops == 0); + CU_ASSERT(stats.thread.first == first); CU_ASSERT(stats.thread.last == last); for (j = 0; j < ODP_POOL_MAX_THREAD_STATS; j++) CU_ASSERT(stats.thread.cache_available[j] <= stats.cache_available); /* Allocate the events */ - for (j = 0; j < num_alloc_rounds; j++) { + for (j = 0; j < num_allocs; j++) { odp_event_t new_event = ODP_EVENT_INVALID; uint64_t total_cached = 0; uint16_t first_id = 0; @@ -1236,8 +1255,14 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type) num_fails++; CU_ASSERT_FATAL(odp_pool_stats(pool[i], &stats) == 0); + CU_ASSERT_FATAL(odp_pool_stats_selected(pool[i], &selected, + &supported) == 0); CU_ASSERT(stats.available <= num_obj - num_events); + if (supported.bit.available) + CU_ASSERT(selected.available <= num_obj - num_events); CU_ASSERT(stats.cache_available <= num_obj - num_events); + if (supported.bit.cache_available) + CU_ASSERT(selected.cache_available <= num_obj - num_events); while (first_id < odp_thread_count_max()) { stats.thread.first = first_id; @@ -1264,39 +1289,70 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type) CU_ASSERT(num_events == num_obj); num_event[i] = num_events; + /* Allow implementation some time to update counters */ + odp_time_wait_ns(ODP_TIME_MSEC_IN_NS); + stats.thread.first = first; stats.thread.last = last; CU_ASSERT_FATAL(odp_pool_stats(pool[i], &stats) == 0); + CU_ASSERT_FATAL(odp_pool_stats_selected(pool[i], &selected, &supported) == 0); /* All events are allocated, available count in pool and pool * local caches should be zero. */ CU_ASSERT(stats.available == 0); + if (supported.bit.available) + CU_ASSERT(selected.available == 0); CU_ASSERT(stats.cache_available == 0); + if (supported.bit.cache_available) + CU_ASSERT(selected.cache_available == 0); for (j = 0; j < ODP_POOL_MAX_THREAD_STATS; j++) CU_ASSERT(stats.thread.cache_available[j] == 0); - if (supported.bit.alloc_ops) - CU_ASSERT(stats.alloc_ops > 0 && stats.alloc_ops <= num_obj + 1); - if (supported.bit.alloc_fails) + if (supported.bit.alloc_ops) { + CU_ASSERT(stats.alloc_ops > 0 && stats.alloc_ops <= num_allocs); + CU_ASSERT(selected.alloc_ops > 0 && selected.alloc_ops <= num_allocs); + } + if (supported.bit.alloc_fails) { CU_ASSERT(stats.alloc_fails == num_fails); - if (supported.bit.total_ops) - CU_ASSERT(stats.total_ops > 0 && stats.total_ops <= num_obj + 1); + CU_ASSERT(selected.alloc_fails == num_fails); + } + if (supported.bit.total_ops) { + CU_ASSERT(stats.total_ops > 0 && stats.total_ops <= num_allocs); + CU_ASSERT(selected.total_ops > 0 && selected.total_ops <= num_allocs); + } CU_ASSERT(stats.free_ops == 0); + if (supported.bit.free_ops) + CU_ASSERT(selected.free_ops == 0); + CU_ASSERT(stats.cache_alloc_ops <= num_allocs); + if (supported.bit.cache_alloc_ops) + CU_ASSERT(selected.cache_alloc_ops <= num_allocs); CU_ASSERT(stats.cache_free_ops == 0); + if (supported.bit.cache_free_ops) + CU_ASSERT(selected.cache_free_ops == 0); } for (i = 0; i < num_pool; i++) { odp_event_free_multi(event[i], num_event[i]); + /* Allow implementation some time to update counters */ + odp_time_wait_ns(ODP_TIME_MSEC_IN_NS); + stats.thread.first = odp_thread_id(); stats.thread.last = odp_thread_id(); CU_ASSERT_FATAL(odp_pool_stats(pool[i], &stats) == 0); + CU_ASSERT_FATAL(odp_pool_stats_selected(pool[i], &selected, &supported) == 0); - if (supported.bit.available && supported.bit.cache_available) + if (supported.bit.available && supported.bit.cache_available) { CU_ASSERT(stats.available + stats.cache_available == num_obj); - if (supported.bit.free_ops) + CU_ASSERT(selected.available + selected.cache_available == num_obj); + } + if (supported.bit.free_ops) { CU_ASSERT(stats.free_ops > 0); - if (supported.bit.total_ops) + CU_ASSERT(selected.free_ops > 0); + } + if (supported.bit.total_ops) { CU_ASSERT(stats.total_ops > 0); + CU_ASSERT(selected.total_ops > 0); + } if (i == 0) { printf("\nPool Statistics\n---------------\n"); @@ -1314,13 +1370,26 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type) CU_ASSERT_FATAL(odp_pool_stats_reset(pool[i]) == 0); CU_ASSERT_FATAL(odp_pool_stats(pool[i], &stats) == 0); + CU_ASSERT_FATAL(odp_pool_stats_selected(pool[i], &selected, &supported) == 0); CU_ASSERT(stats.alloc_ops == 0); + if (supported.bit.alloc_ops) + CU_ASSERT(selected.alloc_ops == 0); CU_ASSERT(stats.alloc_fails == 0); + if (supported.bit.alloc_fails) + CU_ASSERT(selected.alloc_fails == 0); CU_ASSERT(stats.free_ops == 0); + if (supported.bit.free_ops) + CU_ASSERT(selected.free_ops == 0); CU_ASSERT(stats.total_ops == 0); + if (supported.bit.total_ops) + CU_ASSERT(selected.total_ops == 0); CU_ASSERT(stats.cache_alloc_ops == 0); + if (supported.bit.cache_alloc_ops) + CU_ASSERT(selected.cache_alloc_ops == 0); CU_ASSERT(stats.cache_free_ops == 0); + if (supported.bit.cache_free_ops) + CU_ASSERT(selected.cache_free_ops == 0); CU_ASSERT(odp_pool_destroy(pool[i]) == 0); } @@ -1858,7 +1927,7 @@ static int pool_suite_init(void) memset(&default_pool_param, 0, sizeof(odp_pool_param_t)); if (odp_pool_capability(&global_pool_capa) < 0) { - printf("pool_capability failed in suite init\n"); + ODPH_ERR("odp_pool_capability() failed in suite init\n"); return -1; } @@ -1872,12 +1941,12 @@ static int pool_ext_suite_init(void) memset(&global_pool_ext_capa, 0, sizeof(odp_pool_ext_capability_t)); if (odp_pool_ext_capability(ODP_POOL_PACKET, &global_pool_ext_capa)) { - printf("Pool ext capa failed in suite init\n"); + ODPH_ERR("Pool ext capa failed in suite init\n"); return -1; } if (global_pool_ext_capa.type != ODP_POOL_PACKET) { - printf("Bad type from pool ext capa in suite init\n"); + ODPH_ERR("Bad type from pool ext capa in suite init\n"); return -1; } |