Fennel: SparseBitmapTest Class Reference (original) (raw)
Unit tests for SparseBitmap. More...
Inheritance diagram for SparseBitmapTest:

| Public Member Functions | |
|---|---|
| SparseBitmapTest () | |
| virtual void | testCaseTearDown () |
| Equivalent to JUnit TestCase.tearDown; this is called after each test case method is invoked. | |
| void | testBasic () |
| void | testSpread () |
| void | testSizes () |
| void | testFullDirectory () |
| 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 | 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. | |
| 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 | openStorage (DeviceMode deviceMode) |
| void | closeStorage () |
| Private Attributes | |
| SharedRandomAccessDevice | pDevice |
| SharedCache | pCache |
| SharedSegmentFactory | pSegmentFactory |
| SharedSegment | pSegment |
| SegmentAccessor | segmentAccessor |
| Static Private Attributes | |
| static const DeviceId | BITMAP_DEVICE_ID |
| Designated device ID for SparseBitmap unit tests. |
Detailed Description
Unit tests for SparseBitmap.
Definition at line 407 of file SparseBitmapTest.cpp.
Constructor & Destructor Documentation
| SparseBitmapTest::SparseBitmapTest | ( | | ) | [inline, explicit] | | ---------------------------------- | - | | - | -------------------- |
Member Function Documentation
| void SparseBitmapTest::openStorage | ( | DeviceMode | deviceMode | ) | [private] |
|---|
Definition at line 442 of file SparseBitmapTest.cpp.
References BITMAP_DEVICE_ID, TestBase::configMap, DeviceMode::create, LinearDeviceSegmentParams::firstBlockId, MAXU, Cache::newCache(), SegmentFactory::newSegmentFactory(), LinearDeviceSegmentParams::nPagesAllocated, pCache, SegmentAccessor::pCacheAccessor, pDevice, SegmentAccessor::pSegment, pSegment, pSegmentFactory, CacheParams::readConfig(), segmentAccessor, CompoundId::setBlockNum(), and CompoundId::setDeviceId().
Referenced by testBasic(), testFullDirectory(), testSizes(), and testSpread().
| void SparseBitmapTest::closeStorage | ( | | ) | [private] | | ----------------------------------- | - | | - | ----------- |
| void SparseBitmapTest::testCaseTearDown | ( | | ) | [virtual] | | --------------------------------------- | - | | - | ----------- |
| void SparseBitmapTest::testBasic | ( | | ) | | -------------------------------- | - | | - |
| void SparseBitmapTest::testSpread | ( | | ) | | --------------------------------- | - | | - |
Definition at line 530 of file SparseBitmapTest.cpp.
References closeStorage(), DeviceMode::createNew, SparseBitmap::getBit(), SparseBitmap::getDirPageId(), DeviceMode::load, openStorage(), segmentAccessor, and SparseBitmap::setBit().
Referenced by SparseBitmapTest().
00531 {
00532
00533
00534 std::vector filledOffsets;
00535 filledOffsets.push_back(5);
00536 filledOffsets.push_back(6);
00537 filledOffsets.push_back(8);
00538 filledOffsets.push_back(100);
00539 filledOffsets.push_back(50000);
00540 filledOffsets.push_back(50001);
00541 filledOffsets.push_back(50004);
00542 filledOffsets.push_back(55000);
00543
00544 std::vector emptyOffsets;
00545 emptyOffsets.push_back(0);
00546 emptyOffsets.push_back(7);
00547 emptyOffsets.push_back(1000);
00548 emptyOffsets.push_back(50003);
00549 emptyOffsets.push_back(1000000);
00550
00551 PageId dirPageId;
00552 openStorage(DeviceMode::createNew);
00553
00554 {
00555 SparseBitmap bitmap(segmentAccessor);
00556 dirPageId = bitmap.getDirPageId();
00557 for (int i = 0; i < filledOffsets.size(); ++i) {
00558 bitmap.setBit(filledOffsets[i], 1);
00559 }
00560 }
00561
00562 closeStorage();
00563
00564 openStorage(DeviceMode::load);
00565
00566 {
00567 SparseBitmap bitmap(segmentAccessor, dirPageId);
00568 for (int i = 0; i < filledOffsets.size(); ++i) {
00569 bool x = bitmap.getBit(filledOffsets[i]);
00570 BOOST_CHECK_EQUAL(1, x);
00571 }
00572
00573
00574 for (int i = 0; i < emptyOffsets.size(); ++i) {
00575 bool x = bitmap.getBit(emptyOffsets[i]);
00576 BOOST_CHECK_EQUAL(0, x);
00577 }
00578 }
00579 }
| void SparseBitmapTest::testSizes | ( | | ) | | -------------------------------- | - | | - |
| void SparseBitmapTest::testFullDirectory | ( | | ) | | ---------------------------------------- | - | | - |
| 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::notifyTrace | ( | std::string | source, |
|---|---|---|---|
| TraceLevel | level, | ||
| std::string | message | ||
| ) | [virtual, inherited] |
| TraceLevel TestBase::getSourceTraceLevel | ( | std::string | source | ) | [virtual, 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(), 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/test/SparseBitmapTest.cpp
