diff --git a/modules/libcom/test/Makefile b/modules/libcom/test/Makefile index cf55760a6..3457b1057 100755 --- a/modules/libcom/test/Makefile +++ b/modules/libcom/test/Makefile @@ -260,6 +260,16 @@ iocshTest_SRCS += iocshTest.cpp TESTS += iocshTest TESTFILES += $(wildcard ../iocshTest*.cmd) +TESTPROD_HOST += epicsLoadTest +epicsLoadTest_SRCS += epicsLoadTest.cpp +# test linked against static libCom? +epicsLoadTest_CPPFLAGS_STATIC_YES = -DLINKING_STATIC +epicsLoadTest_CPPFLAGS += $(epicsLoadTest_CPPFLAGS_STATIC_$(STATIC_BUILD)) +# are dynamic libraries built? +epicsLoadTest_CPPFLAGS_SHARED_YES = -DBUILDING_SHARED_LIBRARIES +epicsLoadTest_CPPFLAGS += $(epicsLoadTest_CPPFLAGS_SHARED_$(SHARED_LIBRARIES)) +TESTS += epicsLoadTest + # The testHarness runs all the test programs in a known working order. testHarness_SRCS += epicsRunLibComTests.c diff --git a/modules/libcom/test/epicsLoadTest.cpp b/modules/libcom/test/epicsLoadTest.cpp new file mode 100644 index 000000000..809081072 --- /dev/null +++ b/modules/libcom/test/epicsLoadTest.cpp @@ -0,0 +1,91 @@ +/*************************************************************************\ +* Copyright (c) 2020 Michael Davidsaver +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +#include + +#include + +#include "epicsUnitTest.h" +#include "testMain.h" + +#include "envDefs.h" +#include "epicsFindSymbol.h" +#include "epicsThread.h" + +namespace { + +// lookup a symbol from libCom +// which this executable is linked against (maybe statically) +// Doesn't work for static builds on windows +void loadCom() +{ + testDiag("Lookup symbol from Com"); + +#if defined (_WIN32) && defined(LINKING_STATIC) + testTodoBegin("windows static build"); +#endif + + void* ptr = epicsFindSymbol("epicsThreadGetCPUs"); + testOk(ptr==(void*)&epicsThreadGetCPUs, + "%p == %p (epicsThreadGetCPUs) : %s", + ptr, (void*)&epicsThreadGetCPUs, + epicsLoadError()); + + testTodoEnd(); +} + +void loadCA() +{ + testDiag("Load and lookup symbol from libca"); + + std::string libname; + { + std::ostringstream strm; + // running in eg. modules/libcom/test/O.linux-x86_64-debug +#ifdef _WIN32 + strm<<"..\\..\\..\\..\\bin\\"<