Skip to content

Commit

Permalink
test/malloc: fix statistics checks
Browse files Browse the repository at this point in the history
[ upstream commit 19606f83e6c1dffea9bda42a792e1cbbc6d5a043 ]

The case expects all stats to be equal.
Therefore the negative conditions in check should be logically or'ed.

Fixes: a40a1f8 ("app: various tests update")

Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Feifei Wang <feifei.wang2@arm.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
  • Loading branch information
Ruifeng Wang authored and kevintraynor committed Jul 11, 2023
1 parent 13c7286 commit c2f6df5
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions app/test/test_malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,11 @@ test_multi_alloc_statistics(void)
rte_malloc_get_socket_stats(socket,&post_stats);
/* Check statistics reported are correct */
/* All post stats should be equal to pre stats after alloc freed */
if ((post_stats.heap_totalsz_bytes != pre_stats.heap_totalsz_bytes) &&
(post_stats.heap_freesz_bytes!=pre_stats.heap_freesz_bytes) &&
(post_stats.heap_allocsz_bytes!=pre_stats.heap_allocsz_bytes)&&
(post_stats.alloc_count!=pre_stats.alloc_count)&&
(post_stats.free_count!=pre_stats.free_count)) {
if ((post_stats.heap_totalsz_bytes != pre_stats.heap_totalsz_bytes) ||
(post_stats.heap_freesz_bytes != pre_stats.heap_freesz_bytes) ||
(post_stats.heap_allocsz_bytes != pre_stats.heap_allocsz_bytes) ||
(post_stats.alloc_count != pre_stats.alloc_count) ||
(post_stats.free_count != pre_stats.free_count)) {
printf("Malloc statistics are incorrect - freed alloc\n");
return -1;
}
Expand Down Expand Up @@ -362,11 +362,11 @@ test_multi_alloc_statistics(void)
return -1;
}

if ((post_stats.heap_totalsz_bytes != pre_stats.heap_totalsz_bytes) &&
(post_stats.heap_freesz_bytes!=pre_stats.heap_freesz_bytes) &&
(post_stats.heap_allocsz_bytes!=pre_stats.heap_allocsz_bytes)&&
(post_stats.alloc_count!=pre_stats.alloc_count)&&
(post_stats.free_count!=pre_stats.free_count)) {
if ((post_stats.heap_totalsz_bytes != pre_stats.heap_totalsz_bytes) ||
(post_stats.heap_freesz_bytes != pre_stats.heap_freesz_bytes) ||
(post_stats.heap_allocsz_bytes != pre_stats.heap_allocsz_bytes) ||
(post_stats.alloc_count != pre_stats.alloc_count) ||
(post_stats.free_count != pre_stats.free_count)) {
printf("Malloc statistics are incorrect - freed alloc\n");
return -1;
}
Expand Down

0 comments on commit c2f6df5

Please sign in to comment.