Fennel: CalcExtContextTest Class Reference (original) (raw)
Inheritance diagram for CalcExtContextTest:

| Public Member Functions | |
|---|---|
| CalcExtContextTest () | |
| virtual | ~CalcExtContextTest () |
| TestSuite * | releaseTestSuite () |
| 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. | |
| TraceTarget & | getTraceTarget () 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 | |
| TestSuite * | pTestSuite |
| Boost test suite. | |
| boost::shared_ptr< TestBase > | pTestObj |
| 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 | setupExtendedTestInstructions () |
| void | testCalcExtContext () |
| void | testCalcExtContextPost () |
| void | printOutput (TupleData const &tup, Calculator const &calc) |
Detailed Description
Definition at line 46 of file CalcExtContextTest.cpp.
Constructor & Destructor Documentation
| CalcExtContextTest::CalcExtContextTest | ( | | ) | [inline, explicit] | | -------------------------------------- | - | | - | -------------------- |
| virtual CalcExtContextTest::~CalcExtContextTest | ( | | ) | [inline, virtual] | | ------------------------------------------------ | - | | - | ------------------- |
Member Function Documentation
| void CalcExtContextTest::setupExtendedTestInstructions | ( | | ) | [private] | | ------------------------------------------------------ | - | | - | ----------- |
Definition at line 178 of file CalcExtContextTest.cpp.
References ExtendedInstructionTable::add(), ctxInst1(), ctxInst2(), ctxInst3(), ctxInst4(), ctxInst5(), InstructionFactory::getExtendedInstructionTable(), ExtendedInstructionDef::getName(), ExtendedInstructionDef::getParameterTypes(), and STANDARD_TYPE_BOOL.
Referenced by testCalcExtContext().
00179 { 00180 ExtendedInstructionTable* eit = 00181 InstructionFactory::getExtendedInstructionTable(); 00182 ExtendedInstructionDef* inst; 00183 00184 vector params; 00185 params.push_back(STANDARD_TYPE_BOOL); 00186 00187 eit->add( 00188 "ctxInst1", params, 00189 (ExtendedInstruction1Context*) NULL, 00190 ctxInst1); 00191 inst = (eit)["ctxInst1(bo)"]; 00192 BOOST_REQUIRE(inst); 00193 BOOST_CHECK_EQUAL(inst->getName(),string("ctxInst1")); 00194 BOOST_CHECK_EQUAL(inst->getParameterTypes().size(), 1); 00195 00196 00197 params.push_back(STANDARD_TYPE_BOOL); 00198 00199 eit->add( 00200 "ctxInst2", params, 00201 (ExtendedInstruction2Context<bool,bool>) NULL, 00202 ctxInst2); 00203 inst = (eit)["ctxInst2(bo,bo)"]; 00204 BOOST_REQUIRE(inst); 00205 BOOST_CHECK_EQUAL(inst->getName(),string("ctxInst2")); 00206 BOOST_CHECK_EQUAL(inst->getParameterTypes().size(), 2); 00207 00208 00209 params.push_back(STANDARD_TYPE_BOOL); 00210 00211 eit->add( 00212 "ctxInst3", params, 00213 (ExtendedInstruction3Context<bool,bool,bool>) NULL, 00214 ctxInst3); 00215 inst = (eit)["ctxInst3(bo,bo,bo)"]; 00216 BOOST_REQUIRE(inst); 00217 BOOST_CHECK_EQUAL(inst->getName(),string("ctxInst3")); 00218 BOOST_CHECK_EQUAL(inst->getParameterTypes().size(), 3); 00219 00220 00221 params.push_back(STANDARD_TYPE_BOOL); 00222 00223 eit->add( 00224 "ctxInst4", params, 00225 (ExtendedInstruction4Context<bool,bool,bool,bool>) NULL, 00226 ctxInst4); 00227 inst = (eit)["ctxInst4(bo,bo,bo,bo)"]; 00228 BOOST_REQUIRE(inst); 00229 BOOST_CHECK_EQUAL(inst->getName(),string("ctxInst4")); 00230 BOOST_CHECK_EQUAL(inst->getParameterTypes().size(), 4); 00231 00232 00233 params.push_back(STANDARD_TYPE_BOOL); 00234 00235 eit->add( 00236 "ctxInst5", params, 00237 (ExtendedInstruction5Context<bool,bool,bool,bool,bool>) NULL, 00238 ctxInst5); 00239 inst = (*eit)["ctxInst5(bo,bo,bo,bo,bo)"]; 00240 BOOST_REQUIRE(inst); 00241 BOOST_CHECK_EQUAL(inst->getName(),string("ctxInst5")); 00242 BOOST_CHECK_EQUAL(inst->getParameterTypes().size(), 5); 00243 00244 }
| void CalcExtContextTest::testCalcExtContext | ( | | ) | [private] | | ------------------------------------------- | - | | - | ----------- |
Definition at line 248 of file CalcExtContextTest.cpp.
References Calculator::assemble(), Calculator::bind(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), printOutput(), and setupExtendedTestInstructions().
Referenced by CalcExtContextTest().
00249 {
00250
00251 setupExtendedTestInstructions();
00252
00253 ostringstream pg("");
00254
00255 pg << "O bo,bo,bo,bo,bo,bo;" << endl;
00256 pg << "L bo,bo,bo,bo,bo,bo;" << endl;
00257 pg << "C bo;" << endl;
00258 pg << "V 0;" << endl;
00259 pg << "T;" << endl;
00260 pg << "MOVE L1, C0;" << endl;
00261 pg << "MOVE L2, C0;" << endl;
00262 pg << "MOVE L3, C0;" << endl;
00263 pg << "MOVE L4, C0;" << endl;
00264 pg << "MOVE L5, C0;" << endl;
00265 pg << "CALL 'ctxInst1(L1);" << endl;
00266 pg << "CALL 'ctxInst2(L2,L0);" << endl;
00267 pg << "CALL 'ctxInst3(L3,L0,L0);" << endl;
00268 pg << "CALL 'ctxInst4(L4,L0,L0,L0);" << endl;
00269 pg << "CALL 'ctxInst5(L5,L0,L0,L0,L0);" << endl;
00270 pg << "REF O0, L0;" << endl;
00271 pg << "REF O1, L1;" << endl;
00272 pg << "REF O2, L2;" << endl;
00273 pg << "REF O3, L3;" << endl;
00274 pg << "REF O4, L4;" << endl;
00275 pg << "REF O5, L5;" << endl;
00276
00277
00278
00279 Calculator calc(0);
00280
00281 try {
00282 calc.assemble(pg.str().c_str());
00283 } catch (FennelExcn& ex) {
00284 BOOST_MESSAGE("Assemble exception " << ex.getMessage());
00285 BOOST_MESSAGE(pg.str());
00286 BOOST_REQUIRE(0);
00287 }
00288
00289 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor());
00290 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor());
00291
00292 calc.bind(&inTuple, &outTuple);
00293 calc.exec();
00294 printOutput(outTuple, calc);
00295
00296 int i;
00297 for (i = 1; i <= 5; i++) {
00298 BOOST_CHECK_EQUAL(
00299 *(reinterpret_cast<bool *>(
00300 const_cast((outTuple[i]).pData))),
00301 true);
00302 }
00303
00304
00305 calc.exec();
00306
00307 for (i = 1; i <= 5; i++) {
00308 BOOST_CHECK_EQUAL(
00309 *(reinterpret_cast<bool *>(
00310 const_cast((outTuple[i]).pData))),
00311 false);
00312 }
00313
00314
00315 calc.exec();
00316
00317 for (i = 1; i <= 5; i++) {
00318 BOOST_CHECK_EQUAL(
00319 *(reinterpret_cast<bool *>(
00320 const_cast((outTuple[i]).pData))),
00321 false);
00322 }
00323
00324 #if 0
00325 tuplePrinter.print(cout, calc.getOutputRegisterDescriptor(), outTuple);
00326 cout << endl;
00327 #endif
00328
00329 }
| void CalcExtContextTest::testCalcExtContextPost | ( | | ) | [private] | | ----------------------------------------------- | - | | - | ----------- |
| void CalcExtContextTest::printOutput | ( | TupleData const & | tup, |
|---|---|---|---|
| Calculator const & | calc | ||
| ) | [private] |
| void TestBase::snooze | ( | uint | nSeconds | ) | [protected, inherited] |
|---|
| 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") {
00123 permAssert(i + 1 < argc);
00124 runSingle = argv[++i];
00125 } else if (arg[1] == 't') {
00126 runSingle = arg.substr(2);
00127 }
00128 } else {
00129 int i = arg.find("=");
00130 if ((0 < i) && (i < arg.size())) {
00131
00132 std::string key = arg.substr(0,i);
00133 std::string val = arg.substr(i + 1);
00134 adhocMap.setStringParam(key,val);
00135 } else {
00136
00137 std::ifstream configFile(arg.c_str());
00138 assert(configFile.good());
00139 configMap.readParams(configFile);
00140 }
00141 }
00142 }
00143 configMap.mergeFrom(adhocMap);
00144
00145
00146
00147 if (.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] | | ---------------------------------------------------------------------------------------------- | - | | - | ------------- |
| void TestBase::beforeTestCase | ( | std::string | testCaseName | ) | [inherited] |
|---|
| void TestBase::afterTestCase | ( | std::string | testCaseName | ) | [inherited] |
|---|
| 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().
| 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().
| void TestBase::notifyTrace | ( | std::string | source, |
|---|---|---|---|
| TraceLevel | level, | ||
| std::string | message | ||
| ) | [virtual, inherited] |
| TraceLevel TestBase::getSourceTraceLevel | ( | std::string | source | ) | [virtual, inherited] |
|---|
| void TraceSource::initTraceSource | ( | SharedTraceTarget | pTraceTarget, |
|---|---|---|---|
| std::string | name | ||
| ) | [virtual, inherited] |
| void TraceSource::trace | ( | TraceLevel | level, |
|---|---|---|---|
| std::string | message | ||
| ) | const [inherited] |
| bool TraceSource::isTracing | ( | | ) | const [inline, inherited] | | --------------------------- | - | | - | --------------------------- |
| bool TraceSource::isTracingLevel | ( | TraceLevel | level | ) | const [inline, inherited] |
|---|
| TraceTarget& TraceSource::getTraceTarget | ( | | ) | const [inline, inherited] | | ----------------------------------------------------------------- | - | | - | --------------------------- |
| std::string TraceSource::getTraceSourceName | ( | | ) | const [inline, inherited] | | ------------------------------------------- | - | | - | --------------------------- |
| 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] | | ------------------------------------------------------------------------------------------------------ | - | | - | --------------------------- |
| void TraceSource::disableTracing | ( | | ) | [inherited] | | -------------------------------- | - | | - | ------------- |
Member Data Documentation
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:
- /home/pub/open/dev/fennel/calctest/CalcExtContextTest.cpp
