EPICS Base  7.0.6.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Typedefs | Functions
dbUnitTest.h File Reference

Helpers for unittests of process database. More...

#include <stdarg.h>
#include "epicsUnitTest.h"
#include "dbAddr.h"
#include "dbCommon.h"
#include "dbCoreAPI.h"
Include dependency graph for dbUnitTest.h:

Go to the source code of this file.

Typedefs

typedef struct testMonitor testMonitor
 

Functions

DBCORE_API void testdbPrepare (void)
 
DBCORE_API void testdbReadDatabase (const char *file, const char *path, const char *substitutions)
 
DBCORE_API void testIocInitOk (void)
 
DBCORE_API void testIocShutdownOk (void)
 
DBCORE_API void testdbCleanup (void)
 
DBCORE_API void testdbPutFieldOk (const char *pv, int dbrType,...)
 
DBCORE_API void testdbPutFieldFail (long status, const char *pv, int dbrType,...)
 
DBCORE_API long testdbVPutField (const char *pv, short dbrType, va_list ap)
 
DBCORE_API void testdbGetFieldEqual (const char *pv, int dbrType,...)
 
DBCORE_API void testdbVGetFieldEqual (const char *pv, short dbrType, va_list ap)
 
DBCORE_API void testdbPutArrFieldOk (const char *pv, short dbrType, unsigned long count, const void *pbuf)
 
DBCORE_API void testdbGetArrFieldEqual (const char *pv, short dbfType, long nRequest, unsigned long pbufcnt, const void *pbuf)
 
DBCORE_API dbCommontestdbRecordPtr (const char *pv)
 
DBCORE_API testMonitor * testMonitorCreate (const char *pvname, unsigned dbe_mask, unsigned opt)
 
DBCORE_API void testMonitorDestroy (testMonitor *)
 
DBCORE_API void testMonitorWait (testMonitor *)
 
DBCORE_API unsigned testMonitorCount (testMonitor *, unsigned reset)
 
DBCORE_API void testSyncCallback (void)
 
DBCORE_API void testGlobalLock (void)
 
DBCORE_API void testGlobalUnlock (void)
 

Detailed Description

Author
Michael Davidsaver, Ralph Lange
See Also
Unit testing of record processing

Definition in file dbUnitTest.h.

Function Documentation

DBCORE_API void testdbPrepare ( void  )

First step in test database setup

See Also
Test skeleton
DBCORE_API void testdbReadDatabase ( const char *  file,
const char *  path,
const char *  substitutions 
)

Read .dbd or .db file

See Also
Test skeleton
DBCORE_API void testIocInitOk ( void  )

Assert success of iocInit()

See Also
Test skeleton
DBCORE_API void testIocShutdownOk ( void  )

Shutdown test database processing.

eg. Stops scan threads

See Also
Test skeleton
DBCORE_API void testdbCleanup ( void  )

Final step in test database cleanup

See Also
Test skeleton
DBCORE_API void testdbPutFieldOk ( const char *  pv,
int  dbrType,
  ... 
)

Assert that a dbPutField() scalar operation will complete successfully.

testdbPutFieldOk("some.TPRO", DBF_LONG, 1);
See Also
Actions
DBCORE_API void testdbPutFieldFail ( long  status,
const char *  pv,
int  dbrType,
  ... 
)

Assert that a dbPutField() operation will fail with a certain S_* code

See Also
Actions
DBCORE_API long testdbVPutField ( const char *  pv,
short  dbrType,
va_list  ap 
)

Assert that a dbPutField() scalar operation will complete successfully.

See Also
Actions
DBCORE_API void testdbGetFieldEqual ( const char *  pv,
int  dbrType,
  ... 
)

Assert that a dbGetField() scalar operation will complete successfully, with the provided value.

testdbGetFieldEqual("some.TPRO", DBF_LONG, 0);
See Also
Actions
DBCORE_API void testdbVGetFieldEqual ( const char *  pv,
short  dbrType,
va_list  ap 
)

Assert that a dbGetField() scalar operation will complete successfully, with the provided value.

See Also
Actions
DBCORE_API void testdbPutArrFieldOk ( const char *  pv,
short  dbrType,
unsigned long  count,
const void *  pbuf 
)

Assert that a dbPutField() array operation will complete successfully.

Parameters
pva PV name, possibly including filter expression
dbrTypea DBF_* type code (cf. dbfType in dbFldTypes.h)
countNumber of elements in pbuf array
pbufArray of values to write
static const epicsUInt32 putval[] = {1,2,3};
testdbVGetFieldEqual("some:wf", DBF_ULONG, NELEMENTS(putval), putval);
See Also
Actions
DBCORE_API void testdbGetArrFieldEqual ( const char *  pv,
short  dbfType,
long  nRequest,
unsigned long  pbufcnt,
const void *  pbuf 
)
Parameters
pvPV name string
dbfTypeOne of the DBF_* macros from dbAccess.h
nRequestNumber of elements to request from pv
pbufcntNumber of elements pointed to be pbuf
pbufExpected value buffer

Execute dbGet() of nRequest elements and compare the result with pbuf (pbufcnt is an element count). Element size is derived from dbfType.

nRequest > pbufcnt will detect truncation. nRequest < pbufcnt always fails. nRequest ==pbufcnt checks prefix (actual may be longer than expected)

DBCORE_API dbCommon* testdbRecordPtr ( const char *  pv)

Obtain pointer to record.

Calls testAbort() on failure. Will never return NULL.

Note
Remember to dbScanLock() when accessing mutable fields.
DBCORE_API testMonitor* testMonitorCreate ( const char *  pvname,
unsigned  dbe_mask,
unsigned  opt 
)

Setup monitoring the named PV for changes

DBCORE_API void testMonitorDestroy ( testMonitor *  )

Stop monitoring

DBCORE_API void testMonitorWait ( testMonitor *  )

Return immediately if it has been updated since create, last wait, or reset (count w/ reset=1). Otherwise, block until the value of the target PV is updated.

DBCORE_API unsigned testMonitorCount ( testMonitor *  ,
unsigned  reset 
)

Return the number of monitor events which have occured since create, or a previous reset (called reset=1). Calling w/ reset=0 only returns the count. Calling w/ reset=1 resets the count to zero and ensures that the next wait will block unless subsequent events occur. Returns the previous count.

DBCORE_API void testSyncCallback ( void  )

Synchronize the shared callback queues.

Block until all callback queue jobs which were queued, or running, have completed.

DBCORE_API void testGlobalLock ( void  )

Lock Global convenience mutex for use by test code.

See Also
Global mutex for use by test code.
DBCORE_API void testGlobalUnlock ( void  )

Unlock Global convenience mutex for use by test code.

See Also
Global mutex for use by test code.