std/rec/test: add linkRetargetLinkTest
This commit is contained in:
@@ -26,6 +26,13 @@ testHarness_SRCS += arrayOpTest.c
|
||||
TESTFILES += ../arrayOpTest.db
|
||||
TESTS += arrayOpTest
|
||||
|
||||
TESTPROD_HOST += linkRetargetLinkTest
|
||||
linkRetargetLinkTest_SRCS += linkRetargetLinkTest.c
|
||||
linkRetargetLinkTest_SRCS += recTestIoc_registerRecordDeviceDriver.cpp
|
||||
testHarness_SRCS += linkRetargetLinkTest.c
|
||||
TESTFILES += ../linkRetargetLink.db
|
||||
TESTS += linkRetargetLinkTest
|
||||
|
||||
TARGETS += $(COMMON_DIR)/asTestIoc.dbd
|
||||
asTestIoc_DBD += base.dbd
|
||||
asTestIoc_DBD += asTest.dbd
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
int analogMonitorTest(void);
|
||||
int arrayOpTest(void);
|
||||
int asTest(void);
|
||||
int linkRetargetLinkTest(void);
|
||||
|
||||
void epicsRunRecordTests(void)
|
||||
{
|
||||
@@ -26,5 +27,7 @@ void epicsRunRecordTests(void)
|
||||
|
||||
runTest(asTest);
|
||||
|
||||
runTest(linkRetargetLinkTest);
|
||||
|
||||
epicsExit(0); /* Trigger test harness */
|
||||
}
|
||||
|
||||
17
src/std/rec/test/linkRetargetLink.db
Normal file
17
src/std/rec/test/linkRetargetLink.db
Normal file
@@ -0,0 +1,17 @@
|
||||
record(ai, "rec:ai") {
|
||||
field(INP, "0")
|
||||
}
|
||||
record(ai, "rec:src1") {
|
||||
field(VAL, "1")
|
||||
}
|
||||
record(ai, "rec:src2") {
|
||||
field(VAL, "2")
|
||||
}
|
||||
record(stringout, "rec:link1") {
|
||||
field(VAL, "rec:src1")
|
||||
field(OUT, "rec:ai.INP CA")
|
||||
}
|
||||
record(stringout, "rec:link2") {
|
||||
field(VAL, "rec:src2 CP")
|
||||
field(OUT, "rec:ai.INP CA")
|
||||
}
|
||||
86
src/std/rec/test/linkRetargetLinkTest.c
Normal file
86
src/std/rec/test/linkRetargetLinkTest.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2015 Michael Davidsaver
|
||||
* EPICS BASE is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
|
||||
/*
|
||||
* Author: Michael Davidsaver <mdavidsaver@gmail.com>
|
||||
*
|
||||
* Test using several stringout records to retarget the link of another record
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "dbAccess.h"
|
||||
|
||||
#include "dbUnitTest.h"
|
||||
#include "errlog.h"
|
||||
#include "epicsThread.h"
|
||||
|
||||
#include "testMain.h"
|
||||
|
||||
void recTestIoc_registerRecordDeviceDriver(struct dbBase *);
|
||||
|
||||
static void testRetarget(void)
|
||||
{
|
||||
testMonitor *lnkmon, *valmon;
|
||||
|
||||
testdbPrepare();
|
||||
|
||||
testdbReadDatabase("recTestIoc.dbd", NULL, NULL);
|
||||
|
||||
recTestIoc_registerRecordDeviceDriver(pdbbase);
|
||||
|
||||
testdbReadDatabase("linkRetargetLink.db", NULL, NULL);
|
||||
|
||||
eltc(0);
|
||||
testIocInitOk();
|
||||
eltc(1);
|
||||
|
||||
lnkmon = testMonitorCreate("rec:ai.INP", DBE_VALUE, 0);
|
||||
valmon = testMonitorCreate("rec:ai", DBE_VALUE, 0);
|
||||
|
||||
/* initially rec:ai.INP is CONSTANT */
|
||||
|
||||
testdbGetFieldEqual("rec:ai", DBR_DOUBLE, 0.0);
|
||||
testdbGetFieldEqual("rec:ai.INP", DBR_STRING, "0");
|
||||
|
||||
/* rec:ai.INP becomes DB_LINK, but no processing is triggered */
|
||||
testdbPutFieldOk("rec:link1.PROC", DBF_LONG, 0);
|
||||
|
||||
testMonitorWait(lnkmon);
|
||||
|
||||
testdbGetFieldEqual("rec:ai", DBR_DOUBLE, 0.0);
|
||||
testdbGetFieldEqual("rec:ai.INP", DBR_STRING, "rec:src1 NPP NMS");
|
||||
|
||||
/* trigger a read from rec:ai.INP */
|
||||
testdbPutFieldOk("rec:ai.PROC", DBF_LONG, 0);
|
||||
|
||||
testMonitorWait(valmon);
|
||||
|
||||
testdbGetFieldEqual("rec:ai", DBR_DOUBLE, 1.0);
|
||||
|
||||
/* rec:ai.INP becomes CA_LINK w/ CP, processing is triggered */
|
||||
testdbPutFieldOk("rec:link2.PROC", DBF_LONG, 0);
|
||||
|
||||
testMonitorWait(lnkmon);
|
||||
testMonitorWait(valmon);
|
||||
|
||||
testdbGetFieldEqual("rec:ai", DBR_DOUBLE, 2.0);
|
||||
testdbGetFieldEqual("rec:ai.INP", DBR_STRING, "rec:src2 CP NMS");
|
||||
|
||||
testMonitorDestroy(lnkmon);
|
||||
testMonitorDestroy(valmon);
|
||||
|
||||
testIocShutdownOk();
|
||||
|
||||
testdbCleanup();
|
||||
}
|
||||
|
||||
MAIN(linkRetargetLinkTest)
|
||||
{
|
||||
testPlan(0);
|
||||
testRetarget();
|
||||
return testDone();
|
||||
}
|
||||
Reference in New Issue
Block a user