diff --git a/src/std/filters/test/Makefile b/src/std/filters/test/Makefile index 355ba9446..b846e488e 100644 --- a/src/std/filters/test/Makefile +++ b/src/std/filters/test/Makefile @@ -18,48 +18,43 @@ Recs_LIBS += dbCore Com PROD_LIBS = Recs dbRecStd dbCore ca Com -TARGETS += $(COMMON_DIR)/tsTest.dbd -DBDDEPENDS_FILES += tsTest.dbd$(DEP) -tsTest_DBD += xRecord.dbd +DBDDEPENDS_FILES += filterTest.dbd$(DEP) +TARGETS += $(COMMON_DIR)/filterTest.dbd +filterTest_DBD += menuGlobal.dbd +filterTest_DBD += menuConvert.dbd +filterTest_DBD += menuScan.dbd +filterTest_DBD += filters.dbd +filterTest_DBD += xRecord.dbd +filterTest_DBD += arrRecord.dbd +TESTFILES += $(COMMON_DIR)/filterTest.dbd + +testHarness_SRCS += filterTest_registerRecordDeviceDriver.cpp + TESTPROD_HOST += tsTest tsTest_SRCS += tsTest.c -tsTest_SRCS += tsTest_registerRecordDeviceDriver.cpp +tsTest_SRCS += filterTest_registerRecordDeviceDriver.cpp testHarness_SRCS += tsTest.c -testHarness_SRCS += tsTest_registerRecordDeviceDriver.cpp -TESTFILES += $(COMMON_DIR)/tsTest.dbd ../xRecord.db +TESTFILES += ../xRecord.db TESTS += tsTest -TARGETS += $(COMMON_DIR)/dbndTest.dbd -DBDDEPENDS_FILES += dbndTest.dbd$(DEP) -dbndTest_DBD += xRecord.dbd TESTPROD_HOST += dbndTest dbndTest_SRCS += dbndTest.c -dbndTest_SRCS += dbndTest_registerRecordDeviceDriver.cpp +dbndTest_SRCS += filterTest_registerRecordDeviceDriver.cpp testHarness_SRCS += dbndTest.c -testHarness_SRCS += dbndTest_registerRecordDeviceDriver.cpp -TESTFILES += $(COMMON_DIR)/dbndTest.dbd TESTS += dbndTest -TARGETS += $(COMMON_DIR)/arrTest.dbd -DBDDEPENDS_FILES += arrTest.dbd$(DEP) -arrTest_DBD += arrRecord.dbd TESTPROD_HOST += arrTest arrTest_SRCS += arrTest.cpp -arrTest_SRCS += arrTest_registerRecordDeviceDriver.cpp +arrTest_SRCS += filterTest_registerRecordDeviceDriver.cpp testHarness_SRCS += arrTest.cpp -testHarness_SRCS += arrTest_registerRecordDeviceDriver.cpp -TESTFILES += $(COMMON_DIR)/arrTest.dbd ../arrTest.db +TESTFILES += ../arrTest.db TESTS += arrTest TARGETS += $(COMMON_DIR)/syncTest.dbd -DBDDEPENDS_FILES += syncTest.dbd$(DEP) -syncTest_DBD += xRecord.dbd TESTPROD_HOST += syncTest syncTest_SRCS += syncTest.c -syncTest_SRCS += syncTest_registerRecordDeviceDriver.cpp +syncTest_SRCS += filterTest_registerRecordDeviceDriver.cpp testHarness_SRCS += syncTest.c -testHarness_SRCS += syncTest_registerRecordDeviceDriver.cpp -TESTFILES += $(COMMON_DIR)/syncTest.dbd TESTS += syncTest # epicsRunFilterTests runs all the test programs in a known working order. diff --git a/src/std/filters/test/arrTest.cpp b/src/std/filters/test/arrTest.cpp index 026185eac..1ec16b32f 100644 --- a/src/std/filters/test/arrTest.cpp +++ b/src/std/filters/test/arrTest.cpp @@ -29,8 +29,8 @@ #include "envDefs.h" #include "dbStaticLib.h" #include "dbmf.h" +#include "errlog.h" #include "registry.h" -#include "subRecord.h" #include "dbAddr.h" #include "dbAccess.h" #include "asDbLib.h" @@ -38,14 +38,14 @@ #include "iocsh.h" #include "dbChannel.h" #include "epicsUnitTest.h" +#include "dbUnitTest.h" #include "testMain.h" #include "osiFileName.h" #include "arrRecord.h" extern "C" { - int arrTest_registerRecordDeviceDriver(struct dbBase *pdbbase); - epicsShareExtern void (*pvar_func_arrInitialize)(void); + void filterTest_registerRecordDeviceDriver(struct dbBase *); } #define CA_SERVER_PORT "65535" @@ -54,12 +54,6 @@ extern "C" { const char *server_port = CA_SERVER_PORT; -extern "C" { -static void exitSubroutine(subRecord *precord) { - epicsExit((precord->a == 0.0) ? EXIT_SUCCESS : EXIT_FAILURE); -} -} - static int fl_equals_array(short type, const db_field_log *pfl1, void *p2) { for (int i = 0; i < pfl1->no_elements; i++) { switch (type) { @@ -298,23 +292,9 @@ static void check(short dbr_type) { TEST5B(3, -8, -4, "both sides from-end"); } -static dbEventCtx evtctx; - -extern "C" { -static void arrTestCleanup(void* junk) -{ - dbFreeBase(pdbbase); - registryFree(); - pdbbase=0; - - db_close_events(evtctx); - - dbmfFreeChunks(); -} -} - MAIN(arrTest) { + dbEventCtx evtctx; const chFilterPlugin *plug; char arr[] = "arr"; @@ -324,26 +304,21 @@ MAIN(arrTest) epicsEnvSet("EPICS_CA_SERVER_PORT", server_port); - if (dbReadDatabase(&pdbbase, "arrTest.dbd", - "." OSI_PATH_LIST_SEPARATOR ".." OSI_PATH_LIST_SEPARATOR - "../O.Common" OSI_PATH_LIST_SEPARATOR "O.Common", NULL)) - testAbort("Database description not loaded"); + testdbPrepare(); - (*pvar_func_arrInitialize)(); - arrTest_registerRecordDeviceDriver(pdbbase); - registryFunctionAdd("exit", (REGISTRYFUNCTION) exitSubroutine); + testdbReadDatabase("filterTest.dbd", NULL, NULL); - if (dbReadDatabase(&pdbbase, "arrTest.db", - "." OSI_PATH_LIST_SEPARATOR "..", NULL)) - testAbort("Test database not loaded"); + filterTest_registerRecordDeviceDriver(pdbbase); - epicsAtExit(&arrTestCleanup,NULL); + testdbReadDatabase("arrTest.db", NULL, NULL); + + eltc(0); + testIocInitOk(); + eltc(1); /* Start the IOC */ - iocInit(); evtctx = db_init_events(); - epicsThreadSleep(0.2); testOk(!!(plug = dbFindFilter(arr, strlen(arr))), "plugin arr registered correctly"); @@ -351,5 +326,11 @@ MAIN(arrTest) check(DBR_DOUBLE); check(DBR_STRING); + db_close_events(evtctx); + + testIocShutdownOk(); + + testdbCleanup(); + return testDone(); } diff --git a/src/std/filters/test/dbndTest.c b/src/std/filters/test/dbndTest.c index d689ae4c4..b35b9a6cc 100644 --- a/src/std/filters/test/dbndTest.c +++ b/src/std/filters/test/dbndTest.c @@ -17,8 +17,10 @@ #include "db_field_log.h" #include "dbCommon.h" #include "registry.h" +#include "errlog.h" #include "chfPlugin.h" #include "epicsUnitTest.h" +#include "dbUnitTest.h" #include "epicsTime.h" #include "dbmf.h" #include "testMain.h" @@ -26,8 +28,7 @@ #define PATTERN 0x55 -void dbndTest_registerRecordDeviceDriver(struct dbBase *); -epicsShareExtern void (*pvar_func_dbndInitialize)(void); +void filterTest_registerRecordDeviceDriver(struct dbBase *); static db_field_log fl; @@ -115,21 +116,20 @@ MAIN(dbndTest) testPlan(59); - dbChannelInit(); + testdbPrepare(); + + testdbReadDatabase("filterTest.dbd", NULL, NULL); + + filterTest_registerRecordDeviceDriver(pdbbase); + + testdbReadDatabase("xRecord.db", NULL, NULL); + + eltc(0); + testIocInitOk(); + eltc(1); + evtctx = db_init_events(); - if (dbReadDatabase(&pdbbase, "dbndTest.dbd", - "." OSI_PATH_LIST_SEPARATOR ".." OSI_PATH_LIST_SEPARATOR - "../O.Common" OSI_PATH_LIST_SEPARATOR "O.Common", NULL)) - testAbort("Database description 'dbndTest.dbd' not found"); - - (*pvar_func_dbndInitialize)(); /* manually initialize plugin */ - dbndTest_registerRecordDeviceDriver(pdbbase); - - if (dbReadDatabase(&pdbbase, "xRecord.db", - "." OSI_PATH_LIST_SEPARATOR "..", NULL)) - testAbort("Test database 'xRecord.db' not found"); - testOk(!!(plug = dbFindFilter(dbnd, strlen(dbnd))), "plugin dbnd registered correctly"); testOk(!!(pch = dbChannelCreate("x.VAL{\"dbnd\":{}}")), "dbChannel with plugin dbnd (delta=0) created"); @@ -274,13 +274,12 @@ MAIN(dbndTest) mustPassOnce(pch, pfl2, "rel", 50., 7); dbChannelDelete(pch); - dbFreeBase(pdbbase); - registryFree(); - pdbbase=0; db_close_events(evtctx); - dbmfFreeChunks(); + testIocShutdownOk(); + + testdbCleanup(); return testDone(); } diff --git a/src/std/filters/test/syncTest.c b/src/std/filters/test/syncTest.c index eea24508b..9af44afd7 100644 --- a/src/std/filters/test/syncTest.c +++ b/src/std/filters/test/syncTest.c @@ -19,8 +19,10 @@ #include "dbChannel.h" #include "registry.h" #include "chfPlugin.h" +#include "errlog.h" #include "dbmf.h" #include "epicsUnitTest.h" +#include "dbUnitTest.h" #include "epicsTime.h" #include "dbState.h" #include "testMain.h" @@ -28,8 +30,7 @@ #define PATTERN 0x55 -void syncTest_registerRecordDeviceDriver(struct dbBase *); -epicsShareExtern void (*pvar_func_syncInitialize)(void); +void filterTest_registerRecordDeviceDriver(struct dbBase *); static db_field_log fl; static dbStateId red; @@ -142,21 +143,20 @@ MAIN(syncTest) testPlan(139); - dbChannelInit(); + testdbPrepare(); + + testdbReadDatabase("filterTest.dbd", NULL, NULL); + + filterTest_registerRecordDeviceDriver(pdbbase); + + testdbReadDatabase("xRecord.db", NULL, NULL); + + eltc(0); + testIocInitOk(); + eltc(1); + evtctx = db_init_events(); - if (dbReadDatabase(&pdbbase, "syncTest.dbd", - "." OSI_PATH_LIST_SEPARATOR ".." OSI_PATH_LIST_SEPARATOR - "../O.Common" OSI_PATH_LIST_SEPARATOR "O.Common", NULL)) - testAbort("Database description 'syncTest.dbd' not found"); - - (*pvar_func_syncInitialize)(); /* manually initialize plugin */ - syncTest_registerRecordDeviceDriver(pdbbase); - - if (dbReadDatabase(&pdbbase, "xRecord.db", - "." OSI_PATH_LIST_SEPARATOR "..", NULL)) - testAbort("Test database 'xRecord.db' not found"); - testOk(!!(plug = dbFindFilter(myname, strlen(myname))), "plugin %s registered correctly", myname); testOk(!!(red = dbStateCreate("red")), "state 'red' created successfully"); @@ -367,13 +367,12 @@ MAIN(syncTest) db_delete_field_log(pfl[9]); dbChannelDelete(pch); - dbFreeBase(pdbbase); - registryFree(); - pdbbase=0; db_close_events(evtctx); - dbmfFreeChunks(); + testIocShutdownOk(); + + testdbCleanup(); return testDone(); } diff --git a/src/std/filters/test/tsTest.c b/src/std/filters/test/tsTest.c index 42895ac00..0315ab442 100644 --- a/src/std/filters/test/tsTest.c +++ b/src/std/filters/test/tsTest.c @@ -15,7 +15,9 @@ #include "dbStaticLib.h" #include "dbAccessDefs.h" #include "chfPlugin.h" +#include "errlog.h" #include "epicsUnitTest.h" +#include "dbUnitTest.h" #include "registry.h" #include "dbmf.h" #include "epicsTime.h" @@ -24,8 +26,7 @@ #define PATTERN 0x55 -void tsTest_registerRecordDeviceDriver(struct dbBase *); -epicsShareExtern void (*pvar_func_tsInitialize)(void); +void filterTest_registerRecordDeviceDriver(struct dbBase *); static db_field_log fl; @@ -56,21 +57,20 @@ MAIN(tsTest) testPlan(12); - dbChannelInit(); + testdbPrepare(); + + testdbReadDatabase("filterTest.dbd", NULL, NULL); + + filterTest_registerRecordDeviceDriver(pdbbase); + + testdbReadDatabase("xRecord.db", NULL, NULL); + + eltc(0); + testIocInitOk(); + eltc(1); + evtctx = db_init_events(); - if (dbReadDatabase(&pdbbase, "tsTest.dbd", - "." OSI_PATH_LIST_SEPARATOR ".." OSI_PATH_LIST_SEPARATOR - "../O.Common" OSI_PATH_LIST_SEPARATOR "O.Common", NULL)) - testAbort("Database description 'tsTest.dbd' not found"); - - (*pvar_func_tsInitialize)(); /* manually initialize plugin */ - tsTest_registerRecordDeviceDriver(pdbbase); - - if (dbReadDatabase(&pdbbase, "xRecord.db", - "." OSI_PATH_LIST_SEPARATOR "..", NULL)) - testAbort("Test database 'xRecord.db' not found"); - testOk(!!(plug = dbFindFilter(ts, strlen(ts))), "plugin ts registered correctly"); testOk(!!(pch = dbChannelCreate("x.VAL{\"ts\":{}}")), "dbChannel with plugin ts created"); @@ -108,13 +108,12 @@ MAIN(tsTest) "ts filter sets time stamp to \"now\""); dbChannelDelete(pch); - dbFreeBase(pdbbase); - registryFree(); - pdbbase=0; db_close_events(evtctx); - dbmfFreeChunks(); + testIocShutdownOk(); + + testdbCleanup(); return testDone(); } diff --git a/src/std/filters/test/xRecord.dbd b/src/std/filters/test/xRecord.dbd index 4837871a4..fd59d1780 100644 --- a/src/std/filters/test/xRecord.dbd +++ b/src/std/filters/test/xRecord.dbd @@ -1,11 +1,7 @@ # This is a combined minimal DBD and DB file recordtype(x) { - field(NAME, DBF_STRING) { - prompt("Record Name") - special(SPC_NOMOD) - size(61) - } + include "dbCommon.dbd" field(VAL, DBF_LONG) { prompt("Value") }