/*********************************************************************/ /* */ /* PROGRAM I.D. : VERIFY.H */ /* */ /* INITIALS : Dan Manocchio */ /* */ /* DATE CREATED : January 15, 1987 */ /* */ /* SYSTEM : */ /* */ /* PURPOSE OF TEST: A general "header" file for use in the IBM */ /* validation test suite for the C Compiler. */ /* */ /* It contains 5 functions: */ /* */ /* (1) SFAIL which reports a failure but */ /* continues execution. */ /* (2) FAIL which is called to signal that a */ /* test case has completed unsuccessfully. */ /* (3) PASS which is called to signal that a */ /* test case has completed successfully. */ /* (4) TERM which terminates the test case, */ /* reporting a successful test if no soft */ /* failures have occured, or reports a */ /* failed test, otherwise. */ /* (5) CHECK which is called to signal that a */ /* test case has passed in the run but */ /* must be further checked as per header */ /* info. */ /* */ /* SYNOPSIS : #include "verify.h" */ /* */ /* SELF-CHECKING : NA */ /* */ /* INPUT DATA : NA */ /* */ /* SET UP */ /* INSTRUCTIONS : NA */ /* */ /* EXECUTION */ /* INSTRUCTIONS : NA */ /* */ /* EXPECTED */ /* RESULTS : NA */ /* */ /* COMMENTS : */ /* */ /* CHANGE ACTIVITY: */ /* */ /* Date Init PTR# Description */ /* --------- ---- ------- -------------------------------------------*/ /* 11/09/88 CC Eliminated prototypes of library functions. */ /* 06/07/89 MF Added the CHECK() fn. */ /* 18/10/89 MF Changed fn's to be macros. */ /* 03/05/90 DG Added sfail() and term() functions */ /* Added conditional inclusion of fn def's */ /* Changed name to "verify.h" */ /* Changed fn's to macros */ /* 03/30/90 JS Added ifndef __VERIFYH */ /* 26.Mar.91 AKS Code clean up from /Kb+ messages */ /* 22.May.92 AKS #include for NULL definition */ /* 17.Nov.92 AKS #include for printf() calls with */ /* /Ms (system) linkage specified */ /* 08.Sep.94 EYL Use printf() instead of puts() for testing */ /* in Subsystem Environment */ /* 06.Oct.94 TY Take out the declarations of printf() and */ /* exit() for C++ in the case when /Ms(_System)*/ /* linkage is specified. */ /* 24.Oct.94 AKS Add conditional code around #define OS2 */ /* 28.Oct.94 AKS DEFINE __VERIFY_LOGICERR 88 */ /*********************************************************************/ /***********************************************/ /* Define ONE of these preprocessor variables */ /* depending on the system on which this is */ /* currently being run. */ /* */ /* VM, MVS, OS2, DOS, OS400, AIX */ /***********************************************/ #ifndef __VERIFYH #define __VERIFYH 1 #include #include #ifndef OS2 #define OS2 #endif #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif #define __VERIFY_SUCCESS 55 #define __VERIFY_FAILURE 66 #define __VERIFY_CHECK 77 #define __VERIFY_LOGICERR 88 int sfail(char *sfile, int sline, char *smessage); void fail(char *sfile, int sline); void pass(char *sfile); void term(char *sfile); void check(char *sfile); #ifndef NOT_MAIN int __vsoft = 0; /* Soft verification errors */ /* Function sfail : a test case has an error, report and continue * * -> called any number of times by program * -> outputs an informative message to STDOUT * -> exits with "failure" code, __VERIFY_FAILURE */ int sfail(char *sfile, int sline, char *smessage) { printf("SOFT FAILURE #%d: %s at line %d\n", ++__vsoft, sfile, sline); if (smessage != NULL && smessage[0] != '\0') printf("%s\n", smessage); return __vsoft; } /* Function fail : a test case has ended unsuccessfully * * -> called at most once per program * -> outputs an informative message to STDOUT * -> exits with "failure" code, __VERIFY_FAILURE */ void fail(char *sfile, int sline) { printf("TEST FAILED: %s at line %d\n", sfile, sline); /* Quit the whole program when FAIL is called */ exit(__VERIFY_FAILURE); return; } /* Function pass : a test case has ended successfully (checks for soft fails) * * -> called at most once per program * -> outputs an informative message to STDOUT * -> exits with a "failure" code ("0") */ void pass(char *sfile) { term(sfile); return; } /* Function term : if any soft failures, then fail, else pass * * -> called only once by program * -> outputs an informative message to STDOUT * -> exits with __VERIFY_FAILURE or __VERIFY_SUCCESS */ void term(char *sfile) { char *fn,*a; a=sfile; /* since our compiler has trouble */ fn=a; /* JB added slow way as workaround */ while (*a!='\0') { /* compiling below with Opt3 4/11/90 JWB */ if (*a=='\\') fn=a+1; a=a+1; } #if 000 for (fn=a=sfile;*a;a++) /* JB 04/90 added to remove path from name */ if (*a=='\\') fn=a+1; #endif if (__vsoft == 0) { /* printf("Test Successful: %s\n", sfile); */ printf("Test Successful: %s\n", fn); exit(__VERIFY_SUCCESS); } else { printf("TEST FAILED: %s, due to %d soft failures.\n", sfile, __vsoft); exit(__VERIFY_FAILURE); } return; } /* Function check : a test case has ended but must be further verified * * -> called at most once per program * -> outputs an informative message to STDOUT * -> exits with "failure" code __VERIFY_CHECK */ void check(char *sfile) { printf("Please check %s as per header information", sfile); printf(" for test success\n"); exit(__VERIFY_CHECK); return; } #endif #endif