This commit is contained in:
Matej Sekoranja
2014-11-10 21:33:47 +01:00
30 changed files with 1036 additions and 170 deletions

View File

@@ -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

View File

@@ -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
/home/msekoranja/epicsV4/pvDataCPP/pvDataApp/pvMisc
testApp/pv
testApp/copy
testApp/misc
testApp
testApp/property

View File

@@ -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;

View File

@@ -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());
}
}

View File

@@ -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<temp.size())
o << *temp[index];
if (index<temp.size())
{
if (temp[index])
o << *temp[index];
else
o << format::indent() << "(none)" << std::endl;
}
return o;
}

View File

@@ -231,8 +231,13 @@ std::ostream& PVUnionArray::dumpValue(std::ostream& o) const
std::ostream& PVUnionArray::dumpValue(std::ostream& o, std::size_t index) const
{
const_svector temp(view());
if(index<temp.size())
o << *temp[index];
if (index<temp.size())
{
if (temp[index])
o << *temp[index];
else
o << format::indent() << "(none)" << std::endl;
}
return o;
}

View File

@@ -26,7 +26,14 @@ namespace epics { namespace pvData {
namespace format
{
std::ostream& operator<<(std::ostream& os, indent_level const& indent)
static int indent_index = std::ios_base::xalloc();
long& indent_value(std::ios_base& ios)
{
return ios.iword(indent_index);
}
std::ostream& operator<<(std::ostream& os, indent_level const& indent)
{
indent_value(os) = indent.level;
return os;

View File

@@ -308,6 +308,71 @@ noconvert:
return 0;
}
#if defined(__vxworks)
/* vxworks version of std::istringstream >>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
}
}}}

View File

@@ -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<typename T>
struct ScalarTypeID { enum {value=-1}; };
struct ScalarTypeID {};
/**
* Static mapping from ScalarType enum to value type.

View File

@@ -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 <stdint.h>

View File

@@ -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

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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

View File

@@ -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();
}

View File

@@ -1,7 +1,8 @@
#include <testMain.h>
#include <epicsEndian.h>
#include <stdio.h>
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");

View File

@@ -132,7 +132,7 @@ void test()
}
MAIN(testOverrunBitSet`)
MAIN(testOverrunBitSet)
{
testPlan(41);
testDiag("Tests for changeBitSet and overrunBitSet");

View File

@@ -716,7 +716,9 @@ void testArraySizeType() {
serializationFieldTest(s);
PVStructurePtr pvs = getPVDataCreate()->createPVStructure(s);
pvs->getSubField<PVArray>("fixedArray")->setLength(10);
PVDoubleArray::shared_pointer pvDA = pvs->getSubField<PVDoubleArray>("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();
}

View File

@@ -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<int> empty, empty2;
epics::pvData::shared_vector<int32> 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<int> internal(5);
epics::pvData::shared_vector<int32> 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<int> internal2(15, 500);
epics::pvData::shared_vector<int32> 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<typename E>
struct callCounter {
std::tr1::shared_ptr<int> count;
callCounter():count(new int){*count=0;}
std::tr1::shared_ptr<int32> 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<int> nullPtr(oops, 42, 100);
int32 *oops=0;
epics::pvData::shared_vector<int32> 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<int> newData(raw, 1, 4);
int32 *raw=new int32[5];
epics::pvData::shared_vector<int32> 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<int*> tracker;
int32 localVar[4] = {1,2,3,4};
callCounter<int32*> tracker;
testOk1(*tracker.count==0);
epics::pvData::shared_vector<int> locvar(localVar,
epics::pvData::shared_vector<int32> locvar(localVar,
tracker,
0, 4);
@@ -137,8 +138,8 @@ static void testShare()
{
testDiag("Test vector Sharing");
epics::pvData::shared_vector<int> one, two(15);
epics::pvData::shared_vector<int> three(two);
epics::pvData::shared_vector<int32> one, two(15);
epics::pvData::shared_vector<int32> three(two);
testOk1(one.unique());
testOk1(!two.unique());
@@ -199,22 +200,22 @@ static void testConst()
{
testDiag("Test constant vector");
epics::pvData::shared_vector<int> writable(15, 100);
epics::pvData::shared_vector<int32> writable(15, 100);
epics::pvData::shared_vector<int>::reference wr = writable[0];
epics::pvData::shared_vector<int>::const_reference ror = writable[0];
epics::pvData::shared_vector<int32>::reference wr = writable[0];
epics::pvData::shared_vector<int32>::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<const int> rodata(freeze(writable));
epics::pvData::shared_vector<const int32> rodata(freeze(writable));
epics::pvData::shared_vector<const int>::reference wcr = rodata[0];
epics::pvData::shared_vector<const int>::const_reference rocr = rodata[0];
epics::pvData::shared_vector<const int32>::reference wcr = rodata[0];
epics::pvData::shared_vector<const int32>::const_reference rocr = rodata[0];
testOk1(wcr==rocr);
@@ -227,7 +228,7 @@ static void testConst()
testOk1(rodata.data()==compare);
epics::pvData::shared_vector<const int> rodata2(rodata);
epics::pvData::shared_vector<const int32> rodata2(rodata);
testOk1(rodata.data()==rodata2.data());
@@ -240,9 +241,9 @@ static void testSlice()
{
testDiag("Test vector slicing");
epics::pvData::shared_vector<int> original(10, 100);
epics::pvData::shared_vector<int32> original(10, 100);
epics::pvData::shared_vector<int> half1(original), half2(original), half2a(original);
epics::pvData::shared_vector<int32> 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<int> vect(10, 100);
epics::pvData::shared_vector<int32> 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<int> vect;
epics::pvData::shared_vector<int32> vect;
testDiag("Test push_back optimizations");
@@ -357,7 +358,7 @@ static void testVoid()
{
testDiag("Test vecter cast to/from void");
epics::pvData::shared_vector<int> typed(4);
epics::pvData::shared_vector<int32> typed(4);
epics::pvData::shared_vector<void> untyped2(epics::pvData::static_shared_vector_cast<void>(typed));
@@ -366,7 +367,7 @@ static void testVoid()
untyped2.slice(sizeof(int), 2*sizeof(int));
typed = epics::pvData::static_shared_vector_cast<int>(untyped2);
typed = epics::pvData::static_shared_vector_cast<int32>(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<int> ints(6, 42), moreints;
epics::pvData::shared_vector<int32> ints(6, 42), moreints;
epics::pvData::shared_vector<float> floats;
epics::pvData::shared_vector<string> strings;
epics::pvData::shared_vector<void> voids;
@@ -414,7 +415,7 @@ static void testVectorConvert()
testOk1(ints.unique());
// no-op convert. Just returns another reference
moreints = epics::pvData::shared_vector_convert<int>(ints);
moreints = epics::pvData::shared_vector_convert<int32>(ints);
testOk1(!ints.unique());
moreints.clear();
@@ -432,11 +433,12 @@ static void testVectorConvert()
voids = epics::pvData::shared_vector_convert<void>(ints);
testOk1(!ints.unique());
testOk1(voids.size()==ints.size()*sizeof(int));
testOk1(voids.size()==ints.size()*sizeof(int32));
// convert from void uses shared_vector<void>::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<string>(voids);
voids.clear();
@@ -450,11 +452,11 @@ static void testWeak()
{
testDiag("Test weak_ptr counting");
epics::pvData::shared_vector<int> data(6);
epics::pvData::shared_vector<int32> data(6);
testOk1(data.unique());
std::tr1::shared_ptr<int> pdata(data.dataPtr());
std::tr1::shared_ptr<int32> pdata(data.dataPtr());
testOk1(!data.unique());
@@ -462,7 +464,7 @@ static void testWeak()
testOk1(data.unique());
std::tr1::weak_ptr<int> wdata(data.dataPtr());
std::tr1::weak_ptr<int32> 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<int> A(6, 42), C;
epics::pvData::shared_vector<const int> B, D;
epics::pvData::shared_vector<int32> A(6, 42), C;
epics::pvData::shared_vector<const int32> 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<int>)=%lu",
(unsigned long)sizeof(epics::pvData::shared_vector<int>));
testDiag("sizeof(shared_vector<int32>)=%lu",
(unsigned long)sizeof(epics::pvData::shared_vector<int32>));
testEmpty();
testInternalAlloc();

View File

@@ -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();
}

View File

@@ -37,11 +37,11 @@ namespace {
};
template<>
struct testequal<double> {
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<float> {
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<typename TO, typename FROM>
@@ -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");

View File

@@ -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

View File

@@ -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

View File

@@ -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<TYPE>::value);\
testOk1(typeid(ScalarTypeTraits<ENUM>::type)==typeid(TYPE)); \
testOk1(ENUM==(ScalarType)ScalarTypeID<TYPE>::value); \
testOk1(ENUM==(ScalarType)ScalarTypeID<const TYPE>::value);
@@ -306,12 +309,11 @@ static void testMapping()
OP(string, pvString)
#undef OP
testOk1((ScalarType)ScalarTypeID<PVField>::value==(ScalarType)-1);
}
MAIN(testIntrospect)
{
testPlan(327);
testPlan(326);
fieldCreate = getFieldCreate();
pvDataCreate = getPVDataCreate();
standardField = getStandardField();

View File

@@ -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();
}

86
testApp/pvDataAllTests.c Normal file
View File

@@ -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 <stdio.h>
#include <epicsThread.h>
#include <epicsUnitTest.h>
/* 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);
}

1
testApp/qemuRunTest.sh Executable file
View File

@@ -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

72
testApp/rtemsConfig.c Normal file
View File

@@ -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.h>
/*
***********************************************************************
* 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 <bsp.h>
#include <rtems/confdefs.h>

294
testApp/rtemsNetworking.h Normal file
View File

@@ -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 <bsp/libbsdport_api.h>
#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 <undefined> hardcoded IP address (e.g.,
* "192.168.0.10"); disables BOOTP;
* must also define FIXED_NETMASK
* FIXED_NETMASK <undefined> IP netmask string
* (e.g. "255.255.255.0")
* MULTI_NETDRIVER <undefined> ugly hack; if defined try to probe
* a variety of PCI and ISA drivers
* (i386 ONLY) use is discouraged!
* NIC_NAME <undefined> Ethernet driver name (e.g. "pcn1");
* must also define NIC_ATTACH
* NIC_ATTACH <undefined> 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 <undefined> 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 <undefined> Allocate few memory for mbufs
* (hint for how much memory the
* board has)
* MEMORY_HUGE <undefined> 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 <rtems/bspIo.h>
#include <bsp.h>
#include <rtems/rtems_bsdnet.h>
#if 0
#ifdef HAVE_CONFIG_H
#include <config.h>
#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_ */

View File

@@ -0,0 +1,37 @@
#include <stdio.h>
#include <stdlib.h>
#include <rtems/rtems_bsdnet.h>
#include <rtems/error.h>
#include "rtemsNetworking.h"
#include <epicsExit.h>
#include <osdTime.h>
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);
}