added testChannelAccess tests
This commit is contained in:
@@ -46,6 +46,11 @@ PROD_HOST += testServer
|
||||
testServer_SRCS += testServer.cpp
|
||||
testServer_LIBS += pvData pvAccess pvMB Com
|
||||
|
||||
TESTPROD_HOST += testChannelAccess
|
||||
testChannelAccess_SRCS = testChannelAccess channelAccessIFTest
|
||||
testChannelAccess_LIBS += pvData pvAccess pvMB Com
|
||||
#TESTS += testChannelAccess
|
||||
|
||||
PROD_HOST += pvget
|
||||
pvget_SRCS += pvget.cpp
|
||||
pvget_LIBS += pvData pvAccess pvMB Com
|
||||
@@ -70,6 +75,8 @@ PROD_HOST += rpcServiceExample
|
||||
rpcServiceExample_SRCS += rpcServiceExample.cpp
|
||||
rpcServiceExample_LIBS += pvData pvAccess pvMB Com
|
||||
|
||||
TESTSCRIPTS_HOST += $(TESTS:%=%.t)
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
#----------------------------------------
|
||||
# ADD RULES AFTER THIS LINE
|
||||
|
||||
2027
testApp/remote/channelAccessIFTest.cpp
Executable file
2027
testApp/remote/channelAccessIFTest.cpp
Executable file
File diff suppressed because it is too large
Load Diff
151
testApp/remote/channelAccessIFTest.h
Executable file
151
testApp/remote/channelAccessIFTest.h
Executable file
@@ -0,0 +1,151 @@
|
||||
#ifndef CHANNELACCESSIFTEST_HPP
|
||||
#define CHANNELACCESSIFTEST_HPP
|
||||
|
||||
#include <pv/pvAccess.h>
|
||||
#include "syncTestRequesters.h"
|
||||
|
||||
|
||||
class ChannelAccessIFTest {
|
||||
|
||||
public:
|
||||
|
||||
int runAllTest();
|
||||
|
||||
~ChannelAccessIFTest() {}
|
||||
|
||||
protected:
|
||||
|
||||
static std::string TEST_COUNTER_CHANNEL_NAME;
|
||||
static std::string TEST_CHANNEL_NAME;
|
||||
static std::string TEST_VALUEONLY_CHANNEL_NAME;
|
||||
static std::string TEST_SUMRPC_CHANNEL_NAME;
|
||||
static std::string TEST_ARRAY_CHANNEL_NAME;
|
||||
|
||||
|
||||
virtual ChannelProvider::shared_pointer getChannelProvider() = 0;
|
||||
virtual long getTimeoutSec() = 0;
|
||||
virtual bool isLocal() = 0;
|
||||
|
||||
|
||||
Channel::shared_pointer createChannel(std::string channelName, bool debug = true );
|
||||
|
||||
|
||||
Channel::shared_pointer syncCreateChannel(std::string channelName, bool debug = true );
|
||||
|
||||
|
||||
SyncChannelGetRequesterImpl::shared_pointer syncCreateChannelGet(
|
||||
Channel::shared_pointer const & channel, std::string const & request, bool debug = true );
|
||||
|
||||
|
||||
SyncChannelPutRequesterImpl::shared_pointer syncCreateChannelPut(
|
||||
Channel::shared_pointer const & channel, std::string const & request, bool debug = true );
|
||||
|
||||
|
||||
SyncChannelPutGetRequesterImpl::shared_pointer syncCreateChannelPutGet(
|
||||
Channel::shared_pointer const & channel, std::string const & request, bool debug = true );
|
||||
|
||||
|
||||
SyncChannelRPCRequesterImpl::shared_pointer syncCreateChannelRPC(
|
||||
Channel::shared_pointer const & channel, bool debug = true);
|
||||
|
||||
|
||||
SyncMonitorRequesterImpl::shared_pointer syncCreateChannelMonitor(
|
||||
Channel::shared_pointer const & channel, std::string const & request, bool debug = true);
|
||||
|
||||
SyncChannelArrayRequesterImpl::shared_pointer syncCreateChannelArray(
|
||||
Channel::shared_pointer const & channel, PVStructure::shared_pointer pvRequest, bool debug = true);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void test_implementation();
|
||||
|
||||
void test_providerName();
|
||||
|
||||
void test_createEmptyChannel();
|
||||
|
||||
void test_createChannelWithInvalidPriority();
|
||||
|
||||
void test_createChannel();
|
||||
|
||||
void test_recreateChannelOnDestroyedProvider();
|
||||
|
||||
void test_findEmptyChannel();
|
||||
|
||||
void test_findChannel();
|
||||
|
||||
void test_channel();
|
||||
|
||||
void test_channelGetWithInvalidChannelAndRequester();
|
||||
|
||||
void test_channelGetNoProcess();
|
||||
|
||||
void test_channelGetIntProcess();
|
||||
|
||||
void test_channelGetNotYetConnected();
|
||||
|
||||
void test_channelGetIntProcessInternal(Channel::shared_pointer channel, std::string const & testMethodName);
|
||||
|
||||
void test_channelGetTestNoConnection();
|
||||
|
||||
void test_channelPutWithInvalidChannelAndRequester();
|
||||
|
||||
void test_channelPutNoProcess();
|
||||
|
||||
void test_channelPutIntProcess();
|
||||
|
||||
void test_channelPutNotYetConnected();
|
||||
|
||||
void test_channelPutIntProcessInternal(Channel::shared_pointer channel, std::string const & testMethodName);
|
||||
|
||||
void test_channelPutTestNoConnection();
|
||||
|
||||
void test_channelGetFieldAll();
|
||||
|
||||
void test_channelGetFieldValue();
|
||||
|
||||
void test_channelGetFieldInvalid();
|
||||
|
||||
void test_channelProcess();
|
||||
|
||||
void test_channelProcesstWithInvalidRequesterAndRequest();
|
||||
|
||||
void test_channelProcessNoConnection();
|
||||
|
||||
void test_channelPutGetWithInvalidRequesterAndRequest();
|
||||
|
||||
void test_channelPutGetNoProcess_putGet();
|
||||
|
||||
void test_channelPutGetNoProcess_getPut();
|
||||
|
||||
void test_channelPutGetNoProcess_getGet();
|
||||
|
||||
void test_channelPutGetNoProcess_destroy();
|
||||
|
||||
void test_channelPutGetIntProcess();
|
||||
|
||||
void test_channelRPC();
|
||||
|
||||
void test_channelRPC_destroy();
|
||||
|
||||
void test_channelRPCWithInvalidRequesterAndRequest();
|
||||
|
||||
void test_channelMonitorWithInvalidRequesterAndRequest();
|
||||
|
||||
void test_channelMonitor(int queueSize);
|
||||
|
||||
void test_channelArray();
|
||||
|
||||
void test_channelArray_destroy();
|
||||
|
||||
void test_stressConnectDisconnect();
|
||||
|
||||
void test_stressConnectGetDisconnect();
|
||||
|
||||
void test_stressMonitorAndProcess();
|
||||
|
||||
PVStructure::shared_pointer createSumArgumentStructure(int a, int b);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
1323
testApp/remote/syncTestRequesters.h
Executable file
1323
testApp/remote/syncTestRequesters.h
Executable file
File diff suppressed because it is too large
Load Diff
89
testApp/remote/testChannelAccess.cpp
Executable file
89
testApp/remote/testChannelAccess.cpp
Executable file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* testChannelAccess.cpp
|
||||
*/
|
||||
#define TESTSERVERNOMAIN
|
||||
|
||||
#include <epicsExit.h>
|
||||
#include <epicsUnitTest.h>
|
||||
#include <testMain.h>
|
||||
|
||||
#include <pv/serverContext.h>
|
||||
#include <pv/clientFactory.h>
|
||||
#include <pv/clientContextImpl.h>
|
||||
|
||||
#include "channelAccessIFTest.h"
|
||||
|
||||
#include "testServer.cpp"
|
||||
|
||||
|
||||
class ServerContextAction : public Runnable {
|
||||
|
||||
public:
|
||||
|
||||
ServerContextAction():
|
||||
m_serverThread(){}
|
||||
|
||||
|
||||
virtual void run()
|
||||
{
|
||||
testServer(0);
|
||||
}
|
||||
|
||||
|
||||
void stop() {
|
||||
testServerShutdown();
|
||||
}
|
||||
|
||||
|
||||
void start() {
|
||||
m_serverThread.reset(new epics::pvData::Thread("pvAccess", highPriority, this));
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
auto_ptr<epics::pvData::Thread> m_serverThread;
|
||||
};
|
||||
|
||||
|
||||
class ChannelAccessIFRemoteTest: public ChannelAccessIFTest {
|
||||
|
||||
public:
|
||||
|
||||
ChannelAccessIFRemoteTest(): m_serverContextAction()
|
||||
{
|
||||
m_serverContextAction.start();
|
||||
ClientFactory::start();
|
||||
}
|
||||
|
||||
|
||||
virtual ChannelProvider::shared_pointer getChannelProvider() {
|
||||
return getChannelAccess()->getProvider(
|
||||
ClientContextImpl::PROVIDER_NAME);
|
||||
}
|
||||
|
||||
|
||||
virtual long getTimeoutSec() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
|
||||
virtual bool isLocal() { return false;}
|
||||
|
||||
|
||||
~ChannelAccessIFRemoteTest() {
|
||||
m_serverContextAction.stop();
|
||||
ClientFactory::stop();
|
||||
structureChangedListeners.clear();
|
||||
structureStore.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
ServerContextAction m_serverContextAction;
|
||||
};
|
||||
|
||||
|
||||
MAIN(testChannelProvider)
|
||||
{
|
||||
ChannelAccessIFRemoteTest caRemoteTest;
|
||||
return caRemoteTest.runAllTest();
|
||||
}
|
||||
@@ -1279,6 +1279,25 @@ public:
|
||||
m_channelRPCRequester->requestDone(Status::Ok, pvArgument);
|
||||
}
|
||||
}
|
||||
else if (m_channelName == "testSum") {
|
||||
|
||||
int a = pvArgument->getIntField("a")->get();
|
||||
int b = pvArgument->getIntField("b")->get();
|
||||
|
||||
FieldCreatePtr fieldCreate = getFieldCreate();
|
||||
|
||||
StringArray fieldNames;
|
||||
fieldNames.push_back("c");
|
||||
FieldConstPtrArray fields;
|
||||
fields.push_back(fieldCreate->createScalar(pvInt));
|
||||
StructureConstPtr resultStructure = fieldCreate->createStructure(fieldNames, fields);
|
||||
|
||||
PVStructure::shared_pointer result = getPVDataCreate()->createPVStructure(resultStructure);
|
||||
result->getIntField("c")->put(a+b);
|
||||
|
||||
m_channelRPCRequester->requestDone(Status::Ok, result);
|
||||
|
||||
}
|
||||
else if (m_channelName.find("testServerShutdown") == 0)
|
||||
{
|
||||
PVStructure::shared_pointer nullPtr;
|
||||
@@ -1475,9 +1494,17 @@ public:
|
||||
|
||||
virtual void setLength(bool lastRequest, int length, int capacity)
|
||||
{
|
||||
m_pvStructureArray->setCapacity(capacity);
|
||||
m_pvStructureArray->setLength(length);
|
||||
if (capacity > 0) {
|
||||
m_pvArray->setCapacity(capacity);
|
||||
}
|
||||
|
||||
if (length > 0) {
|
||||
m_pvArray->setLength(length);
|
||||
}
|
||||
|
||||
m_channelArrayRequester->setLengthDone(Status::Ok);
|
||||
|
||||
cout << "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" << endl;
|
||||
if (lastRequest)
|
||||
destroy();
|
||||
}
|
||||
@@ -2049,19 +2076,19 @@ public:
|
||||
process = c->createChannelProcess(cpr, PVStructure::shared_pointer());
|
||||
m_scan1Hz.toProcess.push_back(process);
|
||||
|
||||
m_scan1HzThread.reset(new Thread("process1hz", highPriority, &m_scan1Hz));
|
||||
m_scan10HzThread.reset(new Thread("process10hz", highPriority, &m_scan10Hz));
|
||||
m_scan1HzThread.reset(new epics::pvData::Thread("process1hz", highPriority, &m_scan1Hz));
|
||||
m_scan10HzThread.reset(new epics::pvData::Thread("process10hz", highPriority, &m_scan10Hz));
|
||||
|
||||
m_adcChannel = MockChannel::create(chProviderPtr, cr, "testADC", "local");
|
||||
m_adcAction.name = "testADC";
|
||||
m_adcAction.adcMatrix = static_pointer_cast<MockChannel>(m_adcChannel)->m_pvStructure;
|
||||
m_adcAction.adcSim = createSimADC("testADC");
|
||||
m_adcThread.reset(new Thread("adcThread", highPriority, &m_adcAction));
|
||||
m_adcThread.reset(new epics::pvData::Thread("adcThread", highPriority, &m_adcAction));
|
||||
|
||||
m_mpChannel = MockChannel::create(chProviderPtr, cr, "testMP", "local");
|
||||
m_imgAction.name = "testMP";
|
||||
m_imgAction.pvImage = static_pointer_cast<MockChannel>(m_mpChannel)->m_pvStructure;
|
||||
m_imgThread.reset(new Thread("imgThread", highPriority, &m_imgAction));
|
||||
m_imgThread.reset(new epics::pvData::Thread("imgThread", highPriority, &m_imgAction));
|
||||
}
|
||||
|
||||
virtual epics::pvData::String getProviderName()
|
||||
@@ -2138,16 +2165,16 @@ private:
|
||||
Channel::shared_pointer m_mpChannel;
|
||||
|
||||
ProcessAction m_scan1Hz;
|
||||
auto_ptr<Thread> m_scan1HzThread;
|
||||
auto_ptr<epics::pvData::Thread> m_scan1HzThread;
|
||||
|
||||
ProcessAction m_scan10Hz;
|
||||
auto_ptr<Thread> m_scan10HzThread;
|
||||
auto_ptr<epics::pvData::Thread> m_scan10HzThread;
|
||||
|
||||
ADCAction m_adcAction;
|
||||
auto_ptr<Thread> m_adcThread;
|
||||
auto_ptr<epics::pvData::Thread> m_adcThread;
|
||||
|
||||
NTImageAction m_imgAction;
|
||||
auto_ptr<Thread> m_imgThread;
|
||||
auto_ptr<epics::pvData::Thread> m_imgThread;
|
||||
};
|
||||
|
||||
String MockServerChannelProvider::PROVIDER_NAME = "local";
|
||||
@@ -2226,6 +2253,7 @@ void usage (char *argv[])
|
||||
}
|
||||
|
||||
|
||||
#ifndef TESTSERVERNOMAIN
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -2286,3 +2314,4 @@ int main(int argc, char *argv[])
|
||||
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user