CalcCastTest Class Reference

Inheritance diagram for CalcCastTest:

TestBase TraceSource TraceTarget List of all members.

Public Member Functions

 CalcCastTest ()
virtual ~CalcCastTest ()
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 Types

typedef void(*) SetFunction (TupleDataWithBuffer &inTuple)
typedef void(*) CheckFunction (TupleDataWithBuffer const &inTuple, int numSrcTypes, deque< CalcMessage > &warnings, vector< int > const &expectedWarnings)

Private Member Functions

void PassAll ()
void NegValues ()
void Round ()
void Overflow ()
void Underflow ()
void testRoundInstruction ()

Static Private Member Functions

static void testExe (SetFunction setF, CheckFunction checkF, char const *const srcTypeStr, int numSrcTypes, char const *const destTypeStr, int numDestTypes, int warningCombos[][2], bool roundValues)
static bool shouldWarn (int warningCombos[][2], int srcIdx, int destIdx)
static void checkWarnings (deque< CalcMessage > &warnings, vector< int > const &expectedWarnings)
static void PassAllSet (TupleDataWithBuffer &inTuple)
static void PassAllCheck (TupleDataWithBuffer const &outTuple, int numSrcTypes, deque< CalcMessage > &warnings, vector< int > const &expectedWarnings)
static void NegValuesSet (TupleDataWithBuffer &inTuple)
static void NegValuesCheck (TupleDataWithBuffer const &outTuple, int numSrcTypes, deque< CalcMessage > &warnings, vector< int > const &expectedWarnings)
static void RoundSet (TupleDataWithBuffer &inTuple)
static void RoundCheck (TupleDataWithBuffer const &outTuple, int numSrcTypes, deque< CalcMessage > &warnings, vector< int > const &expectedWarnings)
static void OverflowSet (TupleDataWithBuffer &inTuple)
static void OverflowCheck (TupleDataWithBuffer const &outTuple, int numSrcTypes, deque< CalcMessage > &warnings, vector< int > const &expectedWarnings)
static void UnderflowSet (TupleDataWithBuffer &inTuple)
static void UnderflowCheck (TupleDataWithBuffer const &outTuple, int numSrcTypes, deque< CalcMessage > &warnings, vector< int > const &expectedWarnings)

Detailed Description

Definition at line 42 of file CalcCastTest.cpp.


Member Typedef Documentation

typedef void(*) CalcCastTest::SetFunction(TupleDataWithBuffer &inTuple) [private]

Definition at line 44 of file CalcCastTest.cpp.

typedef void(*) CalcCastTest::CheckFunction(TupleDataWithBuffer const &inTuple, int numSrcTypes, deque< CalcMessage > &warnings, vector< int > const &expectedWarnings) [private]

Definition at line 45 of file CalcCastTest.cpp.


Constructor & Destructor Documentation

CalcCastTest::CalcCastTest (  )  [inline, explicit]

Definition at line 124 of file CalcCastTest.cpp.

References CalcInit::instance(), NegValues(), Overflow(), PassAll(), Round(), testRoundInstruction(), and Underflow().

00125         : TraceSource(shared_from_this(), "CalcCastTest")
00126     {
00127         srand(time(NULL));
00128         CalcInit::instance();
00129         FENNEL_UNIT_TEST_CASE(CalcCastTest, testRoundInstruction);
00130         FENNEL_UNIT_TEST_CASE(CalcCastTest, PassAll);
00131         FENNEL_UNIT_TEST_CASE(CalcCastTest, NegValues);
00132         FENNEL_UNIT_TEST_CASE(CalcCastTest, Round);
00133         FENNEL_UNIT_TEST_CASE(CalcCastTest, Overflow);
00134         FENNEL_UNIT_TEST_CASE(CalcCastTest, Underflow);
00135     }

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

Definition at line 137 of file CalcCastTest.cpp.

00138     {
00139     }


Member Function Documentation

void CalcCastTest::testExe ( SetFunction  setF,
CheckFunction  checkF,
char const *const  srcTypeStr,
int  numSrcTypes,
char const *const  destTypeStr,
int  numDestTypes,
int  warningCombos[][2],
bool  roundValues 
) [static, private]

Definition at line 278 of file CalcCastTest.cpp.

References FennelExcn::getMessage(), and shouldWarn().

Referenced by NegValues(), Overflow(), PassAll(), Round(), and Underflow().

00287 {
00288     ostringstream pg(""), typeProduct("");
00289 
00290     int destIdx, srcIdx, idx, pc;
00291     bool warn;
00292     vector<int> expectedWarnings;
00293 
00294     // create a dest array with one row for each src type
00295     for (idx = 0; idx < numSrcTypes; idx++) {
00296         if (idx != 0) {
00297             typeProduct << "," << endl << "  ";
00298         }
00299         typeProduct << destTypeStr;
00300     }
00301     typeProduct << ";" << endl;
00302 
00303     pg << "L " << typeProduct.str();
00304     pg << "O " << typeProduct.str();
00305     pg << "I " << srcTypeStr << ";" << endl;
00306     // Slightly abusive use of status register for rounding.
00307     pg << "S " << srcTypeStr << ";" << endl;
00308     pg << "T;" << endl;
00309 
00310     if (roundValues) {
00311         for (srcIdx = 0; srcIdx < numSrcTypes; srcIdx++) {
00312             pg << "ROUND S" << srcIdx << ", I" << srcIdx << ";" << endl;
00313         }
00314     }
00315 
00316     destIdx = 0;
00317     pc = 0;
00318     for (srcIdx = 0; srcIdx < numSrcTypes; srcIdx++) {
00319         for (idx = 0; idx < numDestTypes; idx++) {
00320             warn = shouldWarn(warningCombos, srcIdx, idx);
00321             if (warn) {
00322                 expectedWarnings.push_back(pc);
00323                 BOOST_MESSAGE(
00324                     "ShouldWarn PC=" << pc << " size="
00325                     << expectedWarnings.size());
00326             }
00327             pg << "CAST L" << destIdx;
00328             if (roundValues) {
00329                 pg << ", S";
00330             } else {
00331                 pg << ", I";
00332             }
00333             pg << srcIdx << ";";
00334             pg << "    /* " << pc++ << (warn ? " WARN" : "");
00335             pg << " src=" << srcIdx << " dest=" << idx <<  "  */" << endl;
00336             pg << "REF  O" << destIdx << ", L" << destIdx << ";";
00337             pg << "    /* " << pc++ <<  " */" << endl;
00338             destIdx++;
00339         }
00340     }
00341 
00342     BOOST_MESSAGE(pg.str());
00343 
00344     Calculator calc(0);
00345 
00346     try {
00347         calc.assemble(pg.str().c_str());
00348     } catch (FennelExcn& ex) {
00349         BOOST_MESSAGE("Assemble exception " << ex.getMessage());
00350         BOOST_REQUIRE(0);
00351     }
00352 
00353     TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor());
00354     TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor());
00355 
00356     calc.bind(&inTuple, &outTuple);
00357 
00358     setF(inTuple);
00359 
00360     calc.exec();
00361     BOOST_MESSAGE("Calculator Warnings: |" << calc.warnings() << "|");
00362     checkF(outTuple, numSrcTypes, calc.mWarnings, expectedWarnings);
00363 }

bool CalcCastTest::shouldWarn ( int  warningCombos[][2],
int  srcIdx,
int  destIdx 
) [static, private]

Definition at line 366 of file CalcCastTest.cpp.

Referenced by testExe().

00370 {
00371     int idx = 0;
00372     // Yeah, so this is O(n^2). It's good enough for now, and probably forever.
00373     while (warningCombos[idx][0] >= 0 &&
00374            warningCombos[idx][1] >= 0) {
00375         if (warningCombos[idx][0] == srcIdx &&
00376             warningCombos[idx][1] == destIdx) {
00377             return true;
00378         }
00379         idx++;
00380     }
00381     return false;
00382 }

void CalcCastTest::checkWarnings ( deque< CalcMessage > &  warnings,
vector< int > const &  expectedWarnings 
) [static, private]

Definition at line 385 of file CalcCastTest.cpp.

Referenced by NegValuesCheck(), OverflowCheck(), PassAllCheck(), RoundCheck(), and UnderflowCheck().

00388 {
00389     deque<CalcMessage>::iterator iter = warnings.begin();
00390     deque<CalcMessage>::iterator end = warnings.end();
00391 
00392     int idx = 0;
00393     ostringstream ew("");
00394     ew << "Expected Warnings: (PC=) |";
00395     while (idx < expectedWarnings.size()) {
00396         ew << expectedWarnings[idx++] << ", ";
00397     }
00398     ew << "|" << endl;
00399     BOOST_MESSAGE(ew.str());
00400 
00401     idx = 0;
00402     while (idx < expectedWarnings.size()) {
00403         BOOST_CHECK(iter != end);
00404         BOOST_CHECK_EQUAL(iter->pc, expectedWarnings[idx]);
00405         BOOST_CHECK_EQUAL(0, strcmp(iter->str, "22003"));
00406         iter++;
00407         idx++;
00408     }
00409     BOOST_CHECK(iter == end);
00410 }

void CalcCastTest::PassAll (  )  [private]

Definition at line 518 of file CalcCastTest.cpp.

References PassAllCheck(), PassAllSet(), and testExe().

Referenced by CalcCastTest().

00519 {
00520     char const * const all =
00521         "s1, u1, s2, u2, s4, u4, s8, u8, r, d";
00522     //   0   1   2   3   4   5   6   7   8  9
00523 
00524     int warningCombos[][2] = {
00525         // src index from just above, then dest index from just above
00526         { -1, -1 }   // sentinel
00527     };
00528 
00529     testExe(
00530         CalcCastTest::PassAllSet,
00531         CalcCastTest::PassAllCheck,
00532         all, 10,
00533         all, 10,
00534         warningCombos,
00535         false);
00536 }

void CalcCastTest::PassAllSet ( TupleDataWithBuffer inTuple  )  [static, private]

Definition at line 413 of file CalcCastTest.cpp.

Referenced by PassAll().

00414 {
00415     uint64_t exact = 10;
00416     double approx = 20.0;
00417     int idx = 0;
00418 
00419     *(reinterpret_cast<int8_t *>
00420       (const_cast<PBuffer>(inTuple[idx++].pData))) = exact;
00421     *(reinterpret_cast<uint8_t *>
00422       (const_cast<PBuffer>(inTuple[idx++].pData))) = exact;
00423     *(reinterpret_cast<int16_t *>
00424       (const_cast<PBuffer>(inTuple[idx++].pData))) = exact;
00425     *(reinterpret_cast<uint16_t *>
00426       (const_cast<PBuffer>(inTuple[idx++].pData))) = exact;
00427     *(reinterpret_cast<int32_t *>
00428       (const_cast<PBuffer>(inTuple[idx++].pData))) = exact;
00429     *(reinterpret_cast<uint32_t *>
00430       (const_cast<PBuffer>(inTuple[idx++].pData))) = exact;
00431     *(reinterpret_cast<int64_t *>
00432       (const_cast<PBuffer>(inTuple[idx++].pData))) = exact;
00433     *(reinterpret_cast<uint64_t *>
00434       (const_cast<PBuffer>(inTuple[idx++].pData))) = exact;
00435 
00436     *(reinterpret_cast<float *>
00437       (const_cast<PBuffer>(inTuple[idx++].pData))) = approx;
00438     *(reinterpret_cast<double *>
00439       (const_cast<PBuffer>(inTuple[idx++].pData))) = approx;
00440 
00441 }

void CalcCastTest::PassAllCheck ( TupleDataWithBuffer const &  outTuple,
int  numSrcTypes,
deque< CalcMessage > &  warnings,
vector< int > const &  expectedWarnings 
) [static, private]

Definition at line 444 of file CalcCastTest.cpp.

References checkWarnings().

Referenced by PassAll().

00449 {
00450     checkWarnings(warnings, expectedWarnings);
00451 
00452     uint64_t exact;
00453     double approx;
00454     int i, idx = 0;
00455 
00456     for (i = 0; i < numSrcTypes; i++) {
00457         if (i < 8) {
00458             exact = 10;
00459             approx = 10;
00460         } else {
00461             exact = 20;
00462             approx = 20;
00463         }
00464         BOOST_CHECK_EQUAL(
00465             *(reinterpret_cast<int8_t *>(
00466                 const_cast<PBuffer>(outTuple[idx++].pData))),
00467             exact);
00468 
00469         BOOST_CHECK_EQUAL(
00470             *(reinterpret_cast<uint8_t *>(
00471                 const_cast<PBuffer>(outTuple[idx++].pData))),
00472             exact);
00473 
00474         BOOST_CHECK_EQUAL(
00475             *(reinterpret_cast<int16_t *>(
00476                 const_cast<PBuffer>(outTuple[idx++].pData))),
00477             exact);
00478 
00479         BOOST_CHECK_EQUAL(
00480             *(reinterpret_cast<uint16_t *>(
00481                 const_cast<PBuffer>(outTuple[idx++].pData))),
00482             exact);
00483 
00484         BOOST_CHECK_EQUAL(
00485             *(reinterpret_cast<int32_t *>(
00486                 const_cast<PBuffer>(outTuple[idx++].pData))),
00487             exact);
00488 
00489         BOOST_CHECK_EQUAL(
00490             *(reinterpret_cast<uint32_t *>(
00491                 const_cast<PBuffer>(outTuple[idx++].pData))),
00492             exact);
00493 
00494         BOOST_CHECK_EQUAL(
00495             *(reinterpret_cast<int64_t *>(
00496                 const_cast<PBuffer>(outTuple[idx++].pData))),
00497             exact);
00498 
00499         BOOST_CHECK_EQUAL(
00500             *(reinterpret_cast<uint64_t *>(
00501                 const_cast<PBuffer>(outTuple[idx++].pData))),
00502             exact);
00503 
00504         BOOST_CHECK_EQUAL(
00505             *(reinterpret_cast<float *>(
00506                 const_cast<PBuffer>(outTuple[idx++].pData))),
00507             approx);
00508 
00509         BOOST_CHECK_EQUAL(
00510             *(reinterpret_cast<double *>(
00511                 const_cast<PBuffer>(outTuple[idx++].pData))),
00512             approx);
00513     }
00514 }

void CalcCastTest::NegValues (  )  [private]

Definition at line 628 of file CalcCastTest.cpp.

References NegValuesCheck(), NegValuesSet(), and testExe().

Referenced by CalcCastTest().

00629 {
00630     char const * const src =
00631         "s1, s2, s4, s8, r, d";
00632     //   0   1   2   3   4  5
00633 
00634     char const * const dest =
00635         "s1, u1, s2, u2, s4, u4, s8, u8, r, d";
00636     //   0   1   2   3   4   5   6   7   8  9
00637 
00638     // combinations of types above that should generate warnings
00639     int warningCombos[][2] = {
00640         // src index from just above, then dest index from just above
00641         {0,  1  },  // s1 -> u1
00642         {  0,  3  },  // s1 -> u2
00643         {  0,  5  },
00644         {  0,  7  },
00645         {  1,  1  },  // s2 -> u1
00646         {  1,  3  },  // s2 -> u2
00647         {  1,  5  },
00648         {  1,  7  },
00649         {  2,  1  },  // s4 -> u1
00650         {  2,  3  },  // s4 -> u2
00651         {  2,  5  },
00652         {  2,  7  },
00653         {  3,  1  },  // s8 -> u1
00654         {  3,  3  },  // s8 -> u2
00655         {  3,  5  },
00656         {  3,  7  },
00657         {  4,  1  },  // r -> u1
00658         {  4,  3  },  // r -> u2
00659         {  4,  5  },
00660         {  4,  7  },
00661         {  5,  1  },  // d -> u1
00662         {  5,  3  },  // d -> u2
00663         {  5,  5  },
00664         {  5,  7  },
00665         {  -1, -1 }   // sentinel
00666     };
00667 
00668     testExe(
00669         CalcCastTest::NegValuesSet,
00670         CalcCastTest::NegValuesCheck,
00671         src, 6,
00672         dest, 10,
00673         warningCombos,
00674         false);
00675 }

void CalcCastTest::NegValuesSet ( TupleDataWithBuffer inTuple  )  [static, private]

Definition at line 540 of file CalcCastTest.cpp.

Referenced by NegValues().

00541 {
00542     int64_t exact = -10;
00543     double approx = -20.0;
00544     int idx = 0;
00545 
00546     *(reinterpret_cast<int8_t *>
00547       (const_cast<PBuffer>(inTuple[idx++].pData))) = exact;
00548     *(reinterpret_cast<int16_t *>
00549       (const_cast<PBuffer>(inTuple[idx++].pData))) = exact;
00550     *(reinterpret_cast<int32_t *>
00551       (const_cast<PBuffer>(inTuple[idx++].pData))) = exact;
00552     *(reinterpret_cast<int64_t *>
00553       (const_cast<PBuffer>(inTuple[idx++].pData))) = exact;
00554 
00555     *(reinterpret_cast<float *>
00556       (const_cast<PBuffer>(inTuple[idx++].pData))) = approx;
00557     *(reinterpret_cast<double *>
00558       (const_cast<PBuffer>(inTuple[idx++].pData))) = approx;
00559 }

void CalcCastTest::NegValuesCheck ( TupleDataWithBuffer const &  outTuple,
int  numSrcTypes,
deque< CalcMessage > &  warnings,
vector< int > const &  expectedWarnings 
) [static, private]

Definition at line 562 of file CalcCastTest.cpp.

References checkWarnings().

Referenced by NegValues().

00567 {
00568     checkWarnings(warnings, expectedWarnings);
00569 
00570     int64_t exact = -10;
00571     double approx = -20.0;
00572     int i, idx = 0;
00573 
00574     for (i = 0; i < numSrcTypes; i++) {
00575         if (i < 4) {
00576             exact = -10;
00577             approx = -10;
00578         } else {
00579             exact = -20;
00580             approx = -20;
00581         }
00582         BOOST_CHECK_EQUAL(
00583             *(reinterpret_cast<int8_t *>(
00584                 const_cast<PBuffer>(outTuple[idx++].pData))),
00585             exact);
00586 
00587         // uint8_t always generates a warning
00588         idx++;
00589 
00590         BOOST_CHECK_EQUAL(
00591             *(reinterpret_cast<int16_t *>(
00592                 const_cast<PBuffer>(outTuple[idx++].pData))),
00593             exact);
00594 
00595         // uint16_t always generates a warning
00596         idx++;
00597 
00598         BOOST_CHECK_EQUAL(
00599             *(reinterpret_cast<int32_t *>(
00600                 const_cast<PBuffer>(outTuple[idx++].pData))),
00601             exact);
00602 
00603         // uint32_t always generates a warning
00604         idx++;
00605 
00606         BOOST_CHECK_EQUAL(
00607             *(reinterpret_cast<int64_t *>(
00608                 const_cast<PBuffer>(outTuple[idx++].pData))),
00609             exact);
00610 
00611         // uint64_t always generates a warning
00612         idx++;
00613 
00614         BOOST_CHECK_EQUAL(
00615             *(reinterpret_cast<float *>(
00616                 const_cast<PBuffer>(outTuple[idx++].pData))),
00617             approx);
00618 
00619         BOOST_CHECK_EQUAL(
00620             *(reinterpret_cast<double *>(
00621                 const_cast<PBuffer>(outTuple[idx++].pData))),
00622             approx);
00623     }
00624 }

void CalcCastTest::Round (  )  [private]

Definition at line 754 of file CalcCastTest.cpp.

References RoundCheck(), RoundSet(), and testExe().

Referenced by CalcCastTest().

00755 {
00756     char const * const src =
00757         "r, d, r, d, r, d";
00758     //   0  1  2  3  4  5
00759 
00760     char const * const dest =
00761         "s1, u1, s2, u2, s4, u4, s8, u8";
00762     //   0   1   2   3   4   5   6   7
00763 
00764     // combinations of types above that should generate warnings
00765     int warningCombos[][2] = {
00766         // src index from just above, then dest index from just above
00767         {  -1, -1 }   // sentinel
00768     };
00769 
00770     testExe(
00771         CalcCastTest::RoundSet,
00772         CalcCastTest::RoundCheck,
00773         src, 6,
00774         dest, 8,
00775         warningCombos,
00776         true);
00777 }

void CalcCastTest::RoundSet ( TupleDataWithBuffer inTuple  )  [static, private]

Definition at line 679 of file CalcCastTest.cpp.

Referenced by Round().

00680 {
00681     // expect 20, 21, 21
00682     double val[3] = { 20.2, 20.5, 20.7 };
00683 
00684     int idx = 0, group;
00685 
00686     for (group = 0; group < 3; group++) {
00687         *(reinterpret_cast<float *>
00688           (const_cast<PBuffer>(inTuple[idx++].pData))) = val[group];
00689         *(reinterpret_cast<double *>
00690           (const_cast<PBuffer>(inTuple[idx++].pData))) = val[group];
00691     }
00692 }

void CalcCastTest::RoundCheck ( TupleDataWithBuffer const &  outTuple,
int  numSrcTypes,
deque< CalcMessage > &  warnings,
vector< int > const &  expectedWarnings 
) [static, private]

Definition at line 695 of file CalcCastTest.cpp.

References checkWarnings().

Referenced by Round().

00700 {
00701     checkWarnings(warnings, expectedWarnings);
00702 
00703     int64_t valE[3] = { 20, 21, 21 }, exact;
00704     int group, srcI, idx = 0;
00705 
00706     for (group = 0; group < 3; group++) {
00707         exact = valE[group];
00708         for (srcI = 0; srcI < 2; srcI++) {
00709             BOOST_CHECK_EQUAL(
00710                 *(reinterpret_cast<int8_t *>(
00711                     const_cast<PBuffer>(outTuple[idx++].pData))),
00712                 exact);
00713 
00714             BOOST_CHECK_EQUAL(
00715                 *(reinterpret_cast<uint8_t *>(
00716                     const_cast<PBuffer>(outTuple[idx++].pData))),
00717                 exact);
00718 
00719             BOOST_CHECK_EQUAL(
00720                 *(reinterpret_cast<int16_t *>(
00721                     const_cast<PBuffer>(outTuple[idx++].pData))),
00722                 exact);
00723 
00724             BOOST_CHECK_EQUAL(
00725                 *(reinterpret_cast<uint16_t *>(
00726                     const_cast<PBuffer>(outTuple[idx++].pData))),
00727                 exact);
00728 
00729             BOOST_CHECK_EQUAL(
00730                 *(reinterpret_cast<int32_t *>(
00731                     const_cast<PBuffer>(outTuple[idx++].pData))),
00732                 exact);
00733 
00734             BOOST_CHECK_EQUAL(
00735                 *(reinterpret_cast<uint32_t *>(
00736                     const_cast<PBuffer>(outTuple[idx++].pData))),
00737                 exact);
00738 
00739             BOOST_CHECK_EQUAL(
00740                 *(reinterpret_cast<int64_t *>(
00741                     const_cast<PBuffer>(outTuple[idx++].pData))),
00742                 exact);
00743 
00744             BOOST_CHECK_EQUAL(
00745                 *(reinterpret_cast<uint64_t *>(
00746                     const_cast<PBuffer>(outTuple[idx++].pData))),
00747                 exact);
00748         }
00749     }
00750 }

void CalcCastTest::Overflow (  )  [private]

Definition at line 832 of file CalcCastTest.cpp.

References OverflowCheck(), OverflowSet(), and testExe().

Referenced by CalcCastTest().

00833 {
00834     char const * const src =
00835         "s1, u1, s2, u2, s4, u4, s8, u8, r, d";
00836     //   0   1   2   3   4   5   6   7   8  9
00837 
00838     char const * const dest =
00839         "s1, u1, s2, u2, s4, u4, s8, u8, r, d";
00840     //   0   1   2   3   4   5   6   7   8  9
00841 
00842     // combinations of types above that should generate warnings
00843     int warningCombos[][2] = {
00844         // src index from just above, then dest index from just above
00845         {  1,  0  },  // u1 -> s1
00846         {  2,  0  },  // s2 -> s1
00847         {  2,  1  },  // s2 -> u1
00848         {  3,  0  },  // u2 -> s1
00849         {  3,  1  },  // u2 -> u1
00850         {  3,  2  },  // u2 -> s2
00851         {  4,  0  },  // s4 -> s1
00852         {  4,  1  },  // s4 -> u1
00853         {  4,  2  },  // s4 -> s2
00854         {  4,  3  },  // s4 -> s2
00855         {  5,  0  },  // u4 -> s1
00856         {  5,  1  },  // u4 -> u1
00857         {  5,  2  },  // u4 -> s2
00858         {  5,  3  },  // u4 -> s2
00859         {  5,  4  },  // u4 -> s2
00860         {  6,  0  },  // etc...
00861         {  6,  1  },
00862         {  6,  2  },
00863         {  6,  3  },
00864         {  6,  4  },
00865         {  6,  5  },
00866         {  7,  0  },
00867         {  7,  1  },
00868         {  7,  2  },
00869         {  7,  3  },
00870         {  7,  4  },
00871         {  7,  5  },
00872         {  7,  6  },  // u8 -> s8
00873         // REVIEW jvs 14-Aug-2005:  When I upgraded
00874         // to boost 1.33, the semantics for these two changed.
00875         // Loss of precision isn't the same as overflow, so
00876         // maybe the new semantics are better?
00877         /*
00878         {  7,  8  },  // u8 -> r (loss of precision)
00879         {  7,  9  },  // u8 -> d (loss of precision)
00880         */
00881         {  8,  0  },
00882         {  8,  1  },
00883         {  8,  2  },
00884         {  8,  3  },
00885         {  8,  4  },
00886         {  8,  5  },
00887         {  8,  6  },  // man, you'd think I'da automated this by now.
00888         {  8,  7  },
00889         {  9,  0  },
00890         {  9,  1  },
00891         {  9,  2  },
00892         {  9,  3  },
00893         {  9,  4  },
00894         {  9,  5  },
00895         {  9,  6  },
00896         {  9,  7  },
00897         {  9,  8  },  // d -> r
00898 
00899         { -1, -1  }   // sentinel
00900     };
00901 
00902     testExe(
00903         CalcCastTest::OverflowSet,
00904             CalcCastTest::OverflowCheck,
00905             src, 10,
00906             dest, 10,
00907             warningCombos,
00908             false);
00909 }

void CalcCastTest::OverflowSet ( TupleDataWithBuffer inTuple  )  [static, private]

Definition at line 781 of file CalcCastTest.cpp.

References max().

Referenced by Overflow().

00782 {
00783     int idx = 0;
00784 
00785     *(reinterpret_cast<int8_t *>
00786       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00787         std::numeric_limits<int8_t>::max();
00788     *(reinterpret_cast<uint8_t *>
00789       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00790         std::numeric_limits<uint8_t>::max();
00791     *(reinterpret_cast<int16_t *>
00792       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00793         std::numeric_limits<int16_t>::max();
00794     *(reinterpret_cast<uint16_t *>
00795       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00796         std::numeric_limits<uint16_t>::max();
00797     *(reinterpret_cast<int32_t *>
00798       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00799         std::numeric_limits<int32_t>::max();
00800     *(reinterpret_cast<uint32_t *>
00801       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00802         std::numeric_limits<uint32_t>::max();
00803     *(reinterpret_cast<int64_t *>
00804       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00805         std::numeric_limits<int64_t>::max();
00806     *(reinterpret_cast<uint64_t *>
00807       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00808         std::numeric_limits<uint64_t>::max();
00809     *(reinterpret_cast<float *>
00810       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00811         std::numeric_limits<float>::max();
00812     *(reinterpret_cast<double *>
00813       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00814         std::numeric_limits<double>::max();
00815 }

void CalcCastTest::OverflowCheck ( TupleDataWithBuffer const &  outTuple,
int  numSrcTypes,
deque< CalcMessage > &  warnings,
vector< int > const &  expectedWarnings 
) [static, private]

Definition at line 818 of file CalcCastTest.cpp.

References checkWarnings().

Referenced by Overflow().

00823 {
00824     checkWarnings(warnings, expectedWarnings);
00825 
00826     // TODO: Checking that the non-warning values are correct would be
00827     // rather complex. Punt for now.
00828 }

void CalcCastTest::Underflow (  )  [private]

Definition at line 969 of file CalcCastTest.cpp.

References testExe(), UnderflowCheck(), and UnderflowSet().

Referenced by CalcCastTest().

00970 {
00971     char const * const src =
00972         "s1, u1, s2, u2, s4, u4, s8, u8, r, d";
00973     //   0   1   2   3   4   5   6   7   8  9
00974 
00975     char const * const dest =
00976         "s1, u1, s2, u2, s4, u4, s8, u8, r, d";
00977     //   0   1   2   3   4   5   6   7   8  9
00978 
00979     // combinations of types above that should generate warnings
00980     int warningCombos[][2] = {
00981         // src index from just above, then dest index from just above
00982         {  0,  1  },  // s1 -> u1
00983         {  0,  3  },  // s1 -> u2
00984         {  0,  5  },  // s1 -> u4
00985         {  0,  7  },  // s1 -> u8
00986 
00987         {  2,  0  },  // s2 -> s1
00988         {  2,  1  },  // s2 -> u1
00989         {  2,  3  },  // s2 -> u2
00990         {  2,  5  },  // s2 -> u4
00991         {  2,  7  },  // s2 -> u8
00992 
00993         {  4,  0  },  // s4 -> s1
00994         {  4,  1  },  // s4 -> u1
00995         {  4,  2  },  // s4 -> s2
00996         {  4,  3  },  // s4 -> u2
00997         {  4,  5  },  // s4 -> u4
00998         {  4,  7  },  // s4 -> u8
00999 
01000         {  6,  0  },  // s8 -> s1
01001         {  6,  1  },  // s8 -> u1
01002         {  6,  2  },  // s8 -> s2
01003         {  6,  3  },  // s8 -> u2
01004         {  6,  4  },  // s8 -> s4
01005         {  6,  5  },  // s8 -> u4
01006         {  6,  7  },  // s8 -> u8
01007 
01008         {  8,  0  },  // r -> s1
01009         {  8,  1  },  // r -> u1
01010         {  8,  2  },  // r -> s2
01011         {  8,  3  },  // r -> u2
01012         {  8,  4  },  // r -> s4
01013         {  8,  5  },  // r -> u4
01014         {  8,  6  },  // r -> s8
01015         {  8,  7  },  // r -> u8
01016 
01017         {  9,  0  },  // d -> s1
01018         {  9,  1  },  // d -> u1
01019         {  9,  2  },  // d -> s2
01020         {  9,  3  },  // d -> u2
01021         {  9,  4  },  // d -> s4
01022         {  9,  5  },  // d -> u4
01023         {  9,  6  },  // d -> s8
01024         {  9,  7  },  // d -> u8
01025         {  9,  8  },  // d -> r
01026 
01027         { -1, -1  }   // sentinel
01028     };
01029 
01030     testExe(
01031         CalcCastTest::UnderflowSet,
01032         CalcCastTest::UnderflowCheck,
01033         src, 10,
01034         dest, 10,
01035         warningCombos,
01036         false);
01037 }

void CalcCastTest::UnderflowSet ( TupleDataWithBuffer inTuple  )  [static, private]

Definition at line 914 of file CalcCastTest.cpp.

References max(), and min().

Referenced by Underflow().

00915 {
00916     int idx = 0;
00917 
00918     *(reinterpret_cast<int8_t *>
00919       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00920         std::numeric_limits<int8_t>::min();
00921     *(reinterpret_cast<uint8_t *>
00922       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00923         std::numeric_limits<uint8_t>::min();
00924     *(reinterpret_cast<int16_t *>
00925       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00926         std::numeric_limits<int16_t>::min();
00927     *(reinterpret_cast<uint16_t *>
00928       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00929         std::numeric_limits<uint16_t>::min();
00930     *(reinterpret_cast<int32_t *>
00931       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00932         std::numeric_limits<int32_t>::min();
00933     *(reinterpret_cast<uint32_t *>
00934       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00935         std::numeric_limits<uint32_t>::min();
00936     *(reinterpret_cast<int64_t *>
00937       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00938         std::numeric_limits<int64_t>::min();
00939     *(reinterpret_cast<uint64_t *>
00940       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00941         std::numeric_limits<uint64_t>::min();
00942 
00943     // Note: min() for approx type is the smallest positive
00944     // number, not the most negative number. Unary minus of max()
00945     // gives smallest possible (very negative) number.
00946     *(reinterpret_cast<float *>
00947       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00948         -std::numeric_limits<float>::max();
00949     *(reinterpret_cast<double *>
00950       (const_cast<PBuffer>(inTuple[idx++].pData))) =
00951         -std::numeric_limits<double>::max();
00952 }

void CalcCastTest::UnderflowCheck ( TupleDataWithBuffer const &  outTuple,
int  numSrcTypes,
deque< CalcMessage > &  warnings,
vector< int > const &  expectedWarnings 
) [static, private]

Definition at line 955 of file CalcCastTest.cpp.

References checkWarnings().

Referenced by Underflow().

00960 {
00961     checkWarnings(warnings, expectedWarnings);
00962 
00963     // TODO: Checking that the non-warning values are correct would be
00964     // rather complex. Punt for now.
00965 }

void CalcCastTest::testRoundInstruction (  )  [private]

Definition at line 144 of file CalcCastTest.cpp.

References FennelExcn::getMessage().

Referenced by CalcCastTest().

00145 {
00146     ostringstream pg("");
00147     int idx;
00148 
00149     const char * const all =
00150         "s1, u1, s2, u2, s4, u4, s8, u8, r, r, r, r, r, d, d, d, d, d";
00151     //   0   1   2   3   4   5   6   7   8  9  10 11 12 13 14 15 16 17
00152 
00153     pg << "O " << all << ";" << endl;
00154     pg << "L " << all << ";" << endl;
00155     pg << "C " << all << ";" << endl;
00156     pg << "V 2, 2, 2, 2, 2, 2, 2, 2,";
00157     pg << "  -0.5, -0.25, 0.0, 0.25, 0.5,";
00158     pg << "  -0.5, -0.25, 0.0, 0.25, 0.5;" << endl;
00159     pg << "T;" << endl;
00160 
00161     for (idx = 0; idx < 18; idx++) {
00162         pg << "ROUND L" << idx << ", C" << idx << ";" << endl;
00163         pg << "REF   O" << idx << ", L" << idx << ";" << endl;
00164     }
00165 
00166     BOOST_MESSAGE(pg.str());
00167 
00168     Calculator calc(0);
00169 
00170     try {
00171         calc.assemble(pg.str().c_str());
00172     } catch (FennelExcn& ex) {
00173         BOOST_MESSAGE("Assemble exception " << ex.getMessage());
00174         BOOST_REQUIRE(0);
00175     }
00176 
00177     TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor());
00178     TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor());
00179 
00180     calc.bind(&inTuple, &outTuple);
00181     calc.exec();
00182 
00183     int64_t exact = 2;
00184     idx = 0;
00185 
00186     BOOST_CHECK_EQUAL(
00187         *(reinterpret_cast<int8_t *>(
00188             const_cast<PBuffer>(outTuple[idx++].pData))),
00189         exact);
00190 
00191     BOOST_CHECK_EQUAL(
00192         *(reinterpret_cast<uint8_t *>(
00193             const_cast<PBuffer>(outTuple[idx++].pData))),
00194         exact);
00195 
00196     BOOST_CHECK_EQUAL(
00197         *(reinterpret_cast<int16_t *>(
00198             const_cast<PBuffer>(outTuple[idx++].pData))),
00199         exact);
00200 
00201     BOOST_CHECK_EQUAL(
00202         *(reinterpret_cast<uint16_t *>(
00203             const_cast<PBuffer>(outTuple[idx++].pData))),
00204         exact);
00205 
00206     BOOST_CHECK_EQUAL(
00207         *(reinterpret_cast<int32_t *>(
00208             const_cast<PBuffer>(outTuple[idx++].pData))),
00209         exact);
00210 
00211     BOOST_CHECK_EQUAL(
00212         *(reinterpret_cast<uint32_t *>(
00213             const_cast<PBuffer>(outTuple[idx++].pData))),
00214         exact);
00215 
00216     BOOST_CHECK_EQUAL(
00217         *(reinterpret_cast<int64_t *>(
00218             const_cast<PBuffer>(outTuple[idx++].pData))),
00219         exact);
00220 
00221     BOOST_CHECK_EQUAL(
00222         *(reinterpret_cast<uint64_t *>(
00223             const_cast<PBuffer>(outTuple[idx++].pData))),
00224         exact);
00225 
00226     BOOST_CHECK_EQUAL(
00227         *(reinterpret_cast<float *>(
00228             const_cast<PBuffer>(outTuple[idx++].pData))),
00229         -1.0);
00230 
00231     BOOST_CHECK_EQUAL(
00232         *(reinterpret_cast<float *>(
00233             const_cast<PBuffer>(outTuple[idx++].pData))),
00234         0.0);
00235 
00236     BOOST_CHECK_EQUAL(
00237         *(reinterpret_cast<float *>(
00238             const_cast<PBuffer>(outTuple[idx++].pData))),
00239         0.0);
00240 
00241     BOOST_CHECK_EQUAL(
00242         *(reinterpret_cast<float *>(
00243             const_cast<PBuffer>(outTuple[idx++].pData))),
00244         0.0);
00245 
00246     BOOST_CHECK_EQUAL(
00247         *(reinterpret_cast<float *>(
00248             const_cast<PBuffer>(outTuple[idx++].pData))),
00249         1.0);
00250 
00251     BOOST_CHECK_EQUAL(
00252         *(reinterpret_cast<double *>(
00253             const_cast<PBuffer>(outTuple[idx++].pData))),
00254         -1.0);
00255 
00256     BOOST_CHECK_EQUAL(
00257         *(reinterpret_cast<double *>(
00258             const_cast<PBuffer>(outTuple[idx++].pData))),
00259         0.0);
00260 
00261     BOOST_CHECK_EQUAL(
00262         *(reinterpret_cast<double *>(
00263             const_cast<PBuffer>(outTuple[idx++].pData))),
00264         0.0);
00265 
00266     BOOST_CHECK_EQUAL(
00267         *(reinterpret_cast<double *>(
00268             const_cast<PBuffer>(outTuple[idx++].pData))),
00269         0.0);
00270 
00271     BOOST_CHECK_EQUAL(
00272         *(reinterpret_cast<double *>(
00273             const_cast<PBuffer>(outTuple[idx++].pData))),
00274         1.0);
00275 }

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

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:27 2009 for Fennel by  doxygen 1.5.1