testCa: Move IOC environment checks & configuration from run() to start()

This lets us use testAbort() instead of throw to flag errors.
This commit is contained in:
Andrew Johnson
2018-05-27 15:35:04 -05:00
parent 6681bdc4c6
commit 7bf404913a

View File

@@ -673,6 +673,8 @@ public:
private:
#ifndef USE_DBUNITTEST
std::auto_ptr<epicsThread> thread;
const char *base;
const char *arch;
#endif
};
@@ -692,7 +694,16 @@ void TestIoc::start()
testIocInitOk();
eltc(1);
#else
thread = std::auto_ptr<epicsThread>(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<epicsThread>(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/";