/*-
* BSD LICENSE
- *
+ *
* Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* ======
*
* Allocate some dynamic memory from heap (3 areas). Check that areas
- * don't overlap an that alignment constraints match. This test is
+ * don't overlap and that alignment constraints match. This test is
* done many times on different lcores simultaneously.
*/
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");
+ /* Allocation may increase, or may be the same as before big allocation */
+ if (post_stats.heap_totalsz_bytes < pre_stats.heap_totalsz_bytes) {
+ printf("Malloc statistics are incorrect - heap_totalsz_bytes\n");
return -1;
}
/* Check that allocated size adds up correctly */
return -1;
}
/* New blocks now available - just allocated 1 but also 1 new free */
- if(post_stats.free_count != pre_stats.free_count ) {
+ if (post_stats.free_count != pre_stats.free_count &&
+ post_stats.free_count != pre_stats.free_count - 1) {
printf("Malloc statistics are incorrect - free_count\n");
return -1;
}
}
/* Make sure that we didn't touch our greatest chunk: 2 * 11M) */
- if (second_stats.greatest_free_size != pre_stats.greatest_free_size) {
+ if (post_stats.greatest_free_size != pre_stats.greatest_free_size) {
printf("Incorrect heap statistics: Greatest free size \n");
return -1;
}
printf("NULL pointer returned from rte_zmalloc\n");
return -1;
}
- rte_snprintf(ptr1, size1, "%s" ,hello_str);
+ snprintf(ptr1, size1, "%s" ,hello_str);
char *ptr2 = rte_realloc(ptr1, size2, CACHE_LINE_SIZE);
if (!ptr2){
rte_free(ptr1);
ret = test_multi_alloc_statistics();
if (ret < 0) {
- printf("test_muti_alloc_statistics() failed\n");
+ printf("test_multi_alloc_statistics() failed\n");
return ret;
}
else
- printf("test_muti_alloc_statistics() passed\n");
+ printf("test_multi_alloc_statistics() passed\n");
return 0;
}