dbLockTest: test creation of DB links
This commit is contained in:
@@ -37,6 +37,12 @@ dbPutLinkTest_SRCS += dbTestIoc_registerRecordDeviceDriver.cpp
|
||||
testHarness_SRCS += dbPutLinkTest.c
|
||||
TESTS += dbPutLinkTest
|
||||
|
||||
TESTPROD_HOST += dbLockTest
|
||||
dbLockTest_SRCS += dbLockTest.c
|
||||
dbLockTest_SRCS += dbTestIoc_registerRecordDeviceDriver.cpp
|
||||
testHarness_SRCS += dbLockTest.c
|
||||
TESTS += dbLockTest
|
||||
|
||||
TESTPROD_HOST += testdbConvert
|
||||
testdbConvert_SRCS += testdbConvert.c
|
||||
testHarness_SRCS += testdbConvert.c
|
||||
|
||||
86
src/ioc/db/test/dbLockTest.c
Normal file
86
src/ioc/db/test/dbLockTest.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2014 Brookhaven Science Assoc. as operator of Brookhaven
|
||||
* National Laboratory.
|
||||
* EPICS BASE is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
|
||||
/*
|
||||
* Author: Michael Davidsaver <mdavidsaver@bnl.gov>
|
||||
*/
|
||||
|
||||
#include "dbLock.h"
|
||||
|
||||
#include "dbUnitTest.h"
|
||||
#include "testMain.h"
|
||||
|
||||
#include "dbAccess.h"
|
||||
#include "errlog.h"
|
||||
|
||||
#include "xRecord.h"
|
||||
|
||||
void dbTestIoc_registerRecordDeviceDriver(struct dbBase *);
|
||||
|
||||
static
|
||||
void compareSets(int match, const char *A, const char *B)
|
||||
{
|
||||
int actual;
|
||||
dbCommon *rA, *rB;
|
||||
|
||||
rA = testdbRecordPtr(A);
|
||||
rB = testdbRecordPtr(B);
|
||||
|
||||
actual = dbLockGetLockId(rA)==dbLockGetLockId(rB);
|
||||
|
||||
testOk(match==actual, "dbLockGetLockId(\"%s\")%c=dbLockGetLockId(\"%s\")",
|
||||
A, match?'=':'!', B);
|
||||
}
|
||||
|
||||
static
|
||||
void testSets(void) {
|
||||
testDiag("Check initial creation of DB links");
|
||||
|
||||
testdbPrepare();
|
||||
|
||||
testdbReadDatabase("dbTestIoc.dbd", NULL, NULL);
|
||||
dbTestIoc_registerRecordDeviceDriver(pdbbase);
|
||||
testdbReadDatabase("dbLockTest.db", NULL, NULL);
|
||||
|
||||
eltc(0);
|
||||
testIocInitOk();
|
||||
eltc(1);
|
||||
|
||||
/* reca is by itself */
|
||||
compareSets(0, "reca", "recb");
|
||||
compareSets(0, "reca", "recc");
|
||||
compareSets(0, "reca", "recd");
|
||||
compareSets(0, "reca", "rece");
|
||||
compareSets(0, "reca", "recf");
|
||||
|
||||
/* recb and recc should be in a lockset */
|
||||
compareSets(1, "recb", "recc");
|
||||
compareSets(0, "recb", "recd");
|
||||
compareSets(0, "recb", "rece");
|
||||
compareSets(0, "recb", "recf");
|
||||
|
||||
compareSets(0, "recc", "recd");
|
||||
compareSets(0, "recc", "rece");
|
||||
compareSets(0, "recc", "recf");
|
||||
|
||||
/* recd, e, and f should be in a lockset */
|
||||
compareSets(1, "recd", "rece");
|
||||
compareSets(1, "recd", "recf");
|
||||
|
||||
compareSets(1, "rece", "recf");
|
||||
|
||||
testIocShutdownOk();
|
||||
|
||||
testdbCleanup();
|
||||
}
|
||||
|
||||
MAIN(dbLockTest)
|
||||
{
|
||||
testPlan(15);
|
||||
testSets();
|
||||
return testDone();
|
||||
}
|
||||
21
src/ioc/db/test/dbLockTest.db
Normal file
21
src/ioc/db/test/dbLockTest.db
Normal file
@@ -0,0 +1,21 @@
|
||||
record(x, "reca") {
|
||||
}
|
||||
|
||||
record(x, "recb") {
|
||||
field(SDIS, "recc")
|
||||
}
|
||||
|
||||
record(x, "recc") {
|
||||
field(SDIS, "recc")
|
||||
}
|
||||
|
||||
record(x, "recd") {
|
||||
field(SDIS, "rece")
|
||||
}
|
||||
|
||||
record(x, "rece") {
|
||||
field(SDIS, "recf")
|
||||
}
|
||||
|
||||
record(x, "recf") {
|
||||
}
|
||||
@@ -20,6 +20,7 @@ int testdbConvert(void);
|
||||
int callbackTest(void);
|
||||
int dbStateTest(void);
|
||||
int dbShutdownTest(void);
|
||||
int dbLockTest(void);
|
||||
int dbPutLinkTest(void);
|
||||
int testDbChannel(void);
|
||||
int chfPluginTest(void);
|
||||
@@ -33,6 +34,7 @@ void epicsRunDbTests(void)
|
||||
runTest(callbackTest);
|
||||
runTest(dbStateTest);
|
||||
runTest(dbShutdownTest);
|
||||
runTest(dbLockTest);
|
||||
runTest(dbPutLinkTest);
|
||||
runTest(testDbChannel);
|
||||
runTest(arrShorthandTest);
|
||||
|
||||
Reference in New Issue
Block a user