Changeset 647 for trunk/psLib/test/sysUtils/tst_psMemory.c
- Timestamp:
- May 12, 2004, 9:04:26 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/sysUtils/tst_psMemory.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/sysUtils/tst_psMemory.c
r640 r647 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-05-1 1 20:52:33$8 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-05-12 19:04:26 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 32 32 static int TPrealloc(void); 33 33 static int TPallocCallback(void); 34 static longmemAllocateCallback(const psMemBlock *ptr);35 static longmemFreeCallback(const psMemBlock *ptr);34 static psMemoryId memAllocateCallback(const psMemBlock *ptr); 35 static psMemoryId memFreeCallback(const psMemBlock *ptr); 36 36 int TPcheckLeaks(void); 37 37 int TPmemCorruption(void); … … 41 41 static int allocCallbackCalled = 0; 42 42 static int freeCallbackCalled = 0; 43 44 bool TPOutOfMemoryExhaustedCallbackCalled = false; 43 static int exhaustedCallbackCalled = 0; 45 44 46 45 testDescription tests[] = { 47 46 {TPCheckBufferPositive,"449-TPCheckBufferPositive",0}, 48 {TPOutOfMemory,"450-TPOutOfMemory", 0},47 {TPOutOfMemory,"450-TPOutOfMemory",6}, 49 48 {TPrealloc,"451-TPrealloc",0}, 50 49 {TPallocCallback,"452/453-TPallocCallback",0}, … … 58 57 { 59 58 psSetLogLevel(PS_LOG_INFO); 60 61 59 if (! runTestSuite(stderr,"psMemory",tests)) { 62 60 psAbort(__FILE__,"One or more tests failed"); … … 168 166 "the psMemExhaustedCallback.\n"); 169 167 170 TPOutOfMemoryExhaustedCallbackCalled = false;168 exhaustedCallbackCalled = 0; 171 169 172 170 cb = psMemExhaustedCallbackSet(TPOutOfMemoryExhaustedCallback); 173 171 174 mem = (int*) psAlloc( INT_MAX);172 mem = (int*) psAlloc(LONG_MAX); 175 173 176 174 psMemExhaustedCallbackSet(cb); 177 175 178 if ( !TPOutOfMemoryExhaustedCallbackCalled) {176 if (exhaustedCallbackCalled == 0) { 179 177 psError(__FILE__,"Called psAlloc with HUGE memory requirement and survived in %s!",__func__); 180 178 return 1; … … 187 185 188 186 return 0; 189 }190 191 192 193 void* TPOutOfMemoryExhaustedCallback(size_t size)194 {195 psLogMsg(__func__,PS_LOG_INFO,"Custom MemExhaustedCallback was invoked.");196 TPOutOfMemoryExhaustedCallbackCalled = true;197 return malloc(1024);198 187 } 199 188 … … 487 476 } 488 477 489 longmemAllocateCallback(const psMemBlock *ptr)478 psMemoryId memAllocateCallback(const psMemBlock *ptr) 490 479 { 491 480 psLogMsg(__func__,PS_LOG_INFO,"block %d was (re)allocated",ptr->id); … … 494 483 } 495 484 496 longmemFreeCallback(const psMemBlock *ptr)485 psMemoryId memFreeCallback(const psMemBlock *ptr) 497 486 { 498 487 psLogMsg(__func__,PS_LOG_INFO,"block %d was freed",ptr->id); … … 500 489 return 1; 501 490 } 491 492 void* TPOutOfMemoryExhaustedCallback(size_t size) 493 { 494 psLogMsg(__func__,PS_LOG_INFO,"Custom MemExhaustedCallback was invoked."); 495 exhaustedCallbackCalled++; 496 return NULL; 497 }
Note:
See TracChangeset
for help on using the changeset viewer.
