26 ->addNestedStructure(
"record")
27 ->addNestedStructure(
"_options")
34 ret->getSubFieldT<
pvd::PVScalar>(
"record._options.queueSize")->putFrom<pvd::int32>(bsize);
40 TestProvider::shared_pointer upstream;
41 TestPV::shared_pointer test1;
44 GWServerChannelProvider::shared_pointer gateway;
46 TestChannelRequester::shared_pointer client_req;
47 pva::Channel::shared_pointer
client;
56 ,test1_x(test1->value,
"x")
57 ,test1_y(test1->value,
"y")
60 ,
client(gateway->createChannel(
"test1", client_req))
64 testAbort(
"channel \"test1\" not connected");
77 testDiag(
"Push the initial event through from upstream to downstream");
80 pvd::Monitor::shared_pointer mon(client->createMonitor(mreq, makeRequest(2)));
81 if(!mon)
testAbort(
"Failed to create monitor");
84 testOk1(mon->start().isSuccess());
94 if(elem) mon->release(elem);
106 testDiag(
"Test two downstream monitors sharing the same upstream");
109 pvd::Monitor::shared_pointer mon(client->createMonitor(mreq, makeRequest(2)));
110 if(!mon)
testAbort(
"Failed to create monitor");
114 pvd::Monitor::shared_pointer mon2(client->createMonitor(mreq2, makeRequest(2)));
115 if(!mon2)
testAbort(
"Failed to create monitor2");
119 testOk1(mon->start().isSuccess());
120 testOk1(mon2->start().isSuccess());
121 upstream->dispatch();
136 if(elem) mon->release(elem);
137 if(elem2) mon2->release(elem2);
142 testDiag(
"explicitly push an update");
147 test1->post(changed);
150 elem2 = mon2->poll();
154 if(elem)
testDiag(
"elem changed '%s' overflow '%s'",
toString(*elem->changedBitSet).c_str(),
toString(*elem->overrunBitSet).c_str());
157 if(elem2)
testDiag(
"elem2 changed '%s' overflow '%s'",
toString(*elem2->changedBitSet).c_str(),
toString(*elem2->overrunBitSet).c_str());
161 if(elem) mon->release(elem);
162 if(elem2) mon2->release(elem2);
171 void test_ds_no_start()
173 testDiag(
"Test downstream monitor never start()s");
176 pvd::Monitor::shared_pointer mon(client->createMonitor(mreq, makeRequest(2)));
177 if(!mon)
testAbort(
"Failed to create monitor");
179 upstream->dispatch();
187 test1->post(changed,
false);
189 test1->post(changed,
false);
191 test1->post(changed,
false);
193 test1->post(changed);
200 void test_overflow_upstream()
202 testDiag(
"Check behavour when upstream monitor overflows (mostly transparent)");
205 pvd::Monitor::shared_pointer mon(client->createMonitor(mreq, makeRequest(2)));
206 if(!mon)
testAbort(
"Failed to create monitor");
209 testOk1(mon->start().isSuccess());
210 upstream->dispatch();
216 if(elem) mon->release(elem);
226 test1->post(changed,
false);
229 test1->post(changed,
false);
232 test1->post(changed,
false);
235 test1->post(changed);
242 testOk1(elem && elem->changedBitSet->nextSetBit(0)==1);
243 testOk1(elem && elem->changedBitSet->nextSetBit(2)==-1);
244 testOk1(elem && elem->overrunBitSet->nextSetBit(0)==-1);
246 if(elem) mon->release(elem);
252 testOk1(elem && elem->changedBitSet->nextSetBit(0)==1);
253 testOk1(elem && elem->changedBitSet->nextSetBit(2)==-1);
254 testOk1(elem && elem->overrunBitSet->nextSetBit(0)==-1);
256 if(elem) mon->release(elem);
262 testOk1(elem && elem->changedBitSet->nextSetBit(0)==1);
263 testOk1(elem && elem->changedBitSet->nextSetBit(2)==-1);
264 testOk1(elem && elem->overrunBitSet->nextSetBit(0)==1);
265 testOk1(elem && elem->overrunBitSet->nextSetBit(2)==-1);
267 if(elem) mon->release(elem);
274 void test_overflow_downstream()
276 testDiag(
"Check behavour when downstream monitor overflows");
279 pvd::Monitor::shared_pointer mon(client->createMonitor(mreq, makeRequest(2)));
280 if(!mon)
testAbort(
"Failed to create monitor");
283 testOk1(mon->start().isSuccess());
284 upstream->dispatch();
290 if(elem) mon->release(elem);
298 test1->post(changed);
300 test1->post(changed);
302 test1->post(changed);
304 test1->post(changed);
310 testOk1(elem && elem->changedBitSet->nextSetBit(0)==1);
311 testOk1(elem && elem->changedBitSet->nextSetBit(2)==-1);
312 testOk1(elem && elem->overrunBitSet->nextSetBit(0)==-1);
314 if(elem) mon->release(elem);
320 testOk1(elem && elem->changedBitSet->nextSetBit(0)==1);
321 testOk1(elem && elem->changedBitSet->nextSetBit(2)==-1);
322 testOk1(elem && elem->overrunBitSet->nextSetBit(0)==-1);
324 if(elem) mon->release(elem);
330 testOk1(elem && elem->changedBitSet->nextSetBit(0)==1);
331 testOk1(elem && elem->changedBitSet->nextSetBit(2)==-1);
332 testOk1(elem && elem->overrunBitSet->nextSetBit(0)==1);
333 testOk1(elem && elem->overrunBitSet->nextSetBit(2)==-1);
335 if(elem) mon->release(elem);
352 TEST_METHOD(TestMonitor, test_overflow_downstream);
356 #define TESTC(name) temp=epicsAtomicGetSizeT(&name::num_instances); ok &= temp==0; testDiag("num. live " #name " %u", (unsigned)temp) 363 testOk(ok,
"All instances free'd");
#define testOk1(cond)
Test result using condition as description.
PVScalar is the base class for each scalar field.
void testPlan(int plan)
Declare the test plan, required.
std::tr1::shared_ptr< const Structure > StructureConstPtr
int testDiag(const char *fmt,...)
epicsGuard< epicsMutex > Guard
#define TEST_METHOD(klass, method)
storage_t::arg_type get() const
void testAbort(const char *fmt,...)
int testDone(void)
Mark the end of testing.
FORCE_INLINE const FieldCreatePtr & getFieldCreate()
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Class that holds the data for each possible scalar type.
void testFail(const char *fmt,...)
std::tr1::shared_ptr< MonitorElement > MonitorElementPtr
std::string toString(const T &tbs)
BitSet & set(uint32 bitIndex)
#define testEqual(LHS, RHS)
int testOk(int pass, const char *fmt,...)
FORCE_INLINE const PVDataCreatePtr & getPVDataCreate()