From 8382367495a3960a035677af21b595dd64b94319 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Fri, 21 Apr 2017 14:53:23 -0400 Subject: [PATCH 1/9] libCom/test: epicsCalcTest use exact postifx buffers exposes INFIX_TO_POSTFIX_SIZE() bug --- src/libCom/test/epicsCalcTest.cpp | 62 +++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 15 deletions(-) diff --git a/src/libCom/test/epicsCalcTest.cpp b/src/libCom/test/epicsCalcTest.cpp index f4d5a4660..9bad2000c 100644 --- a/src/libCom/test/epicsCalcTest.cpp +++ b/src/libCom/test/epicsCalcTest.cpp @@ -6,6 +6,9 @@ \*************************************************************************/ // Author: Andrew Johnson +#include +#include + #include "epicsUnitTest.h" #include "epicsTypes.h" #include "epicsMath.h" @@ -20,17 +23,23 @@ double doCalc(const char *expr) { double args[CALCPERFORM_NARGS] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 }; - char rpn[MAX_POSTFIX_SIZE]; + char *rpn = (char*)malloc(INFIX_TO_POSTFIX_SIZE(strlen(expr)+1)); short err; double result = 0.0; result /= result; /* Start as NaN */ - + + if(!rpn) { + testAbort("postfix: %s no memory", expr); + return epicsNAN; + } + if (postfix(expr, rpn, &err)) { testDiag("postfix: %s in expression '%s'", calcErrorStr(err), expr); } else if (calcPerform(args, &result, rpn) && finite(result)) { testDiag("calcPerform: error evaluating '%s'", expr); } + free(rpn); return result; } @@ -40,11 +49,16 @@ void testCalc(const char *expr, double expected) { double args[CALCPERFORM_NARGS] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 }; - char rpn[MAX_POSTFIX_SIZE]; + char *rpn = (char*)malloc(INFIX_TO_POSTFIX_SIZE(strlen(expr)+1)); short err; double result = 0.0; result /= result; /* Start as NaN */ + if(!rpn) { + testFail("postfix: %s no memory", expr); + return; + } + if (postfix(expr, rpn, &err)) { testDiag("postfix: %s in expression '%s'", calcErrorStr(err), expr); } else @@ -63,6 +77,7 @@ void testCalc(const char *expr, double expected) { testDiag("Expected result is %g, actually got %g", expected, result); calcExprDump(rpn); } + free(rpn); } void testUInt32Calc(const char *expr, epicsUInt32 expected) { @@ -71,12 +86,17 @@ void testUInt32Calc(const char *expr, epicsUInt32 expected) { double args[CALCPERFORM_NARGS] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 }; - char rpn[MAX_POSTFIX_SIZE]; + char *rpn = (char*)malloc(INFIX_TO_POSTFIX_SIZE(strlen(expr)+1)); short err; epicsUInt32 uresult; double result = 0.0; result /= result; /* Start as NaN */ + if(!rpn) { + testFail("postfix: %s no memory", expr); + return; + } + if (postfix(expr, rpn, &err)) { testDiag("postfix: %s in expression '%s'", calcErrorStr(err), expr); } else @@ -91,38 +111,50 @@ void testUInt32Calc(const char *expr, epicsUInt32 expected) { expected, expected, uresult, uresult); calcExprDump(rpn); } + free(rpn); } void testArgs(const char *expr, unsigned long einp, unsigned long eout) { - char rpn[MAX_POSTFIX_SIZE]; + char *rpn = (char*)malloc(INFIX_TO_POSTFIX_SIZE(strlen(expr)+1)); short err = 0; unsigned long vinp, vout; + if(!rpn) { + testFail("postfix: %s no memory", expr); + return; + } + if (postfix(expr, rpn, &err)) { - testFail("postfix: %s in expression '%s'", calcErrorStr(err), expr); - return; + testFail("postfix: %s in expression '%s'", calcErrorStr(err), expr); + return; } if (calcArgUsage(rpn, &vinp, &vout)) { - testFail("calcArgUsage returned error for '%s'", expr); - return; + testFail("calcArgUsage returned error for '%s'", expr); + return; } if (!testOk(vinp == einp && vout == eout, "Args for '%s'", expr)) { - testDiag("Expected (%lx, %lx) got (%lx, %lx)", einp, eout, vinp, vout); + testDiag("Expected (%lx, %lx) got (%lx, %lx)", einp, eout, vinp, vout); } + free(rpn); } void testBadExpr(const char *expr, short expected_err) { /* Parse an invalid expression, test against expected error code */ - char rpn[MAX_POSTFIX_SIZE]; + char *rpn = (char*)malloc(INFIX_TO_POSTFIX_SIZE(strlen(expr)+1)); short err = 0; + if(!rpn) { + testFail("postfix: %s no memory", expr); + return; + } + postfix(expr, rpn, &err); if (!testOk(err == expected_err, "Bad expression '%s'", expr)) { - testDiag("Expected '%s', actually got '%s'", - calcErrorStr(expected_err), calcErrorStr(err)); - calcExprDump(rpn); + testDiag("Expected '%s', actually got '%s'", + calcErrorStr(expected_err), calcErrorStr(err)); + calcExprDump(rpn); } - return; + free(rpn); } /* Test an expression that is also valid C code */ From e25a2964bcf57c5ad951e48e99da4bfa327f66f3 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 21 Apr 2017 16:09:36 -0500 Subject: [PATCH 2/9] Fix postfix.h macro arg, document --- src/libCom/calc/postfix.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libCom/calc/postfix.h b/src/libCom/calc/postfix.h index a7a2a3cbe..b90492012 100644 --- a/src/libCom/calc/postfix.h +++ b/src/libCom/calc/postfix.h @@ -19,9 +19,10 @@ #define CALCPERFORM_NARGS 12 #define CALCPERFORM_STACK 80 -#define INFIX_TO_POSTFIX_SIZE(n) (n*21/6) +#define INFIX_TO_POSTFIX_SIZE(n) ((n)*21/6) /* The above expression is an estimate of the maximum postfix buffer - * size needed for a given infix expression buffer. The actual size + * size needed for a given infix expression buffer (the argument must count + * the trailing nil byte in the input expression string). The actual size * needed is never larger than this value, although it is actually a * few bytes smaller for some sizes. * From c5decfbd12cfb239681568edbd1dc9402582a6be Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 24 Apr 2017 18:03:53 -0500 Subject: [PATCH 3/9] Fix for dbCa warning seg-fault Don't queue an errlog message containing a pointer to a string that will disappear soon. Thanks to Matt Pearson for the bug analysis. --- src/db/dbCa.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/db/dbCa.c b/src/db/dbCa.c index 13118eb8b..aaaaa4b5c 100644 --- a/src/db/dbCa.c +++ b/src/db/dbCa.c @@ -142,7 +142,6 @@ static void addAction(caLink *pca, short link_action) if (++removesOutstanding >= removesOutstandingWarning) { errlogPrintf("dbCa::addAction pausing, %d channels to clear\n", removesOutstanding); - printLinks(pca); } while (removesOutstanding >= removesOutstandingWarning) { epicsMutexUnlock(workListLock); From c22670cbb08db1205e6ef4e61477dec8b37b94bc Mon Sep 17 00:00:00 2001 From: Jeong Han Lee Date: Mon, 24 Apr 2017 21:06:30 -0400 Subject: [PATCH 4/9] typo --- src/ca/caeventmask.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ca/caeventmask.h b/src/ca/caeventmask.h index 9b7c2d31d..5f0914509 100644 --- a/src/ca/caeventmask.h +++ b/src/ca/caeventmask.h @@ -24,7 +24,7 @@ DBE_ARCHIVE (DBE_LOG) Trigger an event when an archive significant change in the channel's - valuue occurs. Relies on the archiver monitor deadband field under DCT. + value occurs. Relies on the archiver monitor deadband field under DCT. DBE_ALARM Trigger an event when the alarm state changes From f2e54be965d14c62d879971807ee691f3a3c0c5d Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 27 Apr 2017 10:52:07 -0500 Subject: [PATCH 5/9] catools: Fix SEGFAULT from bad PV names --- src/catools/caget.c | 6 +++--- src/catools/cainfo.c | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/catools/caget.c b/src/catools/caget.c index a2b0e08b0..00056709e 100644 --- a/src/catools/caget.c +++ b/src/catools/caget.c @@ -541,11 +541,11 @@ int main (int argc, char *argv[]) for (n = 0; optind < argc; n++, optind++) pvs[n].name = argv[optind] ; /* Copy PV names from command line */ - connect_pvs(pvs, nPvs); + result = connect_pvs(pvs, nPvs); /* Read and print data */ - - result = caget(pvs, nPvs, request, format, type, count); + if (!result) + result = caget(pvs, nPvs, request, format, type, count); /* Shut down Channel Access */ ca_context_destroy(); diff --git a/src/catools/cainfo.c b/src/catools/cainfo.c index 924c34b10..ad580f473 100644 --- a/src/catools/cainfo.c +++ b/src/catools/cainfo.c @@ -211,10 +211,11 @@ int main (int argc, char *argv[]) for (n = 0; optind < argc; n++, optind++) pvs[n].name = argv[optind] ; /* Copy PV names from command line */ - connect_pvs(pvs, nPvs); + result = connect_pvs(pvs, nPvs); /* Print data */ - result = cainfo(pvs, nPvs); + if (!result) + result = cainfo(pvs, nPvs); /* Shut down Channel Access */ ca_context_destroy(); From 3184371e8d274fe1e3abaa1739219f0f9e1736f7 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 24 Nov 2015 18:00:10 -0500 Subject: [PATCH 6/9] travisci --- .travis.yml | 31 +++++++++++++++ ci/travis-build.sh | 90 ++++++++++++++++++++++++++++++++++++++++++++ ci/travis-prepare.sh | 40 ++++++++++++++++++++ 3 files changed, 161 insertions(+) create mode 100644 .travis.yml create mode 100644 ci/travis-build.sh create mode 100644 ci/travis-prepare.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..11a7b443b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,31 @@ +sudo: false +dist: trusty +language: c +compiler: + - gcc +env: + - CMPLR=gcc + - CMPLR=gcc EXTRA=CMD_CXXFLAGS=-std=c++11 + - CMPLR=gcc STATIC=YES + - CMPLR=clang + - CMPLR=clang STATIC=YES + - WINE=32 TEST=NO STATIC=YES + - RTEMS=4.10 TEST=NO + - RTEMS=4.9 TEST=NO +addons: + apt: + packages: + - libreadline6-dev + - libncurses5-dev + - perl + - clang + - g++-mingw-w64-i686 + - bison + - flex + - texinfo + - install-info +cache: + directories: + - $HOME/.cache +install: sh ci/travis-prepare.sh &2 + exit 1 +} + +ticker() { + while true + do + sleep 60 + date -R + [ -r "$1" ] && tail -n10 "$1" + done +} + +CACHEKEY=1 + +EPICS_HOST_ARCH=`sh startup/EpicsHostArch` + +[ -e configure/os/CONFIG_SITE.Common.linux-x86 ] || die "Wrong location: $PWD" + +case "$CMPLR" in +clang) + echo "Host compiler is clang" + cat << EOF >> configure/os/CONFIG_SITE.Common.$EPICS_HOST_ARCH +GNU = NO +CMPLR_CLASS = clang +CC = clang +CCC = clang++ +EOF + ;; +*) echo "Host compiler is default";; +esac + +if [ "$STATIC" = "YES" ] +then + echo "Build static libraries/executables" + cat << EOF >> configure/CONFIG_SITE +SHARED_LIBRARIES=NO +STATIC_BUILD=YES +EOF +fi + +# requires wine and g++-mingw-w64-i686 +if [ "$WINE" = "32" ] +then + echo "Cross mingw32" + sed -i -e '/CMPLR_PREFIX/d' configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw + cat << EOF >> configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw +CMPLR_PREFIX=i686-w64-mingw32- +EOF + cat << EOF >> configure/CONFIG_SITE +CROSS_COMPILER_TARGET_ARCHS+=win32-x86-mingw +EOF +fi + +# set RTEMS to eg. "4.9" or "4.10" +# requires qemu, bison, flex, texinfo, install-info +if [ -n "$RTEMS" ] +then + echo "Cross RTEMS${RTEMS} for pc386" + install -d /home/travis/.cache + curl -L "https://github.com/mdavidsaver/rsb/releases/download/travis-20160306-2/rtems${RTEMS}-i386-trusty-20190306-2.tar.gz" \ + | tar -C /home/travis/.cache -xj + + sed -i -e '/^RTEMS_VERSION/d' -e '/^RTEMS_BASE/d' configure/os/CONFIG_SITE.Common.RTEMS + cat << EOF >> configure/os/CONFIG_SITE.Common.RTEMS +RTEMS_VERSION=$RTEMS +RTEMS_BASE=/home/travis/.cache/rtems${RTEMS}-i386 +EOF + cat << EOF >> configure/CONFIG_SITE +CROSS_COMPILER_TARGET_ARCHS+=RTEMS-pc386 +EOF + + # find local qemu-system-i386 + export PATH="$HOME/.cache/qemu/usr/bin:$PATH" + echo -n "Using QEMU: " + type qemu-system-i386 || echo "Missing qemu" + EXTRA=RTEMS_QEMU_FIXUPS=YES +fi + +make -j2 $EXTRA + +if [ "$TEST" != "NO" ] +then + make tapfiles + find . -name '*.tap' -print0 | xargs -0 -n1 prove -e cat -f +fi diff --git a/ci/travis-prepare.sh b/ci/travis-prepare.sh new file mode 100644 index 000000000..fd8c6fb4b --- /dev/null +++ b/ci/travis-prepare.sh @@ -0,0 +1,40 @@ +#!/bin/sh +set -e -x + +die() { + echo "$1" >&2 + exit 1 +} + +CURDIR="$PWD" + +QDIR="$HOME/.cache/qemu" + +if [ -n "$RTEMS" -a "$TEST" = "YES" ] +then + git clone --quiet --branch vme --depth 10 https://github.com/mdavidsaver/qemu.git "$HOME/.build/qemu" + cd "$HOME/.build/qemu" + + HEAD=`git log -n1 --pretty=format:%H` + echo "HEAD revision $HEAD" + + [ -e "$HOME/.cache/qemu/built" ] && BUILT=`cat "$HOME/.cache/qemu/built"` + echo "Cached revision $BUILT" + + if [ "$HEAD" != "$BUILT" ] + then + echo "Building QEMU" + git submodule --quiet update --init + + install -d "$HOME/.build/qemu/build" + cd "$HOME/.build/qemu/build" + + "$HOME/.build/qemu/configure" --prefix="$HOME/.cache/qemu/usr" --target-list=i386-softmmu --disable-werror + make -j2 + make install + + echo "$HEAD" > "$HOME/.cache/qemu/built" + fi +fi + +cd "$CURDIR" From 82ff67a20494d786620850ead8401c1d66c80f1a Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 27 Apr 2017 12:57:01 -0400 Subject: [PATCH 7/9] travis-ci enable mingw w/ dll --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 11a7b443b..5079bff0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ env: - CMPLR=clang - CMPLR=clang STATIC=YES - WINE=32 TEST=NO STATIC=YES + - WINE=32 TEST=NO STATIC=NO - RTEMS=4.10 TEST=NO - RTEMS=4.9 TEST=NO addons: From b01dd3852659580831bdb482b539e7803c87ca28 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 27 Apr 2017 14:09:41 -0400 Subject: [PATCH 8/9] std/filter/test: use dbUnitTest --- src/std/filters/test/Makefile | 41 +++++++++++------------- src/std/filters/test/arrTest.cpp | 55 +++++++++++--------------------- src/std/filters/test/dbndTest.c | 37 +++++++++++---------- src/std/filters/test/syncTest.c | 37 +++++++++++---------- src/std/filters/test/tsTest.c | 37 +++++++++++---------- src/std/filters/test/xRecord.dbd | 6 +--- 6 files changed, 91 insertions(+), 122 deletions(-) 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") } From c6910decfcf4973f3714e7a4bd65feb2dd42b117 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 27 Apr 2017 14:19:15 -0400 Subject: [PATCH 9/9] oops --- src/std/filters/test/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/src/std/filters/test/Makefile b/src/std/filters/test/Makefile index b846e488e..5c17d7fe6 100644 --- a/src/std/filters/test/Makefile +++ b/src/std/filters/test/Makefile @@ -50,7 +50,6 @@ testHarness_SRCS += arrTest.cpp TESTFILES += ../arrTest.db TESTS += arrTest -TARGETS += $(COMMON_DIR)/syncTest.dbd TESTPROD_HOST += syncTest syncTest_SRCS += syncTest.c syncTest_SRCS += filterTest_registerRecordDeviceDriver.cpp