From 9f660f2238a6efe85af8a49510edeaee69b6641a Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 4 Sep 2023 09:50:08 +0200 Subject: [PATCH] add initHookAtPrepare --- modules/database/src/ioc/db/dbUnitTest.c | 2 ++ modules/libcom/src/iocsh/initHooks.c | 3 +++ modules/libcom/src/iocsh/initHooks.h | 12 ++++++++++++ 3 files changed, 17 insertions(+) diff --git a/modules/database/src/ioc/db/dbUnitTest.c b/modules/database/src/ioc/db/dbUnitTest.c index 2c7efd8a9..bf4ec205b 100644 --- a/modules/database/src/ioc/db/dbUnitTest.c +++ b/modules/database/src/ioc/db/dbUnitTest.c @@ -50,6 +50,7 @@ void testdbPrepare(void) { if(!testEvtLock) testEvtLock = epicsMutexMustCreate(); + initHookAnnounce(initHookAfterPrepareDatabase); } void testdbReadDatabase(const char* file, @@ -94,6 +95,7 @@ void testIocShutdownOk(void) void testdbCleanup(void) { + initHookAnnounce(initHookBeforeCleanupDatabase); dbFreeBase(pdbbase); db_cleanup_events(); initHookFree(); diff --git a/modules/libcom/src/iocsh/initHooks.c b/modules/libcom/src/iocsh/initHooks.c index 750a76d42..90b1de2c5 100644 --- a/modules/libcom/src/iocsh/initHooks.c +++ b/modules/libcom/src/iocsh/initHooks.c @@ -139,6 +139,9 @@ const char *initHookName(int state) "initHookBeforeFree", "initHookAfterShutdown", + "initHookAfterPrepareDatabase", + "initHookBeforeCleanupDatabase", + "initHookAfterInterruptAccept", "initHookAtEnd" }; diff --git a/modules/libcom/src/iocsh/initHooks.h b/modules/libcom/src/iocsh/initHooks.h index de4a72a32..a5ad93d3f 100644 --- a/modules/libcom/src/iocsh/initHooks.h +++ b/modules/libcom/src/iocsh/initHooks.h @@ -71,6 +71,7 @@ extern "C" { * if the IOC is later paused and restarted. */ typedef enum { + // iocInit() begins initHookAtIocBuild = 0, /**< Start of iocBuild() / iocInit() */ initHookAtBeginning, /**< Database sanity checks passed */ @@ -133,6 +134,17 @@ typedef enum { initHookAfterShutdown, // iocShutdown() ends + /** \brief Called during testdbPrepare() + * Use this hook to repeat actions each time an empty test database is initialized. + * \since UNRELEASED Added, triggered only by unittest code. + */ + initHookAfterPrepareDatabase, + /** \brief Called during testdbCleanup() + * Use this hook to perform cleanup each time before a test database is free()'d. + * \since UNRELEASED Added, triggered only by unittest code. + */ + initHookBeforeCleanupDatabase, + /* Deprecated states: */ /** Only announced once. Deprecated in favor of initHookAfterDatabaseRunning */ initHookAfterInterruptAccept,