Merge remote-tracking branch 'launchpad/master'
* launchpad/master: libCom: dbmfMalloc cantProeed() on failure ioc/db/test: dbCaLinkTest fix sync oops std/filter/test: use dbUnitTest travis-ci enable mingw w/ dll travisci catools: Fix SEGFAULT from bad PV names typo Fix for dbCa warning seg-fault Fix postfix.h macro arg, document libCom/test: epicsCalcTest use exact postifx buffers Conflicts: src/ioc/db/test/dbCaLinkTest.c
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
|
||||
DBE_ARCHIVE (DBE_LOG)
|
||||
Trigger an event when an archive significant change in the channel's
|
||||
valuue occurs. Relies on the archiver monitor deadband field under DCT.
|
||||
value occurs. Relies on the archiver monitor deadband field under DCT.
|
||||
|
||||
DBE_ALARM
|
||||
Trigger an event when the alarm state changes
|
||||
|
||||
@@ -541,11 +541,11 @@ int main (int argc, char *argv[])
|
||||
for (n = 0; optind < argc; n++, optind++)
|
||||
pvs[n].name = argv[optind] ; /* Copy PV names from command line */
|
||||
|
||||
connect_pvs(pvs, nPvs);
|
||||
result = connect_pvs(pvs, nPvs);
|
||||
|
||||
/* Read and print data */
|
||||
|
||||
result = caget(pvs, nPvs, request, format, type, count);
|
||||
if (!result)
|
||||
result = caget(pvs, nPvs, request, format, type, count);
|
||||
|
||||
/* Shut down Channel Access */
|
||||
ca_context_destroy();
|
||||
|
||||
@@ -211,10 +211,11 @@ int main (int argc, char *argv[])
|
||||
for (n = 0; optind < argc; n++, optind++)
|
||||
pvs[n].name = argv[optind] ; /* Copy PV names from command line */
|
||||
|
||||
connect_pvs(pvs, nPvs);
|
||||
result = connect_pvs(pvs, nPvs);
|
||||
|
||||
/* Print data */
|
||||
result = cainfo(pvs, nPvs);
|
||||
if (!result)
|
||||
result = cainfo(pvs, nPvs);
|
||||
|
||||
/* Shut down Channel Access */
|
||||
ca_context_destroy();
|
||||
|
||||
+17
-1
@@ -140,7 +140,6 @@ static void addAction(caLink *pca, short link_action)
|
||||
if (++removesOutstanding >= removesOutstandingWarning) {
|
||||
errlogPrintf("dbCa::addAction pausing, %d channels to clear\n",
|
||||
removesOutstanding);
|
||||
printLinks(pca);
|
||||
}
|
||||
while (removesOutstanding >= removesOutstandingWarning) {
|
||||
epicsMutexUnlock(workListLock);
|
||||
@@ -229,6 +228,22 @@ void dbCaSync(void)
|
||||
epicsEventDestroy(wake);
|
||||
}
|
||||
|
||||
epicsShareFunc unsigned long dbCaGetUpdateCount(struct link *plink)
|
||||
{
|
||||
caLink *pca = (caLink *)plink->value.pv_link.pvt;
|
||||
unsigned long ret;
|
||||
|
||||
if (!pca) return (unsigned long)-1;
|
||||
|
||||
epicsMutexMustLock(pca->lock);
|
||||
|
||||
ret = pca->nUpdate;
|
||||
|
||||
epicsMutexUnlock(pca->lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void dbCaCallbackProcess(void *userPvt)
|
||||
{
|
||||
struct link *plink = (struct link *)userPvt;
|
||||
@@ -827,6 +842,7 @@ static void eventCallback(struct event_handler_args arg)
|
||||
epicsMutexMustLock(pca->lock);
|
||||
plink = pca->plink;
|
||||
if (!plink) goto done;
|
||||
pca->nUpdate++;
|
||||
monitor = pca->monitor;
|
||||
userPvt = pca->userPvt;
|
||||
precord = plink->precord;
|
||||
|
||||
@@ -48,6 +48,7 @@ extern struct ca_client_context * dbCaClientContext;
|
||||
|
||||
#ifdef EPICS_DBCA_PRIVATE_API
|
||||
epicsShareFunc void dbCaSync(void);
|
||||
epicsShareFunc unsigned long dbCaGetUpdateCount(struct link *plink);
|
||||
#endif
|
||||
|
||||
/* These macros are for backwards compatibility */
|
||||
|
||||
@@ -90,6 +90,7 @@ typedef struct caLink
|
||||
/* The following are for dbcar*/
|
||||
unsigned long nDisconnect;
|
||||
unsigned long nNoWrite; /*only modified by dbCaPutLink*/
|
||||
unsigned long nUpdate;
|
||||
}caLink;
|
||||
|
||||
#endif /* INC_dbCaPvt_H */
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#define EPICS_DBCA_PRIVATE_API
|
||||
|
||||
#include "epicsString.h"
|
||||
#include "dbUnitTest.h"
|
||||
#include "epicsThread.h"
|
||||
@@ -46,46 +48,10 @@ static epicsEventId waitEvent;
|
||||
static unsigned waitCounter;
|
||||
|
||||
static
|
||||
void waitCB(void *unused)
|
||||
void waitForUpdateN(DBLINK *plink, unsigned long n)
|
||||
{
|
||||
if(waitEvent)
|
||||
epicsEventMustTrigger(waitEvent);
|
||||
waitCounter++; /* TODO: atomic */
|
||||
}
|
||||
|
||||
static
|
||||
void startWait(DBLINK *plink)
|
||||
{
|
||||
caLink *pca = plink->value.pv_link.pvt;
|
||||
|
||||
assert(!waitEvent);
|
||||
waitEvent = epicsEventMustCreate(epicsEventEmpty);
|
||||
|
||||
assert(pca);
|
||||
epicsMutexMustLock(pca->lock);
|
||||
assert(!pca->monitor && !pca->userPvt);
|
||||
pca->monitor = &waitCB;
|
||||
epicsMutexUnlock(pca->lock);
|
||||
testDiag("Preparing to wait on pca=%p", pca);
|
||||
}
|
||||
|
||||
static
|
||||
void waitForUpdate(DBLINK *plink)
|
||||
{
|
||||
caLink *pca = plink->value.pv_link.pvt;
|
||||
|
||||
assert(pca);
|
||||
|
||||
testDiag("Waiting on pca=%p", pca);
|
||||
epicsEventMustWait(waitEvent);
|
||||
|
||||
epicsMutexMustLock(pca->lock);
|
||||
pca->monitor = NULL;
|
||||
pca->userPvt = NULL;
|
||||
epicsMutexUnlock(pca->lock);
|
||||
|
||||
epicsEventDestroy(waitEvent);
|
||||
waitEvent = NULL;
|
||||
while(dbCaGetUpdateCount(plink)<n)
|
||||
epicsThreadSleep(0.01);
|
||||
}
|
||||
|
||||
static
|
||||
@@ -93,18 +59,13 @@ void putLink(DBLINK *plink, short dbr, const void*buf, long nReq)
|
||||
{
|
||||
long ret;
|
||||
|
||||
waitEvent = epicsEventMustCreate(epicsEventEmpty);
|
||||
|
||||
ret = dbCaPutLinkCallback(plink, dbr, buf, nReq,
|
||||
&waitCB, NULL);
|
||||
ret = dbPutLink(plink, dbr, buf, nReq);
|
||||
if(ret) {
|
||||
testFail("putLink fails %ld", ret);
|
||||
} else {
|
||||
epicsEventMustWait(waitEvent);
|
||||
testPass("putLink ok");
|
||||
dbCaSync();
|
||||
}
|
||||
epicsEventDestroy(waitEvent);
|
||||
waitEvent = NULL;
|
||||
}
|
||||
|
||||
static long getTwice(struct link *psrclnk, void *dummy)
|
||||
@@ -169,14 +130,14 @@ static void testNativeLink(void)
|
||||
|
||||
testOk1(psrclnk->type==CA_LINK);
|
||||
|
||||
startWait(psrclnk);
|
||||
waitForUpdateN(psrclnk, 1);
|
||||
|
||||
dbScanLock((dbCommon*)ptarg);
|
||||
ptarg->val = 42;
|
||||
db_post_events(ptarg, &ptarg->val, DBE_VALUE|DBE_ALARM|DBE_ARCHIVE);
|
||||
dbScanUnlock((dbCommon*)ptarg);
|
||||
|
||||
waitForUpdate(psrclnk);
|
||||
waitForUpdateN(psrclnk, 2);
|
||||
|
||||
dbScanLock((dbCommon*)psrc);
|
||||
/* local CA_LINK connects immediately */
|
||||
@@ -254,14 +215,14 @@ static void testStringLink(void)
|
||||
|
||||
testOk1(psrclnk->type==CA_LINK);
|
||||
|
||||
startWait(psrclnk);
|
||||
waitForUpdateN(psrclnk, 1);
|
||||
|
||||
dbScanLock((dbCommon*)ptarg);
|
||||
strcpy(ptarg->desc, "hello");
|
||||
db_post_events(ptarg, &ptarg->desc, DBE_VALUE|DBE_ALARM|DBE_ARCHIVE);
|
||||
dbScanUnlock((dbCommon*)ptarg);
|
||||
|
||||
waitForUpdate(psrclnk);
|
||||
waitForUpdateN(psrclnk, 2);
|
||||
|
||||
dbScanLock((dbCommon*)psrc);
|
||||
/* local CA_LINK connects immediately */
|
||||
@@ -287,7 +248,8 @@ static void testStringLink(void)
|
||||
|
||||
static void wasproc(xRecord *prec)
|
||||
{
|
||||
waitCB(NULL);
|
||||
waitCounter++;
|
||||
epicsEventTrigger(waitEvent);
|
||||
}
|
||||
|
||||
static void testCP(void)
|
||||
@@ -316,6 +278,7 @@ static void testCP(void)
|
||||
eltc(0);
|
||||
testIocInitOk();
|
||||
eltc(1);
|
||||
dbCaSync();
|
||||
|
||||
epicsEventMustWait(waitEvent);
|
||||
|
||||
@@ -434,6 +397,8 @@ static void testArrayLink(unsigned nsrc, unsigned ntarg)
|
||||
testIocInitOk();
|
||||
eltc(1);
|
||||
|
||||
waitForUpdateN(psrclnk, 1);
|
||||
|
||||
bufsrc = psrc->bptr;
|
||||
buftarg= ptarg->bptr;
|
||||
|
||||
@@ -447,15 +412,13 @@ static void testArrayLink(unsigned nsrc, unsigned ntarg)
|
||||
|
||||
tmpbuf = callocMustSucceed(num_max, sizeof(*tmpbuf), "tmpbuf");
|
||||
|
||||
startWait(psrclnk);
|
||||
|
||||
dbScanLock((dbCommon*)ptarg);
|
||||
fillArray(buftarg, ptarg->nelm, 1);
|
||||
ptarg->nord = ptarg->nelm;
|
||||
db_post_events(ptarg, ptarg->bptr, DBE_VALUE|DBE_ALARM|DBE_ARCHIVE);
|
||||
dbScanUnlock((dbCommon*)ptarg);
|
||||
|
||||
waitForUpdate(psrclnk);
|
||||
waitForUpdateN(psrclnk, 2);
|
||||
|
||||
dbScanLock((dbCommon*)psrc);
|
||||
testDiag("fetch source.INP into source.BPTR");
|
||||
@@ -525,7 +488,8 @@ static void softarr(arrRecord *prec)
|
||||
if(nReq>0)
|
||||
testDiag("%s.VAL[0] - %f", prec->name, *(double*)prec->bptr);
|
||||
}
|
||||
waitCB(NULL);
|
||||
waitCounter++;
|
||||
epicsEventTrigger(waitEvent);
|
||||
}
|
||||
|
||||
static void testreTargetTypeChange(void)
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#endif
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "cantProceed.h"
|
||||
#include "epicsMutex.h"
|
||||
#include "ellLib.h"
|
||||
#include "dbmf.h"
|
||||
@@ -114,7 +115,7 @@ void* dbmfMalloc(size_t size)
|
||||
pmem = (char *)malloc(nbytesTotal);
|
||||
if(!pmem) {
|
||||
epicsMutexUnlock(pdbmfPvt->lock);
|
||||
printf("dbmfMalloc malloc failed\n");
|
||||
cantProceed("dbmfMalloc malloc failed\n");
|
||||
return(NULL);
|
||||
}
|
||||
pchunkNode = (chunkNode *)(pmem + pdbmfPvt->chunkSize);
|
||||
@@ -140,7 +141,7 @@ void* dbmfMalloc(size_t size)
|
||||
pmem = malloc(sizeof(itemHeader) + 2*REDZONE + size);
|
||||
if(!pmem) {
|
||||
epicsMutexUnlock(pdbmfPvt->lock);
|
||||
printf("dbmfMalloc malloc failed\n");
|
||||
cantProceed("dbmfMalloc malloc failed\n");
|
||||
return(NULL);
|
||||
}
|
||||
pdbmfPvt->nAlloc++;
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
\*************************************************************************/
|
||||
// Author: Andrew Johnson
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "epicsUnitTest.h"
|
||||
#include "epicsTypes.h"
|
||||
#include "epicsMath.h"
|
||||
@@ -20,17 +23,23 @@ double doCalc(const char *expr) {
|
||||
double args[CALCPERFORM_NARGS] = {
|
||||
1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0
|
||||
};
|
||||
char rpn[MAX_POSTFIX_SIZE];
|
||||
char *rpn = (char*)malloc(INFIX_TO_POSTFIX_SIZE(strlen(expr)+1));
|
||||
short err;
|
||||
double result = 0.0;
|
||||
result /= result; /* Start as NaN */
|
||||
|
||||
|
||||
if(!rpn) {
|
||||
testAbort("postfix: %s no memory", expr);
|
||||
return epicsNAN;
|
||||
}
|
||||
|
||||
if (postfix(expr, rpn, &err)) {
|
||||
testDiag("postfix: %s in expression '%s'", calcErrorStr(err), expr);
|
||||
} else
|
||||
if (calcPerform(args, &result, rpn) && finite(result)) {
|
||||
testDiag("calcPerform: error evaluating '%s'", expr);
|
||||
}
|
||||
free(rpn);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -40,11 +49,16 @@ void testCalc(const char *expr, double expected) {
|
||||
double args[CALCPERFORM_NARGS] = {
|
||||
1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0
|
||||
};
|
||||
char rpn[MAX_POSTFIX_SIZE];
|
||||
char *rpn = (char*)malloc(INFIX_TO_POSTFIX_SIZE(strlen(expr)+1));
|
||||
short err;
|
||||
double result = 0.0;
|
||||
result /= result; /* Start as NaN */
|
||||
|
||||
if(!rpn) {
|
||||
testFail("postfix: %s no memory", expr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (postfix(expr, rpn, &err)) {
|
||||
testDiag("postfix: %s in expression '%s'", calcErrorStr(err), expr);
|
||||
} else
|
||||
@@ -63,6 +77,7 @@ void testCalc(const char *expr, double expected) {
|
||||
testDiag("Expected result is %g, actually got %g", expected, result);
|
||||
calcExprDump(rpn);
|
||||
}
|
||||
free(rpn);
|
||||
}
|
||||
|
||||
void testUInt32Calc(const char *expr, epicsUInt32 expected) {
|
||||
@@ -71,12 +86,17 @@ void testUInt32Calc(const char *expr, epicsUInt32 expected) {
|
||||
double args[CALCPERFORM_NARGS] = {
|
||||
1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0
|
||||
};
|
||||
char rpn[MAX_POSTFIX_SIZE];
|
||||
char *rpn = (char*)malloc(INFIX_TO_POSTFIX_SIZE(strlen(expr)+1));
|
||||
short err;
|
||||
epicsUInt32 uresult;
|
||||
double result = 0.0;
|
||||
result /= result; /* Start as NaN */
|
||||
|
||||
if(!rpn) {
|
||||
testFail("postfix: %s no memory", expr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (postfix(expr, rpn, &err)) {
|
||||
testDiag("postfix: %s in expression '%s'", calcErrorStr(err), expr);
|
||||
} else
|
||||
@@ -91,38 +111,50 @@ void testUInt32Calc(const char *expr, epicsUInt32 expected) {
|
||||
expected, expected, uresult, uresult);
|
||||
calcExprDump(rpn);
|
||||
}
|
||||
free(rpn);
|
||||
}
|
||||
|
||||
void testArgs(const char *expr, unsigned long einp, unsigned long eout) {
|
||||
char rpn[MAX_POSTFIX_SIZE];
|
||||
char *rpn = (char*)malloc(INFIX_TO_POSTFIX_SIZE(strlen(expr)+1));
|
||||
short err = 0;
|
||||
unsigned long vinp, vout;
|
||||
|
||||
if(!rpn) {
|
||||
testFail("postfix: %s no memory", expr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (postfix(expr, rpn, &err)) {
|
||||
testFail("postfix: %s in expression '%s'", calcErrorStr(err), expr);
|
||||
return;
|
||||
testFail("postfix: %s in expression '%s'", calcErrorStr(err), expr);
|
||||
return;
|
||||
}
|
||||
if (calcArgUsage(rpn, &vinp, &vout)) {
|
||||
testFail("calcArgUsage returned error for '%s'", expr);
|
||||
return;
|
||||
testFail("calcArgUsage returned error for '%s'", expr);
|
||||
return;
|
||||
}
|
||||
if (!testOk(vinp == einp && vout == eout, "Args for '%s'", expr)) {
|
||||
testDiag("Expected (%lx, %lx) got (%lx, %lx)", einp, eout, vinp, vout);
|
||||
testDiag("Expected (%lx, %lx) got (%lx, %lx)", einp, eout, vinp, vout);
|
||||
}
|
||||
free(rpn);
|
||||
}
|
||||
|
||||
void testBadExpr(const char *expr, short expected_err) {
|
||||
/* Parse an invalid expression, test against expected error code */
|
||||
char rpn[MAX_POSTFIX_SIZE];
|
||||
char *rpn = (char*)malloc(INFIX_TO_POSTFIX_SIZE(strlen(expr)+1));
|
||||
short err = 0;
|
||||
|
||||
if(!rpn) {
|
||||
testFail("postfix: %s no memory", expr);
|
||||
return;
|
||||
}
|
||||
|
||||
postfix(expr, rpn, &err);
|
||||
if (!testOk(err == expected_err, "Bad expression '%s'", expr)) {
|
||||
testDiag("Expected '%s', actually got '%s'",
|
||||
calcErrorStr(expected_err), calcErrorStr(err));
|
||||
calcExprDump(rpn);
|
||||
testDiag("Expected '%s', actually got '%s'",
|
||||
calcErrorStr(expected_err), calcErrorStr(err));
|
||||
calcExprDump(rpn);
|
||||
}
|
||||
return;
|
||||
free(rpn);
|
||||
}
|
||||
|
||||
/* Test an expression that is also valid C code */
|
||||
|
||||
@@ -18,48 +18,42 @@ Recs_LIBS += dbCore Com
|
||||
|
||||
PROD_LIBS = Recs dbRecStd dbCore ca Com
|
||||
|
||||
TARGETS += $(COMMON_DIR)/tsTest.dbd
|
||||
DBDDEPENDS_FILES += tsTest.dbd$(DEP)
|
||||
tsTest_DBD += xRecord.dbd
|
||||
DBDDEPENDS_FILES += filterTest.dbd$(DEP)
|
||||
TARGETS += $(COMMON_DIR)/filterTest.dbd
|
||||
filterTest_DBD += menuGlobal.dbd
|
||||
filterTest_DBD += menuConvert.dbd
|
||||
filterTest_DBD += menuScan.dbd
|
||||
filterTest_DBD += filters.dbd
|
||||
filterTest_DBD += xRecord.dbd
|
||||
filterTest_DBD += arrRecord.dbd
|
||||
TESTFILES += $(COMMON_DIR)/filterTest.dbd
|
||||
|
||||
testHarness_SRCS += filterTest_registerRecordDeviceDriver.cpp
|
||||
|
||||
TESTPROD_HOST += tsTest
|
||||
tsTest_SRCS += tsTest.c
|
||||
tsTest_SRCS += tsTest_registerRecordDeviceDriver.cpp
|
||||
tsTest_SRCS += filterTest_registerRecordDeviceDriver.cpp
|
||||
testHarness_SRCS += tsTest.c
|
||||
testHarness_SRCS += tsTest_registerRecordDeviceDriver.cpp
|
||||
TESTFILES += $(COMMON_DIR)/tsTest.dbd ../xRecord.db
|
||||
TESTFILES += ../xRecord.db
|
||||
TESTS += tsTest
|
||||
|
||||
TARGETS += $(COMMON_DIR)/dbndTest.dbd
|
||||
DBDDEPENDS_FILES += dbndTest.dbd$(DEP)
|
||||
dbndTest_DBD += xRecord.dbd
|
||||
TESTPROD_HOST += dbndTest
|
||||
dbndTest_SRCS += dbndTest.c
|
||||
dbndTest_SRCS += dbndTest_registerRecordDeviceDriver.cpp
|
||||
dbndTest_SRCS += filterTest_registerRecordDeviceDriver.cpp
|
||||
testHarness_SRCS += dbndTest.c
|
||||
testHarness_SRCS += dbndTest_registerRecordDeviceDriver.cpp
|
||||
TESTFILES += $(COMMON_DIR)/dbndTest.dbd
|
||||
TESTS += dbndTest
|
||||
|
||||
TARGETS += $(COMMON_DIR)/arrTest.dbd
|
||||
DBDDEPENDS_FILES += arrTest.dbd$(DEP)
|
||||
arrTest_DBD += arrRecord.dbd
|
||||
TESTPROD_HOST += arrTest
|
||||
arrTest_SRCS += arrTest.cpp
|
||||
arrTest_SRCS += arrTest_registerRecordDeviceDriver.cpp
|
||||
arrTest_SRCS += filterTest_registerRecordDeviceDriver.cpp
|
||||
testHarness_SRCS += arrTest.cpp
|
||||
testHarness_SRCS += arrTest_registerRecordDeviceDriver.cpp
|
||||
TESTFILES += $(COMMON_DIR)/arrTest.dbd ../arrTest.db
|
||||
TESTFILES += ../arrTest.db
|
||||
TESTS += arrTest
|
||||
|
||||
TARGETS += $(COMMON_DIR)/syncTest.dbd
|
||||
DBDDEPENDS_FILES += syncTest.dbd$(DEP)
|
||||
syncTest_DBD += xRecord.dbd
|
||||
TESTPROD_HOST += syncTest
|
||||
syncTest_SRCS += syncTest.c
|
||||
syncTest_SRCS += syncTest_registerRecordDeviceDriver.cpp
|
||||
syncTest_SRCS += filterTest_registerRecordDeviceDriver.cpp
|
||||
testHarness_SRCS += syncTest.c
|
||||
testHarness_SRCS += syncTest_registerRecordDeviceDriver.cpp
|
||||
TESTFILES += $(COMMON_DIR)/syncTest.dbd
|
||||
TESTS += syncTest
|
||||
|
||||
# epicsRunFilterTests runs all the test programs in a known working order.
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
#include "envDefs.h"
|
||||
#include "dbStaticLib.h"
|
||||
#include "dbmf.h"
|
||||
#include "errlog.h"
|
||||
#include "registry.h"
|
||||
#include "subRecord.h"
|
||||
#include "dbAddr.h"
|
||||
#include "dbAccess.h"
|
||||
#include "asDbLib.h"
|
||||
@@ -38,14 +38,14 @@
|
||||
#include "iocsh.h"
|
||||
#include "dbChannel.h"
|
||||
#include "epicsUnitTest.h"
|
||||
#include "dbUnitTest.h"
|
||||
#include "testMain.h"
|
||||
#include "osiFileName.h"
|
||||
|
||||
#include "arrRecord.h"
|
||||
|
||||
extern "C" {
|
||||
int arrTest_registerRecordDeviceDriver(struct dbBase *pdbbase);
|
||||
epicsShareExtern void (*pvar_func_arrInitialize)(void);
|
||||
void filterTest_registerRecordDeviceDriver(struct dbBase *);
|
||||
}
|
||||
|
||||
#define CA_SERVER_PORT "65535"
|
||||
@@ -54,12 +54,6 @@ extern "C" {
|
||||
|
||||
const char *server_port = CA_SERVER_PORT;
|
||||
|
||||
extern "C" {
|
||||
static void exitSubroutine(subRecord *precord) {
|
||||
epicsExit((precord->a == 0.0) ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
static int fl_equals_array(short type, const db_field_log *pfl1, void *p2) {
|
||||
for (int i = 0; i < pfl1->no_elements; i++) {
|
||||
switch (type) {
|
||||
@@ -298,23 +292,9 @@ static void check(short dbr_type) {
|
||||
TEST5B(3, -8, -4, "both sides from-end");
|
||||
}
|
||||
|
||||
static dbEventCtx evtctx;
|
||||
|
||||
extern "C" {
|
||||
static void arrTestCleanup(void* junk)
|
||||
{
|
||||
dbFreeBase(pdbbase);
|
||||
registryFree();
|
||||
pdbbase=0;
|
||||
|
||||
db_close_events(evtctx);
|
||||
|
||||
dbmfFreeChunks();
|
||||
}
|
||||
}
|
||||
|
||||
MAIN(arrTest)
|
||||
{
|
||||
dbEventCtx evtctx;
|
||||
const chFilterPlugin *plug;
|
||||
char arr[] = "arr";
|
||||
|
||||
@@ -324,26 +304,21 @@ MAIN(arrTest)
|
||||
|
||||
epicsEnvSet("EPICS_CA_SERVER_PORT", server_port);
|
||||
|
||||
if (dbReadDatabase(&pdbbase, "arrTest.dbd",
|
||||
"." OSI_PATH_LIST_SEPARATOR ".." OSI_PATH_LIST_SEPARATOR
|
||||
"../O.Common" OSI_PATH_LIST_SEPARATOR "O.Common", NULL))
|
||||
testAbort("Database description not loaded");
|
||||
testdbPrepare();
|
||||
|
||||
(*pvar_func_arrInitialize)();
|
||||
arrTest_registerRecordDeviceDriver(pdbbase);
|
||||
registryFunctionAdd("exit", (REGISTRYFUNCTION) exitSubroutine);
|
||||
testdbReadDatabase("filterTest.dbd", NULL, NULL);
|
||||
|
||||
if (dbReadDatabase(&pdbbase, "arrTest.db",
|
||||
"." OSI_PATH_LIST_SEPARATOR "..", NULL))
|
||||
testAbort("Test database not loaded");
|
||||
filterTest_registerRecordDeviceDriver(pdbbase);
|
||||
|
||||
epicsAtExit(&arrTestCleanup,NULL);
|
||||
testdbReadDatabase("arrTest.db", NULL, NULL);
|
||||
|
||||
eltc(0);
|
||||
testIocInitOk();
|
||||
eltc(1);
|
||||
|
||||
/* Start the IOC */
|
||||
|
||||
iocInit();
|
||||
evtctx = db_init_events();
|
||||
epicsThreadSleep(0.2);
|
||||
|
||||
testOk(!!(plug = dbFindFilter(arr, strlen(arr))), "plugin arr registered correctly");
|
||||
|
||||
@@ -351,5 +326,11 @@ MAIN(arrTest)
|
||||
check(DBR_DOUBLE);
|
||||
check(DBR_STRING);
|
||||
|
||||
db_close_events(evtctx);
|
||||
|
||||
testIocShutdownOk();
|
||||
|
||||
testdbCleanup();
|
||||
|
||||
return testDone();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
#include "db_field_log.h"
|
||||
#include "dbCommon.h"
|
||||
#include "registry.h"
|
||||
#include "errlog.h"
|
||||
#include "chfPlugin.h"
|
||||
#include "epicsUnitTest.h"
|
||||
#include "dbUnitTest.h"
|
||||
#include "epicsTime.h"
|
||||
#include "dbmf.h"
|
||||
#include "testMain.h"
|
||||
@@ -26,8 +28,7 @@
|
||||
|
||||
#define PATTERN 0x55
|
||||
|
||||
void dbndTest_registerRecordDeviceDriver(struct dbBase *);
|
||||
epicsShareExtern void (*pvar_func_dbndInitialize)(void);
|
||||
void filterTest_registerRecordDeviceDriver(struct dbBase *);
|
||||
|
||||
static db_field_log fl;
|
||||
|
||||
@@ -115,21 +116,20 @@ MAIN(dbndTest)
|
||||
|
||||
testPlan(59);
|
||||
|
||||
dbChannelInit();
|
||||
testdbPrepare();
|
||||
|
||||
testdbReadDatabase("filterTest.dbd", NULL, NULL);
|
||||
|
||||
filterTest_registerRecordDeviceDriver(pdbbase);
|
||||
|
||||
testdbReadDatabase("xRecord.db", NULL, NULL);
|
||||
|
||||
eltc(0);
|
||||
testIocInitOk();
|
||||
eltc(1);
|
||||
|
||||
evtctx = db_init_events();
|
||||
|
||||
if (dbReadDatabase(&pdbbase, "dbndTest.dbd",
|
||||
"." OSI_PATH_LIST_SEPARATOR ".." OSI_PATH_LIST_SEPARATOR
|
||||
"../O.Common" OSI_PATH_LIST_SEPARATOR "O.Common", NULL))
|
||||
testAbort("Database description 'dbndTest.dbd' not found");
|
||||
|
||||
(*pvar_func_dbndInitialize)(); /* manually initialize plugin */
|
||||
dbndTest_registerRecordDeviceDriver(pdbbase);
|
||||
|
||||
if (dbReadDatabase(&pdbbase, "xRecord.db",
|
||||
"." OSI_PATH_LIST_SEPARATOR "..", NULL))
|
||||
testAbort("Test database 'xRecord.db' not found");
|
||||
|
||||
testOk(!!(plug = dbFindFilter(dbnd, strlen(dbnd))), "plugin dbnd registered correctly");
|
||||
|
||||
testOk(!!(pch = dbChannelCreate("x.VAL{\"dbnd\":{}}")), "dbChannel with plugin dbnd (delta=0) created");
|
||||
@@ -274,13 +274,12 @@ MAIN(dbndTest)
|
||||
mustPassOnce(pch, pfl2, "rel", 50., 7);
|
||||
|
||||
dbChannelDelete(pch);
|
||||
dbFreeBase(pdbbase);
|
||||
registryFree();
|
||||
pdbbase=0;
|
||||
|
||||
db_close_events(evtctx);
|
||||
|
||||
dbmfFreeChunks();
|
||||
testIocShutdownOk();
|
||||
|
||||
testdbCleanup();
|
||||
|
||||
return testDone();
|
||||
}
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
#include "dbChannel.h"
|
||||
#include "registry.h"
|
||||
#include "chfPlugin.h"
|
||||
#include "errlog.h"
|
||||
#include "dbmf.h"
|
||||
#include "epicsUnitTest.h"
|
||||
#include "dbUnitTest.h"
|
||||
#include "epicsTime.h"
|
||||
#include "dbState.h"
|
||||
#include "testMain.h"
|
||||
@@ -28,8 +30,7 @@
|
||||
|
||||
#define PATTERN 0x55
|
||||
|
||||
void syncTest_registerRecordDeviceDriver(struct dbBase *);
|
||||
epicsShareExtern void (*pvar_func_syncInitialize)(void);
|
||||
void filterTest_registerRecordDeviceDriver(struct dbBase *);
|
||||
|
||||
static db_field_log fl;
|
||||
static dbStateId red;
|
||||
@@ -142,21 +143,20 @@ MAIN(syncTest)
|
||||
|
||||
testPlan(139);
|
||||
|
||||
dbChannelInit();
|
||||
testdbPrepare();
|
||||
|
||||
testdbReadDatabase("filterTest.dbd", NULL, NULL);
|
||||
|
||||
filterTest_registerRecordDeviceDriver(pdbbase);
|
||||
|
||||
testdbReadDatabase("xRecord.db", NULL, NULL);
|
||||
|
||||
eltc(0);
|
||||
testIocInitOk();
|
||||
eltc(1);
|
||||
|
||||
evtctx = db_init_events();
|
||||
|
||||
if (dbReadDatabase(&pdbbase, "syncTest.dbd",
|
||||
"." OSI_PATH_LIST_SEPARATOR ".." OSI_PATH_LIST_SEPARATOR
|
||||
"../O.Common" OSI_PATH_LIST_SEPARATOR "O.Common", NULL))
|
||||
testAbort("Database description 'syncTest.dbd' not found");
|
||||
|
||||
(*pvar_func_syncInitialize)(); /* manually initialize plugin */
|
||||
syncTest_registerRecordDeviceDriver(pdbbase);
|
||||
|
||||
if (dbReadDatabase(&pdbbase, "xRecord.db",
|
||||
"." OSI_PATH_LIST_SEPARATOR "..", NULL))
|
||||
testAbort("Test database 'xRecord.db' not found");
|
||||
|
||||
testOk(!!(plug = dbFindFilter(myname, strlen(myname))), "plugin %s registered correctly", myname);
|
||||
testOk(!!(red = dbStateCreate("red")), "state 'red' created successfully");
|
||||
|
||||
@@ -367,13 +367,12 @@ MAIN(syncTest)
|
||||
db_delete_field_log(pfl[9]);
|
||||
|
||||
dbChannelDelete(pch);
|
||||
dbFreeBase(pdbbase);
|
||||
registryFree();
|
||||
pdbbase=0;
|
||||
|
||||
db_close_events(evtctx);
|
||||
|
||||
dbmfFreeChunks();
|
||||
testIocShutdownOk();
|
||||
|
||||
testdbCleanup();
|
||||
|
||||
return testDone();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
#include "dbStaticLib.h"
|
||||
#include "dbAccessDefs.h"
|
||||
#include "chfPlugin.h"
|
||||
#include "errlog.h"
|
||||
#include "epicsUnitTest.h"
|
||||
#include "dbUnitTest.h"
|
||||
#include "registry.h"
|
||||
#include "dbmf.h"
|
||||
#include "epicsTime.h"
|
||||
@@ -24,8 +26,7 @@
|
||||
|
||||
#define PATTERN 0x55
|
||||
|
||||
void tsTest_registerRecordDeviceDriver(struct dbBase *);
|
||||
epicsShareExtern void (*pvar_func_tsInitialize)(void);
|
||||
void filterTest_registerRecordDeviceDriver(struct dbBase *);
|
||||
|
||||
static db_field_log fl;
|
||||
|
||||
@@ -56,21 +57,20 @@ MAIN(tsTest)
|
||||
|
||||
testPlan(12);
|
||||
|
||||
dbChannelInit();
|
||||
testdbPrepare();
|
||||
|
||||
testdbReadDatabase("filterTest.dbd", NULL, NULL);
|
||||
|
||||
filterTest_registerRecordDeviceDriver(pdbbase);
|
||||
|
||||
testdbReadDatabase("xRecord.db", NULL, NULL);
|
||||
|
||||
eltc(0);
|
||||
testIocInitOk();
|
||||
eltc(1);
|
||||
|
||||
evtctx = db_init_events();
|
||||
|
||||
if (dbReadDatabase(&pdbbase, "tsTest.dbd",
|
||||
"." OSI_PATH_LIST_SEPARATOR ".." OSI_PATH_LIST_SEPARATOR
|
||||
"../O.Common" OSI_PATH_LIST_SEPARATOR "O.Common", NULL))
|
||||
testAbort("Database description 'tsTest.dbd' not found");
|
||||
|
||||
(*pvar_func_tsInitialize)(); /* manually initialize plugin */
|
||||
tsTest_registerRecordDeviceDriver(pdbbase);
|
||||
|
||||
if (dbReadDatabase(&pdbbase, "xRecord.db",
|
||||
"." OSI_PATH_LIST_SEPARATOR "..", NULL))
|
||||
testAbort("Test database 'xRecord.db' not found");
|
||||
|
||||
testOk(!!(plug = dbFindFilter(ts, strlen(ts))), "plugin ts registered correctly");
|
||||
|
||||
testOk(!!(pch = dbChannelCreate("x.VAL{\"ts\":{}}")), "dbChannel with plugin ts created");
|
||||
@@ -108,13 +108,12 @@ MAIN(tsTest)
|
||||
"ts filter sets time stamp to \"now\"");
|
||||
|
||||
dbChannelDelete(pch);
|
||||
dbFreeBase(pdbbase);
|
||||
registryFree();
|
||||
pdbbase=0;
|
||||
|
||||
db_close_events(evtctx);
|
||||
|
||||
dbmfFreeChunks();
|
||||
testIocShutdownOk();
|
||||
|
||||
testdbCleanup();
|
||||
|
||||
return testDone();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
# This is a combined minimal DBD and DB file
|
||||
|
||||
recordtype(x) {
|
||||
field(NAME, DBF_STRING) {
|
||||
prompt("Record Name")
|
||||
special(SPC_NOMOD)
|
||||
size(61)
|
||||
}
|
||||
include "dbCommon.dbd"
|
||||
field(VAL, DBF_LONG) {
|
||||
prompt("Value")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user