Changeset f76ff0b for tests/alloc2.cfa


Ignore:
Timestamp:
Sep 2, 2020, 1:13:28 PM (4 years ago)
Author:
m3zulfiq <m3zulfiq@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
3a4834b3, 73f1b1c
Parents:
f6fe597
Message:

alloc2.txt: added expected output file for test alloc2.cfa. heap.cfa: removed alignment bugs from realloc and resize with alignment. stdlib.hfa: removed debug prints from alloc interface. alloc2.cfa, malloc.cfa: uncommented tests that were previously commented because of a bug in realloc and resize.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/alloc2.cfa

    rf6fe597 rf76ff0b  
    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 
    51#include <malloc.h>                                                                             // malloc_usable_size
    62#include <stdint.h>                                                                             // uintptr_t
     
    2016        if (!passed) {
    2117                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;
    2619        }
    2720}
     
    3427        if (!passed) {
    3528                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;
    4030        }
    4131}
     
    4838        if (!passed) {
    4939                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;
    5441        }
    5542}
     
    6047        if (!passed) {
    6148                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;
    6650        }
    6751}
     
    7458        if (!passed) {
    7559                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;
    8061        }
    8162}
     
    8667        if (!passed) {
    8768                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;
    9270        }
    9371}
     
    10078        if (!passed) {
    10179                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;
    10681        }
    10782}
     
    11489        if (!passed) {
    11590                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;
    12092        }
    12193}
     
    331303        free(ip);
    332304
    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);
    336308
    337309        ip = alloc( align`align );
     
    356328        free(ip);
    357329
    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);
    362334
    363335        dp = alloc( dim );
     
    367339        free(ip);
    368340
    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);
    373345
    374346        op = alloc( dim, ((int)0xdeadbeef)`fill);
     
    384356        free(ip);
    385357
    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);
    394366
    395367        ip = alloc( align`align, FillC`fill );
     
    462434        free(ip);
    463435
    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);
    473445
    474446        op = alloc( dim, ((int)0xdeadbeef)`fill );
     
    499471        free(ip);
    500472
    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);
    510482
    511483        if (tests_failed == 0) printf("PASSED alloc tests\n\n");
     
    704676        free(t1p);
    705677
    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);
    709681
    710682        t1p = alloc( align`align );
     
    729701        free(t1p);
    730702
    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);
    735707
    736708        dp = alloc( dim );
     
    740712        free(t1p);
    741713
    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);
    746718
    747719        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
     
    757729        free(t1p);
    758730
    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);
    767739
    768740        t1p = alloc( align`align, FillC`fill );
     
    835807        free(t1p);
    836808
    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);
    846818
    847819        t1op = alloc( dim, ((T1){0xdeadbeef})`fill);
     
    872844        free(t1p);
    873845
    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);
    883855
    884856        if (tests_failed == 0) printf("PASSED alloc tests (aligned struct)\n\n");
Note: See TracChangeset for help on using the changeset viewer.