TupleTest Class Reference

Inheritance diagram for TupleTest:

TestBase TraceSource TraceTarget List of all members.

Public Member Functions

 TupleTest ()
virtual ~TupleTest ()
TestSuitereleaseTestSuite ()
void beforeTestCase (std::string testCaseName)
void afterTestCase (std::string testCaseName)
virtual void testCaseSetUp ()
 Equivalent to JUnit TestCase.setUp; this is called before each test case method is invoked.
virtual void testCaseTearDown ()
 Equivalent to JUnit TestCase.tearDown; this is called after each test case method is invoked.
virtual void notifyTrace (std::string source, TraceLevel level, std::string message)
 Receives notification when a trace event occurs.
virtual TraceLevel getSourceTraceLevel (std::string source)
 Gets the level at which a particular source should be traced.
virtual void initTraceSource (SharedTraceTarget pTraceTarget, std::string name)
 For use when initialization has to be deferred until after construction.
void trace (TraceLevel level, std::string message) const
 Records a trace message.
bool isTracing () const
 
Returns:
true iff tracing is enabled for this source

bool isTracingLevel (TraceLevel level) const
 Determines whether a particular level is being traced.
TraceTargetgetTraceTarget () const
 
Returns:
the TraceTarget for this source

SharedTraceTarget getSharedTraceTarget () const
 
Returns:
the SharedTraceTarget for this source

std::string getTraceSourceName () const
 Gets the name of this source.
void setTraceSourceName (std::string const &n)
 Sets the name of this source.
TraceLevel getMinimumTraceLevel () const
void disableTracing ()

Static Public Member Functions

static void readParams (int argc, char **argv)
 Parses the command line.

Static Public Attributes

static ParamName paramTestSuiteName
static ParamName paramTraceFileName
static ParamName paramDictionaryFileName
static ParamName paramTraceLevel
static ParamName paramStatsFileName
static ParamName paramTraceStdout
static ParamName paramDegreeOfParallelism
static ConfigMap configMap
 Configuration parameters.

Protected Member Functions

void snooze (uint nSeconds)

Protected Attributes

TestSuitepTestSuite
 Boost test suite.
boost::shared_ptr< TestBasepTestObj
std::ofstream traceStream
 Output file stream for tracing.
StrictMutex traceMutex
 Protects traceStream.
std::string testName
 Name of test.
TraceLevel traceLevel
 Level at which to trace test execution.
FileStatsTarget statsTarget
 Output for stats.
StatsTimer statsTimer
 Timer for stats collection.
bool traceStdout
 Copy trace output to stdout.
bool traceFile
 Copy trace output to file.
TestCaseGroup defaultTests
TestCaseGroup extraTests

Static Protected Attributes

static bool runAll
 Run all test cases, including the extra tests.
static std::string runSingle
 Run only the test case of this name.

Private Member Functions

void writeMinData (TupleDatum &datum, uint typeOrdinal)
void writeMaxData (TupleDatum &datum, uint typeOrdinal)
void writeSampleData (TupleDatum &datum, uint typeOrdinal)
uint testMarshal (TupleData const &tupleDataFixed)
void checkData (TupleData const &tupleData1, TupleData const &tupleData2)
void checkAlignment (TupleAttributeDescriptor const &desc, PConstBuffer pBuf)
void testStandardTypesNullable ()
void testStandardTypesNotNull ()
void testStandardTypesNetworkNullable ()
void testStandardTypesNetworkNotNull ()
void testStandardTypes (TupleFormat, bool nullable)
void testZeroByteTuple ()
void testDebugAccess ()
void testLoadStoreUnaligned ()
void loadStore8ByteInts (int64_t initialValue, uint8_t nextByte)
void loadAndStore8ByteInt (int64_t intVal)
void loadStore2ByteLenData (uint dataLen)
void loadStoreNullData (uint typeOrdinal, uint len)
void traceTuple (TupleData const &tupleData)

Private Attributes

TupleDescriptor tupleDesc
TupleAccessor tupleAccessor

Static Private Attributes

static const uint MAX_WIDTH = 512

Detailed Description

Definition at line 41 of file TupleTest.cpp.


Constructor & Destructor Documentation

TupleTest::TupleTest (  )  [inline, explicit]

Definition at line 79 of file TupleTest.cpp.

References testDebugAccess(), testLoadStoreUnaligned(), testStandardTypesNetworkNotNull(), testStandardTypesNetworkNullable(), testStandardTypesNotNull(), testStandardTypesNullable(), and testZeroByteTuple().

00080         : TraceSource(shared_from_this(),"TupleTest")
00081     {
00082         FENNEL_UNIT_TEST_CASE(TupleTest,testStandardTypesNotNull);
00083         FENNEL_UNIT_TEST_CASE(TupleTest,testStandardTypesNullable);
00084         FENNEL_UNIT_TEST_CASE(TupleTest,testStandardTypesNetworkNotNull);
00085         FENNEL_UNIT_TEST_CASE(TupleTest,testStandardTypesNetworkNullable);
00086         FENNEL_UNIT_TEST_CASE(TupleTest,testZeroByteTuple);
00087         FENNEL_UNIT_TEST_CASE(TupleTest,testLoadStoreUnaligned);
00088 
00089         // This one should fail when TupleAccessor.cpp's DEBUG_TUPLE_ACCESS
00090         // is set to 1.
00091         FENNEL_EXTRA_UNIT_TEST_CASE(TupleTest,testDebugAccess);
00092     }

virtual TupleTest::~TupleTest (  )  [inline, virtual]

Definition at line 94 of file TupleTest.cpp.

00095     {
00096     }


Member Function Documentation

void TupleTest::writeMinData ( TupleDatum datum,
uint  typeOrdinal 
) [private]

Definition at line 273 of file TupleTest.cpp.

References TupleDatum::cbData, min(), TupleDatum::pData, STANDARD_TYPE_BINARY, STANDARD_TYPE_BOOL, STANDARD_TYPE_CHAR, STANDARD_TYPE_DOUBLE, STANDARD_TYPE_INT_16, STANDARD_TYPE_INT_32, STANDARD_TYPE_INT_64, STANDARD_TYPE_INT_8, STANDARD_TYPE_REAL, STANDARD_TYPE_UINT_16, STANDARD_TYPE_UINT_32, STANDARD_TYPE_UINT_64, STANDARD_TYPE_UINT_8, STANDARD_TYPE_UNICODE_CHAR, STANDARD_TYPE_UNICODE_VARCHAR, STANDARD_TYPE_VARBINARY, and STANDARD_TYPE_VARCHAR.

Referenced by testStandardTypes().

00274 {
00275     PBuffer pData = const_cast<PBuffer>(datum.pData);
00276     switch (typeOrdinal) {
00277     case STANDARD_TYPE_BOOL:
00278         *(reinterpret_cast<bool *>(pData)) = false;
00279         break;
00280     case STANDARD_TYPE_INT_8:
00281         *(reinterpret_cast<int8_t *>(pData)) =
00282             std::numeric_limits<int8_t>::min();
00283         break;
00284     case STANDARD_TYPE_UINT_8:
00285         *(reinterpret_cast<uint8_t *>(pData)) =
00286             std::numeric_limits<uint8_t>::min();
00287         break;
00288     case STANDARD_TYPE_INT_16:
00289         *(reinterpret_cast<int16_t *>(pData)) =
00290             std::numeric_limits<int16_t>::min();
00291         break;
00292     case STANDARD_TYPE_UINT_16:
00293         *(reinterpret_cast<uint16_t *>(pData)) =
00294             std::numeric_limits<uint16_t>::min();
00295         break;
00296     case STANDARD_TYPE_INT_32:
00297         *(reinterpret_cast<int32_t *>(pData)) =
00298             std::numeric_limits<int32_t>::min();
00299         break;
00300     case STANDARD_TYPE_UINT_32:
00301         *(reinterpret_cast<uint32_t *>(pData)) =
00302             std::numeric_limits<uint32_t>::min();
00303         break;
00304     case STANDARD_TYPE_INT_64:
00305         *(reinterpret_cast<int64_t *>(pData)) =
00306             std::numeric_limits<int64_t>::min();
00307         break;
00308     case STANDARD_TYPE_UINT_64:
00309         *(reinterpret_cast<uint64_t *>(pData)) =
00310             std::numeric_limits<uint64_t>::min();
00311         break;
00312     case STANDARD_TYPE_REAL:
00313         *(reinterpret_cast<float *>(pData)) =
00314             std::numeric_limits<float>::min();
00315         break;
00316     case STANDARD_TYPE_DOUBLE:
00317         *(reinterpret_cast<double *>(pData)) =
00318             std::numeric_limits<double>::min();
00319         break;
00320     case STANDARD_TYPE_BINARY:
00321         memset(pData,0,datum.cbData);
00322         break;
00323     case STANDARD_TYPE_CHAR:
00324         memset(pData,'A',datum.cbData);
00325         break;
00326     case STANDARD_TYPE_UNICODE_CHAR:
00327         {
00328             Ucs2Buffer pStr =
00329                 reinterpret_cast<Ucs2Buffer>(pData);
00330             uint nChars = (datum.cbData >> 1);
00331             for (uint i = 0; i < nChars; ++i) {
00332                 pStr[i] = 'A';
00333             }
00334         }
00335         break;
00336     case STANDARD_TYPE_VARCHAR:
00337     case STANDARD_TYPE_VARBINARY:
00338     case STANDARD_TYPE_UNICODE_VARCHAR:
00339         datum.cbData = 0;
00340         break;
00341     default:
00342         permAssert(false);
00343     }
00344 }

void TupleTest::writeMaxData ( TupleDatum datum,
uint  typeOrdinal 
) [private]

Definition at line 346 of file TupleTest.cpp.

References TupleDatum::cbData, max(), MAX_WIDTH, TupleDatum::pData, STANDARD_TYPE_BINARY, STANDARD_TYPE_BOOL, STANDARD_TYPE_CHAR, STANDARD_TYPE_DOUBLE, STANDARD_TYPE_INT_16, STANDARD_TYPE_INT_32, STANDARD_TYPE_INT_64, STANDARD_TYPE_INT_8, STANDARD_TYPE_REAL, STANDARD_TYPE_UINT_16, STANDARD_TYPE_UINT_32, STANDARD_TYPE_UINT_64, STANDARD_TYPE_UINT_8, STANDARD_TYPE_UNICODE_CHAR, STANDARD_TYPE_UNICODE_VARCHAR, STANDARD_TYPE_VARBINARY, and STANDARD_TYPE_VARCHAR.

Referenced by testStandardTypes().

00347 {
00348     PBuffer pData = const_cast<PBuffer>(datum.pData);
00349     switch (typeOrdinal) {
00350     case STANDARD_TYPE_BOOL:
00351         *(reinterpret_cast<bool *>(pData)) = true;
00352         break;
00353     case STANDARD_TYPE_INT_8:
00354         *(reinterpret_cast<int8_t *>(pData)) =
00355             std::numeric_limits<int8_t>::max();
00356         break;
00357     case STANDARD_TYPE_UINT_8:
00358         *(reinterpret_cast<uint8_t *>(pData)) =
00359             std::numeric_limits<uint8_t>::max();
00360         break;
00361     case STANDARD_TYPE_INT_16:
00362         *(reinterpret_cast<int16_t *>(pData)) =
00363             std::numeric_limits<int16_t>::max();
00364         break;
00365     case STANDARD_TYPE_UINT_16:
00366         *(reinterpret_cast<uint16_t *>(pData)) =
00367             std::numeric_limits<uint16_t>::max();
00368         break;
00369     case STANDARD_TYPE_INT_32:
00370         *(reinterpret_cast<int32_t *>(pData)) =
00371             std::numeric_limits<int32_t>::max();
00372         break;
00373     case STANDARD_TYPE_UINT_32:
00374         *(reinterpret_cast<uint32_t *>(pData)) =
00375             std::numeric_limits<uint32_t>::max();
00376         break;
00377     case STANDARD_TYPE_INT_64:
00378         *(reinterpret_cast<int64_t *>(pData)) =
00379             std::numeric_limits<int64_t>::max();
00380         break;
00381     case STANDARD_TYPE_UINT_64:
00382         *(reinterpret_cast<uint64_t *>(pData)) =
00383             std::numeric_limits<uint64_t>::max();
00384         break;
00385     case STANDARD_TYPE_REAL:
00386         *(reinterpret_cast<float *>(pData)) =
00387             std::numeric_limits<float>::max();
00388         break;
00389     case STANDARD_TYPE_DOUBLE:
00390         *(reinterpret_cast<double *>(pData)) =
00391             std::numeric_limits<double>::max();
00392         break;
00393     case STANDARD_TYPE_UNICODE_CHAR:
00394     case STANDARD_TYPE_BINARY:
00395         memset(pData,0xFF,datum.cbData);
00396         break;
00397     case STANDARD_TYPE_CHAR:
00398         memset(pData,'z',datum.cbData);
00399         break;
00400     case STANDARD_TYPE_VARCHAR:
00401         datum.cbData = MAX_WIDTH;
00402         memset(pData,'z',datum.cbData);
00403         break;
00404     case STANDARD_TYPE_UNICODE_VARCHAR:
00405     case STANDARD_TYPE_VARBINARY:
00406         datum.cbData = MAX_WIDTH;
00407         memset(pData,0xFF,datum.cbData);
00408         break;
00409     default:
00410         permAssert(false);
00411     }
00412 }

void TupleTest::writeSampleData ( TupleDatum datum,
uint  typeOrdinal 
) [private]

Definition at line 414 of file TupleTest.cpp.

References TupleDatum::cbData, MAX_WIDTH, TupleDatum::pData, STANDARD_TYPE_BINARY, STANDARD_TYPE_BOOL, STANDARD_TYPE_CHAR, STANDARD_TYPE_DOUBLE, STANDARD_TYPE_INT_16, STANDARD_TYPE_INT_32, STANDARD_TYPE_INT_64, STANDARD_TYPE_INT_8, STANDARD_TYPE_REAL, STANDARD_TYPE_UINT_16, STANDARD_TYPE_UINT_32, STANDARD_TYPE_UINT_64, STANDARD_TYPE_UINT_8, STANDARD_TYPE_UNICODE_CHAR, STANDARD_TYPE_UNICODE_VARCHAR, STANDARD_TYPE_VARBINARY, and STANDARD_TYPE_VARCHAR.

Referenced by testStandardTypes().

00415 {
00416     /* Some sample data that's between min and max */
00417     std::subtractive_rng randomNumberGenerator(time(NULL));
00418     PBuffer pData = const_cast<PBuffer>(datum.pData);
00419     switch (typeOrdinal) {
00420     case STANDARD_TYPE_BOOL:
00421         if (randomNumberGenerator(2)) {
00422             *(reinterpret_cast<bool *>(pData)) = true;
00423         } else {
00424             *(reinterpret_cast<bool *>(pData)) = false;
00425         }
00426         break;
00427     case STANDARD_TYPE_INT_8:
00428         *(reinterpret_cast<int8_t *>(pData)) =  0x28;
00429         break;
00430     case STANDARD_TYPE_UINT_8:
00431         *(reinterpret_cast<uint8_t *>(pData)) = 0x54;
00432         break;
00433     case STANDARD_TYPE_INT_16:
00434         *(reinterpret_cast<int16_t *>(pData)) = 0xfedc;
00435         break;
00436     case STANDARD_TYPE_UINT_16:
00437         *(reinterpret_cast<uint16_t *>(pData)) = 0x1234;
00438         break;
00439     case STANDARD_TYPE_INT_32:
00440         *(reinterpret_cast<int32_t *>(pData)) = 0xfedcba98;
00441         break;
00442     case STANDARD_TYPE_REAL:
00443     case STANDARD_TYPE_UINT_32:
00444         *(reinterpret_cast<uint32_t *>(pData)) = 0x12345678;
00445         break;
00446     case STANDARD_TYPE_INT_64:
00447         *(reinterpret_cast<int64_t *>(pData)) = 0xfedcba0987654321LL;
00448         break;
00449     case STANDARD_TYPE_DOUBLE:
00450     case STANDARD_TYPE_UINT_64:
00451         *(reinterpret_cast<uint64_t *>(pData)) = 0x1234567890abcdefLL;
00452         break;
00453     case STANDARD_TYPE_UNICODE_CHAR:
00454     case STANDARD_TYPE_BINARY:
00455         for (int i = 0; i < datum.cbData; i++) {
00456             pData[i] = i % 256;
00457         }
00458         break;
00459     case STANDARD_TYPE_CHAR:
00460         for (int i = 0; i < datum.cbData; i++) {
00461             pData[i] = i % ('z' - ' ') + ' ';
00462         }
00463         break;
00464     case STANDARD_TYPE_VARCHAR:
00465         datum.cbData = randomNumberGenerator(MAX_WIDTH);
00466         for (int i = 0; i < datum.cbData; i++) {
00467             pData[i] = i % ('z' - ' ') + ' ';
00468         }
00469         break;
00470     case STANDARD_TYPE_UNICODE_VARCHAR:
00471     case STANDARD_TYPE_VARBINARY:
00472         datum.cbData = randomNumberGenerator(MAX_WIDTH);
00473         if (typeOrdinal == STANDARD_TYPE_UNICODE_VARCHAR) {
00474             if (datum.cbData & 1) {
00475                 // need an even number of bytes for doublebyte characters
00476                 datum.cbData--;
00477             }
00478         }
00479         for (int i = 0; i < datum.cbData; i++) {
00480             pData[i] = i % 256;
00481         }
00482         break;
00483     default:
00484         assert(false);
00485     }
00486 }

uint TupleTest::testMarshal ( TupleData const &  tupleDataFixed  )  [private]

Definition at line 199 of file TupleTest.cpp.

References checkData(), FixedBuffer, TupleAccessor::getAttributeAccessor(), TupleAccessor::getByteCount(), TupleAccessor::getCurrentByteCount(), TupleAccessor::getMaxByteCount(), TupleAccessor::marshal(), TRACE_FINE, traceTuple(), tupleAccessor, tupleDesc, TupleAccessor::unmarshal(), and AttributeAccessor::unmarshalValue().

Referenced by testStandardTypes().

00200 {
00201     FENNEL_TRACE(TRACE_FINE,"reference tuple:");
00202     traceTuple(tupleDataFixed);
00203     boost::scoped_array<FixedBuffer> pTupleBufVar(
00204         new FixedBuffer[tupleAccessor.getMaxByteCount()]);
00205 
00206     uint cbTuple = tupleAccessor.getByteCount(tupleDataFixed);
00207     tupleAccessor.marshal(tupleDataFixed,pTupleBufVar.get());
00208     BOOST_CHECK_EQUAL(cbTuple,tupleAccessor.getCurrentByteCount());
00209 
00210     TupleData tupleDataTogether(tupleDesc);
00211     tupleAccessor.unmarshal(tupleDataTogether);
00212     FENNEL_TRACE(TRACE_FINE,"unmarshalled tuple (together):");
00213     traceTuple(tupleDataTogether);
00214     BOOST_CHECK_EQUAL(cbTuple,tupleAccessor.getByteCount(tupleDataTogether));
00215     checkData(tupleDataFixed,tupleDataTogether);
00216 
00217     TupleData tupleDataIndividual(tupleDesc);
00218     for (uint i = 0; i < tupleDataIndividual.size(); ++i) {
00219         tupleAccessor.getAttributeAccessor(i).unmarshalValue(
00220             tupleAccessor,tupleDataIndividual[i]);
00221     }
00222     FENNEL_TRACE(TRACE_FINE,"unmarshalled tuple (individual):");
00223     traceTuple(tupleDataIndividual);
00224     BOOST_CHECK_EQUAL(cbTuple,tupleAccessor.getByteCount(tupleDataIndividual));
00225     checkData(tupleDataFixed,tupleDataIndividual);
00226 
00227     return tupleAccessor.getCurrentByteCount();
00228 }

void TupleTest::checkData ( TupleData const &  tupleData1,
TupleData const &  tupleData2 
) [private]

Definition at line 230 of file TupleTest.cpp.

References TupleDatum::cbData, checkAlignment(), TupleDatum::pData, and tupleDesc.

Referenced by testMarshal().

00232 {
00233     for (uint i = 0; i < tupleData1.size(); ++i) {
00234         TupleDatum const &datum1 = tupleData1[i];
00235         TupleDatum const &datum2 = tupleData2[i];
00236         if (!datum1.pData || !datum2.pData) {
00237             BOOST_CHECK_EQUAL(
00238                 static_cast<void const *>(datum1.pData),
00239                 static_cast<void const *>(datum2.pData));
00240             continue;
00241         }
00242         checkAlignment(tupleDesc[i], datum1.pData);
00243         checkAlignment(tupleDesc[i], datum2.pData);
00244         BOOST_CHECK_EQUAL(datum1.cbData,datum2.cbData);
00245         BOOST_CHECK_EQUAL_COLLECTIONS(
00246             datum1.pData,
00247             datum1.pData + datum1.cbData,
00248             datum2.pData,
00249             datum2.pData + datum2.cbData);
00250     }
00251 }

void TupleTest::checkAlignment ( TupleAttributeDescriptor const &  desc,
PConstBuffer  pBuf 
) [private]

Definition at line 253 of file TupleTest.cpp.

References TupleAttributeDescriptor::cbStorage, StoredTypeDescriptor::getAlignmentByteCount(), and TupleAttributeDescriptor::pTypeDescriptor.

Referenced by checkData().

00255 {
00256     uint iAlign = desc.pTypeDescriptor->getAlignmentByteCount(
00257         desc.cbStorage);
00258     switch (iAlign) {
00259     case 1:
00260         return;
00261     case 2:
00262         BOOST_CHECK_EQUAL(0, uintptr_t(pBuf) & 1);
00263         break;
00264     case 4:
00265         BOOST_CHECK_EQUAL(0, uintptr_t(pBuf) & 3);
00266         break;
00267     case 8:
00268         BOOST_CHECK_EQUAL(0, uintptr_t(pBuf) & 7);
00269         break;
00270     }
00271 }

void TupleTest::testStandardTypesNullable (  )  [private]

Definition at line 99 of file TupleTest.cpp.

References testStandardTypes(), and TUPLE_FORMAT_STANDARD.

Referenced by testDebugAccess(), and TupleTest().

00100 {
00101     testStandardTypes(TUPLE_FORMAT_STANDARD,true);
00102 }

void TupleTest::testStandardTypesNotNull (  )  [private]

Definition at line 104 of file TupleTest.cpp.

References testStandardTypes(), and TUPLE_FORMAT_STANDARD.

Referenced by TupleTest().

00105 {
00106     testStandardTypes(TUPLE_FORMAT_STANDARD,false);
00107 }

void TupleTest::testStandardTypesNetworkNullable (  )  [private]

Definition at line 109 of file TupleTest.cpp.

References testStandardTypes(), and TUPLE_FORMAT_NETWORK.

Referenced by TupleTest().

00110 {
00111     testStandardTypes(TUPLE_FORMAT_NETWORK,true);
00112 }

void TupleTest::testStandardTypesNetworkNotNull (  )  [private]

Definition at line 114 of file TupleTest.cpp.

References testStandardTypes(), and TUPLE_FORMAT_NETWORK.

Referenced by TupleTest().

00115 {
00116     testStandardTypes(TUPLE_FORMAT_NETWORK,false);
00117 }

void TupleTest::testStandardTypes ( TupleFormat  ,
bool  nullable 
) [private]

Definition at line 119 of file TupleTest.cpp.

References TupleAccessor::compute(), FixedBuffer, TupleAccessor::getMaxByteCount(), TupleAccessor::getMinByteCount(), MAX_WIDTH, StandardTypeDescriptorFactory::newDataType(), STANDARD_TYPE_END, STANDARD_TYPE_MIN, testMarshal(), TRACE_FINE, TUPLE_FORMAT_ALL_FIXED, tupleAccessor, tupleDesc, writeMaxData(), writeMinData(), and writeSampleData().

Referenced by testStandardTypesNetworkNotNull(), testStandardTypesNetworkNullable(), testStandardTypesNotNull(), and testStandardTypesNullable().

00121 {
00122     StandardTypeDescriptorFactory typeFactory;
00123     uint cbMin = 0;
00124     tupleDesc.clear();
00125     for (uint i = STANDARD_TYPE_MIN; i < STANDARD_TYPE_END; ++i) {
00126         StoredTypeDescriptor const &typeDesc = typeFactory.newDataType(i);
00127         uint cbFixed = typeDesc.getFixedByteCount();
00128         if (cbFixed) {
00129             cbMin += cbFixed;
00130         } else {
00131             cbMin += typeDesc.getMinByteCount(MAX_WIDTH);
00132         }
00133         tupleDesc.push_back(
00134             TupleAttributeDescriptor(
00135                 typeDesc,
00136                 nullable,
00137                 cbFixed ? 0 : MAX_WIDTH));
00138     }
00139 
00140     tupleAccessor.compute(tupleDesc,format);
00141     BOOST_CHECK(tupleAccessor.getMinByteCount() >= cbMin);
00142     BOOST_CHECK(tupleAccessor.getMaxByteCount() > cbMin);
00143 
00144     TupleAccessor tupleAccessorFixed;
00145     tupleAccessorFixed.compute(
00146         tupleDesc,
00147         TUPLE_FORMAT_ALL_FIXED);
00148 
00149     boost::scoped_array<FixedBuffer> pTupleBufFixed(
00150         new FixedBuffer[tupleAccessor.getMaxByteCount()]);
00151     tupleAccessorFixed.setCurrentTupleBuf(pTupleBufFixed.get(), false);
00152 
00153     TupleData tupleDataFixed(tupleDesc);
00154     tupleAccessorFixed.unmarshal(tupleDataFixed);
00155 
00156     TupleData::iterator pDatum = tupleDataFixed.begin();
00157     for (uint i = STANDARD_TYPE_MIN; i < STANDARD_TYPE_END; ++i) {
00158         writeMinData(*pDatum,i);
00159         ++pDatum;
00160     }
00161     FENNEL_TRACE(TRACE_FINE,"testMarshal(MinData)");
00162     uint cbMinData = testMarshal(tupleDataFixed);
00163     BOOST_CHECK(cbMinData >= tupleAccessor.getMinByteCount());
00164     BOOST_CHECK(cbMinData < tupleAccessor.getMaxByteCount());
00165 
00166     pDatum = tupleDataFixed.begin();
00167     for (uint i = STANDARD_TYPE_MIN; i < STANDARD_TYPE_END; ++i) {
00168         writeMaxData(*pDatum,i);
00169         ++pDatum;
00170     }
00171     FENNEL_TRACE(TRACE_FINE,"testMarshal(MaxData)");
00172     uint cbMaxData = testMarshal(tupleDataFixed);
00173     BOOST_CHECK(cbMaxData > cbMinData);
00174     BOOST_CHECK(cbMaxData <= tupleAccessor.getMaxByteCount());
00175 
00176     pDatum = tupleDataFixed.begin();
00177     for (uint i = STANDARD_TYPE_MIN; i < STANDARD_TYPE_END; ++i) {
00178         writeSampleData(*pDatum,i);
00179         ++pDatum;
00180     }
00181     FENNEL_TRACE(TRACE_FINE,"testMarshal(SampleData)");
00182     uint cbSampleData = testMarshal(tupleDataFixed);
00183     BOOST_CHECK(cbSampleData >= tupleAccessor.getMinByteCount());
00184     BOOST_CHECK(cbSampleData <= tupleAccessor.getMaxByteCount());
00185 
00186     if (nullable) {
00187         pDatum = tupleDataFixed.begin();
00188         for (uint i = STANDARD_TYPE_MIN; i < STANDARD_TYPE_END; ++i) {
00189             pDatum->pData = NULL;
00190             ++pDatum;
00191         }
00192         FENNEL_TRACE(TRACE_FINE,"testMarshal(NullData)");
00193         uint cbNullData = testMarshal(tupleDataFixed);
00194         BOOST_CHECK(cbNullData >= tupleAccessor.getMinByteCount());
00195         BOOST_CHECK(cbNullData < tupleAccessor.getMaxByteCount());
00196     }
00197 }

void TupleTest::testZeroByteTuple (  )  [private]

Definition at line 504 of file TupleTest.cpp.

References TupleAccessor::compute(), TupleAccessor::getMaxByteCount(), TupleAccessor::getMinByteCount(), StandardTypeDescriptorFactory::newDataType(), STANDARD_TYPE_CHAR, tupleAccessor, and tupleDesc.

Referenced by TupleTest().

00505 {
00506     StandardTypeDescriptorFactory typeFactory;
00507     tupleDesc.clear();
00508     tupleDesc.push_back(
00509         TupleAttributeDescriptor(
00510             typeFactory.newDataType(STANDARD_TYPE_CHAR),
00511             false,
00512             0));
00513     TupleAccessor tupleAccessor;
00514     tupleAccessor.compute(tupleDesc);
00515 
00516     // verify that we didn't end up with a 0-byte tuple layout,
00517     // and that the min and max are equal since it's fixed-width
00518     BOOST_CHECK(tupleAccessor.getMinByteCount());
00519     BOOST_CHECK(tupleAccessor.getMaxByteCount());
00520     BOOST_CHECK_EQUAL(
00521         tupleAccessor.getMinByteCount(),
00522         tupleAccessor.getMaxByteCount());
00523 }

void TupleTest::testDebugAccess (  )  [private]

Definition at line 488 of file TupleTest.cpp.

References FixedBuffer, TupleAccessor::getMaxByteCount(), TupleAccessor::setCurrentTupleBuf(), testStandardTypesNullable(), and tupleAccessor.

Referenced by TupleTest().

00489 {
00490     StandardTypeDescriptorFactory typeFactory;
00491 
00492     // Just to set up tupleAccessor
00493     testStandardTypesNullable();
00494 
00495     boost::scoped_array<FixedBuffer> buf(
00496         new FixedBuffer[tupleAccessor.getMaxByteCount()]);
00497     memset(buf.get(), 0, tupleAccessor.getMaxByteCount());
00498 
00499     // This should cause an assertion failure when TupleAccessor.cpp's
00500     // DEBUG_TUPLE_ACCESS is set to 1.
00501     tupleAccessor.setCurrentTupleBuf(buf.get());
00502 }

void TupleTest::testLoadStoreUnaligned (  )  [private]

Definition at line 525 of file TupleTest.cpp.

References TupleDatum::cbData, FixedBuffer, loadAndStore8ByteInt(), loadStore2ByteLenData(), loadStore8ByteInts(), loadStoreNullData(), StandardTypeDescriptorFactory::newDataType(), TupleDatum::pData, STANDARD_TYPE_INT_16, STANDARD_TYPE_INT_32, STANDARD_TYPE_INT_64, and STANDARD_TYPE_VARBINARY.

Referenced by TupleTest().

00526 {
00527     // test compression of 8-byte integers
00528     loadStore8ByteInts(0, 0xff);
00529     loadStore8ByteInts(0x80, 0);
00530 
00531     // make sure zero is handled correctly
00532     loadAndStore8ByteInt(0);
00533 
00534     // test data that requires a 2-byte storage length
00535     loadStore2ByteLenData(128);
00536     loadStore2ByteLenData(129);
00537     loadStore2ByteLenData(255);
00538     loadStore2ByteLenData(256);
00539     loadStore2ByteLenData(257);
00540     loadStore2ByteLenData(510);
00541     loadStore2ByteLenData(511);
00542     loadStore2ByteLenData(512);
00543 
00544     // test special case of empty string
00545     loadStore2ByteLenData(0);
00546 
00547     // test null data
00548     loadStoreNullData(STANDARD_TYPE_INT_64, 8);
00549     loadStoreNullData(STANDARD_TYPE_INT_32, 4);
00550 
00551     // test fixed width data
00552     TupleDatum tupleDatum;
00553     tupleDatum.cbData = 2;
00554     int16_t intVal = 43981;
00555     tupleDatum.pData = (PConstBuffer) &intVal;
00556     FixedBuffer storageBuf[4];
00557     StandardTypeDescriptorFactory stdTypeFactory;
00558     TupleAttributeDescriptor attrDesc_int16(
00559         stdTypeFactory.newDataType(STANDARD_TYPE_INT_16));
00560     UnalignedAttributeAccessor accessor_int16(attrDesc_int16);
00561     accessor_int16.storeValue(tupleDatum, storageBuf);
00562     uint len = accessor_int16.getStoredByteCount(storageBuf);
00563     BOOST_REQUIRE(len == 2);
00564 
00565     FixedBuffer loadBuf[4];
00566     tupleDatum.cbData = 0xff;
00567     tupleDatum.pData = loadBuf;
00568     accessor_int16.loadValue(tupleDatum, storageBuf);
00569 
00570     BOOST_REQUIRE(tupleDatum.cbData == 2);
00571     bool rc = (intVal == *reinterpret_cast<int16_t const *> (tupleDatum.pData));
00572     BOOST_REQUIRE(rc);
00573 
00574     // test data with 1-byte storage length
00575     tupleDatum.cbData = 3;
00576     FixedBuffer data[3];
00577     data[0] = 0xba;
00578     data[0] = 0xdc;
00579     data[0] = 0xfe;
00580     tupleDatum.pData = data;
00581     TupleAttributeDescriptor attrDesc_varBinary(
00582         stdTypeFactory.newDataType(STANDARD_TYPE_VARBINARY),
00583         true,
00584         4);
00585     UnalignedAttributeAccessor accessor_varBinary(attrDesc_varBinary);
00586     accessor_varBinary.storeValue(tupleDatum, storageBuf);
00587     len = accessor_varBinary.getStoredByteCount(storageBuf);
00588     BOOST_REQUIRE(len == 4);
00589 
00590     tupleDatum.cbData = 0xff;
00591     tupleDatum.pData = loadBuf;
00592     accessor_varBinary.loadValue(tupleDatum, storageBuf);
00593 
00594     BOOST_REQUIRE(tupleDatum.cbData == 3);
00595     BOOST_REQUIRE(memcmp(tupleDatum.pData, data, 3) == 0);
00596 }

void TupleTest::loadStore8ByteInts ( int64_t  initialValue,
uint8_t  nextByte 
) [private]

Definition at line 598 of file TupleTest.cpp.

References loadAndStore8ByteInt().

Referenced by testLoadStoreUnaligned().

00599 {
00600     // Take the intial value, shift it to the left and OR the nextByte value
00601     // to generate the different test values.  Do this 8 times.  For each
00602     // value, try the value, value - 1, value + 1, as well as the negative of
00603     // each of those three values.
00604 
00605     int64_t intVal = initialValue;
00606     for (int i = 0; i < 8; i++) {
00607         intVal <<= 8;
00608         intVal |= nextByte;
00609 
00610         intVal--;
00611         loadAndStore8ByteInt(intVal);
00612         loadAndStore8ByteInt(-intVal);
00613 
00614         intVal++;
00615         loadAndStore8ByteInt(intVal);
00616         loadAndStore8ByteInt(-intVal);
00617 
00618         intVal++;
00619         loadAndStore8ByteInt(intVal);
00620         loadAndStore8ByteInt(-intVal);
00621 
00622         intVal--;
00623     }
00624 }

void TupleTest::loadAndStore8ByteInt ( int64_t  intVal  )  [private]

Definition at line 626 of file TupleTest.cpp.

References TupleDatum::cbData, FixedBuffer, StandardTypeDescriptorFactory::newDataType(), TupleDatum::pData, and STANDARD_TYPE_INT_64.

Referenced by loadStore8ByteInts(), and testLoadStoreUnaligned().

00627 {
00628     TupleDatum tupleDatum;
00629     // need 8+1 bytes in buffer; +1 for the length byte
00630     FixedBuffer storageBuf[9];
00631     FixedBuffer loadBuf[9];
00632 
00633     // compress and uncompress various 8-byte integers; verify the data
00634     // by storing the original value, loading the stored value and then
00635     // checking that it's the same as the original value
00636     tupleDatum.cbData = 8;
00637     tupleDatum.pData = (PConstBuffer) &intVal;
00638     StandardTypeDescriptorFactory stdTypeFactory;
00639     TupleAttributeDescriptor attrDesc(
00640         stdTypeFactory.newDataType(STANDARD_TYPE_INT_64));
00641     UnalignedAttributeAccessor accessor(attrDesc);
00642     accessor.storeValue(tupleDatum, storageBuf);
00643 
00644     // load the data into a different buffer so we're sure we're not reusing
00645     // the original stored value
00646     tupleDatum.cbData = 0;
00647     tupleDatum.pData = loadBuf;
00648     accessor.loadValue(tupleDatum, storageBuf);
00649     bool rc = (intVal == *reinterpret_cast<int64_t const *> (tupleDatum.pData));
00650     BOOST_REQUIRE(rc);
00651     BOOST_REQUIRE(tupleDatum.cbData == 8);
00652 }

void TupleTest::loadStore2ByteLenData ( uint  dataLen  )  [private]

Definition at line 654 of file TupleTest.cpp.

References TupleDatum::cbData, FixedBuffer, StandardTypeDescriptorFactory::newDataType(), TupleDatum::pData, and STANDARD_TYPE_BINARY.

Referenced by testLoadStoreUnaligned().

00655 {
00656     // initialize the source TupleDatum
00657     TupleDatum tupleDatum;
00658     tupleDatum.cbData = dataLen;
00659     boost::scoped_array<FixedBuffer> dataBuf(new FixedBuffer[dataLen + 2]);
00660     for (int i = 0; i < dataLen; i++) {
00661         dataBuf[i] = i;
00662     }
00663     tupleDatum.pData = dataBuf.get();
00664 
00665     // store it and verify the storage length
00666     boost::scoped_array<FixedBuffer> storageBuf(new FixedBuffer[dataLen + 2]);
00667     StandardTypeDescriptorFactory stdTypeFactory;
00668     TupleAttributeDescriptor attrDesc(
00669         stdTypeFactory.newDataType(STANDARD_TYPE_BINARY), true, dataLen);
00670     UnalignedAttributeAccessor accessor(attrDesc);
00671     accessor.storeValue(tupleDatum, storageBuf.get());
00672     uint len = accessor.getStoredByteCount(storageBuf.get());
00673     BOOST_REQUIRE(len == dataLen + 2);
00674 
00675     // load the stored value and compare it against the original data buffer
00676     boost::scoped_array<FixedBuffer> loadBuf(new FixedBuffer[dataLen + 2]);
00677     tupleDatum.cbData = 0;
00678     tupleDatum.pData = loadBuf.get();
00679     accessor.loadValue(tupleDatum, storageBuf.get());
00680     BOOST_REQUIRE(tupleDatum.cbData == dataLen);
00681     BOOST_REQUIRE(memcmp(tupleDatum.pData, dataBuf.get(), dataLen) == 0);
00682 }

void TupleTest::loadStoreNullData ( uint  typeOrdinal,
uint  len 
) [private]

Definition at line 684 of file TupleTest.cpp.

References TupleDatum::cbData, FixedBuffer, StandardTypeDescriptorFactory::newDataType(), and TupleDatum::pData.

Referenced by testLoadStoreUnaligned().

00685 {
00686     FixedBuffer storageBuf[2];
00687     TupleDatum tupleDatum;
00688     tupleDatum.cbData = 0;
00689     tupleDatum.pData = 0;
00690 
00691     StandardTypeDescriptorFactory stdTypeFactory;
00692     TupleAttributeDescriptor attrDesc(
00693         stdTypeFactory.newDataType(typeOrdinal),
00694         true,
00695         dataLen);
00696     UnalignedAttributeAccessor accessor(attrDesc);
00697 
00698     accessor.storeValue(tupleDatum, storageBuf);
00699     uint len = accessor.getStoredByteCount(storageBuf);
00700     BOOST_REQUIRE(len == 1);
00701 
00702     FixedBuffer loadBuf[2];
00703     tupleDatum.cbData = 0xff;
00704     tupleDatum.pData = loadBuf;
00705     accessor.loadValue(tupleDatum, storageBuf);
00706 
00707     BOOST_REQUIRE(tupleDatum.pData == NULL);
00708 }

void TupleTest::traceTuple ( TupleData const &  tupleData  )  [inline, private]

Definition at line 69 of file TupleTest.cpp.

References TuplePrinter::print(), TRACE_FINE, and tupleDesc.

Referenced by testMarshal().

00070     {
00071         std::ostringstream oss;
00072         TuplePrinter tuplePrinter;
00073         tuplePrinter.print(oss,tupleDesc,tupleData);
00074         std::string s = oss.str();
00075         FENNEL_TRACE(TRACE_FINE,s);
00076     }

void TestBase::snooze ( uint  nSeconds  )  [protected, inherited]

Definition at line 263 of file TestBase.cpp.

Referenced by DatabaseTest::executeForceTxn(), ThreadedTestBase::runThreadedTestCase(), PagingTestBase::testCacheResize(), BTreeTxnTest::testCheckpoint(), PagingTestBase::testCheckpointGuarded(), PagingTestBase::testPrefetch(), and PagingTestBase::testPrefetchBatch().

00264 {
00265 #ifdef __MSVC__
00266     ::_sleep(nSeconds*1000);
00267 #else
00268     ::sleep(nSeconds);
00269 #endif
00270 }

void TestBase::readParams ( int  argc,
char **  argv 
) [static, inherited]

Parses the command line.

format: [-v] [-t TEST | -all] {param=val}* [CONFIGFILE | -] Normally, the test program runs the default test cases. With the option "-all", runs the extra test cases as well. With the option "-t TEST", runs only the single test case named TEST. CONFIGFILE is read to load configuration parameters. Configuration parameters can also be set ad hoc, from the command line, as pairs name=val. These take precedence.

Definition at line 108 of file TestBase.cpp.

References TestBase::configMap, ConfigMap::dumpParams(), ConfigMap::isParamSet(), ConfigMap::mergeFrom(), TestBase::paramDictionaryFileName, ConfigMap::readParams(), TestBase::runAll, TestBase::runSingle, ConfigMap::setStringParam(), and verbose.

00109 {
00110     bool verbose = false;
00111     ConfigMap adhocMap;
00112 
00113     for (int i = 1; i < argc; ++i) {
00114         std::string arg = argv[i];
00115         if (argv[i][0] == '-') {
00116             if (arg == "-v") {
00117                 verbose = true;
00118             } else if (arg == "-") {
00119                 configMap.readParams(std::cin);
00120             } else if (arg == "-all") {
00121                 runAll = true;
00122             } else if (arg == "-t") {   // -t TEST
00123                 permAssert(i + 1 < argc);
00124                 runSingle = argv[++i];
00125             } else if (arg[1] == 't') { // allow -tTEST
00126                 runSingle = arg.substr(2);
00127             }
00128         } else {
00129             int i = arg.find("=");
00130             if ((0 < i) && (i < arg.size())) {
00131                 // an ad hoc parameter
00132                 std::string key = arg.substr(0,i);
00133                 std::string val = arg.substr(i + 1);
00134                 adhocMap.setStringParam(key,val);
00135             } else {
00136                 // a config file name
00137                 std::ifstream configFile(arg.c_str());
00138                 assert(configFile.good());
00139                 configMap.readParams(configFile);
00140             }
00141         }
00142     }
00143     configMap.mergeFrom(adhocMap);
00144 
00145     // set a default dictionary file location for use by tests that need a
00146     // small non-random sorted data set
00147     if (!configMap.isParamSet(paramDictionaryFileName)) {
00148         std::string dictFileName = "dictWords";
00149         configMap.setStringParam(paramDictionaryFileName,dictFileName);
00150     }
00151 
00152     if (verbose) {
00153         configMap.dumpParams(std::cout);
00154     }
00155 }

TestSuite * TestBase::releaseTestSuite (  )  [inherited]

Definition at line 157 of file TestBase.cpp.

References TestBase::TestCaseGroup::addAllToTestSuite(), TestBase::defaultTests, TestBase::extraTests, TestBase::TestCaseGroup::findTest(), TestBase::pTestObj, TestBase::pTestSuite, TestBase::runAll, TestBase::runSingle, and TestBase::testName.

00158 {
00159     assert(pTestObj);
00160     assert(pTestObj.use_count() > 1);
00161 
00162     // release self-reference now that all test cases have been registered
00163     pTestObj.reset();
00164 
00165     TestSuite* pTestSuite = BOOST_TEST_SUITE(testName.c_str());
00166 
00167     if (runSingle.size()) {
00168         test_unit *p =  defaultTests.findTest(runSingle);
00169         if (!p) {
00170             p = extraTests.findTest(runSingle);
00171         }
00172         if (!p) {
00173             std::cerr << "test " << runSingle << " not found\n";
00174             exit(2);
00175         }
00176         pTestSuite->add(p);
00177     } else {
00178         defaultTests.addAllToTestSuite(pTestSuite);
00179         if (runAll) {
00180             extraTests.addAllToTestSuite(pTestSuite);
00181         }
00182     }
00183     return pTestSuite;
00184 }

void TestBase::beforeTestCase ( std::string  testCaseName  )  [inherited]

Definition at line 214 of file TestBase.cpp.

References TestBase::configMap, TraceSource::initTraceSource(), AutoBacktrace::install(), TestBase::notifyTrace(), AutoBacktrace::setOutputStream(), AutoBacktrace::setTraceTarget(), TestBase::testName, and TRACE_INFO.

00215 {
00216     notifyTrace(testName,TRACE_INFO,"ENTER:  " + testCaseName);
00217 
00218     // Install the AutoBacktrace signal handler now, after
00219     // boost::execution_monitor::catch_signals() has installed its own, so that
00220     // on SIGABRT AutoBacktrace goes first, prints the backtrace, then chains
00221     // to boost, which handles the error.
00222     AutoBacktrace::setOutputStream();
00223     AutoBacktrace::setTraceTarget(shared_from_this());
00224     AutoBacktrace::install();
00225     configMap.initTraceSource(shared_from_this(), "testConfig");
00226 }

void TestBase::afterTestCase ( std::string  testCaseName  )  [inherited]

Definition at line 228 of file TestBase.cpp.

References TestBase::configMap, TraceSource::disableTracing(), TestBase::notifyTrace(), AutoBacktrace::setTraceTarget(), TestBase::testName, and TRACE_INFO.

00229 {
00230     AutoBacktrace::setTraceTarget();
00231     configMap.disableTracing();
00232     notifyTrace(testName,TRACE_INFO,"LEAVE:  " + testCaseName);
00233 }

void TestBase::testCaseSetUp (  )  [virtual, inherited]

Equivalent to JUnit TestCase.setUp; this is called before each test case method is invoked.

Default is no-op.

Reimplemented in LbmEntryTest, LbmExecStreamTestBase, LbmLoadBitmapTest, LbmSearchTest, LbmSplicerExecStreamTest, LcsClusterAppendExecStreamTest, LcsClusterReplaceExecStreamTest, LcsMultiClusterAppendTest, LcsRowScanExecStreamTest, BTreeReadersTest, BTreeTest, BTreeTxnTest, ExecStreamGovernorTest, ExecStreamTestBase, ExecStreamUnitTestBase, ExternalSortExecStreamTest, LhxHashTableTest, LogicalTxnTest, and SnapshotSegmentTestBase.

Definition at line 235 of file TestBase.cpp.

Referenced by ExecStreamTestBase::testCaseSetUp().

00236 {
00237 }

void TestBase::testCaseTearDown (  )  [virtual, inherited]

Equivalent to JUnit TestCase.tearDown; this is called after each test case method is invoked.

Default is no-op.

Reimplemented in LbmEntryTest, LbmLoadBitmapTest, LbmSearchTest, LcsClusterAppendExecStreamTest, LcsClusterReplaceExecStreamTest, LcsMultiClusterAppendTest, LcsRowScanExecStreamTest, BTreeReadersTest, BTreeTest, BTreeTxnTest, CacheTestBase, DatabaseTest, ExecStreamTestBase, LhxHashTableTest, RandomAccessFileDeviceTest, and SparseBitmapTest.

Definition at line 239 of file TestBase.cpp.

Referenced by SparseBitmapTest::testCaseTearDown().

00240 {
00241 }

void TestBase::notifyTrace ( std::string  source,
TraceLevel  level,
std::string  message 
) [virtual, inherited]

Receives notification when a trace event occurs.

Parameters:
source the facility from which the message originated
level the trace event severity level
message the text of the message

Implements TraceTarget.

Definition at line 243 of file TestBase.cpp.

References TestBase::traceFile, TestBase::traceMutex, TestBase::traceStdout, and TestBase::traceStream.

Referenced by TestBase::afterTestCase(), and TestBase::beforeTestCase().

00244 {
00245     if (traceFile || traceStdout) {
00246         StrictMutexGuard traceMutexGuard(traceMutex);
00247         if (traceFile) {
00248             traceStream << "[" << source << "] " << message << std::endl;
00249             traceStream.flush();
00250         }
00251         if (traceStdout) {
00252             std::cout << "[" << source << "] " << message << std::endl;
00253             std::cout.flush();
00254         }
00255     }
00256 }

TraceLevel TestBase::getSourceTraceLevel ( std::string  source  )  [virtual, inherited]

Gets the level at which a particular source should be traced.

Parameters:
source name of source to be traced
Returns:
minimum severity level which should be traced

Implements TraceTarget.

Definition at line 258 of file TestBase.cpp.

References TestBase::traceLevel.

Referenced by LbmExecStreamTestBase::generateBitmaps().

00259 {
00260     return traceLevel;
00261 }

void TraceSource::initTraceSource ( SharedTraceTarget  pTraceTarget,
std::string  name 
) [virtual, inherited]

For use when initialization has to be deferred until after construction.

Parameters:
pTraceTarget the TraceTarget to which messages will be sent
name the name of this source

Definition at line 46 of file TraceSource.cpp.

References TraceSource::isTracing(), TraceSource::minimumLevel, TraceSource::name, TraceSource::pTraceTarget, and TRACE_OFF.

Referenced by TestBase::beforeTestCase(), TestBase::TestBase(), and TraceSource::TraceSource().

00049 {
00050     assert(!pTraceTarget.get());
00051 
00052     pTraceTarget = pTraceTargetInit;
00053     name = nameInit;
00054     if (isTracing()) {
00055         minimumLevel = pTraceTarget->getSourceTraceLevel(name);
00056     } else {
00057         minimumLevel = TRACE_OFF;
00058     }
00059 }

void TraceSource::trace ( TraceLevel  level,
std::string  message 
) const [inherited]

Records a trace message.

Normally only called via FENNEL_TRACE.

Parameters:
level severity level of event being trace
message the text of the message

Definition at line 61 of file TraceSource.cpp.

References TraceSource::getTraceTarget(), TraceSource::isTracing(), TraceSource::name, and TraceTarget::notifyTrace().

Referenced by Calculator::exec(), and ExecStreamScheduler::traceStreamBufferContents().

00062 {
00063     if (isTracing()) {
00064         getTraceTarget().notifyTrace(name,level,message);
00065     }
00066 }

bool TraceSource::isTracing (  )  const [inline, inherited]

Returns:
true iff tracing is enabled for this source

Definition at line 88 of file TraceSource.h.

Referenced by TraceSource::initTraceSource(), CalcExecStream::prepare(), and TraceSource::trace().

00089     {
00090         return pTraceTarget.get() ? true : false;
00091     }

bool TraceSource::isTracingLevel ( TraceLevel  level  )  const [inline, inherited]

Determines whether a particular level is being traced.

Parameters:
level trace level to test
Returns:
true iff tracing is enabled for the given level

Definition at line 100 of file TraceSource.h.

Referenced by ExecStreamScheduler::addGraph(), SimpleExecStreamGovernor::assignCachePages(), SimpleExecStreamGovernor::distributeCachePages(), Calculator::exec(), ExecStreamScheduler::ExecStreamScheduler(), LcsClusterNodeWriter::getLastClusterPageForWrite(), LcsClusterNodeWriter::moveFromTempToIndex(), JavaSinkExecStream::stuffByteBuffer(), and ExecStreamScheduler::traceStreamBuffers().

00101     {
00102         return level >= minimumLevel;
00103     }

TraceTarget& TraceSource::getTraceTarget (  )  const [inline, inherited]

Returns:
the TraceTarget for this source

Definition at line 108 of file TraceSource.h.

Referenced by TraceSource::trace().

00109     {
00110         assert(isTracing());
00111         return *(pTraceTarget.get());
00112     }

SharedTraceTarget TraceSource::getSharedTraceTarget (  )  const [inline, inherited]

Returns:
the SharedTraceTarget for this source

Definition at line 117 of file TraceSource.h.

Referenced by Database::init(), LcsClusterAppendExecStream::initLoad(), and CalcExecStream::prepare().

00118     {
00119         return pTraceTarget;
00120     }

std::string TraceSource::getTraceSourceName (  )  const [inline, inherited]

Gets the name of this source.

Useful to construct nested names for subcomponents that are also TraceSources.

Returns:
the name

Definition at line 127 of file TraceSource.h.

Referenced by LcsClusterAppendExecStream::initLoad().

00128     {
00129         return name;
00130     }

void TraceSource::setTraceSourceName ( std::string const &  n  )  [inline, inherited]

Sets the name of this source.

Useful to construct dynamic names for fine-grained filtering.

Definition at line 136 of file TraceSource.h.

00137     {
00138         name = n;
00139     }

TraceLevel TraceSource::getMinimumTraceLevel (  )  const [inline, inherited]

Definition at line 141 of file TraceSource.h.

00142     {
00143         return minimumLevel;
00144     }

void TraceSource::disableTracing (  )  [inherited]

Definition at line 68 of file TraceSource.cpp.

References TraceSource::minimumLevel, TraceSource::pTraceTarget, and TRACE_OFF.

Referenced by TestBase::afterTestCase().

00069 {
00070     pTraceTarget.reset();
00071     minimumLevel = TRACE_OFF;
00072 }


Member Data Documentation

const uint TupleTest::MAX_WIDTH = 512 [static, private]

Definition at line 43 of file TupleTest.cpp.

Referenced by testStandardTypes(), writeMaxData(), and writeSampleData().

TupleDescriptor TupleTest::tupleDesc [private]

Definition at line 45 of file TupleTest.cpp.

Referenced by checkData(), testMarshal(), testStandardTypes(), testZeroByteTuple(), and traceTuple().

TupleAccessor TupleTest::tupleAccessor [private]

Definition at line 46 of file TupleTest.cpp.

Referenced by testDebugAccess(), testMarshal(), testStandardTypes(), and testZeroByteTuple().

TestSuite* TestBase::pTestSuite [protected, inherited]

Boost test suite.

Definition at line 59 of file TestBase.h.

Referenced by TestBase::releaseTestSuite().

boost::shared_ptr<TestBase> TestBase::pTestObj [protected, inherited]

Definition at line 61 of file TestBase.h.

Referenced by TestBase::releaseTestSuite(), and TestBase::TestBase().

std::ofstream TestBase::traceStream [protected, inherited]

Output file stream for tracing.

Definition at line 66 of file TestBase.h.

Referenced by TestBase::notifyTrace(), TestBase::TestBase(), and TestBase::~TestBase().

StrictMutex TestBase::traceMutex [protected, inherited]

Protects traceStream.

Definition at line 71 of file TestBase.h.

Referenced by TestBase::notifyTrace().

std::string TestBase::testName [protected, inherited]

Name of test.

Definition at line 76 of file TestBase.h.

Referenced by TestBase::afterTestCase(), TestBase::beforeTestCase(), TestBase::releaseTestSuite(), TestBase::TestBase(), LhxHashTableTest::testInsert1Ka(), and LhxHashTableTest::testInsert1Kb().

TraceLevel TestBase::traceLevel [protected, inherited]

Level at which to trace test execution.

Definition at line 81 of file TestBase.h.

Referenced by TestBase::getSourceTraceLevel(), and TestBase::TestBase().

FileStatsTarget TestBase::statsTarget [protected, inherited]

Output for stats.

Definition at line 86 of file TestBase.h.

StatsTimer TestBase::statsTimer [protected, inherited]

Timer for stats collection.

Definition at line 91 of file TestBase.h.

Referenced by CacheTestBase::closeStorage(), CacheTestBase::openStorage(), BTreeTxnTest::testCaseSetUp(), BTreeTxnTest::testCaseTearDown(), and BTreeTxnTest::testTxns().

bool TestBase::traceStdout [protected, inherited]

Copy trace output to stdout.

Definition at line 99 of file TestBase.h.

Referenced by TestBase::notifyTrace(), and TestBase::TestBase().

bool TestBase::traceFile [protected, inherited]

Copy trace output to file.

Definition at line 104 of file TestBase.h.

Referenced by TestBase::notifyTrace(), and TestBase::TestBase().

bool TestBase::runAll [static, protected, inherited]

Run all test cases, including the extra tests.

(static, since set by readParams())

Definition at line 110 of file TestBase.h.

Referenced by TestBase::readParams(), and TestBase::releaseTestSuite().

std::string TestBase::runSingle [static, protected, inherited]

Run only the test case of this name.

(static, since set by readParams())

Definition at line 116 of file TestBase.h.

Referenced by TestBase::readParams(), and TestBase::releaseTestSuite().

TestCaseGroup TestBase::defaultTests [protected, inherited]

Definition at line 139 of file TestBase.h.

Referenced by TestBase::releaseTestSuite().

TestCaseGroup TestBase::extraTests [protected, inherited]

Definition at line 140 of file TestBase.h.

Referenced by TestBase::releaseTestSuite().

ParamName TestBase::paramTestSuiteName [static, inherited]

Definition at line 143 of file TestBase.h.

Referenced by TestBase::TestBase().

ParamName TestBase::paramTraceFileName [static, inherited]

Definition at line 144 of file TestBase.h.

Referenced by TestBase::TestBase().

ParamName TestBase::paramDictionaryFileName [static, inherited]

Definition at line 145 of file TestBase.h.

Referenced by TestBase::readParams(), SegStreamTest::testRead(), and SegStreamTest::testWrite().

ParamName TestBase::paramTraceLevel [static, inherited]

Definition at line 146 of file TestBase.h.

Referenced by TestBase::TestBase().

ParamName TestBase::paramStatsFileName [static, inherited]

Definition at line 147 of file TestBase.h.

ParamName TestBase::paramTraceStdout [static, inherited]

Definition at line 148 of file TestBase.h.

Referenced by TestBase::TestBase().

ParamName TestBase::paramDegreeOfParallelism [static, inherited]

Definition at line 149 of file TestBase.h.

Referenced by ParallelExecStreamSchedulerTest::ParallelExecStreamSchedulerTest().

ConfigMap TestBase::configMap [static, inherited]

Configuration parameters.

The reason this is static is so that no constructor parameters (which burden virtual bases) are needed.

Definition at line 155 of file TestBase.h.

Referenced by TestBase::afterTestCase(), TestBase::beforeTestCase(), BTreeTxnTest::BTreeTxnTest(), CacheTestBase::CacheTestBase(), BackupRestoreTest::createSnapshotData(), DatabaseTest::DatabaseTest(), TestOptionsTest::extra(), DatabaseTest::loadDatabase(), SparseBitmapTest::openStorage(), PagingTestBase::PagingTestBase(), ParallelExecStreamSchedulerTest::ParallelExecStreamSchedulerTest(), RandomAccessFileDeviceTest::RandomAccessFileDeviceTest(), TestBase::readParams(), SegStorageTestBase::SegStorageTestBase(), TestOptionsTest::test1(), TestOptionsTest::test2(), BackupRestoreTest::testBackupCleanup(), TestBase::TestBase(), BTreeTxnTest::testCaseSetUp(), BTreeTxnTest::testCheckpoint(), DatabaseTest::testCreateEmpty(), DatabaseTest::testForceTxns(), BackupRestoreTest::testHeaderBackupRestore(), SegPageEntryIterTest::testIter(), SegStreamTest::testRead(), BTreeTxnTest::testTxns(), SegStreamTest::testWrite(), ThreadedTestBase::ThreadedTestBase(), and TestBase::~TestBase().


The documentation for this class was generated from the following file:
Generated on Mon Jun 22 04:00:48 2009 for Fennel by  doxygen 1.5.1