From 5f02bad3fc389f465056d1234b79ee6d94862dea Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 8 Jul 2022 15:55:14 -0500 Subject: [PATCH] Fix decimate filter for testing on VxWorks Also adds checks to all filter tests to abort if they can't continue because their filter wasn't registered. --- modules/database/src/std/filters/decimate.c | 14 +++++++++----- modules/database/test/std/filters/arrTest.cpp | 5 ++++- modules/database/test/std/filters/decTest.c | 6 ++++-- modules/database/test/std/filters/syncTest.c | 2 ++ modules/database/test/std/filters/tsTest.c | 5 ++++- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/modules/database/src/std/filters/decimate.c b/modules/database/src/std/filters/decimate.c index e9d31bf84..7ce12cb66 100644 --- a/modules/database/src/std/filters/decimate.c +++ b/modules/database/src/std/filters/decimate.c @@ -19,6 +19,7 @@ #include "freeList.h" #include "db_field_log.h" #include "chfPlugin.h" +#include "epicsExit.h" #include "epicsExport.h" typedef struct myStruct { @@ -102,17 +103,20 @@ static chfPluginIf pif = { NULL /* channel_close */ }; +static void decShutdown(void *ignore) +{ + if (myStructFreeList) + freeListCleanup(myStructFreeList); + myStructFreeList = NULL; +} + static void decInitialize(void) { - static int firstTime = 1; - - if (!firstTime) return; - firstTime = 0; - if (!myStructFreeList) freeListInitPvt(&myStructFreeList, sizeof(myStruct), 64); chfPluginRegister("dec", &pif, opts); + epicsAtExit(decShutdown, NULL); } epicsExportRegistrar(decInitialize); diff --git a/modules/database/test/std/filters/arrTest.cpp b/modules/database/test/std/filters/arrTest.cpp index dfbbf463f..0fe9db01e 100644 --- a/modules/database/test/std/filters/arrTest.cpp +++ b/modules/database/test/std/filters/arrTest.cpp @@ -321,7 +321,10 @@ MAIN(arrTest) evtctx = db_init_events(); - testOk(!!(plug = dbFindFilter(arr, strlen(arr))), "plugin arr registered correctly"); + plug = dbFindFilter(arr, strlen(arr)); + if (!plug) + testAbort("plugin '%s' not registered", arr); + testPass("plugin '%s' registered correctly", arr); check(DBR_LONG); check(DBR_DOUBLE); diff --git a/modules/database/test/std/filters/decTest.c b/modules/database/test/std/filters/decTest.c index e0961af10..1e485c9b7 100644 --- a/modules/database/test/std/filters/decTest.c +++ b/modules/database/test/std/filters/decTest.c @@ -145,8 +145,10 @@ MAIN(decTest) evtctx = db_init_events(); - testOk(!!(plug = dbFindFilter(myname, strlen(myname))), - "plugin '%s' registered correctly", myname); + plug = dbFindFilter(myname, strlen(myname)); + if (!plug) + testAbort("Plugin '%s' not registered", myname); + testPass("plugin '%s' registered correctly", myname); /* N < 1 */ testOk(!(pch = dbChannelCreate("x.VAL{dec:{n:-1}}")), diff --git a/modules/database/test/std/filters/syncTest.c b/modules/database/test/std/filters/syncTest.c index 6527d2c96..83cea281e 100644 --- a/modules/database/test/std/filters/syncTest.c +++ b/modules/database/test/std/filters/syncTest.c @@ -223,6 +223,8 @@ MAIN(syncTest) testOk(!!(plug = dbFindFilter(myname, strlen(myname))), "plugin %s registered correctly", myname); testOk(!!(red = dbStateCreate("red")), "state 'red' created successfully"); + if (!plug || !red) + testAbort("Can't continue given above failure(s)"); /* nonexisting state */ testOk(!(pch = dbChannelCreate("x.VAL{sync:{m:'while',s:'blue'}}")), diff --git a/modules/database/test/std/filters/tsTest.c b/modules/database/test/std/filters/tsTest.c index bd0b799e9..e26dd41d1 100644 --- a/modules/database/test/std/filters/tsTest.c +++ b/modules/database/test/std/filters/tsTest.c @@ -72,7 +72,10 @@ MAIN(tsTest) evtctx = db_init_events(); - testOk(!!(plug = dbFindFilter(ts, strlen(ts))), "plugin ts registered correctly"); + plug = dbFindFilter(ts, strlen(ts)); + if (!plug) + testAbort("plugin '%s' not registered", ts); + testPass("plugin '%s' registered correctly", ts); testOk(!!(pch = dbChannelCreate("x.VAL{ts:{}}")), "dbChannel with plugin ts created"); testOk((ellCount(&pch->filters) == 1), "channel has one plugin");