Changeset 6a25b8f


Ignore:
Timestamp:
Nov 22, 2019, 3:37:28 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
9aa1317
Parents:
d74369b
Message:

update allocation tests to reflect allocation changes, change from NULL to 0p, update expected values for changed tests

Location:
tests
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • tests/.expect/alloc-ERROR.txt

    rd74369b r6a25b8f  
    1 alloc.cfa:311:1 error: No reasonable alternatives for expression Applying untyped:
     1alloc.cfa:317:1 error: No reasonable alternatives for expression Applying untyped:
    22  Name: ?=?
    33...to:
     
    1919
    2020
    21 alloc.cfa:312:1 error: No reasonable alternatives for expression Applying untyped:
     21alloc.cfa:318:1 error: No reasonable alternatives for expression Applying untyped:
    2222  Name: ?=?
    2323...to:
     
    3939
    4040
    41 alloc.cfa:313:1 error: No reasonable alternatives for expression Applying untyped:
     41alloc.cfa:319:1 error: No reasonable alternatives for expression Applying untyped:
    4242  Name: ?=?
    4343...to:
     
    5050
    5151
    52 alloc.cfa:314:1 error: No reasonable alternatives for expression Applying untyped:
     52alloc.cfa:320:1 error: No reasonable alternatives for expression Applying untyped:
    5353  Name: ?=?
    5454...to:
  • tests/.expect/alloc.txt

    rd74369b r6a25b8f  
    3030CFA resize array alloc
    31310xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    32 CFA resize array alloc, fill
     32CFA resize array alloc
    33330xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede
    34 CFA resize array alloc, fill
     34CFA resize array alloc
    35350xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    3636CFA resize array alloc, fill
    37 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede
     370xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede
    3838
    3939C   memalign 42 42.5
  • tests/alloc.cfa

    rd74369b r6a25b8f  
    1010// Created On       : Wed Feb  3 07:56:22 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Oct 20 21:45:21 2019
    13 // Update Count     : 391
     12// Last Modified On : Fri Nov 22 15:34:19 2019
     13// Update Count     : 404
    1414//
    1515
     
    126126
    127127        p = alloc( p, 2 * dim );                            // CFA resize array alloc
    128         for ( i; dim ~ 2 * dim ) { p[i] = 0x1010101; }
     128        for ( i; dim ~ 2 * dim ) { p[i] = 0x1010101; }          // fill upper part
    129129        printf( "CFA resize array alloc\n" );
    130130        for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }
     
    139139
    140140        p = alloc_set( p, 3 * dim, fill );                                      // CFA resize array alloc, fill
    141         printf( "CFA resize array alloc, fill\n" );
     141        printf( "CFA resize array alloc\n" );
    142142        for ( i; 3 * dim ) { printf( "%#x ", p[i] ); }
    143143        printf( "\n" );
     
    145145
    146146        p = alloc_set( p, dim, fill );                                          // CFA resize array alloc, fill
    147         printf( "CFA resize array alloc, fill\n" );
     147        printf( "CFA resize array alloc\n" );
    148148        for ( i; dim ) { printf( "%#x ", p[i] ); }
    149149        printf( "\n" );
  • tests/heap.cfa

    rd74369b r6a25b8f  
    1010// Created On       : Tue Nov  6 17:54:56 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 19 08:22:34 2019
    13 // Update Count     : 19
     12// Last Modified On : Wed Nov 20 16:10:24 2019
     13// Update Count     : 25
    1414//
    1515
     
    7474                size_t s = (i + 1) * 20;
    7575                char * area = (char *)malloc( s );
    76                 if ( area == 0 ) abort( "malloc/free out of memory" );
     76                if ( area == 0p ) abort( "malloc/free out of memory" );
    7777                area[0] = '\345'; area[s - 1] = '\345';                 // fill first/last
    7878                area[malloc_usable_size( area ) - 1] = '\345';  // fill ultimate byte
     
    8383                size_t s = i + 1;                                                               // +1 to make initialization simpler
    8484                locns[i] = (char *)malloc( s );
    85                 if ( locns[i] == 0 ) abort( "malloc/free out of memory" );
     85                if ( locns[i] == 0p ) abort( "malloc/free out of memory" );
    8686                locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last
    8787                locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte
     
    9999                size_t s = i + default_mmap_start();                    // cross over point
    100100                char * area = (char *)malloc( s );
    101                 if ( area == 0 ) abort( "malloc/free out of memory" );
     101                if ( area == 0p ) abort( "malloc/free out of memory" );
    102102                area[0] = '\345'; area[s - 1] = '\345';                 // fill first/last
    103103                area[malloc_usable_size( area ) - 1] = '\345';  // fill ultimate byte
     
    108108                size_t s = i + default_mmap_start();                    // cross over point
    109109                locns[i] = (char *)malloc( s );
    110                 if ( locns[i] == 0 ) abort( "malloc/free out of memory" );
     110                if ( locns[i] == 0p ) abort( "malloc/free out of memory" );
    111111                locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last
    112112                locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte
     
    124124                size_t s = (i + 1) * 20;
    125125                char * area = (char *)calloc( 5, s );
    126                 if ( area == 0 ) abort( "calloc/free out of memory" );
     126                if ( area == 0p ) abort( "calloc/free out of memory" );
    127127                if ( area[0] != '\0' || area[s - 1] != '\0' ||
    128128                         area[malloc_usable_size( area ) - 1] != '\0' ||
     
    136136                size_t s = i + 1;
    137137                locns[i] = (char *)calloc( 5, s );
    138                 if ( locns[i] == 0 ) abort( "calloc/free out of memory" );
     138                if ( locns[i] == 0p ) abort( "calloc/free out of memory" );
    139139                if ( locns[i][0] != '\0' || locns[i][s - 1] != '\0' ||
    140140                         locns[i][malloc_usable_size( locns[i] ) - 1] != '\0' ||
     
    155155                size_t s = i + default_mmap_start();                    // cross over point
    156156                char * area = (char *)calloc( 1, s );
    157                 if ( area == 0 ) abort( "calloc/free out of memory" );
     157                if ( area == 0p ) abort( "calloc/free out of memory" );
    158158                if ( area[0] != '\0' || area[s - 1] != '\0' ) abort( "calloc/free corrupt storage4.1" );
    159159                if ( area[malloc_usable_size( area ) - 1] != '\0' ) abort( "calloc/free corrupt storage4.2" );
     
    167167                size_t s = i + default_mmap_start();                    // cross over point
    168168                locns[i] = (char *)calloc( 1, s );
    169                 if ( locns[i] == 0 ) abort( "calloc/free out of memory" );
     169                if ( locns[i] == 0p ) abort( "calloc/free out of memory" );
    170170                if ( locns[i][0] != '\0' || locns[i][s - 1] != '\0' ||
    171171                         locns[i][malloc_usable_size( locns[i] ) - 1] != '\0' ||
     
    189189                for ( s; 1 ~ NoOfAllocs ) {                                             // allocation of size 0 can return null
    190190                        char * area = (char *)memalign( a, s );
    191                         if ( area == 0 ) abort( "memalign/free out of memory" );
    192                         //sout | i | " " | area;
     191                        if ( area == 0p ) abort( "memalign/free out of memory" );
     192                        //sout | i | area;
    193193                        if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    194194                                abort( "memalign/free bad alignment : memalign(%d,%d) = %p", (int)a, s, area );
    195195                        } // if
    196                         area[0] = '\345'; area[s - 1] = '\345'; // fill first/last byte
     196                        area[0] = '\345'; area[s - 1] = '\345';         // fill first/last byte
    197197                        area[malloc_usable_size( area ) - 1] = '\345'; // fill ultimate byte
    198198                        free( area );
     
    207207                        size_t s = i + default_mmap_start();            // cross over point
    208208                        char * area = (char *)memalign( a, s );
    209                         if ( area == 0 ) abort( "memalign/free out of memory" );
    210                         //sout | i | " " | area;
     209                        if ( area == 0p ) abort( "memalign/free out of memory" );
     210                        //sout | i | area;
    211211                        if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    212212                                abort( "memalign/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)s, area );
     
    223223                // initial N byte allocation
    224224                char * area = (char *)calloc( 5, i );
    225                 if ( area == 0 ) abort( "calloc/realloc/free out of memory" );
     225                if ( area == 0p ) abort( "calloc/realloc/free out of memory" );
    226226                if ( area[0] != '\0' || area[i - 1] != '\0' ||
    227227                         area[malloc_usable_size( area ) - 1] != '\0' ||
     
    231231                for ( s; i ~ 256 * 1024 ~ 26 ) {                                // start at initial memory request
    232232                        area = (char *)realloc( area, s );                      // attempt to reuse storage
    233                         if ( area == 0 ) abort( "calloc/realloc/free out of memory" );
     233                        if ( area == 0p ) abort( "calloc/realloc/free out of memory" );
    234234                        if ( area[0] != '\0' || area[s - 1] != '\0' ||
    235235                                 area[malloc_usable_size( area ) - 1] != '\0' ||
     
    245245                size_t s = i + default_mmap_start();                    // cross over point
    246246                char * area = (char *)calloc( 1, s );
    247                 if ( area == 0 ) abort( "calloc/realloc/free out of memory" );
     247                if ( area == 0p ) abort( "calloc/realloc/free out of memory" );
    248248                if ( area[0] != '\0' || area[s - 1] != '\0' ||
    249249                         area[malloc_usable_size( area ) - 1] != '\0' ||
     
    253253                for ( r; i ~ 256 * 1024 ~ 26 ) {                                // start at initial memory request
    254254                        area = (char *)realloc( area, r );                      // attempt to reuse storage
    255                         if ( area == 0 ) abort( "calloc/realloc/free out of memory" );
     255                        if ( area == 0p ) abort( "calloc/realloc/free out of memory" );
    256256                        if ( area[0] != '\0' || area[r - 1] != '\0' ||
    257257                                 area[malloc_usable_size( area ) - 1] != '\0' ||
     
    267267                // initial N byte allocation
    268268                char * area = (char *)memalign( a, amount );    // aligned N-byte allocation
    269                 if ( area == 0 ) abort( "memalign/realloc/free out of memory" ); // no storage ?
    270                 //sout | alignments[a] | " " | area;
     269                if ( area == 0p ) abort( "memalign/realloc/free out of memory" ); // no storage ?
     270                //sout | alignments[a] | area;
    271271                if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    272272                        abort( "memalign/realloc/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)amount, area );
     
    278278                        if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "memalign/realloc/free corrupt storage" );
    279279                        area = (char *)realloc( area, s );                      // attempt to reuse storage
    280                         if ( area == 0 ) abort( "memalign/realloc/free out of memory" ); // no storage ?
    281                         //sout | i | " " | area;
     280                        if ( area == 0p ) abort( "memalign/realloc/free out of memory" ); // no storage ?
     281                        //sout | i | area;
    282282                        if ( (size_t)area % a != 0 ) {                          // check for initial alignment
    283283                                abort( "memalign/realloc/free bad alignment %p", area );
     
    294294                for ( s; 1 ~ limit ) {                                                  // allocation of size 0 can return null
    295295                        char * area = (char *)cmemalign( a, 1, s );
    296                         if ( area == 0 ) abort( "cmemalign/free out of memory" );
    297                         //sout | i | " " | area;
     296                        if ( area == 0p ) abort( "cmemalign/free out of memory" );
     297                        //sout | i | area;
    298298                        if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    299299                                abort( "cmemalign/free bad alignment : cmemalign(%d,%d) = %p", (int)a, s, area );
     
    313313                // initial N byte allocation
    314314                char * area = (char *)cmemalign( a, 1, amount ); // aligned N-byte allocation
    315                 if ( area == 0 ) abort( "cmemalign/realloc/free out of memory" ); // no storage ?
    316                 //sout | alignments[a] | " " | area;
     315                if ( area == 0p ) abort( "cmemalign/realloc/free out of memory" ); // no storage ?
     316                //sout | alignments[a] | area;
    317317                if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    318318                        abort( "cmemalign/realloc/free bad alignment : cmemalign(%d,%d) = %p", (int)a, (int)amount, area );
     
    327327                        if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "cmemalign/realloc/free corrupt storage2" );
    328328                        area = (char *)realloc( area, s );                      // attempt to reuse storage
    329                         if ( area == 0 ) abort( "cmemalign/realloc/free out of memory" ); // no storage ?
    330                         //sout | i | " " | area;
     329                        if ( area == 0p ) abort( "cmemalign/realloc/free out of memory" ); // no storage ?
     330                        //sout | i | area;
    331331                        if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    332332                                abort( "cmemalign/realloc/free bad alignment %p", area );
     333                        } // if
     334                        if ( area[s - 1] != '\0' || area[s - 1] != '\0' ||
     335                                 area[malloc_usable_size( area ) - 1] != '\0' ||
     336                                 ! malloc_zero_fill( area ) ) abort( "cmemalign/realloc/free corrupt storage3" );
     337                        area[s - 1] = '\345';                                           // fill last byte
     338                } // for
     339                free( area );
     340        } // for
     341
     342        // check memalign/realloc with align/free
     343
     344        amount = 2;
     345        for ( a; libAlign() ~= limit ~ a ) {                            // generate powers of 2
     346                // initial N byte allocation
     347                char * area = (char *)memalign( a, amount );    // aligned N-byte allocation
     348                if ( area == 0p ) abort( "memalign/realloc with align/free out of memory" ); // no storage ?
     349                //sout | alignments[a] | area | endl;
     350                if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
     351                        abort( "memalign/realloc with align/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)amount, area );
     352                } // if
     353                area[0] = '\345'; area[amount - 2] = '\345';    // fill first/penultimate byte
     354
     355                // Do not start this loop index at 0 because realloc of 0 bytes frees the storage.
     356                for ( s; amount ~ 256 * 1024 ) {                                // start at initial memory request
     357                        if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "memalign/realloc/free corrupt storage" );
     358                        area = (char *)realloc( area, a * 2, s );       // attempt to reuse storage
     359                        if ( area == 0p ) abort( "memalign/realloc with align/free out of memory" ); // no storage ?
     360                        //sout | i | area | endl;
     361                        if ( (size_t)area % a * 2 != 0 ) {                      // check for initial alignment
     362                                abort( "memalign/realloc with align/free bad alignment %p", area );
     363                        } // if
     364                        area[s - 1] = '\345';                                           // fill last byte
     365                } // for
     366                free( area );
     367        } // for
     368
     369        // check cmemalign/realloc with align/free
     370
     371        amount = 2;
     372        for ( size_t a = libAlign() + libAlign(); a <= limit; a += a ) { // generate powers of 2
     373                // initial N byte allocation
     374                char *area = (char *)cmemalign( a, 1, amount ); // aligned N-byte allocation
     375                if ( area == 0p ) abort( "cmemalign/realloc with align/free out of memory" ); // no storage ?
     376                //sout | alignments[a] | area | endl;
     377                if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
     378                        abort( "cmemalign/realloc with align/free bad alignment : cmemalign(%d,%d) = %p", (int)a, (int)amount, area );
     379                } // if
     380                if ( area[0] != '\0' || area[amount - 1] != '\0' ||
     381                         area[malloc_usable_size( area ) - 1] != '\0' ||
     382                         ! malloc_zero_fill( area ) ) abort( "cmemalign/realloc with align/free corrupt storage1" );
     383                area[0] = '\345'; area[amount - 2] = '\345';    // fill first/penultimate byte
     384
     385                // Do not start this loop index at 0 because realloc of 0 bytes frees the storage.
     386                for ( int s = amount; s < 256 * 1024; s += 1 ) { // start at initial memory request
     387                        if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "cmemalign/realloc with align/free corrupt storage2" );
     388                        area = (char *)realloc( area, a * 2, s );       // attempt to reuse storage
     389                        if ( area == 0p ) abort( "cmemalign/realloc with align/free out of memory" ); // no storage ?
     390                        //sout | i | area | endl;
     391                        if ( (size_t)area % a * 2 != 0 || malloc_alignment( area ) != a * 2 ) { // check for initial alignment
     392                                abort( "cmemalign/realloc with align/free bad alignment %p %jd %jd", area, malloc_alignment( area ), a * 2 );
    333393                        } // if
    334394                        if ( area[s - 1] != '\0' || area[s - 1] != '\0' ||
Note: See TracChangeset for help on using the changeset viewer.