aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2024-01-05 15:43:49 +0200
committerMatias Elo <matias.elo@nokia.com>2024-01-29 12:53:16 +0200
commitfa734755ba7ada322b568bc63a4c3ccbbb815b8b (patch)
tree7f7f29147877fdb26fd3558ece47656cfe5742ad /test
parent016946a13c33899b075d31e97169857c04c83614 (diff)
validation: pool: fix pool statistics test
Values of per thread counters (odp_pool_stats_t.thread.cache_available[]) are undefined if these counters are not supported/enabled. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
Diffstat (limited to 'test')
-rw-r--r--test/validation/api/pool/pool.c65
1 files changed, 36 insertions, 29 deletions
diff --git a/test/validation/api/pool/pool.c b/test/validation/api/pool/pool.c
index 6f9b054ac..ee8aa4b67 100644
--- a/test/validation/api/pool/pool.c
+++ b/test/validation/api/pool/pool.c
@@ -1446,8 +1446,10 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type)
CU_ASSERT(stats.thread.first == first);
CU_ASSERT(stats.thread.last == last);
- for (j = 0; j < num_thr; j++)
- CU_ASSERT(stats.thread.cache_available[j] <= stats.cache_available);
+ if (supported.bit.thread_cache_available) {
+ for (j = 0; j < num_thr; j++)
+ CU_ASSERT(stats.thread.cache_available[j] <= stats.cache_available);
+ }
/* Allocate the events */
for (j = 0; j < num_allocs; j++) {
@@ -1493,29 +1495,31 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type)
if (supported.bit.cache_available)
CU_ASSERT(selected.cache_available <= num_obj - num_events);
- while (first_id < odp_thread_count_max()) {
- memset(&stats, 0xff, sizeof(odp_pool_stats_t));
-
- stats.thread.first = first_id;
- stats.thread.last = last_id;
- num_thr = last_id - first_id + 1;
- CU_ASSERT_FATAL(odp_pool_stats(pool[i], &stats) == 0);
-
- for (uint32_t k = 0; k < num_thr; k++) {
- uint64_t cached = stats.thread.cache_available[k];
-
- CU_ASSERT(cached <= num_obj - num_events);
- total_cached += cached;
- }
- first_id = last_id + 1;
- last_id += ODP_POOL_MAX_THREAD_STATS;
- if (last_id >= odp_thread_count_max())
- last_id = odp_thread_count_max() - 1;
- };
-
- if (supported.bit.cache_available && supported.bit.thread_cache_available &&
- ODP_POOL_MAX_THREAD_STATS >= odp_thread_count_max())
- CU_ASSERT(stats.cache_available == total_cached);
+ if (supported.bit.thread_cache_available) {
+ while (first_id < odp_thread_count_max()) {
+ memset(&stats, 0xff, sizeof(odp_pool_stats_t));
+
+ stats.thread.first = first_id;
+ stats.thread.last = last_id;
+ num_thr = last_id - first_id + 1;
+ CU_ASSERT_FATAL(odp_pool_stats(pool[i], &stats) == 0);
+
+ for (uint32_t k = 0; k < num_thr; k++) {
+ uint64_t cached = stats.thread.cache_available[k];
+
+ CU_ASSERT(cached <= num_obj - num_events);
+ total_cached += cached;
+ }
+ first_id = last_id + 1;
+ last_id += ODP_POOL_MAX_THREAD_STATS;
+ if (last_id >= odp_thread_count_max())
+ last_id = odp_thread_count_max() - 1;
+ };
+
+ if (supported.bit.cache_available &&
+ ODP_POOL_MAX_THREAD_STATS >= odp_thread_count_max())
+ CU_ASSERT(stats.cache_available == total_cached);
+ }
}
CU_ASSERT(num_events == num_obj);
@@ -1541,8 +1545,10 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type)
CU_ASSERT(stats.cache_available == 0);
if (supported.bit.cache_available)
CU_ASSERT(selected.cache_available == 0);
- for (j = 0; j < num_thr; j++)
- CU_ASSERT(stats.thread.cache_available[j] == 0);
+ if (supported.bit.thread_cache_available) {
+ for (j = 0; j < num_thr; j++)
+ CU_ASSERT(stats.thread.cache_available[j] == 0);
+ }
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);
@@ -1600,8 +1606,9 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type)
printf(" cache_available: %" PRIu64 "\n", stats.cache_available);
printf(" cache_alloc_ops: %" PRIu64 "\n", stats.cache_alloc_ops);
printf(" cache_free_ops: %" PRIu64 "\n", stats.cache_free_ops);
- printf(" thread.cache_available[0]: %" PRIu64 "\n",
- stats.thread.cache_available[0]);
+ if (supported.bit.thread_cache_available)
+ printf(" thread.cache_available[0]: %" PRIu64 "\n",
+ stats.thread.cache_available[0]);
}
CU_ASSERT_FATAL(odp_pool_stats_reset(pool[i]) == 0);