From de1478d7ba08646a08cd9d32f5ef69008ace3f01 Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Tue, 25 Nov 2014 10:43:07 +0100 Subject: [PATCH] Event test added --- pvDataCPP.files | 18 +++++++++++--- src/misc/event.cpp | 3 +-- src/misc/event.h | 1 - testApp/misc/Makefile | 5 ++++ testApp/misc/testEvent.cpp | 51 ++++++++++++++++++++++++++++++++++++++ testApp/pvDataAllTests.c | 2 ++ 6 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 testApp/misc/testEvent.cpp diff --git a/pvDataCPP.files b/pvDataCPP.files index 6ed0127..9fd16db 100644 --- a/pvDataCPP.files +++ b/pvDataCPP.files @@ -234,7 +234,6 @@ testApp/pv/testPVType.cpp testApp/pv/testStandardField.cpp testApp/pv/testStandardPVField.cpp src/factory/printer.cpp -configure/O.darwin-x86/Makefile configure/Makefile include/pv/alarm.h include/pv/bitSet.h @@ -349,7 +348,6 @@ src/monitor/monitor.cpp src/monitor/monitor.h src/monitor/monitorPlugin.cpp src/monitor/monitorPlugin.h -src/O.darwin-x86/Makefile src/property/alarm.cpp src/property/alarm.h src/property/control.h @@ -437,7 +435,6 @@ testApp/misc/testThread.cpp testApp/misc/testTimer.cpp testApp/misc/testTimeStamp.cpp testApp/misc/testTypeCast.cpp -testApp/O.darwin-x86/Makefile testApp/property/epicsRunPVDataTests.c testApp/property/Makefile testApp/property/testProperty.cpp @@ -489,3 +486,18 @@ testApp/pvDataAllTests.c testApp/rtemsConfig.c testApp/rtemsNetworking.h testApp/rtemsTestHarness.c +testApp/misc/Makefile +testApp/misc/testBaseException.cpp +testApp/misc/testBitSet.cpp +testApp/misc/testByteBuffer.cpp +testApp/misc/testByteOrder.cpp +testApp/misc/testEvent.cpp +testApp/misc/testMessageQueue.cpp +testApp/misc/testOverrunBitSet.cpp +testApp/misc/testQueue.cpp +testApp/misc/testSerialization.cpp +testApp/misc/testSharedVector.cpp +testApp/misc/testThread.cpp +testApp/misc/testTimer.cpp +testApp/misc/testTimeStamp.cpp +testApp/misc/testTypeCast.cpp diff --git a/src/misc/event.cpp b/src/misc/event.cpp index 1a898ce..d10963b 100644 --- a/src/misc/event.cpp +++ b/src/misc/event.cpp @@ -38,8 +38,7 @@ Event::~Event() { Event::Event(bool full) -: id(epicsEventCreate(full?epicsEventFull : epicsEventEmpty)), - alreadyOn("already on list") +: id(epicsEventCreate(full?epicsEventFull : epicsEventEmpty)) { } diff --git a/src/misc/event.h b/src/misc/event.h index 2517662..027954c 100644 --- a/src/misc/event.h +++ b/src/misc/event.h @@ -46,7 +46,6 @@ public: bool tryWait (); /* false if empty */ private: epicsEventId id; - std::string alreadyOn; }; }} diff --git a/testApp/misc/Makefile b/testApp/misc/Makefile index 06b95ed..8cf1ef6 100644 --- a/testApp/misc/Makefile +++ b/testApp/misc/Makefile @@ -7,6 +7,11 @@ testThread_SRCS += testThread.cpp testHarness_SRCS += testThread.cpp TESTS += testThread +TESTPROD_HOST += testEvent +testEvent_SRCS += testEvent.cpp +testHarness_SRCS += testEvent.cpp +TESTS += testEvent + TESTPROD_HOST += testTimer testTimer_SRCS += testTimer.cpp testHarness_SRCS += testTimer.cpp diff --git a/testApp/misc/testEvent.cpp b/testApp/misc/testEvent.cpp new file mode 100644 index 0000000..2ab61b9 --- /dev/null +++ b/testApp/misc/testEvent.cpp @@ -0,0 +1,51 @@ +/** + * Copyright - See the COPYRIGHT that is included with this distribution. + * EPICS pvData is distributed subject to a Software License Agreement found + * in file LICENSE that is included with this distribution. + */ + +#include +#include + +#include + +using namespace epics::pvData; + +static void testBasicEvent() +{ + testDiag("testBasicEvent"); + + Event e; + + // 0 signals, 2 waits + testOk1(!e.tryWait()); + testOk1(!e.tryWait()); + + // signal, wait, signal, wait + e.signal(); + testOk1(e.tryWait()); + e.signal(); + testOk1(e.tryWait()); + + // 1 signal, 2 waits + e.signal(); + testOk1(e.tryWait()); + testOk1(!e.tryWait()); + + // 2 signals, 2 waits + e.signal(); + e.signal(); + testOk1(e.tryWait()); + testOk1(!e.tryWait()); + + // 0 signals, 1 wait + testOk1(!e.tryWait()); +} + +MAIN(testEvent) +{ + testPlan(9); + testBasicEvent(); + return testDone(); +} + diff --git a/testApp/pvDataAllTests.c b/testApp/pvDataAllTests.c index 5868c90..00ec522 100644 --- a/testApp/pvDataAllTests.c +++ b/testApp/pvDataAllTests.c @@ -23,6 +23,7 @@ int testQueue(void); int testSerialization(void); int testSharedVector(void); int testThread(void); +int testEvent(void); int testTimeStamp(void); int testTimer(void); int testTypeCast(void); @@ -72,6 +73,7 @@ void pvDataAllTests(void) runTest(testSerialization); runTest(testSharedVector); runTest(testThread); + runTest(testEvent); runTest(testTimeStamp); runTest(testTimer); runTest(testTypeCast);