diff --git a/pvDataCPP.files b/pvDataCPP.files index 10cd1dc..6ed0127 100644 --- a/pvDataCPP.files +++ b/pvDataCPP.files @@ -234,3 +234,258 @@ 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 +include/pv/bitSetUtil.h +include/pv/byteBuffer.h +include/pv/control.h +include/pv/convert.h +include/pv/createRequest.h +include/pv/current_function.h +include/pv/destroyable.h +include/pv/display.h +include/pv/epicsException.h +include/pv/event.h +include/pv/executor.h +include/pv/factory.h +include/pv/localStaticLock.h +include/pv/lock.h +include/pv/messageQueue.h +include/pv/monitor.h +include/pv/monitorPlugin.h +include/pv/noDefaultMethods.h +include/pv/printer.h +include/pv/pvAlarm.h +include/pv/pvControl.h +include/pv/pvCopy.h +include/pv/pvData.h +include/pv/pvDisplay.h +include/pv/pvEnumerated.h +include/pv/pvIntrospect.h +include/pv/pvSubArrayCopy.h +include/pv/pvTimeStamp.h +include/pv/pvType.h +include/pv/queue.h +include/pv/requester.h +include/pv/serialize.h +include/pv/serializeHelper.h +include/pv/sharedPtr.h +include/pv/sharedVector.h +include/pv/standardField.h +include/pv/standardPVField.h +include/pv/status.h +include/pv/templateMeta.h +include/pv/thread.h +include/pv/timeFunction.h +include/pv/timer.h +include/pv/timeStamp.h +include/pv/typeCast.h +src/copy/createRequest.cpp +src/copy/createRequest.h +src/copy/Makefile +src/copy/pvCopy.cpp +src/copy/pvCopy.h +src/factory/Compare.cpp +src/factory/Convert.cpp +src/factory/factory.h +src/factory/FieldCreateFactory.cpp +src/factory/Makefile +src/factory/printer.cpp +src/factory/PVArray.cpp +src/factory/PVDataCreateFactory.cpp +src/factory/PVField.cpp +src/factory/PVScalar.cpp +src/factory/PVScalarArray.cpp +src/factory/PVStructure.cpp +src/factory/PVStructureArray.cpp +src/factory/pvSubArrayCopy.cpp +src/factory/PVUnion.cpp +src/factory/PVUnionArray.cpp +src/factory/StandardField.cpp +src/factory/StandardPVField.cpp +src/factory/TypeFunc.cpp +src/misc/bitSet.cpp +src/misc/bitSet.h +src/misc/byteBuffer.cpp +src/misc/byteBuffer.h +src/misc/current_function.h +src/misc/destroyable.h +src/misc/epicsException.cpp +src/misc/epicsException.h +src/misc/event.cpp +src/misc/event.h +src/misc/executor.cpp +src/misc/executor.h +src/misc/localStaticLock.cpp +src/misc/localStaticLock.h +src/misc/lock.h +src/misc/Makefile +src/misc/messageQueue.cpp +src/misc/messageQueue.h +src/misc/noDefaultMethods.h +src/misc/parseToPOD.cpp +src/misc/queue.h +src/misc/requester.cpp +src/misc/requester.h +src/misc/serialize.h +src/misc/serializeHelper.cpp +src/misc/serializeHelper.h +src/misc/sharedPtr.h +src/misc/sharedVector.h +src/misc/status.cpp +src/misc/status.h +src/misc/templateMeta.h +src/misc/thread.h +src/misc/timeFunction.cpp +src/misc/timeFunction.h +src/misc/timer.cpp +src/misc/timer.h +src/misc/typeCast.cpp +src/misc/typeCast.h +src/monitor/Makefile +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 +src/property/display.h +src/property/Makefile +src/property/pvAlarm.cpp +src/property/pvAlarm.h +src/property/pvControl.cpp +src/property/pvControl.h +src/property/pvDisplay.cpp +src/property/pvDisplay.h +src/property/pvEnumerated.cpp +src/property/pvEnumerated.h +src/property/pvTimeStamp.cpp +src/property/pvTimeStamp.h +src/property/timeStamp.cpp +src/property/timeStamp.h +src/pv/convert.h +src/pv/Makefile +src/pv/printer.h +src/pv/pvData.h +src/pv/pvIntrospect.h +src/pv/pvSubArrayCopy.h +src/pv/pvType.h +src/pv/standardField.h +src/pv/standardPVField.h +src/pvMisc/bitSetUtil.cpp +src/pvMisc/bitSetUtil.h +src/pvMisc/Makefile +src/Makefile +testApp/copy/epicsRunPVDataTests.c +testApp/copy/Makefile +testApp/copy/testCreateRequest.cpp +testApp/copy/testPVCopy.cpp +testApp/misc/epicsRunPVDataTests.c +testApp/misc/Makefile +testApp/misc/testBaseException.cpp +testApp/misc/testBitSet.cpp +testApp/misc/testByteBuffer.cpp +testApp/misc/testByteOrder.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 +testApp/property/epicsRunPVDataTests.c +testApp/property/Makefile +testApp/property/testProperty.cpp +testApp/pv/epicsRunPVDataTests.c +testApp/pv/Makefile +testApp/pv/testBitSetUtil.cpp +testApp/pv/testConvert.cpp +testApp/pv/testFieldBuilder.cpp +testApp/pv/testIntrospect.cpp +testApp/pv/testOperators.cpp +testApp/pv/testPVData.cpp +testApp/pv/testPVScalarArray.cpp +testApp/pv/testPVStructureArray.cpp +testApp/pv/testPVType.cpp +testApp/pv/testPVUnion.cpp +testApp/pv/testStandardField.cpp +testApp/pv/testStandardPVField.cpp +testApp/Makefile +Makefile +testApp/copy/epicsRunPVDataTests.c +testApp/copy/Makefile +testApp/copy/testCreateRequest.cpp +testApp/copy/testPVCopy.cpp +testApp/misc/epicsRunPVDataTests.c +testApp/misc/Makefile +testApp/misc/testBaseException.cpp +testApp/misc/testBitSet.cpp +testApp/misc/testByteBuffer.cpp +testApp/misc/testByteOrder.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 +testApp/O.darwin-x86/Makefile +testApp/property/epicsRunPVDataTests.c +testApp/property/Makefile +testApp/property/testProperty.cpp +testApp/pv/epicsRunPVDataTests.c +testApp/pv/Makefile +testApp/pv/testBitSetUtil.cpp +testApp/pv/testConvert.cpp +testApp/pv/testFieldBuilder.cpp +testApp/pv/testIntrospect.cpp +testApp/pv/testOperators.cpp +testApp/pv/testPVData.cpp +testApp/pv/testPVScalarArray.cpp +testApp/pv/testPVStructureArray.cpp +testApp/pv/testPVType.cpp +testApp/pv/testPVUnion.cpp +testApp/pv/testStandardField.cpp +testApp/pv/testStandardPVField.cpp +testApp/Makefile +testApp/pvDataAllTests.c +testApp/copy/testCreateRequest.cpp +testApp/copy/testPVCopy.cpp +testApp/misc/testBaseException.cpp +testApp/misc/testBitSet.cpp +testApp/misc/testByteBuffer.cpp +testApp/misc/testByteOrder.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 +testApp/property/testProperty.cpp +testApp/pv/testBitSetUtil.cpp +testApp/pv/testConvert.cpp +testApp/pv/testFieldBuilder.cpp +testApp/pv/testIntrospect.cpp +testApp/pv/testOperators.cpp +testApp/pv/testPVData.cpp +testApp/pv/testPVScalarArray.cpp +testApp/pv/testPVStructureArray.cpp +testApp/pv/testPVType.cpp +testApp/pv/testPVUnion.cpp +testApp/pv/testStandardField.cpp +testApp/pv/testStandardPVField.cpp +testApp/pvDataAllTests.c +testApp/rtemsConfig.c +testApp/rtemsNetworking.h +testApp/rtemsTestHarness.c diff --git a/pvDataCPP.includes b/pvDataCPP.includes index 56eba21..766a41f 100644 --- a/pvDataCPP.includes +++ b/pvDataCPP.includes @@ -3,4 +3,9 @@ /home/msekoranja/epicsV4/pvDataCPP/pvDataApp/monitor /home/msekoranja/epicsV4/pvDataCPP/pvDataApp/property /home/msekoranja/epicsV4/pvDataCPP/pvDataApp/pv -/home/msekoranja/epicsV4/pvDataCPP/pvDataApp/pvMisc \ No newline at end of file +/home/msekoranja/epicsV4/pvDataCPP/pvDataApp/pvMisc +testApp/pv +testApp/copy +testApp/misc +testApp +testApp/property diff --git a/src/factory/Compare.cpp b/src/factory/Compare.cpp index 6d902df..06b4e27 100644 --- a/src/factory/Compare.cpp +++ b/src/factory/Compare.cpp @@ -251,7 +251,13 @@ bool compareField(const PVStructureArray* left, const PVStructureArray* right) lit!=lend; ++lit, ++rit) { - if(**lit != **rit) + // element can be null + if (!(*lit) || !(*rit)) + { + if (*lit || *rit) + return false; + } + else if (**lit != **rit) return false; } return true; @@ -304,7 +310,13 @@ bool compareField(const PVUnionArray* left, const PVUnionArray* right) lit!=lend; ++lit, ++rit) { - if(**lit != **rit) + // element can be null + if (!(*lit) || !(*rit)) + { + if (*lit || *rit) + return false; + } + else if (**lit != **rit) return false; } return true; diff --git a/src/factory/Convert.cpp b/src/factory/Convert.cpp index ce00129..15a700a 100644 --- a/src/factory/Convert.cpp +++ b/src/factory/Convert.cpp @@ -462,17 +462,14 @@ void Convert::copyUnion(PVUnionPtr const & from, PVUnionPtr const & to) PVFieldPtr fromValue = from->get(); if (from->getUnion()->isVariant()) { - if (fromValue.get() == 0) - to->set(PVFieldPtr()); - else - to->set(getPVDataCreate()->createPVField(fromValue)); // clone value // TODO cache getPVDataCreate() + to->set(from->get()); } else { if (fromValue.get() == 0) to->select(PVUnion::UNDEFINED_INDEX); else - to->set(from->getSelectedFieldName(),from->get()); + to->set(from->getSelectedIndex(),from->get()); } } diff --git a/src/factory/PVStructureArray.cpp b/src/factory/PVStructureArray.cpp index 29e4663..1536ad5 100644 --- a/src/factory/PVStructureArray.cpp +++ b/src/factory/PVStructureArray.cpp @@ -232,8 +232,13 @@ std::ostream& PVStructureArray::dumpValue(std::ostream& o) const std::ostream& PVStructureArray::dumpValue(std::ostream& o, std::size_t index) const { const_svector temp(view()); - if(index>uint64_t is buggy, we use out own implementation */ +static +unsigned long long strtoull(const char *nptr, char **endptr, int base) +{ + const char *s = nptr; + unsigned long long acc; + int c; + unsigned long long cutoff; + int neg = 0, any, cutlim; + + do + c = *s++; + while (isspace(c)); + if (c == '-') + { + neg = 1; + c = *s++; + } + else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) + { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + cutoff = (unsigned long long) UINT64_MAX / (unsigned long long) base; + cutlim = (unsigned long long) UINT64_MAX % (unsigned long long) base; + + for (acc = 0, any = 0;; c = *s++) + { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) + any = -1; + else + { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) + { + acc = UINT64_MAX; + errno = ERANGE; + } + else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = any ? (char *) s - 1 : (char *) nptr; + return (acc); +} +#else static unsigned long long strtoull(const char *ptr, char ** endp, int base) { @@ -350,7 +415,7 @@ noconvert: *endp = (char*)ptr; return 0; } - +#endif #endif /* do we need long long? */ @@ -486,6 +551,26 @@ void parseToPOD(const string& in, float *out) { void parseToPOD(const string& in, double *out) { int err = epicsParseDouble(in.c_str(), out, NULL); if(err) handleParseError(err); +#if defined(__vxworks) + /* vxWorks strtod returns [-]epicsINF when it should return ERANGE error + * if [-]epicsINF is returned and first char is a digit then translate this into ERANGE error + */ + else if (*out == epicsINF || *out == -epicsINF) { + const char* s = in.c_str(); + int c; + + /* skip spaces and the sign */ + do { + c = *s++; + } while (isspace(c)); + + if (c == '-' || c == '+') + c = *s++; + + if (isdigit(c)) + handleParseError(S_stdlib_overflow); + } +#endif } }}} diff --git a/src/pv/pvIntrospect.h b/src/pv/pvIntrospect.h index 1dab6d9..4a966ad 100644 --- a/src/pv/pvIntrospect.h +++ b/src/pv/pvIntrospect.h @@ -32,11 +32,7 @@ struct indent_level indent_level(long l) : level(l) {} }; -inline long& indent_value(std::ios_base& ios) -{ - static int indent_index = std::ios_base::xalloc(); - return ios.iword(indent_index); -} +epicsShareExtern long& indent_value(std::ios_base& ios); epicsShareExtern std::ostream& operator<<(std::ostream& os, indent_level const& indent); @@ -1153,7 +1149,7 @@ epicsShareExtern FieldCreatePtr getFieldCreate(); * value (eg -1). */ template -struct ScalarTypeID { enum {value=-1}; }; +struct ScalarTypeID {}; /** * Static mapping from ScalarType enum to value type. diff --git a/src/pv/pvType.h b/src/pv/pvType.h index 506b835..89ec667 100644 --- a/src/pv/pvType.h +++ b/src/pv/pvType.h @@ -29,7 +29,7 @@ typedef int intptr_t; typedef unsigned int uintptr_t; #ifndef INT64_MAX #define INT64_MAX (0x7fffffffffffffffLL) -#define UINT64_MAX (0xffffffffffffffffLL) +#define UINT64_MAX (0xffffffffffffffffULL) #endif #else #include diff --git a/testApp/Makefile b/testApp/Makefile index 6d49e69..7e5b083 100644 --- a/testApp/Makefile +++ b/testApp/Makefile @@ -1,8 +1,31 @@ +# Makefile for the pvData tests + TOP = .. include $(TOP)/configure/CONFIG -DIRS += misc -DIRS += pv -DIRS += property -DIRS += copy -include $(TOP)/configure/RULES_DIRS + +PVDATA_TEST = $(TOP)/testApp + +PROD_LIBS += pvData Com + +include $(PVDATA_TEST)/misc/Makefile +include $(PVDATA_TEST)/pv/Makefile +include $(PVDATA_TEST)/property/Makefile +include $(PVDATA_TEST)/copy/Makefile + +# The testHarness runs all the test programs in a known working order. +testHarness_SRCS += pvDataAllTests.c + +PROD_vxWorks = vxTestHarness +vxTestHarness_SRCS += $(testHarness_SRCS) +TESTSPEC_vxWorks = vxTestHarness.$(MUNCH_SUFFIX); pvDataAllTests + +PROD_RTEMS += rtemsTestHarness +rtemsTestHarness_SRCS += rtemsTestHarness.c rtemsConfig.c +rtemsTestHarness_SRCS += $(testHarness_SRCS) +TESTSPEC_RTEMS = rtemsTestHarness.$(MUNCH_SUFFIX); pvDataAllTests + +TESTSCRIPTS_HOST += $(TESTS:%=%.t) + +include $(TOP)/configure/RULES + diff --git a/testApp/copy/Makefile b/testApp/copy/Makefile index dab7623..bee2227 100644 --- a/testApp/copy/Makefile +++ b/testApp/copy/Makefile @@ -1,22 +1,13 @@ -TOP=../.. +# This is a Makefile fragment, see ../Makefile -include $(TOP)/configure/CONFIG +SRC_DIRS += $(PVDATA_TEST)/copy -PROD_HOST += testCreateRequest +TESTPROD_HOST += testCreateRequest testCreateRequest_SRCS = testCreateRequest.cpp -testCreateRequest_LIBS = pvData Com +testHarness_SRCS += testCreateRequest.cpp TESTS += testCreateRequest -PROD_HOST += testPVCopy +TESTPROD_HOST += testPVCopy testPVCopy_SRCS += testPVCopy.cpp -testPVCopy_LIBS += pvData Com +testHarness_SRCS += testPVCopy.cpp TESTS += testPVCopy - -TESTSCRIPTS_HOST += $(TESTS:%=%.t) - - - -include $(TOP)/configure/RULES -#---------------------------------------- -# ADD RULES AFTER THIS LINE - diff --git a/testApp/copy/testCreateRequest.cpp b/testApp/copy/testCreateRequest.cpp index e957fc1..3c0db1c 100644 --- a/testApp/copy/testCreateRequest.cpp +++ b/testApp/copy/testCreateRequest.cpp @@ -20,7 +20,7 @@ using std::endl; static bool debug = false; -static void testCreateRequest() { +static void testCreateRequestInternal() { printf("testCreateRequest... \n"); CreateRequest::shared_pointer createRequest = CreateRequest::create(); PVStringPtr pvString; @@ -307,7 +307,7 @@ static void testCreateRequest() { MAIN(testCreateRequest) { testPlan(117); - testCreateRequest(); + testCreateRequestInternal(); return testDone(); } diff --git a/testApp/misc/Makefile b/testApp/misc/Makefile index dbf99ad..06b95ed 100644 --- a/testApp/misc/Makefile +++ b/testApp/misc/Makefile @@ -1,63 +1,66 @@ -TOP=../.. +# This is a Makefile fragment, see ../Makefile -include $(TOP)/configure/CONFIG +SRC_DIRS += $(PVDATA_TEST)/misc -PROD_LIBS += pvData Com - -PROD_HOST += testThread +TESTPROD_HOST += testThread testThread_SRCS += testThread.cpp +testHarness_SRCS += testThread.cpp TESTS += testThread -PROD_HOST += testTimer +TESTPROD_HOST += testTimer testTimer_SRCS += testTimer.cpp +testHarness_SRCS += testTimer.cpp TESTS += testTimer -PROD_HOST += testBitSet +TESTPROD_HOST += testBitSet testBitSet_SRCS += testBitSet.cpp +testHarness_SRCS += testBitSet.cpp TESTS += testBitSet -PROD_HOST += testOverrunBitSet +TESTPROD_HOST += testOverrunBitSet testOverrunBitSet_SRCS += testOverrunBitSet.cpp +testHarness_SRCS += testOverrunBitSet.cpp TESTS += testOverrunBitSet -PROD_HOST += testByteOrder +TESTPROD_HOST += testByteOrder testByteOrder_SRCS += testByteOrder.cpp -PROD_HOST += testByteBuffer +TESTPROD_HOST += testByteBuffer testByteBuffer_SRCS += testByteBuffer.cpp +testHarness_SRCS += testByteBuffer.cpp TESTS += testByteBuffer -PROD_HOST += testBaseException +TESTPROD_HOST += testBaseException testBaseException_SRCS += testBaseException.cpp +testHarness_SRCS += testBaseException.cpp TESTS += testBaseException -PROD_HOST += testSharedVector +TESTPROD_HOST += testSharedVector testSharedVector_SRCS += testSharedVector.cpp +testHarness_SRCS += testSharedVector.cpp TESTS += testSharedVector -PROD_HOST += testSerialization +TESTPROD_HOST += testSerialization testSerialization_SRCS += testSerialization.cpp +testHarness_SRCS += testSerialization.cpp TESTS += testSerialization -PROD_HOST += testTimeStamp +TESTPROD_HOST += testTimeStamp testTimeStamp_SRCS += testTimeStamp.cpp +testHarness_SRCS += testTimeStamp.cpp TESTS += testTimeStamp -PROD_HOST += testQueue +TESTPROD_HOST += testQueue testQueue_SRCS += testQueue.cpp +testHarness_SRCS += testQueue.cpp TESTS += testQueue -PROD_HOST += testMessageQueue +TESTPROD_HOST += testMessageQueue testMessageQueue_SRCS += testMessageQueue.cpp +testHarness_SRCS += testMessageQueue.cpp TESTS += testMessageQueue -PROD_HOST += testTypeCast +TESTPROD_HOST += testTypeCast testTypeCast_SRCS += testTypeCast.cpp +testHarness_SRCS += testTypeCast.cpp TESTS += testTypeCast - -TESTSCRIPTS_HOST += $(TESTS:%=%.t) - -include $(TOP)/configure/RULES -#---------------------------------------- -# ADD RULES AFTER THIS LINE - diff --git a/testApp/misc/testBaseException.cpp b/testApp/misc/testBaseException.cpp index dad14d5..dcbf02c 100644 --- a/testApp/misc/testBaseException.cpp +++ b/testApp/misc/testBaseException.cpp @@ -42,7 +42,7 @@ void internalTestBaseException(int /*unused*/ = 0) } } -void testBaseException() { +void testBaseExceptionTest() { printf("testBaseException... "); try { @@ -86,7 +86,7 @@ MAIN(testBaseException) testPlan(2); testDiag("Tests base exception"); testLogicException(); - testBaseException(); + testBaseExceptionTest(); return testDone(); } diff --git a/testApp/misc/testByteOrder.cpp b/testApp/misc/testByteOrder.cpp index 123bfc3..57d7aa3 100644 --- a/testApp/misc/testByteOrder.cpp +++ b/testApp/misc/testByteOrder.cpp @@ -1,7 +1,8 @@ +#include #include #include -int main() +MAIN(testByteOrder) { printf("EPICS_BYTE_ORDER: %s\n", (EPICS_BYTE_ORDER == EPICS_ENDIAN_LITTLE) ? "little" : "big"); printf("EPICS_FLOAT_WORD_ORDER: %s\n", (EPICS_FLOAT_WORD_ORDER == EPICS_ENDIAN_LITTLE) ? "little" : "big"); diff --git a/testApp/misc/testOverrunBitSet.cpp b/testApp/misc/testOverrunBitSet.cpp index 0b8c778..0c0d560 100644 --- a/testApp/misc/testOverrunBitSet.cpp +++ b/testApp/misc/testOverrunBitSet.cpp @@ -132,7 +132,7 @@ void test() } -MAIN(testOverrunBitSet`) +MAIN(testOverrunBitSet) { testPlan(41); testDiag("Tests for changeBitSet and overrunBitSet"); diff --git a/testApp/misc/testSerialization.cpp b/testApp/misc/testSerialization.cpp index 7f97a00..8e619aa 100644 --- a/testApp/misc/testSerialization.cpp +++ b/testApp/misc/testSerialization.cpp @@ -716,7 +716,9 @@ void testArraySizeType() { serializationFieldTest(s); PVStructurePtr pvs = getPVDataCreate()->createPVStructure(s); - pvs->getSubField("fixedArray")->setLength(10); + PVDoubleArray::shared_pointer pvDA = pvs->getSubField("fixedArray"); + PVDoubleArray::svector vec(10, 42); + pvDA->replace(freeze(vec)); serializationTest(pvs); } @@ -790,7 +792,6 @@ MAIN(testSerialization) { delete control; delete flusher; - epicsExitCallAtExits(); return testDone(); } diff --git a/testApp/misc/testSharedVector.cpp b/testApp/misc/testSharedVector.cpp index fc7666e..5cc4455 100644 --- a/testApp/misc/testSharedVector.cpp +++ b/testApp/misc/testSharedVector.cpp @@ -19,11 +19,12 @@ #include "pv/sharedVector.h" using std::string; +using namespace epics::pvData; static void testEmpty() { testDiag("Test empty vector"); - epics::pvData::shared_vector empty, empty2; + epics::pvData::shared_vector empty, empty2; testOk1(empty.size()==0); testOk1(empty.empty()); @@ -42,7 +43,7 @@ static void testInternalAlloc() { testDiag("Test vector alloc w/ new[]"); - epics::pvData::shared_vector internal(5); + epics::pvData::shared_vector internal(5); testOk1(internal.size()==5); testOk1(!internal.empty()); @@ -57,7 +58,7 @@ static void testInternalAlloc() internal[2] = 42; testOk1(internal[2]==42); - epics::pvData::shared_vector internal2(15, 500); + epics::pvData::shared_vector internal2(15, 500); testOk1(internal2.size()==15); testOk1(internal2[1]==500); @@ -79,8 +80,8 @@ namespace { //Note: STL shared_ptr requires that deletors be copy constructable template struct callCounter { - std::tr1::shared_ptr count; - callCounter():count(new int){*count=0;} + std::tr1::shared_ptr count; + callCounter():count(new int32){*count=0;} callCounter(const callCounter& o):count(o.count) {}; callCounter& operator=(const callCounter& o){count=o.count;} void operator()(E){*count=1;} @@ -92,8 +93,8 @@ static void testExternalAlloc() testDiag("Test vector external alloc"); // Simulate a failed malloc() or similar - int *oops=0; - epics::pvData::shared_vector nullPtr(oops, 42, 100); + int32 *oops=0; + epics::pvData::shared_vector nullPtr(oops, 42, 100); testOk1(nullPtr.size()==0); testOk1(nullPtr.empty()); @@ -102,8 +103,8 @@ static void testExternalAlloc() testOk1(nullPtr.data()==NULL); - int *raw=new int[5]; - epics::pvData::shared_vector newData(raw, 1, 4); + int32 *raw=new int32[5]; + epics::pvData::shared_vector newData(raw, 1, 4); testOk1(newData.size()==4); testOk1(!newData.empty()); @@ -113,11 +114,11 @@ static void testExternalAlloc() testOk1(newData[0]==14); // Check use of custom deleter - int localVar[4] = {1,2,3,4}; - callCounter tracker; + int32 localVar[4] = {1,2,3,4}; + callCounter tracker; testOk1(*tracker.count==0); - epics::pvData::shared_vector locvar(localVar, + epics::pvData::shared_vector locvar(localVar, tracker, 0, 4); @@ -137,8 +138,8 @@ static void testShare() { testDiag("Test vector Sharing"); - epics::pvData::shared_vector one, two(15); - epics::pvData::shared_vector three(two); + epics::pvData::shared_vector one, two(15); + epics::pvData::shared_vector three(two); testOk1(one.unique()); testOk1(!two.unique()); @@ -199,22 +200,22 @@ static void testConst() { testDiag("Test constant vector"); - epics::pvData::shared_vector writable(15, 100); + epics::pvData::shared_vector writable(15, 100); - epics::pvData::shared_vector::reference wr = writable[0]; - epics::pvData::shared_vector::const_reference ror = writable[0]; + epics::pvData::shared_vector::reference wr = writable[0]; + epics::pvData::shared_vector::const_reference ror = writable[0]; testOk1(wr==ror); - int *compare = writable.data(); + int32 *compare = writable.data(); testOk1(writable.unique()); // can re-target container, but data is R/O - epics::pvData::shared_vector rodata(freeze(writable)); + epics::pvData::shared_vector rodata(freeze(writable)); - epics::pvData::shared_vector::reference wcr = rodata[0]; - epics::pvData::shared_vector::const_reference rocr = rodata[0]; + epics::pvData::shared_vector::reference wcr = rodata[0]; + epics::pvData::shared_vector::const_reference rocr = rodata[0]; testOk1(wcr==rocr); @@ -227,7 +228,7 @@ static void testConst() testOk1(rodata.data()==compare); - epics::pvData::shared_vector rodata2(rodata); + epics::pvData::shared_vector rodata2(rodata); testOk1(rodata.data()==rodata2.data()); @@ -240,9 +241,9 @@ static void testSlice() { testDiag("Test vector slicing"); - epics::pvData::shared_vector original(10, 100); + epics::pvData::shared_vector original(10, 100); - epics::pvData::shared_vector half1(original), half2(original), half2a(original); + epics::pvData::shared_vector half1(original), half2(original), half2a(original); half1.slice(0, 5); half2.slice(5, 5); @@ -290,9 +291,9 @@ static void testCapacity() { testDiag("Test vector capacity"); - epics::pvData::shared_vector vect(10, 100); + epics::pvData::shared_vector vect(10, 100); - int *peek = vect.dataPtr().get(); + int32 *peek = vect.dataPtr().get(); vect.slice(0, 5); @@ -330,7 +331,7 @@ static void testCapacity() static void testPush() { - epics::pvData::shared_vector vect; + epics::pvData::shared_vector vect; testDiag("Test push_back optimizations"); @@ -357,7 +358,7 @@ static void testVoid() { testDiag("Test vecter cast to/from void"); - epics::pvData::shared_vector typed(4); + epics::pvData::shared_vector typed(4); epics::pvData::shared_vector untyped2(epics::pvData::static_shared_vector_cast(typed)); @@ -366,7 +367,7 @@ static void testVoid() untyped2.slice(sizeof(int), 2*sizeof(int)); - typed = epics::pvData::static_shared_vector_cast(untyped2); + typed = epics::pvData::static_shared_vector_cast(untyped2); testOk1(typed.dataOffset()==1); testOk1(typed.size()==2); @@ -406,7 +407,7 @@ static void testVectorConvert() { testDiag("Test shared_vector_convert"); - epics::pvData::shared_vector ints(6, 42), moreints; + epics::pvData::shared_vector ints(6, 42), moreints; epics::pvData::shared_vector floats; epics::pvData::shared_vector strings; epics::pvData::shared_vector voids; @@ -414,7 +415,7 @@ static void testVectorConvert() testOk1(ints.unique()); // no-op convert. Just returns another reference - moreints = epics::pvData::shared_vector_convert(ints); + moreints = epics::pvData::shared_vector_convert(ints); testOk1(!ints.unique()); moreints.clear(); @@ -432,11 +433,12 @@ static void testVectorConvert() voids = epics::pvData::shared_vector_convert(ints); testOk1(!ints.unique()); - testOk1(voids.size()==ints.size()*sizeof(int)); + testOk1(voids.size()==ints.size()*sizeof(int32)); // convert from void uses shared_vector::original_type() - // to find that the actual type is 'int'. + // to find that the actual type is 'int32'. // returns a new vector + testOk1(voids.original_type()==epics::pvData::pvInt); strings = epics::pvData::shared_vector_convert(voids); voids.clear(); @@ -450,11 +452,11 @@ static void testWeak() { testDiag("Test weak_ptr counting"); - epics::pvData::shared_vector data(6); + epics::pvData::shared_vector data(6); testOk1(data.unique()); - std::tr1::shared_ptr pdata(data.dataPtr()); + std::tr1::shared_ptr pdata(data.dataPtr()); testOk1(!data.unique()); @@ -462,7 +464,7 @@ static void testWeak() testOk1(data.unique()); - std::tr1::weak_ptr wdata(data.dataPtr()); + std::tr1::weak_ptr wdata(data.dataPtr()); testOk1(data.unique()); // True, but I wish it wasn't!!! @@ -475,10 +477,10 @@ static void testICE() { testDiag("Test freeze and thaw"); - epics::pvData::shared_vector A(6, 42), C; - epics::pvData::shared_vector B, D; + epics::pvData::shared_vector A(6, 42), C; + epics::pvData::shared_vector B, D; - int *check = A.data(); + int32 *check = A.data(); // check freeze w/ unique reference @@ -537,11 +539,11 @@ static void testICE() MAIN(testSharedVector) { - testPlan(162); + testPlan(163); testDiag("Tests for shared_vector"); - testDiag("sizeof(shared_vector)=%lu", - (unsigned long)sizeof(epics::pvData::shared_vector)); + testDiag("sizeof(shared_vector)=%lu", + (unsigned long)sizeof(epics::pvData::shared_vector)); testEmpty(); testInternalAlloc(); diff --git a/testApp/misc/testTimeStamp.cpp b/testApp/misc/testTimeStamp.cpp index 0284724..c7bfd53 100644 --- a/testApp/misc/testTimeStamp.cpp +++ b/testApp/misc/testTimeStamp.cpp @@ -28,7 +28,7 @@ using namespace epics::pvData; static bool debug = false; -void testTimeStamp() +void testTimeStampInternal() { testOk1(nanoSecPerSec==1000000000); TimeStamp current; @@ -131,6 +131,6 @@ MAIN(testTimeStamp) { testPlan(37); testDiag("Tests timeStamp"); - testTimeStamp(); + testTimeStampInternal(); return testDone(); } diff --git a/testApp/misc/testTypeCast.cpp b/testApp/misc/testTypeCast.cpp index efd46d8..cab5fb7 100644 --- a/testApp/misc/testTypeCast.cpp +++ b/testApp/misc/testTypeCast.cpp @@ -37,11 +37,11 @@ namespace { }; template<> struct testequal { - static bool op(double A, double B) {return fabs(A-B)<1e-300; } + static bool op(double A, double B) {return fabs(A-B)<1e-15; } }; template<> struct testequal { - static bool op(float A, float B) {return fabs(A-B)<1e-30; } + static bool op(float A, float B) {return fabs(A-B)<1e-7; } }; template @@ -117,7 +117,7 @@ namespace { MAIN(testTypeCast) { - testPlan(122); + testPlan(123); try { @@ -387,7 +387,8 @@ try { FAIL(int8_t, string, "1000"); FAIL(int8_t, string, "-1000"); - FAIL(double, string, "1e+10000000"); + FAIL(double, string, "1e+1000"); + FAIL(double, string, "-1e+1000"); FAIL(epics::pvData::boolean, string, "hello"); FAIL(epics::pvData::boolean, string, "1"); diff --git a/testApp/property/Makefile b/testApp/property/Makefile index 5daa114..c468d79 100644 --- a/testApp/property/Makefile +++ b/testApp/property/Makefile @@ -1,16 +1,8 @@ -TOP=../.. +# This is a Makefile fragment, see ../Makefile -include $(TOP)/configure/CONFIG +SRC_DIRS += $(PVDATA_TEST)/property TESTPROD_HOST += testProperty testProperty_SRCS += testProperty.cpp +testHarness_SRCS += testProperty.cpp TESTS += testProperty - -testProperty_LIBS += pvData Com - -TESTSCRIPTS_HOST += $(TESTS:%=%.t) - -include $(TOP)/configure/RULES -#---------------------------------------- -# ADD RULES AFTER THIS LINE - diff --git a/testApp/pv/Makefile b/testApp/pv/Makefile index 2f7a4a3..a32dedd 100644 --- a/testApp/pv/Makefile +++ b/testApp/pv/Makefile @@ -1,70 +1,63 @@ -TOP=../.. +# This is a Makefile fragment, see ../Makefile -include $(TOP)/configure/CONFIG +SRC_DIRS += $(PVDATA_TEST)/pv -PROD_HOST += testBitSetUtil +TESTPROD_HOST += testBitSetUtil testBitSetUtil_SRCS += testBitSetUtil.cpp -testBitSetUtil_LIBS += pvData Com +testHarness_SRCS += testBitSetUtil.cpp TESTS += testBitSetUtil -PROD_HOST += testIntrospect +TESTPROD_HOST += testIntrospect testIntrospect_SRCS += testIntrospect.cpp -testIntrospect_LIBS += pvData Com +testHarness_SRCS += testIntrospect.cpp TESTS += testIntrospect -PROD_HOST += testPVType +TESTPROD_HOST += testPVType testPVType_SRCS += testPVType.cpp -testPVType_LIBS += pvData Com +testHarness_SRCS += testPVType.cpp TESTS += testPVType -PROD_HOST += testStandardField +TESTPROD_HOST += testStandardField testStandardField_SRCS += testStandardField.cpp -testStandardField_LIBS += pvData Com +testHarness_SRCS += testStandardField.cpp TESTS += testStandardField -PROD_HOST += testStandardPVField +TESTPROD_HOST += testStandardPVField testStandardPVField_SRCS += testStandardPVField.cpp -testStandardPVField_LIBS += pvData Com +testHarness_SRCS += testStandardPVField.cpp TESTS += testStandardPVField -PROD_HOST += testPVData +TESTPROD_HOST += testPVData testPVData_SRCS += testPVData.cpp -testPVData_LIBS += pvData Com +testHarness_SRCS += testPVData.cpp TESTS += testPVData -PROD_HOST += testPVUnion +TESTPROD_HOST += testPVUnion testPVUnion_SRCS += testPVUnion.cpp -testPVUnion_LIBS += pvData Com +testHarness_SRCS += testPVUnion.cpp TESTS += testPVUnion -PROD_HOST += testConvert +TESTPROD_HOST += testConvert testConvert_SRCS += testConvert.cpp -testConvert_LIBS += pvData Com +testHarness_SRCS += testConvert.cpp TESTS += testConvert -PROD_HOST += testPVScalarArray +TESTPROD_HOST += testPVScalarArray testPVScalarArray_SRCS += testPVScalarArray.cpp -testPVScalarArray_LIBS += pvData Com +testHarness_SRCS += testPVScalarArray.cpp TESTS += testPVScalarArray -PROD_HOST += testPVStructureArray +TESTPROD_HOST += testPVStructureArray testPVStructureArray_SRCS += testPVStructureArray.cpp -testPVStructureArray_LIBS += pvData Com +testHarness_SRCS += testPVStructureArray.cpp TESTS += testPVStructureArray -PROD_HOST += testOperators +TESTPROD_HOST += testOperators testOperators_SRCS += testOperators.cpp -testOperators_LIBS += pvData Com +testHarness_SRCS += testOperators.cpp TESTS += testOperators -PROD_HOST += testFieldBuilder +TESTPROD_HOST += testFieldBuilder testFieldBuilder_SRCS += testFieldBuilder.cpp -testFieldBuilder_LIBS += pvData Com +testHarness_SRCS += testFieldBuilder.cpp TESTS += testFieldBuilder - -TESTSCRIPTS_HOST += $(TESTS:%=%.t) - -include $(TOP)/configure/RULES -#---------------------------------------- -# ADD RULES AFTER THIS LINE - diff --git a/testApp/pv/testIntrospect.cpp b/testApp/pv/testIntrospect.cpp index 1ddc910..ab2e6a9 100644 --- a/testApp/pv/testIntrospect.cpp +++ b/testApp/pv/testIntrospect.cpp @@ -289,6 +289,9 @@ static void testError() static void testMapping() { #define OP(TYPE, ENUM) \ + printf(#TYPE ": sizeof %u typeid '%s' ScalarTypeID %d\n",\ + (unsigned)sizeof(TYPE), typeid(TYPE).name(),\ + epics::pvData::ScalarTypeID::value);\ testOk1(typeid(ScalarTypeTraits::type)==typeid(TYPE)); \ testOk1(ENUM==(ScalarType)ScalarTypeID::value); \ testOk1(ENUM==(ScalarType)ScalarTypeID::value); @@ -306,12 +309,11 @@ static void testMapping() OP(string, pvString) #undef OP - testOk1((ScalarType)ScalarTypeID::value==(ScalarType)-1); } MAIN(testIntrospect) { - testPlan(327); + testPlan(326); fieldCreate = getFieldCreate(); pvDataCreate = getPVDataCreate(); standardField = getStandardField(); diff --git a/testApp/pv/testPVUnion.cpp b/testApp/pv/testPVUnion.cpp index 1ff0fc5..cb64321 100644 --- a/testApp/pv/testPVUnion.cpp +++ b/testApp/pv/testPVUnion.cpp @@ -37,7 +37,7 @@ static StandardFieldPtr standardField = getStandardField(); static StandardPVFieldPtr standardPVField = getStandardPVField(); static ConvertPtr convert = getConvert(); -static void testPVUnion() +static void testPVUnionType() { if(debug) std::cout << std::endl << "testPVUnion" << std::endl; @@ -115,10 +115,10 @@ static void testPVUnionArray() } -MAIN(testPVData) +MAIN(testPVUnion) { testPlan(6); - testPVUnion(); + testPVUnionType(); testPVUnionArray(); return testDone(); } diff --git a/testApp/pvDataAllTests.c b/testApp/pvDataAllTests.c new file mode 100644 index 0000000..5868c90 --- /dev/null +++ b/testApp/pvDataAllTests.c @@ -0,0 +1,86 @@ +/* + * Run pvData tests as a batch. + * + * Do *not* include performance measurements here, they don't help to + * prove functionality (which is the point of this convenience routine). + */ + +#include +#include +#include + +/* copy */ +int testCreateRequest(void); +int testPVCopy(void); + +/* misc */ +int testBaseException(void); +int testBitSet(void); +int testByteBuffer(void); +int testMessageQueue(void); +int testOverrunBitSet(void); +int testQueue(void); +int testSerialization(void); +int testSharedVector(void); +int testThread(void); +int testTimeStamp(void); +int testTimer(void); +int testTypeCast(void); + +/* property */ +int testCreateRequest(void); + +/* pv */ +int testBitSetUtil(void); +int testConvert(void); +int testFieldBuilder(void); +int testIntrospect(void); +int testOperators(void); +int testPVData(void); +int testPVScalarArray(void); +int testPVStructureArray(void); +int testPVType(void); +int testPVUnion(void); +int testStandardField(void); +int testStandardPVField(void); + +void pvDataAllTests(void) +{ + testHarness(); + + /* pv */ + runTest(testBitSetUtil); + runTest(testConvert); + runTest(testFieldBuilder); + runTest(testIntrospect); + runTest(testOperators); + runTest(testPVData); + runTest(testPVScalarArray); + runTest(testPVStructureArray); + runTest(testPVType); + runTest(testPVUnion); + runTest(testStandardField); + runTest(testStandardPVField); + + /* misc */ + runTest(testBaseException); + runTest(testBitSet); + runTest(testByteBuffer); + runTest(testMessageQueue); + runTest(testOverrunBitSet); + runTest(testQueue); + runTest(testSerialization); + runTest(testSharedVector); + runTest(testThread); + runTest(testTimeStamp); + runTest(testTimer); + runTest(testTypeCast); + + /* copy */ + runTest(testCreateRequest); + runTest(testPVCopy); + + /* property */ + runTest(testCreateRequest); +} + diff --git a/testApp/qemuRunTest.sh b/testApp/qemuRunTest.sh new file mode 100755 index 0000000..b9cd499 --- /dev/null +++ b/testApp/qemuRunTest.sh @@ -0,0 +1 @@ +qemu-system-i386 --kernel O.RTEMS-pc386/rtemsTestHarness -netdev user,id=mynet0 -device ne2k_isa,netdev=mynet0 -redir tcp:5075::5075 -redir udp:5076::5076 -m 1024 --no-reboot -curses diff --git a/testApp/rtemsConfig.c b/testApp/rtemsConfig.c new file mode 100644 index 0000000..ac3059f --- /dev/null +++ b/testApp/rtemsConfig.c @@ -0,0 +1,72 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Saskatchewan +* EPICS BASE Versions 3.13.7 +* and higher are distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* + * RTEMS configuration for EPICS + * Revision-Id: anj@aps.anl.gov-20101005192737-disfz3vs0f3fiixd + * Author: W. Eric Norum + * norume@aps.anl.gov + * (630) 252-4793 + */ + +#include + +/* + *********************************************************************** + * RTEMS CONFIGURATION * + *********************************************************************** + */ +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#if __RTEMS_MAJOR__>4 || (__RTEMS_MAJOR__==4 && __RTEMS_MINOR__>9) || (__RTEMS_MAJOR__==4 && __RTEMS_MINOR__==9 && __RTEMS_REVISION__==99) +# define CONFIGURE_UNIFIED_WORK_AREAS +#else +# define CONFIGURE_EXECUTIVE_RAM_SIZE (2000*1024) +#endif + +#define CONFIGURE_MAXIMUM_TASKS rtems_resource_unlimited(30) +#define CONFIGURE_MAXIMUM_SEMAPHORES rtems_resource_unlimited(500) +#define CONFIGURE_MAXIMUM_TIMERS rtems_resource_unlimited(20) +#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES rtems_resource_unlimited(5) +#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1 + +#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 150 +#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM +#define CONFIGURE_MAXIMUM_DRIVERS 8 + +#define CONFIGURE_MICROSECONDS_PER_TICK 20000 + +#define CONFIGURE_INIT_TASK_PRIORITY 80 + +#define CONFIGURE_MALLOC_STATISTICS 1 + +#define CONFIGURE_INIT +#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \ + RTEMS_NO_TIMESLICE | \ + RTEMS_NO_ASR | \ + RTEMS_INTERRUPT_LEVEL(0)) +#define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_FLOATING_POINT | RTEMS_LOCAL) +#define CONFIGURE_INIT_TASK_STACK_SIZE (16*1024) +rtems_task Init (rtems_task_argument argument); + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_FILESYSTEM_NFS +#define CONFIGURE_FILESYSTEM_IMFS + +/* + * This should be made BSP dependent, not CPU dependent but I know of no + * appropriate conditionals to use. + * The new general time support makes including the RTC driverr less important. + */ +#if !defined(mpc604) && !defined(__mc68040__) && !defined(__mcf5200__) && !defined(mpc7455) && !defined(__arm__) /* don't have RTC code */ +#define CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER +#endif + + +#include +#include diff --git a/testApp/rtemsNetworking.h b/testApp/rtemsNetworking.h new file mode 100644 index 0000000..e8d37f6 --- /dev/null +++ b/testApp/rtemsNetworking.h @@ -0,0 +1,294 @@ +/* + * Network configuration -- QEMU NOT using DHCP + * + ************************************************************ + * EDIT THIS FILE TO REFLECT YOUR NETWORK CONFIGURATION * + * BEFORE RUNNING ANY RTEMS PROGRAMS WHICH USE THE NETWORK! * + ************************************************************ + * + * The dynamic probing is based upon the EPICS network + * configuration file written by: + * W. Eric Norum + * eric.norum@usask.ca + * (306) 966-5394 + */ + +#ifndef _RTEMS_NETWORKCONFIG_H_ +#define _RTEMS_NETWORKCONFIG_H_ + +/* #define USE_LIBBSDPORT */ + +#if defined(USE_LIBBSDPORT) + #include + #define CONFIGURE_MAXIMUM_TIMERS 10 +#endif +/* + * For TFTP test application + */ +#if (defined (RTEMS_USE_BOOTP)) +#define RTEMS_TFTP_TEST_HOST_NAME "BOOTP_HOST" +#define RTEMS_TFTP_TEST_FILE_NAME "BOOTP_FILE" +#else +#define RTEMS_TFTP_TEST_HOST_NAME "XXX.YYY.ZZZ.XYZ" +#define RTEMS_TFTP_TEST_FILE_NAME "tftptest" +#endif + +/* + * For NFS test application + * + * NFS mount and a directory to ls once mounted + */ +#define RTEMS_NFS_SERVER "192.168.1.210" +#define RTEMS_NFS_SERVER_PATH "/home" +#define RTEMS_NFS_LS_PATH "/mnt/nfstest" + + + +/* + * This file can be copied to an application source dirctory + * and modified to override the values shown below. + * + * The following CPP symbols may be passed from the Makefile: + * + * symbol default description + * + * NETWORK_TASK_PRIORITY 150 can be read by app from public + * var 'gesysNetworkTaskPriority' + * FIXED_IP_ADDR hardcoded IP address (e.g., + * "192.168.0.10"); disables BOOTP; + * must also define FIXED_NETMASK + * FIXED_NETMASK IP netmask string + * (e.g. "255.255.255.0") + * MULTI_NETDRIVER ugly hack; if defined try to probe + * a variety of PCI and ISA drivers + * (i386 ONLY) use is discouraged! + * NIC_NAME Ethernet driver name (e.g. "pcn1"); + * must also define NIC_ATTACH + * NIC_ATTACH Ethernet driver attach function + * (e.g., rtems_fxp_attach). + * If these are undefined then + * a) MULTI_NETDRIVER is used + * (if defined) + * b) RTEMS_BSP_NETWORK_DRIVER_NAME/ + * RTEMS_BSP_NETWORK_DRIVER_ATTACH + * are tried + * MEMORY_CUSTOM Allocate the defined amount of + * memory for mbufs and mbuf clusters, + * respectively. Define to a comma ',' + * separated pair of two numerical + * values, e.g: 100*1024,200*1024 + * MEMORY_SCARCE Allocate few memory for mbufs + * (hint for how much memory the + * board has) + * MEMORY_HUGE Allocate a lot of memory for mbufs + * (hint for how much memory the + * board has) + * If none of MEMORY_CUSTOM/ + * MEMORY_SCARCE/MEMORY_HUGE are + * defined then a medium amount of + * memory is allocated for mbufs. + */ + +#include +#include +#include + +#if 0 +#ifdef HAVE_CONFIG_H +#include +#else +#include "verscheck.h" +#endif +#endif + +//#define MULTI_NETDRIVER +//#define RTEMS_BSP_NETWORK_DRIVER_NAME 1 + +#define FIXED_IP_ADDR "192.168.1.249" +#define FIXED_NETMASK "255.255.255.0" + +#ifndef NETWORK_TASK_PRIORITY +#define NETWORK_TASK_PRIORITY 150 /* within EPICS' range */ +#endif + +/* make publicily available for startup scripts... */ +const int gesysNetworkTaskPriority = NETWORK_TASK_PRIORITY; + +#ifdef FIXED_IP_ADDR +#define RTEMS_DO_BOOTP 0 +#else +#define RTEMS_DO_BOOTP rtems_bsdnet_do_bootp +#define FIXED_IP_ADDR 0 +#undef FIXED_NETMASK +#define FIXED_NETMASK 0 +#endif + +#if !defined(NIC_NAME) + +#ifdef MULTI_NETDRIVER + +#if 0 + #if RTEMS_VERSION_ATLEAST(4,6,99) + #define pcib_init pci_initialize + #endif +#endif + +extern int rtems_3c509_driver_attach (struct rtems_bsdnet_ifconfig *, int); +extern int rtems_fxp_attach (struct rtems_bsdnet_ifconfig *, int); +extern int rtems_elnk_driver_attach (struct rtems_bsdnet_ifconfig *, int); +extern int rtems_dec21140_driver_attach (struct rtems_bsdnet_ifconfig *, int); + +/* these don't probe and will be used even if there's no device :-( */ +extern int rtems_ne_driver_attach (struct rtems_bsdnet_ifconfig *, int); +extern int rtems_wd_driver_attach (struct rtems_bsdnet_ifconfig *, int); + +static struct rtems_bsdnet_ifconfig isa_netdriver_config[] = { + { + "ep0", rtems_3c509_driver_attach, isa_netdriver_config + 1, + }, + { + "ne1", rtems_ne_driver_attach, 0, irno: 9 /* qemu cannot configure irq-no :-(; has it hardwired to 9 */ + }, +}; + +static struct rtems_bsdnet_ifconfig pci_netdriver_config[]={ + { + "dc1", rtems_dec21140_driver_attach, pci_netdriver_config+1, + }, + #if !defined(USE_LIBBSDPORT) + { + "fxp1", rtems_fxp_attach, pci_netdriver_config+2, + }, + #else + { + "", libbsdport_netdriver_attach, pci_netdriver_config+2, + }, + #endif + { + "elnk1", rtems_elnk_driver_attach, isa_netdriver_config, + }, +}; + +static int pci_check(struct rtems_bsdnet_ifconfig *ocfg, int attaching) +{ +struct rtems_bsdnet_ifconfig *cfg; +int if_index_pre; +extern int if_index; + if ( attaching ) { + cfg = pci_initialize() ? + isa_netdriver_config : pci_netdriver_config; + } + while ( cfg ) { + printk("Probing '%s'", cfg->name); + /* unfortunately, the return value is unreliable - some drivers report + * success even if they fail. + * Check if they chained an interface (ifnet) structure instead + */ + if_index_pre = if_index; + cfg->attach(cfg, attaching); + if ( if_index > if_index_pre ) { + /* assume success */ + printk(" .. seemed to work\n"); + ocfg->name = cfg->name; + ocfg->attach = cfg->attach; + return 0; + } + printk(" .. failed\n"); + cfg = cfg->next; + } + return -1; +} + + +#define NIC_NAME "dummy" +#define NIC_ATTACH pci_check + +#else + +#if defined(RTEMS_BSP_NETWORK_DRIVER_NAME) /* Use NIC provided by BSP */ + +/* force ne2k_isa on i386 for qemu */ +#if defined(__i386__) +# define NIC_NAME BSP_NE2000_NETWORK_DRIVER_NAME +# define NIC_ATTACH BSP_NE2000_NETWORK_DRIVER_ATTACH + +#else + +# define NIC_NAME RTEMS_BSP_NETWORK_DRIVER_NAME +# define NIC_ATTACH RTEMS_BSP_NETWORK_DRIVER_ATTACH +#endif + +#endif + +#endif /* ifdef MULTI_NETDRIVER */ +#endif + + +#ifdef NIC_NAME + +extern int NIC_ATTACH(); + +#if RTEMS_BSP_NETWORK_DRIVER_ATTACH == BSP_NE2000_NETWORK_DRIVER_ATTACH +static char ethernet_address[6] = { 0x00, 0xab, 0xcd, 0xef, 0x12, 0x34 }; +#endif + +static struct rtems_bsdnet_ifconfig netdriver_config[1] = {{ + NIC_NAME, /* name */ + (int (*)(struct rtems_bsdnet_ifconfig*,int))NIC_ATTACH, /* attach function */ + 0, /* link to next interface */ + FIXED_IP_ADDR, + FIXED_NETMASK +#if RTEMS_BSP_NETWORK_DRIVER_ATTACH == BSP_NE2000_NETWORK_DRIVER_ATTACH + , + ethernet_address, + irno:9, + port:0xc100 +#endif +}}; +#else +#warning "NO KNOWN NETWORK DRIVER FOR THIS BSP -- YOU MAY HAVE TO EDIT networkconfig.h" +#endif + +struct rtems_bsdnet_config rtems_bsdnet_config = { +#ifdef NIC_NAME + netdriver_config, /* link to next interface */ + RTEMS_DO_BOOTP, /* Use BOOTP to get network configuration */ +#else + 0, + 0, +#endif + NETWORK_TASK_PRIORITY, /* Network task priority */ +#if defined(MEMORY_CUSTOM) + MEMORY_CUSTOM, +#elif defined(MEMORY_SCARCE) + 100*1024, /* MBUF space */ + 200*1024, /* MBUF cluster space */ +#elif defined(MEMORY_HUGE) + 2*1024*1024, /* MBUF space */ + 5*1024*1024, /* MBUF cluster space */ +#else + 180*1024, /* MBUF space */ + 350*1024, /* MBUF cluster space */ +#endif +#if (!defined (RTEMS_USE_BOOTP)) && defined(ON_RTEMS_LAB_WINSYSTEMS) + "rtems", /* Host name */ + "nodomain.com", /* Domain name */ + "192.168.1.14", /* Gateway */ + "192.168.1.1", /* Log host */ + {"89.212.75.6" }, /* Name server(s) */ + {"192.168.1.1" }, /* NTP server(s) */ +#else + NULL, /* Host name */ + NULL, /* Domain name */ + NULL, /* Gateway */ + NULL, /* Log host */ + { NULL }, /* Name server(s) */ + { NULL }, /* NTP server(s) */ +#endif /* !RTEMS_USE_BOOTP */ + 0, /* efficiency */ + 0, /* udp TX buffer */ + 0, /* udp RX buffer */ + 0, /* tcp TX buffer */ + 0, /* tcp RX buffer */ +}; +#endif /* _RTEMS_NETWORKCONFIG_H_ */ diff --git a/testApp/rtemsTestHarness.c b/testApp/rtemsTestHarness.c new file mode 100644 index 0000000..b6ef3ba --- /dev/null +++ b/testApp/rtemsTestHarness.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include + +#include "rtemsNetworking.h" + +#include +#include + +rtems_task +Init (rtems_task_argument ignored) +{ + rtems_bsdnet_initialize_network (); + //rtems_bsdnet_show_if_stats (); + + rtems_time_of_day timeOfDay; + if (rtems_clock_get(RTEMS_CLOCK_GET_TOD,&timeOfDay) != RTEMS_SUCCESSFUL) { + timeOfDay.year = 2014; + timeOfDay.month = 1; + timeOfDay.day = 1; + timeOfDay.hour = 0; + timeOfDay.minute = 0; + timeOfDay.second = 0; + timeOfDay.ticks = 0; + + rtems_status_code ret = rtems_clock_set(&timeOfDay); + if (ret != RTEMS_SUCCESSFUL) { + printf("**** Can't set time %s\n", rtems_status_text(ret)); + } + } + osdTimeRegister(); + + extern void pvDataAllTests(void); + pvDataAllTests(); + epicsExit(0); +}