diff --git a/testApp/remote/channelAccessIFTest.cpp b/testApp/remote/channelAccessIFTest.cpp index e31c037..05a25ba 100755 --- a/testApp/remote/channelAccessIFTest.cpp +++ b/testApp/remote/channelAccessIFTest.cpp @@ -68,6 +68,7 @@ int ChannelAccessIFTest::runAllTest() { .build()); TestServer::shared_pointer tstserv(new TestServer(base_config)); + tstserv->start(); testDiag("TestServer on ports TCP=%u UDP=%u\n", tstserv->getServerPort(), tstserv->getBroadcastPort()); diff --git a/testApp/remote/testServer.cpp b/testApp/remote/testServer.cpp index b49fdc2..45e1926 100644 --- a/testApp/remote/testServer.cpp +++ b/testApp/remote/testServer.cpp @@ -2750,10 +2750,20 @@ struct TestServer : public Runnable context = ServerContextImpl::create(conf); context->initialize(getChannelProviderRegistry()); - - runner.start(); - startup.wait(); // wait for thread to start } + void start(bool inSameThread = false) + { + if (inSameThread) + { + context->run(conf->getPropertyAsInteger("timeToRun", 0)); // default is no timeout + } + else + { + runner.start(); + startup.wait(); // wait for thread to start + } + } + ~TestServer() { context->shutdown(); @@ -2788,6 +2798,9 @@ struct TestServer : public Runnable startup.signal(); context->run(conf->getPropertyAsInteger("timeToRun", 0)); // default is no timeout } + void waitForShutdown() { + context->shutdown(); + } void shutdown() { context->shutdown(); } @@ -2861,15 +2874,13 @@ int main(int argc, char *argv[]) srand ( time(NULL) ); - { - TestServer::shared_pointer srv(new TestServer(ConfigurationBuilder() - .push_env() - .add("timeToRun", timeToRun) - .push_map() - .build())); - TestServer::ctx = srv; - } - TestServer::ctx.reset(); + TestServer::shared_pointer srv(new TestServer(ConfigurationBuilder() + .push_env() + .add("timeToRun", timeToRun) + .push_map() + .build())); + TestServer::ctx = srv; + srv->start(true); cout << "Done" << endl;