Changeset 1193 for trunk/psLib/test
- Timestamp:
- Jul 7, 2004, 3:05:01 PM (22 years ago)
- Location:
- trunk/psLib/test
- Files:
-
- 12 edited
-
collections/tst_psList.c (modified) (17 diffs)
-
dataManip/builddir/tst_psImageFFT.d (modified) (1 diff)
-
dataManip/builddir/tst_psImageIO.d (modified) (1 diff)
-
dataManip/builddir/tst_psVectorFFT.d (modified) (1 diff)
-
dataManip/tst_psVectorFFT.c (modified) (2 diffs)
-
image/tst_psImage.c (modified) (3 diffs)
-
image/tst_psImageFFT.c (modified) (2 diffs)
-
image/tst_psImageIO.c (modified) (2 diffs)
-
psTest.c (modified) (4 diffs)
-
psTest.h (modified) (1 diff)
-
sysUtils/builddir/tst_psMemory.d (modified) (1 diff)
-
sysUtils/tst_psMemory.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/collections/tst_psList.c
r1126 r1193 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 6-29 23:18:00$8 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-07-08 01:05:01 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 28 28 29 29 testDescription tests[] = { 30 {testListAlloc, "487-testListAlloc",0},31 {testListAdd, "488-testListAdd",0},32 {testListGet, "489-testListGet",0},33 {testListRemove, "490-testListRemove",0},34 {testListConvert, "491-testListConvert",0},35 {testListIterator, "494-testListIterator",0},36 {testListFree, "627-testListFree",0},37 {testListSort, "624-testListSort",0},30 {testListAlloc,487,"psListAlloc",0,false}, 31 {testListAdd,488,"psListAdd",0,false}, 32 {testListGet,489,"psListGet",0,false}, 33 {testListRemove,490,"psListRemove",0,false}, 34 {testListConvert,491,"psListConvert",0,false}, 35 {testListIterator,494,"psListIterator",0,false}, 36 {testListFree,627,"psListFree",0,false}, 37 {testListSort,624,"psListSort",0,false}, 38 38 {NULL} 39 39 }; 40 40 41 int main( )41 int main(int argc, char* argv[]) 42 42 { 43 43 psLogSetLevel(PS_LOG_INFO); 44 44 45 if (! runTestSuite(stderr,"psList",tests )) {45 if (! runTestSuite(stderr,"psList",tests,argc,argv) ) { 46 46 psError(__FILE__,"One or more tests failed"); 47 47 return 1; … … 138 138 139 139 // 1. list is NULL (error) 140 list = psListAdd(NULL,data,PS_LIST_HEAD); 141 142 if (list != NULL) { 143 psError(__func__,"psListAdd was given a NULL list, but returned a non-NULL list."); 144 return 1; 145 } 146 147 // 2. data is NULL (error, list should not grow) 140 if (psListAdd(NULL,data,PS_LIST_HEAD)) { 141 psError(__func__,"psListAdd was given a NULL list, but returned a true/success."); 142 return 1; 143 } 144 148 145 list = psListAlloc(data); 149 146 psFree(data); … … 153 150 } 154 151 155 list = psListAdd(list, NULL,PS_LIST_HEAD); 156 157 if (list->size != 1) { 158 psError(__func__,"psListAdd with a NULL data element changed the list size."); 152 // 2. data is NULL (error, list should not grow) 153 if (psListAdd(list, NULL,PS_LIST_HEAD)) { 154 psError(__func__,"psListAdd successfully added a NULL data item?"); 155 return 40; 156 } 157 if ( list->size != 1) { 158 psError(__func__,"psListAdd with a NULL data element changed the list size or returned success."); 159 159 return 3; 160 160 } … … 163 163 data = psAlloc(sizeof(int)); 164 164 *data = 2; 165 list = psListAdd(list,data,PS_LIST_HEAD); 165 if ( ! psListAdd(list,data,PS_LIST_HEAD) ) { 166 psError(__func__,"psListAdd failed to add a data item to head."); 167 return 21; 168 } 169 166 170 if (psMemGetRefCounter(data) != 2) { 167 171 psError(__func__,"psListAdd didn't increment the data reference count."); … … 169 173 } 170 174 psFree(data); 175 171 176 // verify that the size incremented 172 177 if (list->size != 2) { … … 183 188 data = psAlloc(sizeof(int)); 184 189 *data = 3; 185 list = psListAdd(list,data,PS_LIST_TAIL); 190 if ( ! psListAdd(list,data,PS_LIST_TAIL) ) { 191 psError(__func__,"psListAdd failed to add a data item to tail."); 192 return 21; 193 } 194 186 195 if (psMemGetRefCounter(data) != 2) { 187 196 psError(__func__,"psListAdd didn't increment the data reference count."); 188 return 2 0;197 return 22; 189 198 } 190 199 psFree(data); … … 211 220 data = psAlloc(sizeof(int)); 212 221 *data = 4; 213 psLogMsg(__func__,PS_LOG_INFO,"Following should warn with invalid insert location"); 214 list = psListAdd(list,data,-10); 215 if (psMemGetRefCounter(data) != 2) { 216 psError(__func__,"psListAdd didn't increment the data reference count."); 217 return 20; 218 } 219 psFree(data); 220 // verify that the size incremented 221 if (list->size != 4 || *(int*)list->head->data != 4) { 222 psLogMsg(__func__,PS_LOG_INFO,"Following should error with invalid insert location"); 223 224 if ( psListAdd(list,data,-10) ) { 225 psError(__func__,"psListAdd successfully added data to a -10 position?"); 226 return 30; 227 } 228 if (psMemGetRefCounter(data) != 1) { 229 psError(__func__,"psListAdd incremented the data reference count."); 230 return 24; 231 } 232 psFree(data); 233 // verify that the size wasn't incremented 234 if (list->size != 3) { 222 235 printListInt(list); 223 236 psError(__func__,"psListAdd didn't insert to head when where was invalid."); … … 228 241 data = psAlloc(sizeof(int)); 229 242 *data = 5; 230 list = psListAdd(list,data,1); 243 244 if ( ! psListAdd(list,data,1) ) { 245 psError(__func__,"psListAdd failed to add data to 1 position."); 246 return 30; 247 } 248 231 249 if (psMemGetRefCounter(data) != 2) { 232 250 psError(__func__,"psListAdd didn't increment the data reference count."); 233 return 2 0;251 return 25; 234 252 } 235 253 psFree(data); 236 254 // verify that the size incremented 237 if (list->size != 5|| *(int*)list->head->next->data != 5) {255 if (list->size != 4 || *(int*)list->head->next->data != 5) { 238 256 printListInt(list); 239 257 psError(__func__,"psListAdd didn't insert to position #1."); 240 return 9;258 return 10; 241 259 } 242 260 243 261 data = psAlloc(sizeof(int)); 244 262 *data = 6; 245 list = psListAdd(list,data,4); 263 if ( ! psListAdd(list,data,3) ) { 264 psError(__func__,"psListAdd failed to add data to 4 position."); 265 return 31; 266 } 246 267 if (psMemGetRefCounter(data) != 2) { 247 268 psError(__func__,"psListAdd didn't increment the data reference count."); 248 return 2 0;269 return 26; 249 270 } 250 271 psFree(data); 251 272 // verify that the size incremented 252 if (list->size != 6 || *(int *)list->head->next->next->next->next->data != 6) {273 if (list->size != 5 || *(int *)list->head->next->next->next->data != 6) { 253 274 printListInt(list); 254 275 psError(__func__,"psListAdd didn't insert to position #4."); 255 return 9;276 return 50; 256 277 } 257 278 258 279 data = psAlloc(sizeof(int)); 259 280 *data = 7; 260 list = psListAdd(list,data,2); 281 if ( ! psListAdd(list,data,2) ) { 282 psError(__func__,"psListAdd failed to add data to 2 position."); 283 return 32; 284 } 261 285 if (psMemGetRefCounter(data) != 2) { 262 286 psError(__func__,"psListAdd didn't increment the data reference count."); 263 return 2 0;287 return 28; 264 288 } 265 289 psFree(data); 266 290 // verify that the size incremented 267 if (list->size != 7|| *(int *)list->head->next->next->data != 7) {291 if (list->size != 6 || *(int *)list->head->next->next->data != 7) { 268 292 printListInt(list); 269 293 psError(__func__,"psListAdd didn't insert to position #2."); 270 return 9;294 return 11; 271 295 } 272 296 … … 274 298 *data = 7; 275 299 psLogMsg(__func__,PS_LOG_INFO,"Following should be a warning."); 276 list = psListAdd(list,data,9); 300 301 if ( ! psListAdd(list,data,9) ) { 302 psError(__func__,"psListAdd failed to add data to a 9 position?"); 303 return 30; 304 } 305 277 306 if (psMemGetRefCounter(data) != 2) { 278 307 psError(__func__,"psListAdd didn't increment the data reference count."); 279 return 20; 280 } 281 psFree(data); 308 return 29; 309 } 310 311 psFree(data); 312 282 313 // verify that the size incremented 283 if (list->size != 8) {314 if (list->size != 7) { 284 315 printListInt(list); 285 316 psError(__func__,"psListAdd didn't insert to position #9."); 286 return 9;317 return 12; 287 318 } 288 319 … … 347 378 data = psAlloc(sizeof(int)); 348 379 *data = 1; 349 list =psListAdd(list,data,PS_LIST_TAIL);380 psListAdd(list,data,PS_LIST_TAIL); 350 381 psFree(data); 351 382 352 383 data = psAlloc(sizeof(int)); 353 384 *data = 2; 354 list =psListAdd(list,data,PS_LIST_TAIL);385 psListAdd(list,data,PS_LIST_TAIL); 355 386 psFree(data); 356 387 357 388 data = psAlloc(sizeof(int)); 358 389 *data = 3; 359 list =psListAdd(list,data,PS_LIST_TAIL);390 psListAdd(list,data,PS_LIST_TAIL); 360 391 psFree(data); 361 392 … … 452 483 data = psAlloc(sizeof(int)); 453 484 *data = lcv; 454 list =psListAdd(list,data,PS_LIST_TAIL);485 psListAdd(list,data,PS_LIST_TAIL); 455 486 psMemDecrRefCounter(data); 456 487 } … … 671 702 data = psAlloc(sizeof(int)); 672 703 *data = lcv; 673 list =psListAdd(list,data,PS_LIST_TAIL);704 psListAdd(list,data,PS_LIST_TAIL); 674 705 psMemDecrRefCounter(data); 675 706 } … … 809 840 data = psAlloc(sizeof(int)); 810 841 *data = lcv; 811 list =psListAdd(list,data,PS_LIST_TAIL);842 psListAdd(list,data,PS_LIST_TAIL); 812 843 psFree(data); 813 844 } … … 926 957 data[lcv] = psAlloc(sizeof(int)); 927 958 *data[lcv] = lcv; 928 list =psListAdd(list,data[lcv],PS_LIST_TAIL);959 psListAdd(list,data[lcv],PS_LIST_TAIL); 929 960 if (psMemGetRefCounter(data[lcv]) != 2) { 930 961 psError(__func__,"Reference counter for data was not incremented"); … … 980 1011 *data = lcv*2-12; 981 1012 } 982 list =psListAdd(list,data,PS_LIST_TAIL);1013 psListAdd(list,data,PS_LIST_TAIL); 983 1014 psFree(data); 984 1015 … … 1046 1077 *data = lcv*2-12; 1047 1078 } 1048 list =psListAdd(list,data,PS_LIST_TAIL);1079 psListAdd(list,data,PS_LIST_TAIL); 1049 1080 psFree(data); 1050 1081 -
trunk/psLib/test/dataManip/builddir/tst_psImageFFT.d
r1109 r1193 3 3 ../../include/psTrace.h ../../include/psAbort.h ../../include/psError.h \ 4 4 ../../include/psString.h ../../include/psType.h ../../include/psList.h \ 5 ../../include/ps Vector.h ../../include/psHash.h \6 ../../include/ps Scalar.h ../../include/psImage.h \5 ../../include/psCompare.h ../../include/psVector.h \ 6 ../../include/psHash.h ../../include/psScalar.h ../../include/psImage.h \ 7 7 ../../include/psBitSet.h ../../include/psSort.h ../../include/psStats.h \ 8 8 ../../include/psMatrix.h ../../include/psMatrixVectorArithmetic.h \ -
trunk/psLib/test/dataManip/builddir/tst_psImageIO.d
r1109 r1193 3 3 ../../include/psTrace.h ../../include/psAbort.h ../../include/psError.h \ 4 4 ../../include/psString.h ../../include/psType.h ../../include/psList.h \ 5 ../../include/ps Vector.h ../../include/psHash.h \6 ../../include/ps Scalar.h ../../include/psImage.h \5 ../../include/psCompare.h ../../include/psVector.h \ 6 ../../include/psHash.h ../../include/psScalar.h ../../include/psImage.h \ 7 7 ../../include/psBitSet.h ../../include/psSort.h ../../include/psStats.h \ 8 8 ../../include/psMatrix.h ../../include/psMatrixVectorArithmetic.h \ -
trunk/psLib/test/dataManip/builddir/tst_psVectorFFT.d
r1109 r1193 3 3 ../../include/psTrace.h ../../include/psAbort.h ../../include/psError.h \ 4 4 ../../include/psString.h ../../include/psType.h ../../include/psList.h \ 5 ../../include/ps Vector.h ../../include/psHash.h \6 ../../include/ps Scalar.h ../../include/psImage.h \5 ../../include/psCompare.h ../../include/psVector.h \ 6 ../../include/psHash.h ../../include/psScalar.h ../../include/psImage.h \ 7 7 ../../include/psBitSet.h ../../include/psSort.h ../../include/psStats.h \ 8 8 ../../include/psMatrix.h ../../include/psMatrixVectorArithmetic.h \ -
trunk/psLib/test/dataManip/tst_psVectorFFT.c
r1073 r1193 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 6-23 23:00:17$8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-07-08 01:05:01 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 34 34 35 35 testDescription tests[] = { 36 {testVectorFFT, "600-testVectorFFT",0},37 {testVectorRealImaginary, "601-testVectorRealImaginary",0},38 {testVectorComplex, "602-testVectorComplex",0},39 {testVectorConjugate, "603-testVectorConjugate",0},40 {testVectorPowerSpectrum, "604-testVectorPowerSpectrum",0},36 {testVectorFFT,600,"psVectorFFT",0,false}, 37 {testVectorRealImaginary,601,"psVectorRealImaginary",0,false}, 38 {testVectorComplex,602,"psVectorComplex",0,false}, 39 {testVectorConjugate,603,"psVectorConjugate",0,false}, 40 {testVectorPowerSpectrum,604,"psVectorPowerSpectrum",0,false}, 41 41 {NULL} 42 42 }; 43 43 44 int main( )44 int main(int argc, char* argv[]) 45 45 { 46 46 psLogSetLevel(PS_LOG_INFO); 47 47 48 if (! runTestSuite(stderr,"psFFT",tests )) {48 if (! runTestSuite(stderr,"psFFT",tests,argc,argv) ) { 49 49 psAbort(__FILE__,"One or more tests failed"); 50 50 } -
trunk/psLib/test/image/tst_psImage.c
r1073 r1193 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 6-23 23:00:15$8 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-07-08 01:05:01 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 29 29 30 30 testDescription tests[] = { 31 {testImageAlloc,"546/548-testImageAlloc/Free",0}, 32 {testImageSubset,"547/550-testImageSubset",0}, 33 {testImageCopy,"551-testImageCopy",0}, 34 {testImageClip,"571-testImageClip",0}, 35 {testImageClipNAN,"572-testImageClipNAN",0}, 36 {testImageOverlay,"573-testImageOverlay",0}, 31 {testImageAlloc,546,"psImageAlloc",0,false}, 32 {testImageAlloc,548,"psImageFree",0,true}, 33 {testImageSubset,547,"psImageSubset",0,false}, 34 {testImageSubset,550,"psImageSubset",0,true}, 35 {testImageCopy,551,"psImageCopy",0,false}, 36 {testImageClip,571,"psImageClip",0,false}, 37 {testImageClipNAN,572,"psImageClipNAN",0,false}, 38 {testImageOverlay,573,"psImageOverlay",0,false}, 37 39 {NULL} 38 40 }; 39 41 40 int main( )42 int main(int argc, char* argv[]) 41 43 { 42 44 psLogSetLevel(PS_LOG_INFO); 43 testImageOverlay(); 44 if (! runTestSuite(stderr,"psImage",tests )) {45 46 if (! runTestSuite(stderr,"psImage",tests,argc,argv)) { 45 47 psError(__FILE__,"One or more tests failed"); 46 48 return 1; … … 572 574 573 575 #define testImageCopyTypes(IN) \ 576 printf("to psF32\n"); \ 577 testImageCopyType(IN,F32);\ 578 printf("to psF64\n"); \ 579 testImageCopyType(IN,F64); \ 580 printf("to psU8\n"); \ 574 581 testImageCopyType(IN,U8); \ 582 printf("to psU16\n"); \ 575 583 testImageCopyType(IN,U16); \ 584 printf("to psU32\n"); \ 576 585 testImageCopyType(IN,U32); \ 586 printf("to psS8\n"); \ 577 587 testImageCopyType(IN,S8);\ 588 printf("to psS16\n"); \ 578 589 testImageCopyType(IN,S16);\ 579 testImageCopyType(IN,S32);\580 testImageCopyType(IN, F32);\581 testImageCopyType(IN,F64); 582 590 printf("to psS32\n"); \ 591 testImageCopyType(IN,S32); 592 593 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psU8"); 583 594 testImageCopyTypes(U8); 595 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psU16"); 584 596 testImageCopyTypes(U16); 597 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psU32"); 585 598 testImageCopyTypes(U32); 599 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psS8"); 586 600 testImageCopyTypes(S8); 601 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psS16"); 587 602 testImageCopyTypes(S16); 603 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psS32"); 588 604 testImageCopyTypes(S32); 605 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psF32"); 589 606 testImageCopyTypes(F32); 607 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psF64"); 590 608 testImageCopyTypes(F64); 591 609 -
trunk/psLib/test/image/tst_psImageFFT.c
r1073 r1193 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 6-23 23:00:17$8 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-07-08 01:05:01 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 34 34 35 35 testDescription tests[] = { 36 {testImageFFT, "600-testImageFFT",0},37 {testImageRealImaginary, "601-testImageRealImaginary",0},38 {testImageComplex, "602-testImageComplex",0},39 {testImageConjugate, "603-testImageConjugate",0},40 {testImagePowerSpectrum, "604-testImagePowerSpectrum",0},36 {testImageFFT,600,"psImageFFT",0,false}, 37 {testImageRealImaginary,601,"psImageRealImaginary",0,false}, 38 {testImageComplex,602,"psImageComplex",0,false}, 39 {testImageConjugate,603,"psImageConjugate",0,false}, 40 {testImagePowerSpectrum,604,"psImagePowerSpectrum",0,false}, 41 41 {NULL} 42 42 }; 43 43 44 int main( )44 int main(int argc, char* argv[]) 45 45 { 46 46 psLogSetLevel(PS_LOG_INFO); 47 47 48 if (! runTestSuite(stderr,"psFFT",tests )) {48 if (! runTestSuite(stderr,"psFFT",tests,argc,argv) ) { 49 49 psAbort(__FILE__,"One or more tests failed"); 50 50 } -
trunk/psLib/test/image/tst_psImageIO.c
r1073 r1193 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 6-23 23:00:17$8 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-07-08 01:05:01 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 36 36 testDescription tests[] = { 37 {testImageRead, "567-testImageRead",0},38 {testImageWrite, "569-testImageWrite",0},37 {testImageRead,567,"psImageReadSection",0,false}, 38 {testImageWrite,569,"psImageWriteSection",0,false}, 39 39 {NULL} 40 40 }; 41 41 42 int main( )42 int main(int argc, char* argv[]) 43 43 { 44 44 psLogSetLevel(PS_LOG_INFO); 45 45 46 testImageRead(); 47 48 if (! runTestSuite(stderr,"psImage",tests)) { 46 if (! runTestSuite(stderr,"psImage",tests,argc,argv)) { 49 47 psAbort(__FILE__,"One or more tests failed"); 50 48 } -
trunk/psLib/test/psTest.c
r1034 r1193 15 15 #include <unistd.h> 16 16 #include <sys/wait.h> 17 #include <stdbool.h> 18 #include <string.h> 17 19 18 20 #include "psTest.h" … … 25 27 #define HEADER_BOTTOM "\\**********************************************************************************/\n\n" 26 28 27 bool p_runTestSuite(FILE *fp, const char* testPointFile, const char* packageName, testDescription tests[]) 29 bool p_runTestSuite(FILE *fp, const char* testPointFile, const char* packageName, 30 testDescription tests[], int argc, char * const argv[]) 28 31 { 29 32 bool success = true; 30 31 for (int index=0; tests[index].fcn != NULL; index++) { 32 success = p_runTest(fp,testPointFile,packageName,tests[index].testPointName, 33 tests[index].fcn,tests[index].expectedReturn) && success; 33 bool runAll = true; 34 bool useFork = true; 35 bool found; 36 int c; 37 int n; 38 extern char *optarg; 39 40 if (argc > 0) { 41 while ( (c=getopt(argc,argv,"lhn:dt:")) != -1) { 42 switch (c) { 43 case 'h': 44 printf("Usage: %s [-l] [-d] [-h] [-n=Testpoint#] [-t=TestpointName]\n" 45 " where:\n" 46 " -l : lists the testpoints contained in this test driver executable\n" 47 " -d : turns on debugger-friendly mode (no forking, aborts/signals are not handled)\n" 48 " -h : prints this help\n" 49 " -n : specifies a particular testpoint by number to run\n" 50 " -t : specifies a particular testpoint by name to run\n" 51 " (if no -l, -n or -t options are given, all testpoints are run)\n", 52 argv[0]); 53 runAll = false; 54 break; 55 case 'd': 56 useFork = false; 57 break; 58 case 'l': 59 printf("Test Driver: %s\n",testPointFile); 60 printf("Package Name: %s\n",packageName); 61 printf("Testpoints:\n"); 62 runAll = false; 63 for (int index=0; tests[index].fcn != NULL; index++) { 64 printf(" %6d - %s \n",tests[index].testPointNumber, 65 tests[index].testPointName); 66 } 67 printf("\n"); 68 break; 69 case 't': 70 runAll = false; 71 for (int index=0; tests[index].fcn != NULL; index++) { 72 if (strcmp(optarg,tests[index].testPointName) == 0) { 73 success = p_runTest(fp, 74 testPointFile, 75 packageName, 76 tests[index].testPointName, 77 tests[index].fcn, 78 tests[index].expectedReturn, 79 useFork) && success; 80 } 81 } 82 break; 83 case 'n': 84 runAll = false; 85 if (sscanf(optarg,"%i",&n) != 1) { 86 psError(__func__,"Failed to parse the testpoint number (%s).", 87 optarg); 88 break; 89 } 90 found = false; 91 for (int index=0; tests[index].fcn != NULL; index++) { 92 if (n==tests[index].testPointNumber) { 93 found = true; 94 success = p_runTest(fp, 95 testPointFile, 96 packageName, 97 tests[index].testPointName, 98 tests[index].fcn, 99 tests[index].expectedReturn, 100 useFork) && success; 101 } 102 } 103 if (! found) { 104 psError(__func__,"The specified testpoint number (%d) doesn't exist in this test driver.", 105 n); 106 break; 107 } 108 break; 109 case '?': 110 psError(__func__,"Option %s is not recognized and is ignored.",optarg); 111 break; 112 } 113 } 114 } 115 116 if (runAll) { 117 for (int index=0; tests[index].fcn != NULL; index++) { 118 if (! tests[index].isDuplicateEntry) { 119 success = p_runTest(fp, 120 testPointFile, 121 packageName, 122 tests[index].testPointName, 123 tests[index].fcn, 124 tests[index].expectedReturn, 125 useFork) && success; 126 } 127 } 34 128 } 35 129 return success; … … 37 131 38 132 bool p_runTest(FILE *fp, const char* testPointFile, const char* packageName, const char* testPointName, 39 testFcn fcn, int expectedReturn )133 testFcn fcn, int expectedReturn, bool useFork) 40 134 { 41 135 int childReturn = 0; … … 44 138 p_printPositiveTestHeader(fp,testPointFile,packageName,testPointName); 45 139 46 child = fork(); 47 if (child == 0) { // I am the child process, run the test 140 if (useFork) { 141 child = fork(); 142 if (child == 0) { // I am the child process, run the test 143 int currentId = psMemGetId(); 144 int retVal = fcn(); 145 if (retVal == 0) { // only bother checking memory if test executed to end. 146 if (psMemCheckLeaks(currentId,NULL,stderr) != 0) { 147 psError(__func__,"Memory Leaks Detected"); 148 retVal = 64; 149 } 150 psMemCheckCorruption(1); 151 } 152 exit(retVal); 153 } else if (child < 0) { 154 fprintf(fp,"Couldn't fork a process to run a negative test (%s|%s)", 155 packageName, testPointName); 156 abort(); 157 } 158 159 waitpid(child,&childReturn,0); 160 if (WIFSIGNALED(childReturn)) { 161 childReturn = -WTERMSIG(childReturn); 162 } else { 163 childReturn = WEXITSTATUS(childReturn); 164 } 165 } else { 48 166 int currentId = psMemGetId(); 49 int retVal= fcn();50 if ( retVal== 0) { // only bother checking memory if test executed to end.167 childReturn = fcn(); 168 if (childReturn == 0) { // only bother checking memory if test executed to end. 51 169 if (psMemCheckLeaks(currentId,NULL,stderr) != 0) { 52 170 psError(__func__,"Memory Leaks Detected"); 53 retVal= 64;171 childReturn = 64; 54 172 } 55 173 psMemCheckCorruption(1); 56 174 } 57 exit(retVal); 58 } else if (child < 0) { 59 fprintf(fp,"Couldn't fork a process to run a negative test (%s|%s)", 60 packageName, testPointName); 61 abort(); 62 } 63 64 waitpid(child,&childReturn,0); 65 if (WIFSIGNALED(childReturn)) { 66 childReturn = -WTERMSIG(childReturn); 67 } else { 68 childReturn = WEXITSTATUS(childReturn); 69 } 175 } 176 70 177 71 178 if (childReturn != expectedReturn) { -
trunk/psLib/test/psTest.h
r637 r1193 20 20 { 21 21 testFcn fcn; 22 int testPointNumber; 22 23 const char* testPointName; 23 24 int expectedReturn; 25 bool isDuplicateEntry; 24 26 } 25 27 testDescription; 26 28 27 #define runTest(filePtr, packageName, testPointName, fcn, expectedReturn ) \28 p_runTest(filePtr, __FILE__, packageName, testPointName, fcn, expectedReturn )29 #define runTest(filePtr, packageName, testPointName, fcn, expectedReturn, useFork) \ 30 p_runTest(filePtr, __FILE__, packageName, testPointName, fcn, expectedReturn, useFork) 29 31 30 #define runTestSuite(filePtr, packageName, tests ) \31 p_runTestSuite(filePtr, __FILE__, packageName, tests )32 #define runTestSuite(filePtr, packageName, tests, argc, argv) \ 33 p_runTestSuite(filePtr, __FILE__, packageName, tests, argc, argv) 32 34 33 35 34 36 /////////////////////////// PRIVATE FUNCTIONS ////////////////////////////// 35 37 36 bool p_runTest(FILE *fp, const char* testPointFile, const char* packageName, const char* testPointName, 37 testFcn fcn, int expectedReturn); 38 bool p_runTest( 39 FILE *fp, 40 const char* testPointFile, 41 const char* packageName, 42 const char* testPointName, 43 testFcn fcn, 44 int expectedReturn, 45 bool useFork 46 ); 38 47 39 bool p_runTestSuite(FILE *fp, const char* testPointFile, const char* packageName, testDescription tests[]); 48 bool p_runTestSuite( 49 FILE *fp, 50 const char* testPointFile, 51 const char* packageName, 52 testDescription tests[], 53 int argc, 54 char * const argv[] 55 ); 40 56 41 void p_printPositiveTestHeader(FILE *fp, const char* testPointFile, const char* packageName, 42 const char* testPointName); 57 void p_printPositiveTestHeader( 58 FILE *fp, 59 const char* testPointFile, 60 const char* packageName, 61 const char* testPointName 62 ); 43 63 44 void p_printNegativeTestHeader(FILE *fp, const char* testPointFile, const char* packageName, 45 const char* testPointName,const char* expectedError, int exitValue); 64 void p_printNegativeTestHeader( 65 FILE *fp, 66 const char* testPointFile, 67 const char* packageName, 68 const char* testPointName, 69 const char* expectedError, 70 int exitValue 71 ); 46 72 47 void p_printFooter(FILE *fp, const char* testPointFile, const char* packageName, const char* testPointName, 48 bool success); 73 void p_printFooter( 74 FILE *fp, 75 const char* testPointFile, 76 const char* packageName, 77 const char* testPointName, 78 bool success 79 ); 49 80 50 81 #endif -
trunk/psLib/test/sysUtils/builddir/tst_psMemory.d
r1109 r1193 3 3 ../../include/psTrace.h ../../include/psAbort.h ../../include/psError.h \ 4 4 ../../include/psString.h ../../include/psType.h ../../include/psList.h \ 5 ../../include/ps Vector.h ../../include/psHash.h \6 ../../include/ps Scalar.h ../../include/psImage.h \5 ../../include/psCompare.h ../../include/psVector.h \ 6 ../../include/psHash.h ../../include/psScalar.h ../../include/psImage.h \ 7 7 ../../include/psBitSet.h ../../include/psSort.h ../../include/psStats.h \ 8 8 ../../include/psMatrix.h ../../include/psMatrixVectorArithmetic.h \ -
trunk/psLib/test/sysUtils/tst_psMemory.c
r1097 r1193 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 6-25 21:51:46$8 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-07-08 01:05:01 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 45 45 46 46 testDescription tests[] = { 47 {TPCheckBufferPositive,"449-TPCheckBufferPositive",0}, 48 {TPOutOfMemory,"450-TPOutOfMemory",-6}, 49 {TPReallocOutOfMemory,"562-TPReallocOutOfMemory",-6}, 50 {TPrealloc,"451-TPrealloc",0}, 51 {TPallocCallback,"452/453-TPallocCallback",0}, 52 {TPcheckLeaks,"454-TPcheckLeaks",0}, 53 {TPmemCorruption,"455-TPmemCorruption",0}, 54 {TPFreeReferencedMemory,"456-TPFreeReferencedMemory",0}, 47 {TPCheckBufferPositive,449,"checkBufferPositive",0,false}, 48 {TPOutOfMemory,450,"outOfMemory",-6,false}, 49 {TPReallocOutOfMemory,562,"reallocOutOfMemory",-6,false}, 50 {TPrealloc,451,"psRealloc",0,false}, 51 {TPallocCallback,452,"allocCallback",0,false}, 52 {TPallocCallback,453,"allocCallback2",0,true}, 53 {TPcheckLeaks,454,"checkLeaks",0,false}, 54 {TPmemCorruption,455,"psMemCorruption",0,false}, 55 {TPFreeReferencedMemory,456,"freeReferencedMemory",0,false}, 55 56 {NULL} 56 57 }; 57 58 58 int main( )59 int main(int argc, char* argv[]) 59 60 { 60 61 psLogSetLevel(PS_LOG_INFO); 61 62 62 if (! runTestSuite(stderr,"psMemory",tests )) {63 if (! runTestSuite(stderr,"psMemory",tests,argc,argv) ) { 63 64 psError(__FILE__,"One or more tests failed"); 64 65 return 1;
Note:
See TracChangeset
for help on using the changeset viewer.
