-static int
-test_big_alloc(void)
-{
- int socket = 0;
- struct rte_malloc_socket_stats pre_stats, post_stats;
- size_t size =rte_str_to_size(MALLOC_MEMZONE_SIZE)*2;
- int align = 0;
-#ifndef RTE_LIBRTE_MALLOC_DEBUG
- int overhead = 64 + 64;
-#else
- int overhead = 64 + 64 + 64;
-#endif
-
- rte_malloc_get_socket_stats(socket, &pre_stats);
-
- void *p1 = rte_malloc_socket("BIG", size , align, socket);
- if (!p1)
- return -1;
- rte_malloc_get_socket_stats(socket,&post_stats);
-
- /* Check statistics reported are correct */
- /* Allocation increase, cannot be the same as before big allocation */
- if (post_stats.heap_totalsz_bytes == pre_stats.heap_totalsz_bytes) {
- printf("Malloc statistics are incorrect - heap_totalz_bytes\n");
- return -1;
- }
- /* Check that allocated size adds up correctly */
- if (post_stats.heap_allocsz_bytes !=
- pre_stats.heap_allocsz_bytes + size + align + overhead) {
- printf("Malloc statistics are incorrect - alloc_size\n");
- return -1;
- }
- /* Check free size against tested allocated size */
- if (post_stats.heap_freesz_bytes !=
- post_stats.heap_totalsz_bytes - post_stats.heap_allocsz_bytes) {
- printf("Malloc statistics are incorrect - heap_freesz_bytes\n");
- return -1;
- }
- /* Number of allocated blocks must increase after allocation */
- if (post_stats.alloc_count != pre_stats.alloc_count + 1) {
- printf("Malloc statistics are incorrect - alloc_count\n");
- return -1;
- }
- /* New blocks now available - just allocated 1 but also 1 new free */
- if(post_stats.free_count != pre_stats.free_count ) {
- printf("Malloc statistics are incorrect - free_count\n");
- return -1;
- }
-
- rte_free(p1);
- return 0;
-}
-