ioc/db/test: dbStaticTest test operations on aliases
This commit is contained in:
@@ -7,42 +7,48 @@
|
||||
#include <dbUnitTest.h>
|
||||
#include <testMain.h>
|
||||
|
||||
static void testEntry(void)
|
||||
static void testEntry(const char *pv)
|
||||
{
|
||||
DBENTRY entry;
|
||||
|
||||
testDiag("testEntry");
|
||||
testDiag("testEntry(\"%s\")", pv);
|
||||
|
||||
dbInitEntry(pdbbase, &entry);
|
||||
|
||||
testOk1(dbFindRecord(&entry, "testrec.VAL")==0);
|
||||
testOk1(dbFindRecord(&entry, pv)==0);
|
||||
|
||||
testDiag("precordType=%p precnode=%p", entry.precordType, entry.precnode);
|
||||
testOk1(entry.precordType && strcmp(entry.precordType->name, "x")==0);
|
||||
testOk1(entry.precnode && strcmp(((dbCommon*)entry.precnode->precord)->name, "testrec")==0);
|
||||
testOk1(entry.pflddes && strcmp(entry.pflddes->name, "VAL")==0);
|
||||
|
||||
testOk1(dbFollowAlias(&entry)==0);
|
||||
|
||||
testOk1(dbFindInfo(&entry, "A")==0 && strcmp(dbGetInfoString(&entry), "B")==0);
|
||||
|
||||
dbFinishEntry(&entry);
|
||||
}
|
||||
|
||||
static void testAddr2Entry(void)
|
||||
static void testAddr2Entry(const char *pv)
|
||||
{
|
||||
DBENTRY entry, entry2;
|
||||
dbAddr addr;
|
||||
|
||||
testDiag("testAddr2Entry");
|
||||
testDiag("testAddr2Entry(\"%s\")", pv);
|
||||
|
||||
memset(&entry, 0, sizeof(entry));
|
||||
memset(&entry2, 0, sizeof(entry2));
|
||||
|
||||
dbInitEntry(pdbbase, &entry);
|
||||
|
||||
if(dbFindRecord(&entry, "testrec.VAL")!=0)
|
||||
testAbort("no entry for testrec.VAL");
|
||||
if(dbFindRecord(&entry, pv)!=0)
|
||||
testAbort("no entry for %s", pv);
|
||||
|
||||
if(dbNameToAddr("testrec.VAL", &addr))
|
||||
testAbort("no addr for testrec.VAL");
|
||||
if(dbFollowAlias(&entry))
|
||||
testAbort("Can't follow alias");
|
||||
|
||||
if(dbNameToAddr(pv, &addr))
|
||||
testAbort("no addr for %s", pv);
|
||||
|
||||
dbInitEntryFromAddr(&addr, &entry2);
|
||||
|
||||
@@ -61,27 +67,85 @@ static void testAddr2Entry(void)
|
||||
testOk1(memcmp(&entry, &entry2, sizeof(entry))==0);
|
||||
|
||||
dbFinishEntry(&entry);
|
||||
dbFinishEntry(&entry2);
|
||||
}
|
||||
|
||||
static void testRec2Entry(const char *recname)
|
||||
{
|
||||
DBENTRY entry, entry2;
|
||||
dbCommon *prec;
|
||||
|
||||
testDiag("testRec2Entry(\"%s\")", recname);
|
||||
|
||||
memset(&entry, 0, sizeof(entry));
|
||||
memset(&entry2, 0, sizeof(entry2));
|
||||
|
||||
prec = testdbRecordPtr(recname);
|
||||
|
||||
dbInitEntry(pdbbase, &entry);
|
||||
|
||||
if(dbFindRecord(&entry, recname)!=0)
|
||||
testAbort("no entry for %s", recname);
|
||||
|
||||
if(dbFollowAlias(&entry))
|
||||
testAbort("Can't follow alias");
|
||||
|
||||
dbInitEntryFromRecord(prec, &entry2);
|
||||
|
||||
testOk1(entry.pdbbase==entry2.pdbbase);
|
||||
testOk1(entry.precordType==entry2.precordType);
|
||||
testOk1(entry.pflddes==entry2.pflddes);
|
||||
testOk1(entry.precnode==entry2.precnode);
|
||||
testOk1(entry.pfield==entry2.pfield);
|
||||
testOk1(entry2.indfield==-1);
|
||||
testOk1(!entry2.pinfonode);
|
||||
testOk1(!entry2.message);
|
||||
|
||||
/* no way to look this up, so not set */
|
||||
entry.indfield = -1;
|
||||
|
||||
testOk1(memcmp(&entry, &entry2, sizeof(entry))==0);
|
||||
|
||||
dbFinishEntry(&entry);
|
||||
dbFinishEntry(&entry2);
|
||||
}
|
||||
|
||||
void dbTestIoc_registerRecordDeviceDriver(struct dbBase *);
|
||||
|
||||
MAIN(dbStaticTest)
|
||||
{
|
||||
testPlan(19);
|
||||
testPlan(156);
|
||||
testdbPrepare();
|
||||
|
||||
testdbReadDatabase("dbTestIoc.dbd", NULL, NULL);
|
||||
dbTestIoc_registerRecordDeviceDriver(pdbbase);
|
||||
testdbReadDatabase("dbStaticTest.db", NULL, NULL);
|
||||
|
||||
testEntry();
|
||||
testEntry("testrec.VAL");
|
||||
testEntry("testalias.VAL");
|
||||
testEntry("testalias2.VAL");
|
||||
testEntry("testalias3.VAL");
|
||||
testRec2Entry("testrec");
|
||||
testRec2Entry("testalias");
|
||||
testRec2Entry("testalias2");
|
||||
testRec2Entry("testalias3");
|
||||
|
||||
eltc(0);
|
||||
testIocInitOk();
|
||||
eltc(1);
|
||||
|
||||
testEntry();
|
||||
testAddr2Entry();
|
||||
testEntry("testrec.VAL");
|
||||
testEntry("testalias.VAL");
|
||||
testEntry("testalias2.VAL");
|
||||
testEntry("testalias3.VAL");
|
||||
testAddr2Entry("testrec.VAL");
|
||||
testAddr2Entry("testalias.VAL");
|
||||
testAddr2Entry("testalias2.VAL");
|
||||
testAddr2Entry("testalias3.VAL");
|
||||
testRec2Entry("testrec");
|
||||
testRec2Entry("testalias");
|
||||
testRec2Entry("testalias2");
|
||||
testRec2Entry("testalias3");
|
||||
|
||||
testIocShutdownOk();
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
|
||||
record(x, "testrec") {
|
||||
info("A", "B")
|
||||
alias("testalias")
|
||||
}
|
||||
|
||||
alias("testrec", "testalias2")
|
||||
alias("testalias2", "testalias3")
|
||||
|
||||
Reference in New Issue
Block a user