dbUnitTest.h

Helpers for unittests of process database.

See also

Unit testing of record processing

Author

Michael Davidsaver, Ralph Lange

Typedefs

typedef struct testMonitor testMonitor

Functions

void testdbPrepare(void)

First step in test database setup

See also

Test skeleton

void testdbReadDatabase(const char *file, const char *path, const char *substitutions)

Read .dbd or .db file

See also

Test skeleton

void testIocInitOk(void)

Assert success of iocInit()

See also

Test skeleton

void testIocShutdownOk(void)

Shutdown test database processing.

eg. Stops scan threads

See also

Test skeleton

void testdbCleanup(void)

Final step in test database cleanup

See also

Test skeleton

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

void testdbPutFieldFail(long status, const char *pv, int dbrType, ...)

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

See also

Actions

long testdbVPutField(const char *pv, short dbrType, va_list ap)

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

See also

Actions

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

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

void testdbPutArrFieldOk(const char *pv, short dbrType, unsigned long count, const void *pbuf)

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

static const epicsUInt32 putval[] = {1,2,3};
testdbPutArrFieldOk("some:wf", DBF_ULONG, NELEMENTS(putval), putval);

See also

Actions

Parameters:
  • pv – a PV name, possibly including filter expression

  • dbrType – a DBF_* type code (cf. dbfType in dbFldTypes.h)

  • count – Number of elements in pbuf array

  • pbuf – Array of values to write

void testdbGetArrFieldEqual(const char *pv, short dbfType, long nRequest, unsigned long pbufcnt, const void *pbuf)

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)

Parameters:
  • pv – PV name string

  • dbfType – One of the DBF_* macros from dbAccess.h

  • nRequest – Number of elements to request from pv

  • pbufcnt – Number of elements pointed to be pbuf

  • pbuf – Expected value buffer

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.

testMonitor *testMonitorCreate(const char *pvname, unsigned dbe_mask, unsigned opt)

Setup monitoring the named PV for changes

void testMonitorDestroy(testMonitor*)

Stop monitoring

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.

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.

void testSyncCallback(void)

Synchronize the shared callback queues.

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

void testGlobalLock(void)

Lock Global convenience mutex for use by test code.

See also

Global mutex for use by test code.

void testGlobalUnlock(void)

Unlock Global convenience mutex for use by test code.

See also

Global mutex for use by test code.