From 3ff49fc9b294aa295272c75d98c0d73f1628a0fb Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 10 Jul 2014 14:27:44 -0500 Subject: [PATCH] Fixed build errors, remove dependency on std. Build errors: Include guard missing from epicsUnitTest.h; dbShutdownTest.c was calling the non-universal strcasecmp() instead of epicsStrCaseCmp(). ioc/db/test no longer depends on std. I modified xRecord to make it a working record type, and simplified the other test programs so they all use the same new expanded dbd file rather than each making their own. I also added dbShutdownTest() to epicsRunDbTests(). --- src/Makefile | 2 +- src/ioc/db/test/Makefile | 39 ++++++++++++------------------ src/ioc/db/test/arrShorthandTest.c | 8 +++--- src/ioc/db/test/chfPluginTest.c | 8 +++--- src/ioc/db/test/dbChannelTest.c | 8 +++--- src/ioc/db/test/dbShutdownTest.c | 13 +++++----- src/ioc/db/test/epicsRunDbTests.c | 4 ++- src/ioc/db/test/xRecord.c | 16 ++++++++++-- src/ioc/db/test/xRecord.dbd | 8 ++---- src/libCom/misc/epicsUnitTest.h | 5 ++++ 10 files changed, 59 insertions(+), 52 deletions(-) diff --git a/src/Makefile b/src/Makefile index 8205a427b..3307b8786 100644 --- a/src/Makefile +++ b/src/Makefile @@ -62,7 +62,7 @@ DIRS += ioc ioc_DEPEND_DIRS = libCom ca/client DIRS += ioc/db/test -ioc/db/test_DEPEND_DIRS = ioc std libCom/RTEMS +ioc/db/test_DEPEND_DIRS = ioc libCom/RTEMS DIRS += ioc/dbtemplate/test ioc/dbtemplate/test_DEPEND_DIRS = ioc diff --git a/src/ioc/db/test/Makefile b/src/ioc/db/test/Makefile index dd149c8a0..4f1bc973b 100644 --- a/src/ioc/db/test/Makefile +++ b/src/ioc/db/test/Makefile @@ -10,19 +10,24 @@ TOP=../../../.. include $(TOP)/configure/CONFIG -TESTLIBRARY = xRec +TESTLIBRARY = dbTestIoc -xRec_SRCS = xRecord.c +dbTestIoc_SRCS = xRecord.c -PROD_LIBS = xRec dbCore ca Com +TARGETS += $(COMMON_DIR)/dbTestIoc.dbd +dbTestIoc_DBD += menuGlobal.dbd +dbTestIoc_DBD += menuConvert.dbd +dbTestIoc_DBD += xRecord.dbd +TESTFILES += $(COMMON_DIR)/dbTestIoc.dbd ../xRecord.db + +testHarness_SRCS += dbTestIoc_registerRecordDeviceDriver.cpp + +PROD_LIBS = dbTestIoc dbCore ca Com TESTPROD_HOST += dbShutdownTest -TARGETS += $(COMMON_DIR)/dbShutdownTest.dbd dbShutdownTest_SRCS += dbShutdownTest.c -dbShutdownTest_SRCS += dbShutdownTest_registerRecordDeviceDriver.cpp -dbShutdownTest_LIBS += $(EPICS_BASE_IOC_LIBS) -dbShutdownTest_DBD += base.dbd -TESTFILES += $(COMMON_DIR)/dbShutdownTest.dbd ../sRecord.db +dbShutdownTest_SRCS += dbTestIoc_registerRecordDeviceDriver.cpp +testHarness_SRCS += dbShutdownTest.c TESTS += dbShutdownTest TESTPROD_HOST += callbackTest @@ -35,34 +40,22 @@ dbStateTest_SRCS += dbStateTest.c testHarness_SRCS += dbStateTest.c TESTS += dbStateTest -TARGETS += $(COMMON_DIR)/dbChannelTest.dbd -dbChannelTest_DBD += xRecord.dbd TESTPROD_HOST += dbChannelTest dbChannelTest_SRCS += dbChannelTest.c -dbChannelTest_SRCS += dbChannelTest_registerRecordDeviceDriver.cpp +dbChannelTest_SRCS += dbTestIoc_registerRecordDeviceDriver.cpp testHarness_SRCS += dbChannelTest.c -testHarness_SRCS += dbChannelTest_registerRecordDeviceDriver.cpp -TESTFILES += $(COMMON_DIR)/dbChannelTest.dbd ../xRecord.db TESTS += dbChannelTest -TARGETS += $(COMMON_DIR)/chfPluginTest.dbd -chfPluginTest_DBD += xRecord.dbd TESTPROD_HOST += chfPluginTest chfPluginTest_SRCS += chfPluginTest.c -chfPluginTest_SRCS += chfPluginTest_registerRecordDeviceDriver.cpp +chfPluginTest_SRCS += dbTestIoc_registerRecordDeviceDriver.cpp testHarness_SRCS += chfPluginTest.c -testHarness_SRCS += chfPluginTest_registerRecordDeviceDriver.cpp -TESTFILES += $(COMMON_DIR)/chfPluginTest.dbd TESTS += chfPluginTest -TARGETS += $(COMMON_DIR)/arrShorthandTest.dbd -arrShorthandTest_DBD += xRecord.dbd TESTPROD_HOST += arrShorthandTest arrShorthandTest_SRCS += arrShorthandTest.c -arrShorthandTest_SRCS += arrShorthandTest_registerRecordDeviceDriver.cpp +arrShorthandTest_SRCS += dbTestIoc_registerRecordDeviceDriver.cpp testHarness_SRCS += arrShorthandTest.c -testHarness_SRCS += arrShorthandTest_registerRecordDeviceDriver.cpp -TESTFILES += $(COMMON_DIR)/arrShorthandTest.dbd TESTS += arrShorthandTest # The testHarness runs all the test programs in a known working order. diff --git a/src/ioc/db/test/arrShorthandTest.c b/src/ioc/db/test/arrShorthandTest.c index dafa9e6e8..afb37e577 100644 --- a/src/ioc/db/test/arrShorthandTest.c +++ b/src/ioc/db/test/arrShorthandTest.c @@ -77,7 +77,7 @@ static void testHead (char* title) { testDiag("--------------------------------------------------------"); } -void arrShorthandTest_registerRecordDeviceDriver(struct dbBase *); +void dbTestIoc_registerRecordDeviceDriver(struct dbBase *); MAIN(arrShorthandTest) { @@ -88,12 +88,12 @@ MAIN(arrShorthandTest) db_init_events(); dbChannelInit(); - if (dbReadDatabase(&pdbbase, "arrShorthandTest.dbd", + if (dbReadDatabase(&pdbbase, "dbTestIoc.dbd", "." OSI_PATH_LIST_SEPARATOR ".." OSI_PATH_LIST_SEPARATOR "../O.Common" OSI_PATH_LIST_SEPARATOR "O.Common", NULL)) - testAbort("Database description 'arrShorthandTest.dbd' not found"); + testAbort("Database description 'dbTestIoc.dbd' not found"); - arrShorthandTest_registerRecordDeviceDriver(pdbbase); + dbTestIoc_registerRecordDeviceDriver(pdbbase); if (dbReadDatabase(&pdbbase, "xRecord.db", "." OSI_PATH_LIST_SEPARATOR "..", NULL)) testAbort("Test database 'xRecord.db' not found"); diff --git a/src/ioc/db/test/chfPluginTest.c b/src/ioc/db/test/chfPluginTest.c index de34b989a..028ecceb2 100644 --- a/src/ioc/db/test/chfPluginTest.c +++ b/src/ioc/db/test/chfPluginTest.c @@ -481,7 +481,7 @@ static void testHead (char* title) { testDiag("--------------------------------------------------------"); } -void chfPluginTest_registerRecordDeviceDriver(struct dbBase *); +void dbTestIoc_registerRecordDeviceDriver(struct dbBase *); MAIN(chfPluginTest) { @@ -508,12 +508,12 @@ MAIN(chfPluginTest) testOk(strcmp(chfPluginEnumString(colorEnum, 3, "-"), "-") == 0, "Enum to string: invalid index"); - if (dbReadDatabase(&pdbbase, "chfPluginTest.dbd", + if (dbReadDatabase(&pdbbase, "dbTestIoc.dbd", "." OSI_PATH_LIST_SEPARATOR ".." OSI_PATH_LIST_SEPARATOR "../O.Common" OSI_PATH_LIST_SEPARATOR "O.Common", NULL)) - testAbort("Database description 'chfPluginTest.dbd' not found"); + testAbort("Database description 'dbTestIoc.dbd' not found"); - chfPluginTest_registerRecordDeviceDriver(pdbbase); + dbTestIoc_registerRecordDeviceDriver(pdbbase); if (dbReadDatabase(&pdbbase, "xRecord.db", "." OSI_PATH_LIST_SEPARATOR "..", NULL)) testAbort("Test database 'xRecord.db' not found"); diff --git a/src/ioc/db/test/dbChannelTest.c b/src/ioc/db/test/dbChannelTest.c index a4011f646..5eb431f3e 100644 --- a/src/ioc/db/test/dbChannelTest.c +++ b/src/ioc/db/test/dbChannelTest.c @@ -149,7 +149,7 @@ chFilterIf testIf = p_string, p_start_map, p_map_key, p_end_map, p_start_array, p_end_array, c_open, c_reg_pre, c_reg_post, c_report, c_close }; -void dbChannelTest_registerRecordDeviceDriver(struct dbBase *); +void dbTestIoc_registerRecordDeviceDriver(struct dbBase *); MAIN(testDbChannel) /* dbChannelTest is an API routine... */ { @@ -157,12 +157,12 @@ MAIN(testDbChannel) /* dbChannelTest is an API routine... */ testPlan(66); - if (dbReadDatabase(&pdbbase, "dbChannelTest.dbd", + if (dbReadDatabase(&pdbbase, "dbTestIoc.dbd", "." OSI_PATH_LIST_SEPARATOR ".." OSI_PATH_LIST_SEPARATOR "../O.Common" OSI_PATH_LIST_SEPARATOR "O.Common", NULL)) - testAbort("Database description 'dbChannelTest.dbd' not found"); + testAbort("Database description 'dbTestIoc.dbd' not found"); - dbChannelTest_registerRecordDeviceDriver(pdbbase); + dbTestIoc_registerRecordDeviceDriver(pdbbase); if (dbReadDatabase(&pdbbase, "xRecord.db", "." OSI_PATH_LIST_SEPARATOR "..", NULL)) testAbort("Test database 'xRecord.db' not found"); diff --git a/src/ioc/db/test/dbShutdownTest.c b/src/ioc/db/test/dbShutdownTest.c index d3a993b6e..69f43814f 100644 --- a/src/ioc/db/test/dbShutdownTest.c +++ b/src/ioc/db/test/dbShutdownTest.c @@ -10,8 +10,7 @@ * Ralph Lange */ -#include - +#include "epicsString.h" #include "dbUnitTest.h" #include "epicsThread.h" #include "iocInit.h" @@ -24,7 +23,7 @@ #include "testMain.h" -void dbShutdownTest_registerRecordDeviceDriver(struct dbBase *); +void dbTestIoc_registerRecordDeviceDriver(struct dbBase *); static struct threadItem { char *name; @@ -46,7 +45,7 @@ void findCommonThread (epicsThreadId id) { epicsThreadGetName(id, name, 32); for (thr = commonThreads; thr->name; thr++) { - if (strcasecmp(thr->name, name) == 0) { + if (epicsStrCaseCmp(thr->name, name) == 0) { thr->found = 1; } } @@ -67,11 +66,11 @@ void cycle(void) { testdbPrepare(); - testdbReadDatabase("dbShutdownTest.dbd", NULL, NULL); + testdbReadDatabase("dbTestIoc.dbd", NULL, NULL); - dbShutdownTest_registerRecordDeviceDriver(pdbbase); + dbTestIoc_registerRecordDeviceDriver(pdbbase); - testdbReadDatabase("sRecord.db", NULL, NULL); + testdbReadDatabase("xRecord.db", NULL, NULL); testOk1(!testiocInit()); diff --git a/src/ioc/db/test/epicsRunDbTests.c b/src/ioc/db/test/epicsRunDbTests.c index d8633702e..ef759d9d7 100644 --- a/src/ioc/db/test/epicsRunDbTests.c +++ b/src/ioc/db/test/epicsRunDbTests.c @@ -18,6 +18,7 @@ int callbackTest(void); int dbStateTest(void); +int dbShutdownTest(void); int testDbChannel(void); int chfPluginTest(void); int arrShorthandTest(void); @@ -28,9 +29,10 @@ void epicsRunDbTests(void) runTest(callbackTest); runTest(dbStateTest); + runTest(dbShutdownTest); runTest(testDbChannel); - runTest(chfPluginTest); runTest(arrShorthandTest); + runTest(chfPluginTest); dbmfFreeChunks(); diff --git a/src/ioc/db/test/xRecord.c b/src/ioc/db/test/xRecord.c index 568fbb838..dcc1f776c 100644 --- a/src/ioc/db/test/xRecord.c +++ b/src/ioc/db/test/xRecord.c @@ -14,12 +14,24 @@ */ #include "dbAccessDefs.h" -#include +#include "recSup.h" +#include "recGbl.h" #define GEN_SIZE_OFFSET #include "xRecord.h" #include -static rset xRSET; +static long process(xRecord *prec) +{ + prec->pact = TRUE; + recGblGetTimeStamp(prec); + recGblFwdLink(prec); + prec->pact = FALSE; + return 0; +} + +static rset xRSET = { + RSETNUMBER, NULL, NULL, NULL, process +}; epicsExportAddress(rset,xRSET); diff --git a/src/ioc/db/test/xRecord.dbd b/src/ioc/db/test/xRecord.dbd index 4837871a4..77e67147a 100644 --- a/src/ioc/db/test/xRecord.dbd +++ b/src/ioc/db/test/xRecord.dbd @@ -1,11 +1,7 @@ -# This is a combined minimal DBD and DB file +# This is a minimal record definition recordtype(x) { - field(NAME, DBF_STRING) { - prompt("Record Name") - special(SPC_NOMOD) - size(61) - } + include "dbCommon.dbd" field(VAL, DBF_LONG) { prompt("Value") } diff --git a/src/libCom/misc/epicsUnitTest.h b/src/libCom/misc/epicsUnitTest.h index c1f0a5939..0489752a1 100644 --- a/src/libCom/misc/epicsUnitTest.h +++ b/src/libCom/misc/epicsUnitTest.h @@ -9,6 +9,9 @@ * Author: Andrew Johnson */ +#ifndef INC_epicsUnitTest_H +#define INC_epicsUnitTest_H + #include #include "compilerDependencies.h" @@ -47,3 +50,5 @@ epicsShareFunc void runTestFunc(const char *name, TESTFUNC func); #ifdef __cplusplus } #endif + +#endif /* INC_epicsUnitTest_H */