CalcMiscTest Class Reference

Inheritance diagram for CalcMiscTest:

TestBase TraceSource TraceTarget List of all members.

Public Member Functions

 CalcMiscTest ()
virtual ~CalcMiscTest ()
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 testCalcStatusReg ()
void testCalcStatusRegZero ()
void testCalcRefInst ()
void testCalcReturn ()
void testCalcRaise ()
void testCalcContinueOnException ()

Detailed Description

Definition at line 43 of file CalcMiscTest.cpp.


Constructor & Destructor Documentation

CalcMiscTest::CalcMiscTest (  )  [inline, explicit]

Definition at line 53 of file CalcMiscTest.cpp.

References CalcInit::instance(), testCalcContinueOnException(), testCalcRaise(), testCalcRefInst(), testCalcReturn(), testCalcStatusReg(), and testCalcStatusRegZero().

00054         : TraceSource(shared_from_this(),"CalcMiscTest")
00055     {
00056         srand(time(NULL));
00057         CalcInit::instance();
00058         FENNEL_UNIT_TEST_CASE(CalcMiscTest, testCalcStatusReg);
00059         FENNEL_UNIT_TEST_CASE(CalcMiscTest, testCalcStatusRegZero);
00060         FENNEL_UNIT_TEST_CASE(CalcMiscTest, testCalcRefInst);
00061         FENNEL_UNIT_TEST_CASE(CalcMiscTest, testCalcReturn);
00062         FENNEL_UNIT_TEST_CASE(CalcMiscTest, testCalcRaise);
00063         FENNEL_UNIT_TEST_CASE(CalcMiscTest, testCalcContinueOnException);
00064     }

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

Definition at line 66 of file CalcMiscTest.cpp.

00067     {
00068     }


Member Function Documentation

void CalcMiscTest::testCalcStatusReg (  )  [private]

Definition at line 72 of file CalcMiscTest.cpp.

References Calculator::assemble(), Calculator::bind(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), Calculator::getStatusRegister(), Calculator::getStatusRegisterDescriptor(), and TuplePrinter::print().

Referenced by CalcMiscTest().

00073 {
00074     ostringstream pg("");
00075 
00076     pg << "L u2;" << endl;
00077     pg << "O u2;" << endl;
00078     pg << "S u2, u2, u2;" << endl;
00079     pg << "C u2, u2, u2;" << endl;
00080     pg << "V 4, 5, 6;" << endl;
00081     pg << "T;" << endl;
00082     pg << "MOVE S 0, C 0;" << endl;
00083     pg << "MOVE L 0, C 1;" << endl;
00084     pg << "REF  O 0, C 2;" << endl;
00085     pg << "MOVE S 1, L 0;" << endl;
00086     pg << "MOVE S 2, O 0;" << endl;
00087 
00088     // BOOST_MESSAGE(pg.str());
00089 
00090     Calculator calc(0);
00091 
00092     try {
00093         calc.assemble(pg.str().c_str());
00094     } catch (FennelExcn& ex) {
00095         BOOST_MESSAGE("Assemble exception " << ex.getMessage());
00096         BOOST_REQUIRE(0);
00097     }
00098 
00099     TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor());
00100     TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor());
00101 
00102     calc.bind(&inTuple, &outTuple);
00103     calc.exec();
00104 
00105     TupleData const * const statusTuple = calc.getStatusRegister();
00106 #if 0
00107     TupleDescriptor statusDesc = calc.getStatusRegisterDescriptor();
00108     TuplePrinter tuplePrinter;
00109     tuplePrinter.print(cout, statusDesc, *statusTuple);
00110     cout << endl;
00111 #endif
00112 
00113     BOOST_CHECK_EQUAL(
00114         *(reinterpret_cast<uint16_t *>(
00115             const_cast<PBuffer>((*statusTuple)[0].pData))),
00116         4);
00117     BOOST_CHECK_EQUAL(
00118         *(reinterpret_cast<uint16_t *>(
00119             const_cast<PBuffer>((*statusTuple)[1].pData))),
00120         5);
00121     BOOST_CHECK_EQUAL(
00122         *(reinterpret_cast<uint16_t *>(
00123             const_cast<PBuffer>((*statusTuple)[2].pData))),
00124         6);
00125 }

void CalcMiscTest::testCalcStatusRegZero (  )  [private]

Definition at line 128 of file CalcMiscTest.cpp.

References Calculator::assemble(), Calculator::bind(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), Calculator::getStatusRegister(), and Calculator::zeroStatusRegister().

Referenced by CalcMiscTest().

00129 {
00130     ostringstream pg("");
00131 
00132     pg << "L u2;" << endl;
00133     pg << "O u2;" << endl;
00134     pg << "S u2, u2;" << endl;
00135     pg << "C u2, u2;" << endl;
00136     pg << "V 1, 2;" << endl;
00137     pg << "T;" << endl;
00138     pg << "MOVE L 0, S 0;" << endl;
00139     pg << "ADD S 0, L 0, C 0;" << endl;
00140     pg << "MOVE L 0, S 1;" << endl;
00141     pg << "ADD S 1, L 0, C 1;" << endl;
00142 
00143     // BOOST_MESSAGE(pg.str());
00144 
00145     Calculator calc(0);
00146 
00147     try {
00148         calc.assemble(pg.str().c_str());
00149     } catch (FennelExcn& ex) {
00150         BOOST_MESSAGE("Assemble exception " << ex.getMessage());
00151         BOOST_REQUIRE(0);
00152     }
00153 
00154     TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor());
00155     TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor());
00156 
00157     calc.bind(&inTuple, &outTuple);
00158 
00159     TupleData const * const statusTuple = calc.getStatusRegister();
00160 
00161     for (int i = 1; i <= 3; i++) {
00162         calc.exec();
00163 
00164         BOOST_CHECK_EQUAL(
00165             *(reinterpret_cast<uint16_t *>(
00166                 const_cast<PBuffer>((*statusTuple)[0].pData))),
00167             i);
00168         BOOST_CHECK_EQUAL(
00169             *(reinterpret_cast<uint16_t *>(
00170                 const_cast<PBuffer>((*statusTuple)[1].pData))),
00171             i * 2);
00172     }
00173 
00174     calc.zeroStatusRegister();
00175 
00176     BOOST_CHECK_EQUAL(
00177         *(reinterpret_cast<uint16_t *>(
00178             const_cast<PBuffer>((*statusTuple)[0].pData))),
00179         0);
00180     BOOST_CHECK_EQUAL(
00181         *(reinterpret_cast<uint16_t *>(
00182             const_cast<PBuffer>((*statusTuple)[1].pData))),
00183         0);
00184 
00185     calc.exec();
00186 
00187     BOOST_CHECK_EQUAL(
00188         *(reinterpret_cast<uint16_t *>(
00189             const_cast<PBuffer>((*statusTuple)[0].pData))),
00190         1);
00191     BOOST_CHECK_EQUAL(
00192         *(reinterpret_cast<uint16_t *>(
00193             const_cast<PBuffer>((*statusTuple)[1].pData))),
00194         2);
00195 }

void CalcMiscTest::testCalcRefInst (  )  [private]

Definition at line 198 of file CalcMiscTest.cpp.

References Calculator::assemble(), Calculator::bind(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), and stringToHex().

Referenced by CalcMiscTest().

00199 {
00200     ostringstream pg("");
00201 
00202     char const * const all =
00203         "bo, s1, u1, s2, u2, s4, u4, s8, u8, r, d, vc,2, c,2";
00204     //   0   1   2   3   4   5   6   7   8   9  10 11    12
00205     int const numTypes = 13;
00206     char regs[] = { 'I', 'L', 'C' };
00207     int const numRegSets = 3;
00208 
00209     // TODO: Add binary and varbinary once supported.
00210     pg << "I " << all << ";" << endl;
00211     pg << "O " << all << ", " << endl;
00212     pg << "  " << all << ", " << endl;
00213     pg << "  " << all << ";" << endl;
00214     pg << "L " << all << ";" << endl;
00215     pg << "C " << all << ";" << endl;
00216     pg << "V 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.0, 10.0, 0x";
00217     pg << stringToHex("11") << ", 0x" << stringToHex("12") << ";" << endl;
00218     pg << "T;" << endl;
00219 
00220     int outReg = 0, regSet, regFrom;
00221     // copy constants to local
00222     for (regFrom = 0; regFrom < numTypes; regFrom++) {
00223         pg << "MOVE L" << regFrom << ", C" << regFrom << ";" << endl;
00224     }
00225 
00226     // have output refer to other three sets
00227     for (regSet = 0; regSet < numRegSets; regSet++) {
00228         for (regFrom = 0; regFrom < numTypes; regFrom++) {
00229             pg << "REF O" << outReg++ << ", " << regs[regSet];
00230             pg << regFrom << ";" << endl;
00231         }
00232     }
00233 
00234     //    BOOST_MESSAGE(pg.str());
00235 
00236     Calculator calc(0);
00237 
00238     try {
00239         calc.assemble(pg.str().c_str());
00240     } catch (FennelExcn& ex) {
00241         BOOST_MESSAGE("Assemble exception " << ex.getMessage());
00242         BOOST_REQUIRE(0);
00243     }
00244 
00245     TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor());
00246     TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor());
00247 
00248     calc.bind(&inTuple, &outTuple);
00249     calc.exec();
00250 
00251     outReg = 0;
00252     for (regSet = 0; regSet < numRegSets; regSet++) {
00253         for (regFrom = 0; regFrom < numTypes; regFrom++) {
00254             switch (regs[regSet]) {
00255             case 'I':
00256                 // verify that pointers are identical
00257                 BOOST_CHECK_EQUAL(
00258                     outTuple[outReg].pData,
00259                     inTuple[regFrom].pData);
00260                 break;
00261             case 'L':
00262             case 'C':
00263                 // no trivial way to verify that pointers
00264                 // are identical w/o breaking object encapsulation
00265                 // of calculator. instead, see if data matches up.
00266                 // should be sufficent.
00267                 if (regFrom <= 8) {
00268                     // integer natives cast correctly w/o help
00269                     // (at least on x86!)
00270                     BOOST_CHECK_EQUAL(
00271                         *(outTuple[outReg].pData),
00272                         regFrom);
00273                 } else if (regFrom == 9) {
00274                     // real (float)
00275                     BOOST_CHECK_EQUAL(
00276                         *(reinterpret_cast<float const *>(
00277                             outTuple[outReg].pData)),
00278                         static_cast<float>(regFrom));
00279                 } else if (regFrom == 10) {
00280                     // double
00281                     BOOST_CHECK_EQUAL(
00282                         *(reinterpret_cast<double const*>(
00283                             outTuple[outReg].pData)),
00284                         static_cast<double>(regFrom));
00285                 } else if (regFrom == 11) {
00286                     // varchar string
00287                     BOOST_CHECK_EQUAL(
00288                         0,
00289                         strncmp(
00290                             reinterpret_cast<char const *>(
00291                                 outTuple[outReg].pData),
00292                             "11",
00293                             2));
00294                 } else if (regFrom == 12) {
00295                     // char string
00296                     BOOST_CHECK_EQUAL(
00297                         0,
00298                         strncmp(
00299                             reinterpret_cast<char const *>(
00300                                 outTuple[outReg].pData),
00301                             "12",
00302                             2));
00303                 } else {
00304                     BOOST_FAIL("logic error");
00305                 }
00306                 break;
00307             }
00308             outReg++;
00309         }
00310     }
00311 }

void CalcMiscTest::testCalcReturn (  )  [private]

Definition at line 314 of file CalcMiscTest.cpp.

References Calculator::assemble(), Calculator::bind(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), Calculator::getStatusRegister(), Calculator::getStatusRegisterDescriptor(), and TuplePrinter::print().

Referenced by CalcMiscTest().

00315 {
00316     ostringstream pg("");
00317 
00318     pg << "S u4;" << endl;
00319     pg << "C u4, u4, u4;" << endl;
00320     pg << "V 4, 5, 6;" << endl;
00321     pg << "T;" << endl;
00322     pg << "MOVE S 0, C 0;" << endl;
00323     pg << "RETURN;" << endl;
00324     pg << "MOVE S 0, C 1;" << endl;
00325 
00326     // BOOST_MESSAGE(pg.str());
00327 
00328     Calculator calc(0);
00329 
00330     try {
00331         calc.assemble(pg.str().c_str());
00332     } catch (FennelExcn& ex) {
00333         BOOST_MESSAGE("Assemble exception " << ex.getMessage());
00334         BOOST_REQUIRE(0);
00335     }
00336 
00337     TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor());
00338     TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor());
00339 
00340     calc.bind(&inTuple, &outTuple);
00341     calc.exec();
00342 
00343     TupleData const * const statusTuple = calc.getStatusRegister();
00344 #if 0
00345     TupleDescriptor statusDesc = calc.getStatusRegisterDescriptor();
00346     TuplePrinter tuplePrinter;
00347     tuplePrinter.print(cout, statusDesc, *statusTuple);
00348     cout << endl;
00349 #endif
00350 
00351     BOOST_CHECK_EQUAL(
00352         *(reinterpret_cast<uint32_t *>(
00353             const_cast<PBuffer>((*statusTuple)[0].pData))),
00354         4);
00355 }

void CalcMiscTest::testCalcRaise (  )  [private]

Definition at line 359 of file CalcMiscTest.cpp.

References Calculator::assemble(), Calculator::bind(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), Calculator::getStatusRegister(), Calculator::getStatusRegisterDescriptor(), Calculator::mWarnings, TuplePrinter::print(), and stringToHex().

Referenced by CalcMiscTest().

00360 {
00361     ostringstream pg("");
00362 
00363     pg << "I u4;" << endl;
00364     pg << "S u4;" << endl;
00365     pg << "C u4, u4, vc,5, vc,5;" << endl;
00366     pg << "V 4, 5, 0x" << stringToHex("12345") << ",;" << endl;
00367     pg << "T;" << endl;
00368     pg << "MOVE S0, C0;" << endl;
00369     pg << "RAISE C2;" << endl;
00370     pg << "RAISE C3;" << endl; // null should induce no-op mode;
00371     pg << "MOVE S0, C1;" << endl;
00372     pg << "RETURN;" << endl;
00373 
00374     //    BOOST_MESSAGE(pg.str());
00375 
00376     Calculator calc(0);
00377 
00378     try {
00379         calc.assemble(pg.str().c_str());
00380     } catch (FennelExcn& ex) {
00381         BOOST_MESSAGE("Assemble exception " << ex.getMessage());
00382         BOOST_REQUIRE(0);
00383     }
00384 
00385     TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor());
00386     TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor());
00387 
00388     calc.bind(&inTuple, &outTuple);
00389     calc.exec();
00390 
00391     TupleData const * const statusTuple = calc.getStatusRegister();
00392 #if 0
00393     TupleDescriptor statusDesc = calc.getStatusRegisterDescriptor();
00394     TuplePrinter tuplePrinter;
00395     tuplePrinter.print(cout, statusDesc, *statusTuple);
00396     cout << endl;
00397 #endif
00398 
00399     BOOST_CHECK_EQUAL(
00400         *(reinterpret_cast<uint32_t *>(
00401             const_cast<PBuffer>((*statusTuple)[0].pData))),
00402         5);
00403 
00404     deque<CalcMessage>::iterator iter = calc.mWarnings.begin();
00405     deque<CalcMessage>::iterator end = calc.mWarnings.end();
00406 
00407     //BOOST_MESSAGE("warnings: |" << calc.warnings() << "|");
00408 
00409     BOOST_CHECK(iter != end);
00410     BOOST_CHECK_EQUAL(iter->pc, 1);
00411     BOOST_CHECK_EQUAL(0, strcmp(iter->str, "12345"));
00412     iter++;
00413     BOOST_CHECK(iter == end);
00414 }

void CalcMiscTest::testCalcContinueOnException (  )  [private]

Definition at line 417 of file CalcMiscTest.cpp.

References FennelExcn::getMessage(), TuplePrinter::print(), and stringToHex().

Referenced by CalcMiscTest().

00418 {
00419     ostringstream pg("");
00420 
00421     pg << "I u4;" << endl;
00422     pg << "S u4;" << endl;
00423     pg << "C u4, u4, vc,5, vc,5;" << endl;
00424     pg << "V 4, 5, 0x" << stringToHex("12345") << ",;" << endl;
00425     pg << "T;" << endl;
00426     pg << "MOVE S0, C0;" << endl;
00427     pg << "RAISE C2;" << endl;
00428     pg << "MOVE S0, C1;" << endl;
00429     pg << "RETURN;" << endl;
00430 
00431     BOOST_MESSAGE(pg.str());
00432 
00433     Calculator calc(0);
00434 
00435     try {
00436         calc.assemble(pg.str().c_str());
00437     } catch (FennelExcn& ex) {
00438         BOOST_MESSAGE("Assemble exception " << ex.getMessage());
00439         BOOST_REQUIRE(0);
00440     }
00441 
00442     TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor());
00443     TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor());
00444 
00445     calc.bind(&inTuple, &outTuple);
00446     // run default mode, which continues after exception
00447     calc.exec();
00448 
00449     TupleData const * const statusTuple = calc.getStatusRegister();
00450 #if 0
00451     TupleDescriptor statusDesc = calc.getStatusRegisterDescriptor();
00452     TuplePrinter tuplePrinter;
00453     tuplePrinter.print(cout, statusDesc, *statusTuple);
00454     cout << endl;
00455 #endif
00456 
00457     BOOST_CHECK_EQUAL(
00458         *(reinterpret_cast<uint32_t *>(
00459             const_cast<PBuffer>((*statusTuple)[0].pData))),
00460         5);
00461 
00462     deque<CalcMessage>::iterator iter = calc.mWarnings.begin();
00463     deque<CalcMessage>::iterator end = calc.mWarnings.end();
00464 
00465     BOOST_MESSAGE("warnings: |" << calc.warnings() << "|");
00466 
00467     BOOST_CHECK(iter != end);
00468     BOOST_CHECK_EQUAL(
00469             iter->pc, 1);
00470     BOOST_CHECK_EQUAL(
00471             0, strcmp(iter->str, "12345"));
00472     iter++;
00473     BOOST_CHECK(iter == end);
00474 
00475     // change mode to return on exception
00476     calc.continueOnException(false);
00477     calc.exec();
00478 
00479     BOOST_CHECK_EQUAL(
00480         *(reinterpret_cast<uint32_t *>(
00481             const_cast<PBuffer>((*statusTuple)[0].pData))),
00482         4);
00483 
00484     iter = calc.mWarnings.begin();
00485     end = calc.mWarnings.end();
00486 
00487     BOOST_MESSAGE("warnings: |" << calc.warnings() << "|");
00488 
00489     BOOST_CHECK(iter != end);
00490     BOOST_CHECK_EQUAL(
00491             iter->pc, 1);
00492     BOOST_CHECK_EQUAL(
00493             0, strcmp(iter->str, "12345"));
00494     iter++;
00495     BOOST_CHECK(iter == end);
00496 
00497 }

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