From 7bf404913a22dc6bb013a6279c7122e90982eb2a Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sun, 27 May 2018 15:35:04 -0500 Subject: [PATCH] testCa: Move IOC environment checks & configuration from run() to start() This lets us use testAbort() instead of throw to flag errors. --- testCa/testCaProvider.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/testCa/testCaProvider.cpp b/testCa/testCaProvider.cpp index 9b3c1e2..5a1664f 100644 --- a/testCa/testCaProvider.cpp +++ b/testCa/testCaProvider.cpp @@ -673,6 +673,8 @@ public: private: #ifndef USE_DBUNITTEST std::auto_ptr thread; + const char *base; + const char *arch; #endif }; @@ -692,7 +694,16 @@ void TestIoc::start() testIocInitOk(); eltc(1); #else - thread = std::auto_ptr(new epicsThread( + base = getenv("EPICS_BASE"); + if (!base) + testAbort("Environment variable $EPICS_BASE not defined"); + arch = getenv("EPICS_HOST_ARCH"); + if (!arch) + testAbort("Environment variable $EPICS_HOST_ARCH not defined"); + setenv("EPICS_CA_ADDR_LIST", "localhost", 1); + setenv("EPICS_CA_AUTO_ADDR_LIST", "NO", 1); + + thread = std::auto_ptr(new epicsThread( *this, "testIoc", epicsThreadGetStackSize(epicsThreadStackSmall), @@ -708,14 +719,6 @@ void TestIoc::run() // tests with an embedded IOC fail with a Base before 3.16.2. // This version only works on workstation targets, it runs the // softIoc from Base as a separate process, using system(). - char * base; - base = getenv("EPICS_BASE"); - if(base==NULL) throw std::runtime_error("TestIoc::run $EPICS_BASE not defined"); - char * arch; - arch = getenv("EPICS_HOST_ARCH"); - if(arch==NULL) throw std::runtime_error("TestIoc::run $$EPICS_HOST_ARCH not defined"); - setenv("EPICS_CA_ADDR_LIST", "localhost", 1); - setenv("EPICS_CA_AUTO_ADDR_LIST", "NO", 1); if(system("$EPICS_BASE/bin/$EPICS_HOST_ARCH/softIoc -x test -d ../testCaProvider.db")!=0) { string message(base); message += "/bin/";