From 87003df25ce7f7d3aaed7b56bfe10cb8796f2e5a Mon Sep 17 00:00:00 2001 From: smathis Date: Thu, 16 Apr 2026 13:16:09 +0200 Subject: [PATCH] Added target for library --- CMakeLists.txt | 20 ++++++++++++++++++++ bus/m_epics_ca.tpp | 2 +- test/ioc/st.cmd | 6 ------ test/ioc/startioc | 10 +++------- test/m_epics_ca_test.cxx | 10 +++++++--- 5 files changed, 31 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c35fa7..1b48d19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,24 @@ set(LIBS $ENV{MIDASSYS}/lib/libmscb.a ) +################################################################################ +## Driver Library +################################################################################ + +add_library( + m_epics_ca + INTERFACE +) + +target_sources(m_epics_ca INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR}/bus/m_epics_ca.h + ${CMAKE_CURRENT_SOURCE_DIR}/bus/m_epics_ca.tpp +) + +target_include_directories(m_epics_ca INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR}/bus +) + ################################################################################ ## Test executable ################################################################################ @@ -62,6 +80,7 @@ target_include_directories( PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE + m_epics_ca $ENV{MIDASSYS}/drivers $ENV{MIDASSYS}/include # This is redundant if MIDASSYS =/ Midas repo, but needed if MIDAS has been @@ -77,6 +96,7 @@ target_include_directories( target_link_libraries( m_epics_ca_test + m_epics_ca ${LIBS} ) diff --git a/bus/m_epics_ca.tpp b/bus/m_epics_ca.tpp index 9e2f5dd..1445d96 100644 --- a/bus/m_epics_ca.tpp +++ b/bus/m_epics_ca.tpp @@ -42,7 +42,7 @@ template constexpr int dbfFromType() { } } -template void assertEqual() { +template constexpr void assertEqual() { static_assert(dbfFromType() == dbfFromType()); } diff --git a/test/ioc/st.cmd b/test/ioc/st.cmd index 2308874..0374674 100755 --- a/test/ioc/st.cmd +++ b/test/ioc/st.cmd @@ -1,11 +1,5 @@ #!/usr/local/bin/iocsh -errlogInit(10000) - dbLoadRecords("$(IOCDIR)/record.db") iocInit() - -# Apparently, the IOC needs a bit of time to "settle" down before exiting st.cmd -# This is again typical EPICS shenaningans ... -epicsThreadSleep(1.0) \ No newline at end of file diff --git a/test/ioc/startioc b/test/ioc/startioc index 9469dcc..4b30f4a 100755 --- a/test/ioc/startioc +++ b/test/ioc/startioc @@ -2,13 +2,9 @@ export EPICS_BASE=/usr/local/epics/base-7.0.7 export EPICS_HOST_ARCH=RHEL8-x86_64 export EPICS_CA_AUTO_ADDR_LIST=NO - -# Detect primary IPv4 used for routing -IP=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++) if ($i=="src") print $(i+1)}') - -export EPICS_CAS_INTF_ADDR_LIST="$IP" -export EPICS_CA_ADDR_LIST="$IP" +export EPICS_CAS_INTF_ADDR_LIST=127.0.0.1 +export EPICS_CA_ADDR_LIST=127.0.0.1 cd "$(dirname "$0")" export IOCDIR=$(pwd) -./st.cmd \ No newline at end of file +./st.cmd diff --git a/test/m_epics_ca_test.cxx b/test/m_epics_ca_test.cxx index cd030dd..797fdbc 100644 --- a/test/m_epics_ca_test.cxx +++ b/test/m_epics_ca_test.cxx @@ -1,5 +1,5 @@ -#include "bus/m_epics_ca.h" #include "cadef.h" +#include "m_epics_ca.h" #include #include #include @@ -38,7 +38,7 @@ class IocProcess { setpgid(0, 0); execl(path.c_str(), path.c_str(), (char *)nullptr); perror("execl failed"); - _exit(127); + _exit(1); } if (_pid < 0) { @@ -77,6 +77,10 @@ class IocProcess { int main() { + // Client setting for local testing + setenv("EPICS_CA_AUTO_ADDR_LIST", "NO", 1); + setenv("EPICS_CA_ADDR_LIST", "127.0.0.255", 1); + // Scope everything so the IOC gets torn down by the IocProcess destructor // before reporting that the tests were successfull. { @@ -146,7 +150,7 @@ int main() { EQUAL(double_val, new_double_val); } - printf("\nTest was successfull\n"); + printf("\nTest was successful\n"); return 0; } \ No newline at end of file