- Timestamp:
- Sep 3, 2020, 12:07:15 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 9617533
- Parents:
- 4bc27c0 (diff), 73f1b1c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- tests
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/alloc2.cfa
r4bc27c0 r447b0d2b 1 /*2 some tests are commented-out because of resize/realloc bug from 0p. They should be uncommented after that bug is resolved.3 */4 5 1 #include <malloc.h> // malloc_usable_size 6 2 #include <stdint.h> // uintptr_t … … 20 16 if (!passed) { 21 17 printf("failed test %3d: %4lu %4lu but got %4lu ( %3lu ) %4lu\n", tests_total, size, align, malloc_size(ip), malloc_usable_size(ip), malloc_alignment(ip)); 22 // if (last_failed != tests_total) { 23 tests_failed += 1; 24 // last_failed = tests_total; 25 // } 18 tests_failed += 1; 26 19 } 27 20 } … … 34 27 if (!passed) { 35 28 printf("failed test %3d: fill C\n", tests_total); 36 // if (last_failed != tests_total) { 37 tests_failed += 1; 38 // last_failed = tests_total; 39 // } 29 tests_failed += 1; 40 30 } 41 31 } … … 48 38 if (!passed) { 49 39 printf("failed test %3d: fill int\n", tests_total); 50 // if (last_failed != tests_total) { 51 tests_failed += 1; 52 // last_failed = tests_total; 53 // } 40 tests_failed += 1; 54 41 } 55 42 } … … 60 47 if (!passed) { 61 48 printf("failed test %3d: fill int A\n", tests_total); 62 // if (last_failed != tests_total) { 63 tests_failed += 1; 64 // last_failed = tests_total; 65 // } 49 tests_failed += 1; 66 50 } 67 51 } … … 74 58 if (!passed) { 75 59 printf("failed test %3d: fill T1\n", tests_total); 76 // if (last_failed != tests_total) { 77 tests_failed += 1; 78 // last_failed = tests_total; 79 // } 60 tests_failed += 1; 80 61 } 81 62 } … … 86 67 if (!passed) { 87 68 printf("failed test %3d: fill T1 A\n", tests_total); 88 // if (last_failed != tests_total) { 89 tests_failed += 1; 90 // last_failed = tests_total; 91 // } 69 tests_failed += 1; 92 70 } 93 71 } … … 100 78 if (!passed) { 101 79 printf("failed test %3d: use int\n", tests_total); 102 // if (last_failed != tests_total) { 103 tests_failed += 1; 104 // last_failed = tests_total; 105 // } 80 tests_failed += 1; 106 81 } 107 82 } … … 114 89 if (!passed) { 115 90 printf("failed test %3d: use T1\n", tests_total); 116 // if (last_failed != tests_total) { 117 tests_failed += 1; 118 // last_failed = tests_total; 119 // } 91 tests_failed += 1; 120 92 } 121 93 } … … 331 303 free(ip); 332 304 333 //ip = alloc( 0, ((int*)0p)`realloc, FillT`fill );334 //est_base(ip, 0, libAlign);335 //free(ip);305 ip = alloc( 0, ((int*)0p)`realloc, FillT`fill ); 306 test_base(ip, 0, libAlign); 307 free(ip); 336 308 337 309 ip = alloc( align`align ); … … 356 328 free(ip); 357 329 358 //ip = alloc( ((int*)0p)`realloc, align`align );359 //est_base(ip, elemSize, align);360 //est_use(ip, elemSize / elemSize);361 //free(ip);330 ip = alloc( ((int*)0p)`realloc, align`align ); 331 test_base(ip, elemSize, align); 332 test_use(ip, elemSize / elemSize); 333 free(ip); 362 334 363 335 dp = alloc( dim ); … … 367 339 free(ip); 368 340 369 //ip = alloc( ((double*)0p)`resize, align`align );370 //est_base(ip, elemSize, align);371 //est_use(ip, elemSize / elemSize);372 //free(ip);341 ip = alloc( ((double*)0p)`resize, align`align ); 342 test_base(ip, elemSize, align); 343 test_use(ip, elemSize / elemSize); 344 free(ip); 373 345 374 346 op = alloc( dim, ((int)0xdeadbeef)`fill); … … 384 356 free(ip); 385 357 386 //ip = alloc( dim, ((int*)0p)`realloc, align`align );387 //est_base(ip, size, align);388 //est_use(ip, size / elemSize);389 //free(ip);390 391 //ip = alloc( 0, ((int*)0p)`realloc, align`align );392 // est_base(ip, 0, align);393 //free(ip);358 ip = alloc( dim, ((int*)0p)`realloc, align`align ); 359 test_base(ip, size, align); 360 test_use(ip, size / elemSize); 361 free(ip); 362 363 ip = alloc( 0, ((int*)0p)`realloc, align`align ); 364 test_base(ip, 0, libAlign); 365 free(ip); 394 366 395 367 ip = alloc( align`align, FillC`fill ); … … 462 434 free(ip); 463 435 464 //ip = alloc( dim, ((int*)0p)`realloc, align`align, FillC`fill );465 //est_base(ip, size, align);466 //est_fill(ip, 0, size, FillC);467 //est_use(ip, size / elemSize);468 //free(ip);469 470 //ip = alloc( 0, ((int*)0p)`realloc, align`align, FillC`fill );471 // est_base(ip, 0, align);472 //free(ip);436 ip = alloc( dim, ((int*)0p)`realloc, align`align, FillC`fill ); 437 test_base(ip, size, align); 438 test_fill(ip, 0, size, FillC); 439 test_use(ip, size / elemSize); 440 free(ip); 441 442 ip = alloc( 0, ((int*)0p)`realloc, align`align, FillC`fill ); 443 test_base(ip, 0, libAlign); 444 free(ip); 473 445 474 446 op = alloc( dim, ((int)0xdeadbeef)`fill ); … … 499 471 free(ip); 500 472 501 //ip = alloc( dim, ((int*)0p)`realloc, align`align, FillT`fill );502 //est_base(ip, size, align);503 //est_fill(ip, 0, dim, FillT);504 //est_use(ip, size / elemSize);505 //free(ip);506 507 //ip = alloc( 0, ((int*)0p)`realloc, align`align, FillT`fill );508 // est_base(ip, 0, align);509 //free(ip);473 ip = alloc( dim, ((int*)0p)`realloc, align`align, FillT`fill ); 474 test_base(ip, size, align); 475 test_fill(ip, 0, dim, FillT); 476 test_use(ip, size / elemSize); 477 free(ip); 478 479 ip = alloc( 0, ((int*)0p)`realloc, align`align, FillT`fill ); 480 test_base(ip, 0, libAlign); 481 free(ip); 510 482 511 483 if (tests_failed == 0) printf("PASSED alloc tests\n\n"); … … 704 676 free(t1p); 705 677 706 // t1p = alloc( (T1*)0p, 0, FillT1);707 // est_base(t1p, 0, tAlign);708 //free(t1p);678 t1p = alloc( 0, ((T1*)0p)`realloc, FillT1`fill ); 679 test_base(t1p, 0, libAlign); 680 free(t1p); 709 681 710 682 t1p = alloc( align`align ); … … 729 701 free(t1p); 730 702 731 //t1p = alloc( ((T1*)0p)`realloc, align`align );732 //est_base(t1p, elemSize, align);733 //est_use(t1p, elemSize / elemSize);734 //free(t1p);703 t1p = alloc( ((T1*)0p)`realloc, align`align ); 704 test_base(t1p, elemSize, align); 705 test_use(t1p, elemSize / elemSize); 706 free(t1p); 735 707 736 708 dp = alloc( dim ); … … 740 712 free(t1p); 741 713 742 //t1p = alloc( ((double*)0p)`resize, align`align );743 //est_base(t1p, elemSize, align);744 //est_use(t1p, elemSize / elemSize);745 //free(t1p);714 t1p = alloc( ((double*)0p)`resize, align`align ); 715 test_base(t1p, elemSize, align); 716 test_use(t1p, elemSize / elemSize); 717 free(t1p); 746 718 747 719 t1op = alloc( dim, ((T1){0xdeadbeef})`fill ); … … 757 729 free(t1p); 758 730 759 //t1p = alloc( dim, ((T1*)0p)`realloc, align`align );760 //est_base(t1p, size, align);761 //est_use(t1p, size / elemSize);762 //free(t1p);763 764 //t1p = alloc( 0, ((T1*)0p)`realloc, align`align );765 // est_base(t1p, 0, align);766 //free(t1p);731 t1p = alloc( dim, ((T1*)0p)`realloc, align`align ); 732 test_base(t1p, size, align); 733 test_use(t1p, size / elemSize); 734 free(t1p); 735 736 t1p = alloc( 0, ((T1*)0p)`realloc, align`align ); 737 test_base(t1p, 0, libAlign); 738 free(t1p); 767 739 768 740 t1p = alloc( align`align, FillC`fill ); … … 835 807 free(t1p); 836 808 837 //t1p = alloc( dim, ((T1*)0p)`realloc, align`align, FillC`fill );838 //est_base(t1p, size, align);839 //est_fill(t1p, 0, size, FillC);840 //est_use(t1p, size / elemSize);841 //free(t1p);842 843 //t1p = alloc( 0, ((T1*)0p)`realloc, align`align, FillC`fill );844 // est_base(t1p, 0, align);845 //free(t1p);809 t1p = alloc( dim, ((T1*)0p)`realloc, align`align, FillC`fill ); 810 test_base(t1p, size, align); 811 test_fill(t1p, 0, size, FillC); 812 test_use(t1p, size / elemSize); 813 free(t1p); 814 815 t1p = alloc( 0, ((T1*)0p)`realloc, align`align, FillC`fill ); 816 test_base(t1p, 0, libAlign); 817 free(t1p); 846 818 847 819 t1op = alloc( dim, ((T1){0xdeadbeef})`fill); … … 872 844 free(t1p); 873 845 874 // t1p = alloc( dim, ((T1*)0p)`realloc, align`aling, FillT1`fill );875 //est_base(t1p, size, align);876 //est_fill(t1p, 0, dim, FillT1);877 //est_use(t1p, size / elemSize);878 //free(t1p);879 880 //t1p = alloc( 0, ((T1*)0p)`realloc, align`align, FillT1`fill );881 // est_base(t1p, 0, align);882 //free(t1p);846 t1p = alloc( dim, ((T1*)0p)`realloc, align`align, FillT1`fill ); 847 test_base(t1p, size, align); 848 test_fill(t1p, 0, dim, FillT1); 849 test_use(t1p, size / elemSize); 850 free(t1p); 851 852 t1p = alloc( 0, ((T1*)0p)`realloc, align`align, FillT1`fill ); 853 test_base(t1p, 0, libAlign); 854 free(t1p); 883 855 884 856 if (tests_failed == 0) printf("PASSED alloc tests (aligned struct)\n\n"); -
tests/malloc.cfa
r4bc27c0 r447b0d2b 252 252 253 253 ip = (int *) (void *) malloc( size ); 254 ip = (int *) (void *) resize( (void *) ip, libAlign, size / 2 ); 255 test_base(ip, size / 2, libAlign); 256 test_use(ip); 257 free(ip); 258 259 ip = (int *) (void *) aligned_alloc( align, size ); 260 ip = (int *) (void *) resize( (void *) ip, align, size / 2 ); 261 test_base(ip, size / 2, align); 262 test_use(ip); 263 free(ip); 264 265 ip = (int *) (void *) malloc( size ); 254 266 ip = (int *) (void *) resize( (void *) ip, align, size / 4 ); 255 267 test_base(ip, size / 4, align); … … 270 282 ip = (int *) (void *) resize( 0p, align, size ); 271 283 test_base(ip, size, align); 284 test_use(ip); 285 free(ip); 286 287 ip = (int *) (void *) calloc( dim, elemSize ); 288 ip = (int *) (void *) realloc( (void *) ip, libAlign, size / 2 ); 289 test_base(ip, size / 2, libAlign); 290 test_fill(ip, 0, size / 2, '\0'); 291 test_use(ip); 292 free(ip); 293 294 ip = (int *) (void *) cmemalign( align, dim, elemSize ); 295 ip = (int *) (void *) realloc( (void *) ip, align, size / 2 ); 296 test_base(ip, size / 2, align); 297 test_fill(ip, 0, size / 2, '\0'); 272 298 test_use(ip); 273 299 free(ip); … … 437 463 else printf("failed CFA malloc tests : %d/%d\n\n", tests_failed, tests_total); 438 464 439 // testing CFA malloc 465 // testing CFA malloc with aligned struct 440 466 441 467 elemSize = sizeof(T1); … … 518 544 free(tp); 519 545 520 /*521 546 tp = realloc( (T1*)0p, size ); 522 est_base(tp, size , tAlign );523 est_use(tp);547 test_base(tp, size , tAlign ); 548 test_use(tp); 524 549 free(tp); 525 550 526 551 tp = realloc( (T1*)0p, size ); 527 est_base(tp, size, tAlign ); 528 est_use(tp); 529 free(tp); 530 */ 552 test_base(tp, size, tAlign ); 553 test_use(tp); 554 free(tp); 531 555 532 556 tp = memalign( align );
Note: See TracChangeset
for help on using the changeset viewer.