first public release
[dpdk.git] / app / test / test_malloc.c
1 /*-
2  *   BSD LICENSE
3  * 
4  *   Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  * 
7  *   Redistribution and use in source and binary forms, with or without 
8  *   modification, are permitted provided that the following conditions 
9  *   are met:
10  * 
11  *     * Redistributions of source code must retain the above copyright 
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright 
14  *       notice, this list of conditions and the following disclaimer in 
15  *       the documentation and/or other materials provided with the 
16  *       distribution.
17  *     * Neither the name of Intel Corporation nor the names of its 
18  *       contributors may be used to endorse or promote products derived 
19  *       from this software without specific prior written permission.
20  * 
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  * 
33  *  version: DPDK.L.1.2.3-3
34  */
35
36 #include <stdio.h>
37 #include <stdint.h>
38 #include <string.h>
39 #include <stdarg.h>
40 #include <errno.h>
41 #include <stdlib.h>
42 #include <sys/queue.h>
43
44 #include <cmdline_parse.h>
45
46 #include <rte_common.h>
47 #include <rte_memory.h>
48 #include <rte_memzone.h>
49 #include <rte_per_lcore.h>
50 #include <rte_launch.h>
51 #include <rte_tailq.h>
52 #include <rte_eal.h>
53 #include <rte_per_lcore.h>
54 #include <rte_lcore.h>
55 #include <rte_malloc.h>
56 #include <rte_cycles.h>
57 #include <rte_random.h>
58 #include <rte_string_fns.h>
59
60 #include "test.h"
61
62 #define N 10000
63
64 #define QUOTE_(x) #x
65 #define QUOTE(x) QUOTE_(x)
66 #define MALLOC_MEMZONE_SIZE QUOTE(RTE_MALLOC_MEMZONE_SIZE)
67
68 /*
69  * Malloc
70  * ======
71  *
72  * Allocate some dynamic memory from heap (3 areas). Check that areas
73  * don't overlap an that alignment constraints match. This test is
74  * done many times on different lcores simultaneously.
75  */
76
77 /* Test if memory overlaps: return 1 if true, or 0 if false. */
78 static int
79 is_memory_overlap(void *p1, size_t len1, void *p2, size_t len2)
80 {
81         unsigned long ptr1 = (unsigned long)p1;
82         unsigned long ptr2 = (unsigned long)p2;
83
84         if (ptr2 >= ptr1 && (ptr2 - ptr1) < len1)
85                 return 1;
86         else if (ptr2 < ptr1 && (ptr1 - ptr2) < len2)
87                 return 1;
88         return 0;
89 }
90
91 static int
92 is_aligned(void *p, int align)
93 {
94         unsigned long addr = (unsigned long)p;
95         unsigned mask = align - 1;
96
97         if (addr & mask)
98                 return 0;
99         return 1;
100 }
101
102 static int
103 test_align_overlap_per_lcore(__attribute__((unused)) void *arg)
104 {
105         const unsigned align1 = 8,
106                         align2 = 64,
107                         align3 = 2048;
108         unsigned i,j;
109         void *p1 = NULL, *p2 = NULL, *p3 = NULL;
110         int ret = 0;
111
112         for (i = 0; i < N; i++) {
113                 p1 = rte_zmalloc("dummy", 1000, align1);
114                 if (!p1){
115                         printf("rte_zmalloc returned NULL (i=%u)\n", i);
116                         ret = -1;
117                         break;
118                 }
119                 for(j = 0; j < 1000 ; j++) {
120                         if( *(char *)p1 != 0) {
121                                 printf("rte_zmalloc didn't zeroed"
122                                        "the allocated memory\n");
123                                 ret = -1;
124                         }
125                 }
126                 p2 = rte_malloc("dummy", 1000, align2);
127                 if (!p2){
128                         printf("rte_malloc returned NULL (i=%u)\n", i);
129                         ret = -1;
130                         rte_free(p1);
131                         break;
132                 }
133                 p3 = rte_malloc("dummy", 1000, align3);
134                 if (!p3){
135                         printf("rte_malloc returned NULL (i=%u)\n", i);
136                         ret = -1;
137                         rte_free(p1);
138                         rte_free(p2);
139                         break;
140                 }
141                 if (is_memory_overlap(p1, 1000, p2, 1000)) {
142                         printf("p1 and p2 overlaps\n");
143                         ret = -1;
144                 }
145                 if (is_memory_overlap(p2, 1000, p3, 1000)) {
146                         printf("p2 and p3 overlaps\n");
147                         ret = -1;
148                 }
149                 if (is_memory_overlap(p1, 1000, p3, 1000)) {
150                         printf("p1 and p3 overlaps\n");
151                         ret = -1;
152                 }
153                 if (!is_aligned(p1, align1)) {
154                         printf("p1 is not aligned\n");
155                         ret = -1;
156                 }
157                 if (!is_aligned(p2, align2)) {
158                         printf("p2 is not aligned\n");
159                         ret = -1;
160                 }
161                 if (!is_aligned(p3, align3)) {
162                         printf("p3 is not aligned\n");
163                         ret = -1;
164                 }
165                 rte_free(p1);
166                 rte_free(p2);
167                 rte_free(p3);
168         }
169         rte_malloc_dump_stats("dummy");
170
171         return ret;
172 }
173
174 static int
175 test_reordered_free_per_lcore(__attribute__((unused)) void *arg)
176 {
177         const unsigned align1 = 8,
178                         align2 = 64,
179                         align3 = 2048;
180         unsigned i,j;
181         void *p1, *p2, *p3;
182         int ret = 0;
183
184         for (i = 0; i < 30; i++) {
185                 p1 = rte_zmalloc("dummy", 1000, align1);
186                 if (!p1){
187                         printf("rte_zmalloc returned NULL (i=%u)\n", i);
188                         ret = -1;
189                         break;
190                 }
191                 for(j = 0; j < 1000 ; j++) {
192                         if( *(char *)p1 != 0) {
193                                 printf("rte_zmalloc didn't zeroed"
194                                        "the allocated memory\n");
195                                 ret = -1;
196                         }
197                 }
198                 /* use calloc to allocate 1000 16-byte items this time */
199                 p2 = rte_calloc("dummy", 1000, 16, align2);
200                 /* for third request use regular malloc again */
201                 p3 = rte_malloc("dummy", 1000, align3);
202                 if (!p2 || !p3){
203                         printf("rte_malloc returned NULL (i=%u)\n", i);
204                         ret = -1;
205                         break;
206                 }
207                 if (is_memory_overlap(p1, 1000, p2, 1000)) {
208                         printf("p1 and p2 overlaps\n");
209                         ret = -1;
210                 }
211                 if (is_memory_overlap(p2, 1000, p3, 1000)) {
212                         printf("p2 and p3 overlaps\n");
213                         ret = -1;
214                 }
215                 if (is_memory_overlap(p1, 1000, p3, 1000)) {
216                         printf("p1 and p3 overlaps\n");
217                         ret = -1;
218                 }
219                 if (!is_aligned(p1, align1)) {
220                         printf("p1 is not aligned\n");
221                         ret = -1;
222                 }
223                 if (!is_aligned(p2, align2)) {
224                         printf("p2 is not aligned\n");
225                         ret = -1;
226                 }
227                 if (!is_aligned(p3, align3)) {
228                         printf("p3 is not aligned\n");
229                         ret = -1;
230                 }
231                 /* try freeing in every possible order */
232                 switch (i%6){
233                 case 0:
234                         rte_free(p1);
235                         rte_free(p2);
236                         rte_free(p3);
237                         break;
238                 case 1:
239                         rte_free(p1);
240                         rte_free(p3);
241                         rte_free(p2);
242                         break;
243                 case 2:
244                         rte_free(p2);
245                         rte_free(p1);
246                         rte_free(p3);
247                         break;
248                 case 3:
249                         rte_free(p2);
250                         rte_free(p3);
251                         rte_free(p1);
252                         break;
253                 case 4:
254                         rte_free(p3);
255                         rte_free(p1);
256                         rte_free(p2);
257                         break;
258                 case 5:
259                         rte_free(p3);
260                         rte_free(p2);
261                         rte_free(p1);
262                         break;
263                 }
264         }
265         rte_malloc_dump_stats("dummy");
266
267         return ret;
268 }
269
270
271 /* test function inside the malloc lib*/
272 static int
273 test_str_to_size(void)
274 {
275         struct {
276                 const char *str;
277                 uint64_t value;
278         } test_values[] =
279                 {{ "5G", (uint64_t)5 * 1024 * 1024 *1024 },
280                                 {"0x20g", (uint64_t)0x20 * 1024 * 1024 *1024},
281                                 {"10M", 10 * 1024 * 1024},
282                                 {"050m", 050 * 1024 * 1024},
283                                 {"8K", 8 * 1024},
284                                 {"15k", 15 * 1024},
285                                 {"0200", 0200},
286                                 {"0x103", 0x103},
287                                 {"432", 432},
288                                 {"-1", 0}, /* negative values return 0 */
289                                 {"  -2", 0},
290                                 {"  -3MB", 0},
291                                 {"18446744073709551616", 0} /* ULLONG_MAX + 1 == out of range*/
292                 };
293         unsigned i;
294         for (i = 0; i < sizeof(test_values)/sizeof(test_values[0]); i++)
295                 if (rte_str_to_size(test_values[i].str) != test_values[i].value)
296                         return -1;
297         return 0;
298 }
299
300 static int
301 test_big_alloc(void)
302 {
303         void *p1 = rte_malloc("BIG", rte_str_to_size(MALLOC_MEMZONE_SIZE) * 2, 1024);
304         if (!p1)
305                 return -1;
306         rte_free(p1);
307         return 0;
308 }
309
310 static int
311 test_memzone_size_alloc(void)
312 {
313         void *p1 = rte_malloc("BIG", rte_str_to_size(MALLOC_MEMZONE_SIZE) - 128, 64);
314         if (!p1)
315                 return -1;
316         rte_free(p1);
317         /* one extra check - check no crashes if free(NULL) */
318         rte_free(NULL);
319         return 0;
320 }
321
322 static int
323 test_rte_malloc_type_limits(void)
324 {
325         /* The type-limits functionality is not yet implemented,
326          * so always return 0 no matter what the retval.
327          */
328         const char *typename = "limit_test";
329         rte_malloc_set_limit(typename, 64 * 1024);
330         rte_malloc_dump_stats(typename);
331         return 0;
332 }
333
334 static int
335 test_realloc(void)
336 {
337         const char hello_str[] = "Hello, world!";
338         const unsigned size1 = 1024;
339         const unsigned size2 = size1 + 1024;
340         const unsigned size3 = size2;
341         const unsigned size4 = size3 + 1024;
342
343         /* test data is the same even if element is moved*/
344         char *ptr1 = rte_zmalloc(NULL, size1, CACHE_LINE_SIZE);
345         if (!ptr1){
346                 printf("NULL pointer returned from rte_zmalloc\n");
347                 return -1;
348         }
349         rte_snprintf(ptr1, size1, "%s" ,hello_str);
350         char *ptr2 = rte_realloc(ptr1, size2, CACHE_LINE_SIZE);
351         if (!ptr2){
352                 rte_free(ptr1);
353                 printf("NULL pointer returned from rte_realloc\n");
354                 return -1;
355         }
356         if (ptr1 == ptr2){
357                 printf("unexpected - ptr1 == ptr2\n");
358         }
359         if (strcmp(ptr2, hello_str) != 0){
360                 printf("Error - lost data from pointed area\n");
361                 rte_free(ptr2);
362                 return -1;
363         }
364         unsigned i;
365         for (i = strnlen(hello_str, sizeof(hello_str)); i < size1; i++)
366                 if (ptr2[i] != 0){
367                         printf("Bad data in realloc\n");
368                         rte_free(ptr2);
369                         return -1;
370                 }
371         /* now allocate third element, free the second
372          * and resize third. It should not move. (ptr1 is now invalid)
373          */
374         char *ptr3 = rte_zmalloc(NULL, size3, CACHE_LINE_SIZE);
375         if (!ptr3){
376                 printf("NULL pointer returned from rte_zmalloc\n");
377                 rte_free(ptr2);
378                 return -1;
379         }
380         for (i = 0; i < size3; i++)
381                 if (ptr3[i] != 0){
382                         printf("Bad data in zmalloc\n");
383                         rte_free(ptr3);
384                         rte_free(ptr2);
385                         return -1;
386                 }
387         rte_free(ptr2);
388         /* first resize to half the size of the freed block */
389         char *ptr4 = rte_realloc(ptr3, size4, CACHE_LINE_SIZE);
390         if (!ptr4){
391                 printf("NULL pointer returned from rte_realloc\n");
392                 rte_free(ptr3);
393                 return -1;
394         }
395         if (ptr3 != ptr4){
396                 printf("Unexpected - ptr4 != ptr3\n");
397                 rte_free(ptr4);
398                 return -1;
399         }
400         /* now resize again to the full size of the freed block */
401         ptr4 = rte_realloc(ptr3, size3 + size2 + size1, CACHE_LINE_SIZE);
402         if (ptr3 != ptr4){
403                 printf("Unexpected - ptr4 != ptr3 on second resize\n");
404                 rte_free(ptr4);
405                 return -1;
406         }
407         rte_free(ptr4);
408
409         /* now try a resize to a smaller size, see if it works */
410         const unsigned size5 = 1024;
411         const unsigned size6 = size5 / 2;
412         char *ptr5 = rte_malloc(NULL, size5, CACHE_LINE_SIZE);
413         if (!ptr5){
414                 printf("NULL pointer returned from rte_malloc\n");
415                 return -1;
416         }
417         char *ptr6 = rte_realloc(ptr5, size6, CACHE_LINE_SIZE);
418         if (!ptr6){
419                 printf("NULL pointer returned from rte_realloc\n");
420                 rte_free(ptr5);
421                 return -1;
422         }
423         if (ptr5 != ptr6){
424                 printf("Error, resizing to a smaller size moved data\n");
425                 rte_free(ptr6);
426                 return -1;
427         }
428         rte_free(ptr6);
429
430         /* check for behaviour changing alignment */
431         const unsigned size7 = 1024;
432         const unsigned orig_align = CACHE_LINE_SIZE;
433         unsigned new_align = CACHE_LINE_SIZE * 2;
434         char *ptr7 = rte_malloc(NULL, size7, orig_align);
435         if (!ptr7){
436                 printf("NULL pointer returned from rte_malloc\n");
437                 return -1;
438         }
439         /* calc an alignment we don't already have */
440         while(RTE_ALIGN(ptr7, new_align) == ptr7)
441                 new_align *= 2;
442         char *ptr8 = rte_realloc(ptr7, size7, new_align);
443         if (!ptr8){
444                 printf("NULL pointer returned from rte_realloc\n");
445                 rte_free(ptr7);
446                 return -1;
447         }
448         if (RTE_ALIGN(ptr8, new_align) != ptr8){
449                 printf("Failure to re-align data\n");
450                 rte_free(ptr8);
451                 return -1;
452         }
453         rte_free(ptr8);
454
455         /* test behaviour when there is a free block after current one,
456          * but its not big enough
457          */
458         unsigned size9 = 1024, size10 = 1024;
459         unsigned size11 = size9 + size10 + 256;
460         char *ptr9 = rte_malloc(NULL, size9, CACHE_LINE_SIZE);
461         if (!ptr9){
462                 printf("NULL pointer returned from rte_malloc\n");
463                 return -1;
464         }
465         char *ptr10 = rte_malloc(NULL, size10, CACHE_LINE_SIZE);
466         if (!ptr10){
467                 printf("NULL pointer returned from rte_malloc\n");
468                 return -1;
469         }
470         rte_free(ptr9);
471         char *ptr11 = rte_realloc(ptr10, size11, CACHE_LINE_SIZE);
472         if (!ptr11){
473                 printf("NULL pointer returned from rte_realloc\n");
474                 rte_free(ptr10);
475                 return -1;
476         }
477         if (ptr11 == ptr10){
478                 printf("Error, unexpected that realloc has not created new buffer\n");
479                 rte_free(ptr11);
480                 return -1;
481         }
482         rte_free(ptr11);
483
484         /* check we don't crash if we pass null to realloc
485          * We should get a malloc of the size requested*/
486         const size_t size12 = 1024;
487         size_t size12_check;
488         char *ptr12 = rte_realloc(NULL, size12, CACHE_LINE_SIZE);
489         if (!ptr12){
490                 printf("NULL pointer returned from rte_realloc\n");
491                 return -1;
492         }
493         if (rte_malloc_validate(ptr12, &size12_check) < 0 ||
494                         size12_check != size12){
495                 rte_free(ptr12);
496                 return -1;
497         }
498         rte_free(ptr12);
499         return 0;
500 }
501
502 static int
503 test_random_alloc_free(void *_ __attribute__((unused)))
504 {
505         struct mem_list {
506                 struct mem_list *next;
507                 char data[0];
508         } *list_head = NULL;
509         unsigned i;
510         unsigned count = 0;
511
512         rte_srand((unsigned)rte_rdtsc());
513
514         for (i = 0; i < N; i++){
515                 unsigned free_mem = 0;
516                 size_t allocated_size;
517                 while (!free_mem){
518                         const unsigned mem_size = sizeof(struct mem_list) + \
519                                 rte_rand() % (64 * 1024);
520                         const unsigned align = 1 << (rte_rand() % 12); /* up to 4k alignment */
521                         struct mem_list *entry = rte_malloc(NULL,
522                                         mem_size, align);
523                         if (entry == NULL)
524                                 return -1;
525                         if (RTE_ALIGN(entry, align)!= entry)
526                                 return -1;
527                         if (rte_malloc_validate(entry, &allocated_size) == -1
528                                         || allocated_size < mem_size)
529                                 return -1;
530                         memset(entry->data, rte_lcore_id(),
531                                         mem_size - sizeof(*entry));
532                         entry->next = list_head;
533                         if (rte_malloc_validate(entry, NULL) == -1)
534                                 return -1;
535                         list_head = entry;
536
537                         count++;
538                         /* switch to freeing the memory with a 20% probability */
539                         free_mem = ((rte_rand() % 10) >= 8);
540                 }
541                 while (list_head){
542                         struct mem_list *entry = list_head;
543                         list_head = list_head->next;
544                         rte_free(entry);
545                 }
546         }
547         printf("Lcore %u allocated/freed %u blocks\n", rte_lcore_id(), count);
548         return 0;
549 }
550
551 #define err_return() do { \
552         printf("%s: %d - Error\n", __func__, __LINE__); \
553         goto err_return; \
554 } while (0)
555
556 static int
557 test_rte_malloc_validate(void)
558 {
559         const size_t request_size = 1024;
560         size_t allocated_size;
561         char *data_ptr = rte_malloc(NULL, request_size, CACHE_LINE_SIZE);
562         if (data_ptr == NULL) {
563                 printf("%s: %d - Allocation error\n", __func__, __LINE__);
564                 return -1;
565         }
566
567         /* check that a null input returns -1 */
568         if (rte_malloc_validate(NULL, NULL) != -1)
569                 err_return();
570
571         /* check that we get ok on a valid pointer */
572         if (rte_malloc_validate(data_ptr, &allocated_size) < 0)
573                 err_return();
574
575         /* check that the returned size is ok */
576         if (allocated_size < request_size)
577                 err_return();
578
579 #ifdef RTE_LIBRTE_MALLOC_DEBUG
580         int retval;
581         char *over_write_vals = NULL;
582
583         /****** change the header to be bad */
584         char save_buf[64];
585         over_write_vals = (char *)((uintptr_t)data_ptr - sizeof(save_buf));
586         /* first save the data as a backup before overwriting it */
587         memcpy(save_buf, over_write_vals, sizeof(save_buf));
588         memset(over_write_vals, 1, sizeof(save_buf));
589         /* then run validate */
590         retval = rte_malloc_validate(data_ptr, NULL);
591         /* finally restore the data again */
592         memcpy(over_write_vals, save_buf, sizeof(save_buf));
593         /* check we previously had an error */
594         if (retval != -1)
595                 err_return();
596
597         /* check all ok again */
598         if (rte_malloc_validate(data_ptr, &allocated_size) < 0)
599                 err_return();
600
601         /**** change the trailer to be bad */
602         over_write_vals = (char *)((uintptr_t)data_ptr + allocated_size);
603         /* first save the data as a backup before overwriting it */
604         memcpy(save_buf, over_write_vals, sizeof(save_buf));
605         memset(over_write_vals, 1, sizeof(save_buf));
606         /* then run validate */
607         retval = rte_malloc_validate(data_ptr, NULL);
608         /* finally restore the data again */
609         memcpy(over_write_vals, save_buf, sizeof(save_buf));
610         if (retval != -1)
611                 err_return();
612
613         /* check all ok again */
614         if (rte_malloc_validate(data_ptr, &allocated_size) < 0)
615                 err_return();
616 #endif
617
618         rte_free(data_ptr);
619         return 0;
620
621 err_return:
622         /*clean up */
623         rte_free(data_ptr);
624         return -1;
625 }
626
627 static int
628 test_zero_aligned_alloc(void)
629 {
630         char *p1 = rte_malloc(NULL,1024, 0);
631         if (!p1)
632                 goto err_return;
633         if (!rte_is_aligned(p1, CACHE_LINE_SIZE))
634                 goto err_return;
635         rte_free(p1);
636         return 0;
637
638 err_return:
639         /*clean up */
640         if (p1) rte_free(p1);
641         return -1;
642 }
643
644 static int
645 test_malloc_bad_params(void)
646 {
647         const char *type = NULL;
648         size_t size = 0;
649         unsigned align = CACHE_LINE_SIZE;
650
651         /* rte_malloc expected to return null with inappropriate size */
652         char *bad_ptr = rte_malloc(type, size, align);
653         if (bad_ptr != NULL)
654                 goto err_return;
655
656         /* rte_malloc expected to return null with inappropriate alignment */
657         align = 17;
658         size = 1024;
659
660         bad_ptr = rte_malloc(type, size, align);
661         if (bad_ptr != NULL)
662                 goto err_return;
663
664         return 0;
665
666 err_return:
667         /* clean up pointer */
668         if (bad_ptr)
669                 rte_free(bad_ptr);
670         return -1;
671 }
672
673 int
674 test_malloc(void)
675 {
676         unsigned lcore_id;
677         int ret = 0;
678
679         if (test_str_to_size() < 0){
680                 printf("test_str_to_size() failed\n");
681                 return -1;
682         }
683         else printf("test_str_to_size() passed\n");
684
685         if (test_memzone_size_alloc() < 0){
686                 printf("test_memzone_size_alloc() failed\n");
687                 return -1;
688         }
689         else printf("test_memzone_size_alloc() passed\n");
690
691         if (test_big_alloc() < 0){
692                 printf("test_big_alloc() failed\n");
693                 return -1;
694         }
695         else printf("test_big_alloc() passed\n");
696
697         if (test_zero_aligned_alloc() < 0){
698                 printf("test_zero_aligned_alloc() failed\n");
699                 return -1;
700         }
701         else printf("test_zero_aligned_alloc() passed\n");
702
703         if (test_malloc_bad_params() < 0){
704                 printf("test_malloc_bad_params() failed\n");
705                 return -1;
706         }
707         else printf("test_malloc_bad_params() passed\n");
708
709         if (test_realloc() < 0){
710                 printf("test_realloc() failed\n");
711                 return -1;
712         }
713         else printf("test_realloc() passed\n");
714 /*----------------------------*/
715         RTE_LCORE_FOREACH_SLAVE(lcore_id) {
716                 rte_eal_remote_launch(test_align_overlap_per_lcore, NULL, lcore_id);
717         }
718
719         RTE_LCORE_FOREACH_SLAVE(lcore_id) {
720                 if (rte_eal_wait_lcore(lcore_id) < 0)
721                         ret = -1;
722         }
723         if (ret < 0){
724                 printf("test_align_overlap_per_lcore() failed\n");
725                 return ret;
726         }
727         else printf("test_align_overlap_per_lcore() passed\n");
728         /*----------------------------*/
729         RTE_LCORE_FOREACH_SLAVE(lcore_id) {
730                 rte_eal_remote_launch(test_reordered_free_per_lcore, NULL, lcore_id);
731         }
732
733         RTE_LCORE_FOREACH_SLAVE(lcore_id) {
734                 if (rte_eal_wait_lcore(lcore_id) < 0)
735                         ret = -1;
736         }
737         if (ret < 0){
738                 printf("test_reordered_free_per_lcore() failed\n");
739                 return ret;
740         }
741         else printf("test_reordered_free_per_lcore() passed\n");
742
743         /*----------------------------*/
744         RTE_LCORE_FOREACH_SLAVE(lcore_id) {
745                 rte_eal_remote_launch(test_random_alloc_free, NULL, lcore_id);
746         }
747
748         RTE_LCORE_FOREACH_SLAVE(lcore_id) {
749                 if (rte_eal_wait_lcore(lcore_id) < 0)
750                         ret = -1;
751         }
752         if (ret < 0){
753                 printf("test_random_alloc_free() failed\n");
754                 return ret;
755         }
756         else printf("test_random_alloc_free() passed\n");
757
758         /*----------------------------*/
759         ret = test_rte_malloc_type_limits();
760         if (ret < 0){
761                 printf("test_rte_malloc_type_limits() failed\n");
762                 return ret;
763         }
764         /* TODO: uncomment following line once type limits are valid */
765         /*else printf("test_rte_malloc_type_limits() passed\n");*/
766
767         /*----------------------------*/
768         ret = test_rte_malloc_validate();
769         if (ret < 0){
770                 printf("test_rte_malloc_validate() failed\n");
771                 return ret;
772         }
773         else printf("test_rte_malloc_validate() passed\n");
774
775         return 0;
776 }