IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1097


Ignore:
Timestamp:
Jun 25, 2004, 11:51:46 AM (22 years ago)
Author:
desonia
Message:

added regression test for psRealloc.

Location:
trunk/psLib/test/sysUtils
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/sysUtils/tst_psMemory.c

    r1075 r1097  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-06-24 00:54:59 $
     8 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-06-25 21:51:46 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2828static int TPFreeReferencedMemory(void);
    2929static int TPOutOfMemory(void);
     30static int TPReallocOutOfMemory(void);
    3031static void* TPOutOfMemoryExhaustedCallback(size_t size);
    3132static int TPCheckBufferPositive(void);
     
    4647                              {TPCheckBufferPositive,"449-TPCheckBufferPositive",0},
    4748                              {TPOutOfMemory,"450-TPOutOfMemory",-6},
     49                              {TPReallocOutOfMemory,"562-TPReallocOutOfMemory",-6},
    4850                              {TPrealloc,"451-TPrealloc",0},
    4951                              {TPallocCallback,"452/453-TPallocCallback",0},
     
    145147}
    146148
     149// Bug/Task #562 regression test.  Upon requesting more memory than is available, psRealloc shall call
     150// the psMemExhaustedCallback.
     151int TPReallocOutOfMemory(void)
     152{
     153    int* mem[100];
     154    psMemExhaustedCallback cb;
     155
     156    for (int lcv = 0; lcv<100; lcv++) {
     157        mem[lcv] = NULL;
     158    }
     159
     160    psLogMsg(__func__,PS_LOG_INFO,"Upon requesting more memory than is available, psRealloc shall call "
     161             "the psMemExhaustedCallback.\n");
     162
     163    exhaustedCallbackCalled = 0;
     164
     165    cb = psMemExhaustedCallbackSet(TPOutOfMemoryExhaustedCallback);
     166
     167    for (int lcv = 0; lcv<100; lcv++) {
     168        mem[lcv] = (int*) psAlloc(10);
     169    }
     170
     171    for (int lcv = 0; lcv<100; lcv++) {
     172        mem[lcv] = (int*) psRealloc(mem[lcv],SIZE_MAX-1000);
     173    }
     174
     175    psMemExhaustedCallbackSet(cb);
     176
     177    if (exhaustedCallbackCalled == 0) {
     178        psError(__FILE__,"Called psRealloc with HUGE memory requirement and survived in %s!",__func__);
     179        return 1;
     180    }
     181
     182    for (int lcv = 0; lcv<100; lcv++) {
     183        psFree(mem[lcv]);
     184    }
     185
     186    return 0;
     187}
    147188// Testpoint #450,  Upon requesting more memory than is available, psalloc shall call
    148189// the psMemExhaustedCallback.
  • trunk/psLib/test/sysUtils/verified/tst_psMemory.stderr

    r1075 r1097  
    1717 <DATE> <TIME> <HOST> |I|  TPOutOfMemory|Upon requesting more memory than is available, psalloc shall call the psMemExhaustedCallback.
    1818 <DATE> <TIME> <HOST> |I|TPOutOfMemoryEx|Custom MemExhaustedCallback was invoked.
    19  <DATE> <TIME> <HOST> |A|      p_psAlloc|Failed to allocate 4294966295 bytes at tst_psMemory.c:166
     19 <DATE> <TIME> <HOST> |A|      p_psAlloc|Failed to allocate 4294966295 bytes at tst_psMemory.c:207
    2020
    2121---> TESTPOINT PASSED (psMemory{450-TPOutOfMemory} | tst_psMemory.c)
     22
     23/***************************** TESTPOINT ******************************************\
     24*             TestFile: tst_psMemory.c                                             *
     25*            TestPoint: psMemory{562-TPReallocOutOfMemory}                         *
     26*             TestType: Positive                                                   *
     27\**********************************************************************************/
     28
     29 <DATE> <TIME> <HOST> |I|TPReallocOutOfM|Upon requesting more memory than is available, psRealloc shall call the psMemExhaustedCallback.
     30 <DATE> <TIME> <HOST> |I|TPOutOfMemoryEx|Custom MemExhaustedCallback was invoked.
     31 <DATE> <TIME> <HOST> |A|    p_psRealloc|Failed to reallocate -1001 bytes at tst_psMemory.c:172
     32
     33---> TESTPOINT PASSED (psMemory{562-TPReallocOutOfMemory} | tst_psMemory.c)
    2234
    2335/***************************** TESTPOINT ******************************************\
     
    5971 <DATE> <TIME> <HOST> |I|   TPcheckLeaks|following psMemCheckLeaks call should produce one instance.
    6072                   file:line ID
    61          tst_psMemory.c:316  1
     73         tst_psMemory.c:357  1
    6274 <DATE> <TIME> <HOST> |I|   TPcheckLeaks|Testing psMemCheckLeaks again with a different leak location
    6375 <DATE> <TIME> <HOST> |I|   TPcheckLeaks|following psMemCheckLeaks call should produce one error.
    6476                   file:line ID
    65          tst_psMemory.c:346  11
     77         tst_psMemory.c:387  11
    6678 <DATE> <TIME> <HOST> |I|   TPcheckLeaks|Testing psMemCheckLeaks again with multiple leak locations.
    6779 <DATE> <TIME> <HOST> |I|   TPcheckLeaks|following psMemCheckLeaks call should produce two errors.
    6880                   file:line ID
    69          tst_psMemory.c:374  16
    70          tst_psMemory.c:374  14
     81         tst_psMemory.c:415  16
     82         tst_psMemory.c:415  14
    7183
    7284---> TESTPOINT PASSED (psMemory{454-TPcheckLeaks} | tst_psMemory.c)
     
    8193 <DATE> <TIME> <HOST> |I|TPmemCorruption|psMemCheckCorruption should output an error message and memProblemCallback callback should be called.
    8294 <DATE> <TIME> <HOST> |E|psMemCheckCorru|psMemCheckCorruption: memory block 1 is corrupted (buffer underflow)
    83  <DATE> <TIME> <HOST> |I|memProblemCallb|memory callback called for id 1 (psMemCheckCorruption:226).
     95 <DATE> <TIME> <HOST> |I|memProblemCallb|memory callback called for id 1 (psMemCheckCorruption:221).
    8496
    8597---> TESTPOINT PASSED (psMemory{455-TPmemCorruption} | tst_psMemory.c)
Note: See TracChangeset for help on using the changeset viewer.