43 static int perlHarness;
50 static const char *todo;
67 static int testReportHook(
int reportType,
char *message,
int *returnValue)
88 static void testOnce(
void *
dummy) {
90 perlHarness = (getenv(
"HARNESS_ACTIVE") !=
NULL);
92 _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE |_CRTDBG_MODE_DEBUG );
93 _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
94 _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE |_CRTDBG_MODE_DEBUG );
95 _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDERR );
96 _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE |_CRTDBG_MODE_DEBUG );
97 _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR );
98 _CrtSetReportHook2( _CRT_RPTHOOK_INSTALL, testReportHook );
106 tested = passed = failed = skipped = bonus = 0;
108 if (plan)
printf(
"1..%d\n", plan);
112 int testOkV(
int pass,
const char *fmt, va_list pvar) {
113 const char *
result =
"not ok";
127 printf(
"%s %2d - ", result, tested);
130 printf(
" # TODO %s", todo);
137 int testOk(
int pass,
const char *fmt, ...) {
165 printf(
"ok %2d # SKIP %s\n", tested, why);
205 static void testResult(
const char *
result,
int count) {
206 printf(
"%12.12s: %3d = %5.2f%%\n",
result, count, 100.0 * count / tested);
214 if (!planned)
printf(
"1..%d\n", tested);
216 if (planned && tested > planned) {
217 printf(
"\nRan %d tests but only planned for %d!\n", tested, planned);
219 }
else if (planned && tested < planned) {
220 printf(
"\nPlanned %d tests but only ran %d\n", planned, tested);
223 printf(
"\n Results\n =======\n Tests: %-3d\n", tested);
225 testResult(
"Passed", passed);
226 if (bonus) testResult(
"Todo Passes", bonus);
228 testResult(
"Failed", failed);
231 if (skipped) testResult(
"Skipped", skipped);
239 fault->
tests = tested;
241 fault->
skips = skipped;
251 static int impreciseTiming;
255 if(impreciseTiming==0) {
256 const char* env = getenv(
"EPICS_TEST_IMPRECISE_TIMING");
258 impreciseTiming = (env && strcmp(env,
"YES")==0) ? 1 : -1;
260 return impreciseTiming>0;
269 if (!Harness)
return;
273 printf(
"\n\n EPICS Test Harness Results" 274 "\n ==========================\n\n");
278 printf(
"All tests successful.\n");
283 printf(
"Failing Program Tests Faults\n" 284 "---------------------------------------\n");
292 printf(
"\nFailed %d/%d test programs. %d/%d subtests failed.\n",
293 Faulty, Programs, Failures, Tests);
296 printf(
"Programs=%d, Tests=%d, %.0f wallclock secs\n\n",
311 printf(
"\n***** %s *****\n", name);
#define ellCount(PLIST)
Report the number of nodes in a list.
void testPlan(int plan)
Declare the test plan, required.
void testTodoBegin(const char *why)
Mark the start of a group of tests that are expected to fail.
void testHarnessExit(void *dummy)
void testTodoEnd(void)
Mark the end of a failing test group.
void testPass(const char *fmt,...)
ELLNODE * ellGet(ELLLIST *pList)
Deletes and returns the first node from a list.
#define epicsMutexMustCreate()
Create an epicsMutex semaphore for use from C code.
int testDiag(const char *fmt,...)
void epicsStdCall epicsMutexUnlock(epicsMutexId pmutexNode)
Release the semaphore.
void testSkip(int skip, const char *why)
Place-holders for tests that can't be run.
A doubly-linked list library.
void ellAdd(ELLLIST *pList, ELLNODE *pNode)
Adds a node to the end of a list.
#define EPICS_THREAD_ONCE_INIT
void testAbort(const char *fmt,...)
int testDone(void)
Mark the end of testing.
APIs for the epicsMutex mutual exclusion semaphore.
void testHarness(void)
Initialize test harness.
LIBCOM_API void epicsStdCall epicsThreadOnce(epicsThreadOnceId *id, EPICSTHREADFUNC, void *arg)
int epicsStdCall epicsTimeGetCurrent(epicsTimeStamp *pDest)
Get current time into *pDest.
int testImpreciseTiming(void)
Return non-zero in shared/oversubscribed testing envrionments.
Extended replacement for the Posix exit and atexit routines.
LIBCOM_API void * callocMustSucceed(size_t count, size_t size, const char *msg)
A calloc() that never returns NULL.
void epicsStackTrace(void)
epics::pvData::PVStructurePtr dummy
EPICS time stamp, for use from C code.
#define ellInit(PLIST)
Initialize a list type.
LIBCOM_API void epicsStdCall epicsThreadSleep(double seconds)
Block the calling thread for at least the specified time.
void testFail(const char *fmt,...)
LIBCOM_API double epicsStdCall epicsTimeDiffInSeconds(const epicsTimeStamp *pLeft, const epicsTimeStamp *pRight)
Time difference between left and right in seconds.
Routines for code that can't continue or return after an error.
EPICS time-stamps (epicsTimeStamp), epicsTime C++ class and C functions for handling wall-clock times...
#define epicsAtExit(F, A)
Convenience macro to register a function and context value to be run when the process exits...
C++ and C descriptions for a thread.
#define epicsMutexMustLock(ID)
Claim a semaphore (see epicsMutexLock()).
int testOk(int pass, const char *fmt,...)
void runTestFunc(const char *name, TESTFUNC func)
int testOkV(int pass, const char *fmt, va_list pvar)
Test result with var-args description.