From d94c8d1e376e6957550cd02c0441496a71dc1770 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 14 May 2018 19:08:14 -0700 Subject: [PATCH] start asyncproctest --- src/std/rec/test/Makefile | 9 +++++ src/std/rec/test/asyncproctest.c | 67 +++++++++++++++++++++++++++++++ src/std/rec/test/asyncproctest.db | 33 +++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 src/std/rec/test/asyncproctest.c create mode 100644 src/std/rec/test/asyncproctest.db diff --git a/src/std/rec/test/Makefile b/src/std/rec/test/Makefile index 3099cbe23..91443a2b0 100644 --- a/src/std/rec/test/Makefile +++ b/src/std/rec/test/Makefile @@ -105,6 +105,15 @@ regressTest_SRCS += regressTest_registerRecordDeviceDriver.cpp TESTFILES += $(COMMON_DIR)/regressTest.dbd ../regressArray1.db ../regressHex.db ../regressLinkMS.db TESTS += regressTest +TARGETS += $(COMMON_DIR)/asyncproctest.dbd +DBDDEPENDS_FILES += asyncproctest.dbd$(DEP) +asyncproctest_DBD += base.dbd +TESTPROD_HOST += asyncproctest +asyncproctest_SRCS += asyncproctest.c +asyncproctest_SRCS += asyncproctest_registerRecordDeviceDriver.cpp +TESTFILES += $(COMMON_DIR)/asyncproctest.dbd ../asyncproctest.db +#TESTS += asyncproctest # full of races... + # epicsRunRecordTests runs all the test programs in a known working order. testHarness_SRCS += epicsRunRecordTests.c diff --git a/src/std/rec/test/asyncproctest.c b/src/std/rec/test/asyncproctest.c new file mode 100644 index 000000000..1987c05f4 --- /dev/null +++ b/src/std/rec/test/asyncproctest.c @@ -0,0 +1,67 @@ +/*************************************************************************\ +* Copyright (c) 2018 Michael Davidsaver +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* This test covers some situations where asynchronous records are + * dbProcess()'d while busy (PACT==1). + */ + +#include +#include +#include +#include +#include +#include + +void asyncproctest_registerRecordDeviceDriver(struct dbBase *); + +MAIN(asyncproctest) +{ + testPlan(0); + + testdbPrepare(); + + testdbReadDatabase("asyncproctest.dbd", NULL, NULL); + asyncproctest_registerRecordDeviceDriver(pdbbase); + testdbReadDatabase("asyncproctest.db", NULL, "TPRO=1"); + + testIocInitOk(); + testDiag("===== Chain 1 ======"); + + testdbPutFieldOk("chain1.B", DBF_LONG, 6); + testdbPutFieldOk("chain1.B", DBF_LONG, 7); + + epicsThreadSleep(1.0); + + testdbGetFieldEqual("chain1", DBF_LONG, 7); + testdbGetFieldEqual("chain1.A", DBF_LONG, 2); + + testDiag("===== Chain 2 ======"); + + testdbPutFieldOk("chain2:1.B", DBF_LONG, 6); + testdbPutFieldOk("chain2:1.B", DBF_LONG, 7); + + epicsThreadSleep(1.0); + + testdbGetFieldEqual("chain2:1", DBF_LONG, 7); + testdbGetFieldEqual("chain2:2", DBF_LONG, 7); + testdbGetFieldEqual("chain2:1.A", DBF_LONG, 2); + testdbGetFieldEqual("chain2:2.A", DBF_LONG, 2); + + testDiag("===== Chain 3 ======"); + + testdbPutFieldOk("chain3.B", DBF_LONG, 6); + testdbPutFieldOk("chain3.B", DBF_LONG, 7); + + epicsThreadSleep(1.0); + + testdbGetFieldEqual("chain3", DBF_LONG, 7); + testdbGetFieldEqual("chain3.A", DBF_LONG, 2); + + testIocShutdownOk(); + + testdbCleanup(); + + return testDone(); +} diff --git a/src/std/rec/test/asyncproctest.db b/src/std/rec/test/asyncproctest.db new file mode 100644 index 000000000..e2fc946d8 --- /dev/null +++ b/src/std/rec/test/asyncproctest.db @@ -0,0 +1,33 @@ + +# simple case +# stand alone async record +record(calcout, "chain1") { + field(CALC, "A:=A+1;B") + field(ODLY, "0.1") + field(TPRO, "$(TPRO=)") +} + + +# original problem case +# async record chained after syncronous record +record(calcout, "chain2:1") { + field(CALC, "A:=A+1;B") + # DOLY=0 synchronous + field(OUT , "chain2:2.B PP") + field(TPRO, "$(TPRO=)") +} + +record(calcout, "chain2:2") { + field(CALC, "A:=A+1;B") + field(ODLY, "0.1") + field(TPRO, "$(TPRO=)") +} + +# ANJ's error case +# async record FLNK's to itself +record(calcout, "chain3") { + field(CALC, "A:=A+1;B") + field(ODLY, "0.1") + field(FLNK, "chain3") + field(TPRO, "$(TPRO=)") +}