From 554dc06edabecef54ca60a57777d491885f27407 Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Wed, 5 Nov 2014 13:52:10 +0100 Subject: [PATCH] ScalarTypeID mapping fixed in case 'int' == 'long', e.g. RTEMS-i386 --- src/pv/pvIntrospect.h | 2 +- testApp/misc/testSharedVector.cpp | 60 ++++++++++++++++--------------- testApp/pv/testIntrospect.cpp | 6 ++-- testApp/pvDataAllTests.c | 35 +++++++++--------- 4 files changed, 53 insertions(+), 50 deletions(-) diff --git a/src/pv/pvIntrospect.h b/src/pv/pvIntrospect.h index 1dab6d9..540d88f 100644 --- a/src/pv/pvIntrospect.h +++ b/src/pv/pvIntrospect.h @@ -1153,7 +1153,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/testApp/misc/testSharedVector.cpp b/testApp/misc/testSharedVector.cpp index fc7666e..bcea65a 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,7 +80,7 @@ namespace { //Note: STL shared_ptr requires that deletors be copy constructable template struct callCounter { - std::tr1::shared_ptr count; + std::tr1::shared_ptr count; callCounter():count(new int){*count=0;} callCounter(const callCounter& o):count(o.count) {}; callCounter& operator=(const callCounter& o){count=o.count;} @@ -93,7 +94,7 @@ static void testExternalAlloc() // Simulate a failed malloc() or similar int *oops=0; - epics::pvData::shared_vector nullPtr(oops, 42, 100); + epics::pvData::shared_vector nullPtr(oops, 42, 100); testOk1(nullPtr.size()==0); testOk1(nullPtr.empty()); @@ -103,7 +104,7 @@ static void testExternalAlloc() testOk1(nullPtr.data()==NULL); int *raw=new int[5]; - epics::pvData::shared_vector newData(raw, 1, 4); + epics::pvData::shared_vector newData(raw, 1, 4); testOk1(newData.size()==4); testOk1(!newData.empty()); @@ -117,7 +118,7 @@ static void testExternalAlloc() 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,10 +200,10 @@ 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); @@ -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,7 +291,7 @@ 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(); @@ -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,7 +477,7 @@ static void testICE() { testDiag("Test freeze and thaw"); - epics::pvData::shared_vector A(6, 42), C; + epics::pvData::shared_vector A(6, 42), C; epics::pvData::shared_vector B, D; int *check = A.data(); @@ -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/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/pvDataAllTests.c b/testApp/pvDataAllTests.c index 1abbaa7..5868c90 100644 --- a/testApp/pvDataAllTests.c +++ b/testApp/pvDataAllTests.c @@ -48,9 +48,19 @@ void pvDataAllTests(void) { testHarness(); - /* copy */ - runTest(testCreateRequest); - runTest(testPVCopy); + /* 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); @@ -66,22 +76,11 @@ void pvDataAllTests(void) runTest(testTimer); runTest(testTypeCast); + /* copy */ + runTest(testCreateRequest); + runTest(testPVCopy); + /* property */ runTest(testCreateRequest); - - /* 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); - }