From 2a1f7909093a1b6e87dfceea7a00aa8fdca5107a Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Fri, 28 Apr 2017 16:44:55 -0400 Subject: [PATCH] std/rec/test: extend linkRetargetLink w/ jlink --- src/std/rec/test/linkRetargetLink.db | 8 +++ src/std/rec/test/linkRetargetLinkTest.c | 66 +++++++++++++++++-------- 2 files changed, 53 insertions(+), 21 deletions(-) diff --git a/src/std/rec/test/linkRetargetLink.db b/src/std/rec/test/linkRetargetLink.db index 3306e43ea..16d033e44 100644 --- a/src/std/rec/test/linkRetargetLink.db +++ b/src/std/rec/test/linkRetargetLink.db @@ -15,3 +15,11 @@ record(stringout, "rec:link2") { field(VAL, "rec:src2 CP") field(OUT, "rec:ai.INP CA") } + +record(ai, "rec:j1") { + field(INP, {calc:{ + expr:"A+5", + args:{const:5} + }}) + field(PINI, "YES") +} diff --git a/src/std/rec/test/linkRetargetLinkTest.c b/src/std/rec/test/linkRetargetLinkTest.c index 894c94587..8000419d6 100644 --- a/src/std/rec/test/linkRetargetLinkTest.c +++ b/src/std/rec/test/linkRetargetLinkTest.c @@ -27,24 +27,7 @@ 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); - /* wait for local CA links to be connected or dbPutField() will fail */ - /* wait for initial CA_CONNECT actions to be processed. - * Assume that local CA links deliver callbacks synchronously - * eg. that ca_create_channel() will invoke the connection callback - * before returning. - */ - dbCaSync(); + testDiag("In testRetarget"); lnkmon = testMonitorCreate("rec:ai.INP", DBE_VALUE, 0); valmon = testMonitorCreate("rec:ai", DBE_VALUE, 0); @@ -80,15 +63,56 @@ static void testRetarget(void) testMonitorDestroy(lnkmon); testMonitorDestroy(valmon); +} - testIocShutdownOk(); +#define testLongStrEq(PV, VAL) testdbGetArrFieldEqual(PV, DBF_CHAR, sizeof(VAL)+2, sizeof(VAL), VAL) +#define testPutLongStr(PV, VAL) testdbPutArrFieldOk(PV, DBF_CHAR, sizeof(VAL), VAL); - testdbCleanup(); +static void testRetargetJLink(void) +{ + testDiag("In testRetargetJLink"); + + testdbGetFieldEqual("rec:j1", DBF_DOUBLE, 10.0); + /* without [] */ + testLongStrEq("rec:j1.INP$", "{\"calc\":{\"expr\":\"A+5\",\"args\":{\"const\":5}}}"); + + /* with [] */ + testPutLongStr("rec:j1.INP$", "{\"calc\":{\"expr\":\"A+5\",\"args\":[{\"const\":7}]}}"); + testdbPutFieldOk("rec:j1.PROC", DBF_LONG, 1); + + testdbGetFieldEqual("rec:j1", DBF_DOUBLE, 12.0); + testLongStrEq("rec:j1.INP$", "{\"calc\":{\"expr\":\"A+5\",\"args\":[{\"const\":7}]}}"); } MAIN(linkRetargetLinkTest) { - testPlan(10); + testPlan(16); + + testdbPrepare(); + + testdbReadDatabase("recTestIoc.dbd", NULL, NULL); + + recTestIoc_registerRecordDeviceDriver(pdbbase); + + testdbReadDatabase("linkRetargetLink.db", NULL, NULL); + + eltc(0); + testIocInitOk(); + eltc(1); + /* wait for local CA links to be connected or dbPutField() will fail */ + /* wait for initial CA_CONNECT actions to be processed. + * Assume that local CA links deliver callbacks synchronously + * eg. that ca_create_channel() will invoke the connection callback + * before returning. + */ + dbCaSync(); + testRetarget(); + testRetargetJLink(); + + testIocShutdownOk(); + + testdbCleanup(); + return testDone(); }