From 277c71c7deca01259191f3cb0c638e6421c69070 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 9 Feb 2011 21:02:30 -0500 Subject: [PATCH] add remaining tests to testAll --- test/testAll.sh | 3 +++ test/testBaseException | 37 ++++++++++++++++++++++++++++++ test/testBaseException.sh | 1 + test/testBaseExceptionDiff | 0 test/testBaseExceptionGold | 37 ++++++++++++++++++++++++++++++ test/testBitSet | 3 +++ test/testBitSet.sh | 1 + test/testBitSetDiff | 0 test/testBitSetGold | 3 +++ test/testByteBuffer | 5 ++++ test/testByteBuffer.sh | 1 + test/testByteBufferDiff | 0 test/testByteBufferGold | 5 ++++ testApp/misc/testBaseException.cpp | 18 ++++++++++----- testApp/misc/testBitSet.cpp | 16 ++++++------- testApp/misc/testByteBuffer.cpp | 31 +++++++++++++++++-------- 16 files changed, 137 insertions(+), 24 deletions(-) create mode 100644 test/testBaseException create mode 120000 test/testBaseException.sh create mode 100644 test/testBaseExceptionDiff create mode 100644 test/testBaseExceptionGold create mode 100644 test/testBitSet create mode 120000 test/testBitSet.sh create mode 100644 test/testBitSetDiff create mode 100644 test/testBitSetGold create mode 100644 test/testByteBuffer create mode 120000 test/testByteBuffer.sh create mode 100644 test/testByteBufferDiff create mode 100644 test/testByteBufferGold diff --git a/test/testAll.sh b/test/testAll.sh index bf90e1e..9628ee3 100755 --- a/test/testAll.sh +++ b/test/testAll.sh @@ -1,8 +1,11 @@ #!/bin/sh +./testBaseException.sh || exit $? ./testPVType.sh || exit $? ./testThread.sh || exit $? ./testLinkedList.sh || exit $? +./testBitSet.sh || exit $? +./testByteBuffer.sh || exit $? ./testIntrospect.sh || exit $? ./testPVData.sh || exit $? ./testPVStructureArray.sh || exit $? diff --git a/test/testBaseException b/test/testBaseException new file mode 100644 index 0000000..3c7ad61 --- /dev/null +++ b/test/testBaseException @@ -0,0 +1,37 @@ +testBaseException... + +all is OK + at ../testBaseException.cpp:48 + ../bin/linux-x86/testBaseException + ../bin/linux-x86/testBaseException + /lib/libc.so.6: __libc_start_main()+0xe6 + ../bin/linux-x86/testBaseException + + + + +exception 2 + at ../testBaseException.cpp:57 + ../bin/linux-x86/testBaseException + ../bin/linux-x86/testBaseException + ../bin/linux-x86/testBaseException + /lib/libc.so.6: __libc_start_main()+0xe6 + ../bin/linux-x86/testBaseException +exception 1 + at ../testBaseException.cpp:40 + ../bin/linux-x86/testBaseException + ../bin/linux-x86/testBaseException + ../bin/linux-x86/testBaseException + ../bin/linux-x86/testBaseException + /lib/libc.so.6: __libc_start_main()+0xe6 + ../bin/linux-x86/testBaseException +the root cause + at ../testBaseException.cpp:31 + ../bin/linux-x86/testBaseException + ../bin/linux-x86/testBaseException + ../bin/linux-x86/testBaseException + /lib/libc.so.6: __libc_start_main()+0xe6 + ../bin/linux-x86/testBaseException + + +PASSED diff --git a/test/testBaseException.sh b/test/testBaseException.sh new file mode 120000 index 0000000..2dcdfc4 --- /dev/null +++ b/test/testBaseException.sh @@ -0,0 +1 @@ +testPVType.sh \ No newline at end of file diff --git a/test/testBaseExceptionDiff b/test/testBaseExceptionDiff new file mode 100644 index 0000000..e69de29 diff --git a/test/testBaseExceptionGold b/test/testBaseExceptionGold new file mode 100644 index 0000000..3c7ad61 --- /dev/null +++ b/test/testBaseExceptionGold @@ -0,0 +1,37 @@ +testBaseException... + +all is OK + at ../testBaseException.cpp:48 + ../bin/linux-x86/testBaseException + ../bin/linux-x86/testBaseException + /lib/libc.so.6: __libc_start_main()+0xe6 + ../bin/linux-x86/testBaseException + + + + +exception 2 + at ../testBaseException.cpp:57 + ../bin/linux-x86/testBaseException + ../bin/linux-x86/testBaseException + ../bin/linux-x86/testBaseException + /lib/libc.so.6: __libc_start_main()+0xe6 + ../bin/linux-x86/testBaseException +exception 1 + at ../testBaseException.cpp:40 + ../bin/linux-x86/testBaseException + ../bin/linux-x86/testBaseException + ../bin/linux-x86/testBaseException + ../bin/linux-x86/testBaseException + /lib/libc.so.6: __libc_start_main()+0xe6 + ../bin/linux-x86/testBaseException +the root cause + at ../testBaseException.cpp:31 + ../bin/linux-x86/testBaseException + ../bin/linux-x86/testBaseException + ../bin/linux-x86/testBaseException + /lib/libc.so.6: __libc_start_main()+0xe6 + ../bin/linux-x86/testBaseException + + +PASSED diff --git a/test/testBitSet b/test/testBitSet new file mode 100644 index 0000000..b7bdd44 --- /dev/null +++ b/test/testBitSet @@ -0,0 +1,3 @@ +testGetSetClearFlip... PASSED +testOperators... PASSED +bitSet: totalConstruct 4 totalDestruct 4 diff --git a/test/testBitSet.sh b/test/testBitSet.sh new file mode 120000 index 0000000..2dcdfc4 --- /dev/null +++ b/test/testBitSet.sh @@ -0,0 +1 @@ +testPVType.sh \ No newline at end of file diff --git a/test/testBitSetDiff b/test/testBitSetDiff new file mode 100644 index 0000000..e69de29 diff --git a/test/testBitSetGold b/test/testBitSetGold new file mode 100644 index 0000000..b7bdd44 --- /dev/null +++ b/test/testBitSetGold @@ -0,0 +1,3 @@ +testGetSetClearFlip... PASSED +testOperators... PASSED +bitSet: totalConstruct 4 totalDestruct 4 diff --git a/test/testByteBuffer b/test/testByteBuffer new file mode 100644 index 0000000..f0be63d --- /dev/null +++ b/test/testByteBuffer @@ -0,0 +1,5 @@ +Basic operation tests... + First 10 characters of destination: >> cdefgh << +!!! PASSED +Testing inverse endianness... +!!! PASSED diff --git a/test/testByteBuffer.sh b/test/testByteBuffer.sh new file mode 120000 index 0000000..2dcdfc4 --- /dev/null +++ b/test/testByteBuffer.sh @@ -0,0 +1 @@ +testPVType.sh \ No newline at end of file diff --git a/test/testByteBufferDiff b/test/testByteBufferDiff new file mode 100644 index 0000000..e69de29 diff --git a/test/testByteBufferGold b/test/testByteBufferGold new file mode 100644 index 0000000..f0be63d --- /dev/null +++ b/test/testByteBufferGold @@ -0,0 +1,5 @@ +Basic operation tests... + First 10 characters of destination: >> cdefgh << +!!! PASSED +Testing inverse endianness... +!!! PASSED diff --git a/testApp/misc/testBaseException.cpp b/testApp/misc/testBaseException.cpp index 0c6f1b9..f7db33e 100644 --- a/testApp/misc/testBaseException.cpp +++ b/testApp/misc/testBaseException.cpp @@ -41,13 +41,13 @@ void internalTestBaseException(int unused = 0) } } -void testBaseException() { - printf("testBaseException... "); +void testBaseException(FILE *fp) { + fprintf(fp,"testBaseException... "); try { THROW_BASE_EXCEPTION("all is OK"); } catch (BaseException& be) { - printf("\n\n%s\n\n", be.what()); + fprintf(fp,"\n\n%s\n\n", be.what()); } try { @@ -57,15 +57,21 @@ void testBaseException() { THROW_BASE_EXCEPTION_CAUSE("exception 2", be2); } } catch (BaseException& be) { - printf("\n\n%s\n\n", be.what()); + fprintf(fp,"\n\n%s\n\n", be.what()); } - printf("PASSED\n"); + fprintf(fp,"PASSED\n"); } int main(int argc,char *argv[]) { - testBaseException(); + FILE *fp=NULL; + if(argc>1){ + fp=fopen(argv[1], "w"); + if(!fp) fprintf(stderr,"Failed to open test output file\n"); + } + if(!fp) fp=stdout; + testBaseException(fp); return(0); } diff --git a/testApp/misc/testBitSet.cpp b/testApp/misc/testBitSet.cpp index 372689e..ed17ea1 100644 --- a/testApp/misc/testBitSet.cpp +++ b/testApp/misc/testBitSet.cpp @@ -19,8 +19,8 @@ using namespace epics::pvData; -void testGetSetClearFlip() { - printf("testGetSetClearFlip... "); +void testGetSetClearFlip(FILE *fd) { + fprintf(fd,"testGetSetClearFlip... "); // empty BitSet* b1 = new BitSet(); @@ -75,12 +75,12 @@ void testGetSetClearFlip() { assert(str == "{}"); delete b1; - printf("PASSED\n"); + fprintf(fd,"PASSED\n"); } -void testOperators() { - printf("testOperators... "); +void testOperators(FILE *fd) { + fprintf(fd,"testOperators... "); BitSet b1; assert(b1 == b1); @@ -135,7 +135,7 @@ void testOperators() { str.clear(); b1.toString(&str); assert(str == "{2, 128}"); - printf("PASSED\n"); + fprintf(fd,"PASSED\n"); } @@ -148,8 +148,8 @@ int main(int argc,char *argv[]) if(fileName!=0 && fileName[0]!=0) { fd = fopen(fileName,"w+"); } - testGetSetClearFlip(); - testOperators(); + testGetSetClearFlip(fd); + testOperators(fd); epicsExitCallAtExits(); CDRMonitor::get().show(fd); return(0); diff --git a/testApp/misc/testByteBuffer.cpp b/testApp/misc/testByteBuffer.cpp index 551eab9..7bdddce 100644 --- a/testApp/misc/testByteBuffer.cpp +++ b/testApp/misc/testByteBuffer.cpp @@ -11,6 +11,7 @@ */ #include +#include #include #include @@ -20,10 +21,9 @@ #include "pvIntrospect.h" using namespace epics::pvData; -using std::cout; -void testBasicOperations() { - cout<<"Basic operation tests...\n"; +void testBasicOperations(std::ostream& ofile) { + ofile<<"Basic operation tests...\n"; ByteBuffer* buff = new ByteBuffer(); assert(buff->getSize()==32); @@ -173,15 +173,15 @@ void testBasicOperations() { assert(buff->getPosition()==6); assert(strncmp(&src[2],&dst[2],6)==0); - cout<<" First 10 characters of destination: >>"<>"<getInt()==0x0A0B0C0D); delete buff; - cout<<"!!! PASSED\n"; + ofile<<"!!! PASSED\n"; } int main(int argc, char *argv[]) { - testBasicOperations(); - testInverseEndianness(); + std::ofstream outfile; + std::ostream *out=NULL; + if(argc>1) { + outfile.open(argv[1]); + if(outfile.is_open()){ + out=&outfile; + }else{ + fprintf(stderr, "Failed to open test output file\n"); + } + } + if(!out) out=&std::cout; + testBasicOperations(*out); + testInverseEndianness(*out); return (0); }