Skip to content

Commit

Permalink
test INT/EXT link modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
mdavidsaver committed Jun 19, 2024
1 parent c926aa9 commit b277041
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/database/test/ioc/db/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ dbShutdownTest_SRCS += dbShutdownTest.c
dbShutdownTest_SRCS += dbTestIoc_registerRecordDeviceDriver.cpp
testHarness_SRCS += dbShutdownTest.c
TESTS += dbShutdownTest
TESTFILES += ../dbInitLinkTest.db

TESTPROD_HOST += dbPutLinkTest
dbPutLinkTest_SRCS += dbPutLinkTest.c
Expand Down
32 changes: 32 additions & 0 deletions modules/database/test/ioc/db/dbInitLinkTest.db
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# implied default default is AUTO

record(x, "il$(N)src0") {
# implied default is AUTO
field(INP, "no:such:pv")
}

# change implied default to INT
set("link:scope", "INT")

record(x, "il$(N)tgt") {}
record(x, "il$(N)src1") {
field(INP, "il$(N)tgt INT")
}
record(x, "il$(N)src2") {
# implied default is INT
field(INP, "il$(N)tgt")
}
record(x, "il$(N)src3") {
field(INP, "il$(N)tgt AUTO")
}
record(x, "il$(N)src4") {
field(INP, "no:such:pv EXT")
}

set("link:scope", "AUTO")
set("link:scope") # equivalent
# implied default back to AUTO

record(x, "il$(N)src5") {
field(INP, "no:such:pv")
}
59 changes: 58 additions & 1 deletion modules/database/test/ioc/db/dbPutLinkTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,62 @@ static void testCADBSet(void)
testdbCleanup();
}

static
void testInitLocalLink(const char *name, unsigned fileScope, unsigned linkScope)
{
dbCommon *prec = testdbRecordPtr(name);
DBLINK *plink = dbGetDevLink(prec);
if(plink->type != DB_LINK && plink->type != CA_LINK) {
testFail("%s not a PV link (%d)", name, plink->type);
} else {
unsigned fileActual = plink->flags & pvlOptSrcMask;
unsigned linkActual = plink->value.pv_link.pvlMask & pvlOptSrcMask;
testOk(fileScope==fileActual && linkScope==linkActual,
"%s link scopes file %u == %u, link %u == %u",
name, fileActual, fileScope, linkActual, linkScope);
}
}

static
void testInitLocal()
{
testDiag("testInitLocal()");

testdbReadDatabase("dbTestIoc.dbd", NULL, NULL);

dbTestIoc_registerRecordDeviceDriver(pdbbase);

testdbReadDatabase("dbInitLinkTest.db", NULL, "N=1");

eltc(0);
testIocInitOk();
eltc(1);

testdbGetFieldEqual("il1src0.INP", DBF_STRING, "no:such:pv NPP NMS");
testdbGetFieldEqual("il1src1.INP", DBF_STRING, "il1tgt NPP NMS INT");
testdbGetFieldEqual("il1src2.INP", DBF_STRING, "il1tgt NPP NMS INT");
testdbGetFieldEqual("il1src3.INP", DBF_STRING, "il1tgt NPP NMS");
testdbGetFieldEqual("il1src4.INP", DBF_STRING, "no:such:pv NPP NMS EXT");
testdbGetFieldEqual("il1src5.INP", DBF_STRING, "no:such:pv NPP NMS");

testInitLocalLink("il1src0", pvlOptSrcAuto, pvlOptSrcUnDef);
testInitLocalLink("il1src1", pvlOptSrcInt, pvlOptSrcInt );
testInitLocalLink("il1src2", pvlOptSrcInt, pvlOptSrcUnDef);
testInitLocalLink("il1src3", pvlOptSrcInt, pvlOptSrcAuto);
testInitLocalLink("il1src4", pvlOptSrcInt, pvlOptSrcExt);
testInitLocalLink("il1src5", pvlOptSrcAuto, pvlOptSrcUnDef);

/* INT not enforced for runtime changes */
testdbPutFieldOk("il1src1.INP", DBF_STRING, "not:a:pv");
testdbPutFieldOk("il1src1.INP", DBF_STRING, "not:a:pv EXT");
testdbPutFieldOk("il1src1.INP", DBF_STRING, "il1tgt EXT");
testdbPutFieldOk("il1src1.INP", DBF_STRING, "il1tgt");

testIocShutdownOk();

testdbCleanup();
}

typedef struct {
const char * const recname;
short ltype;
Expand Down Expand Up @@ -701,10 +757,11 @@ void testTSEL(void)

MAIN(dbPutLinkTest)
{
testPlan(348);
testPlan(364);
testLinkParse();
testLinkFailParse();
testCADBSet();
testInitLocal();
testHWInitSet();
testHWMod();
testLinkInitFail();
Expand Down

0 comments on commit b277041

Please sign in to comment.