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