00001 /* 00002 // $Id: //open/dev/fennel/test/LinearViewSegmentTest.cpp#8 $ 00003 // Fennel is a library of data storage and processing components. 00004 // Copyright (C) 2005-2009 The Eigenbase Project 00005 // Copyright (C) 2005-2009 SQLstream, Inc. 00006 // Copyright (C) 2005-2009 LucidEra, Inc. 00007 // Portions Copyright (C) 1999-2009 John V. Sichi 00008 // 00009 // This program is free software; you can redistribute it and/or modify it 00010 // under the terms of the GNU General Public License as published by the Free 00011 // Software Foundation; either version 2 of the License, or (at your option) 00012 // any later version approved by The Eigenbase Project. 00013 // 00014 // This program is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU General Public License 00020 // along with this program; if not, write to the Free Software 00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 */ 00023 00024 #include "fennel/common/CommonPreamble.h" 00025 #include "fennel/test/SegmentTestBase.h" 00026 #include "fennel/segment/RandomAllocationSegment.h" 00027 #include "fennel/segment/LinearViewSegment.h" 00028 00029 using namespace fennel; 00030 00031 class LinearViewSegmentTest : virtual public SegmentTestBase 00032 { 00033 uint nDiskPagesTotal; 00034 PageId firstPageId; 00035 00036 public: 00037 explicit LinearViewSegmentTest() 00038 { 00039 nDiskPagesTotal = nDiskPages; 00040 FENNEL_UNIT_TEST_CASE(SegmentTestBase,testSingleThread); 00041 FENNEL_UNIT_TEST_CASE(PagingTestBase,testMultipleThreads); 00042 } 00043 00044 virtual void openSegmentStorage(DeviceMode openMode) 00045 { 00046 nDiskPages = nDiskPagesTotal; 00047 if (openMode.create) { 00048 firstPageId = NULL_PAGE_ID; 00049 } 00050 SharedSegment pDeviceSegment = createLinearDeviceSegment( 00051 dataDeviceId,nDiskPages); 00052 pRandomSegment = pSegmentFactory->newRandomAllocationSegment( 00053 pDeviceSegment,openMode.create); 00054 nDiskPages /= 2; 00055 SharedSegment pLinearViewSegment = 00056 pSegmentFactory->newLinearViewSegment(pRandomSegment,firstPageId); 00057 pLinearSegment = pLinearViewSegment; 00058 } 00059 00060 virtual void testAllocateAll() 00061 { 00062 SegmentTestBase::testAllocateAll(); 00063 assert(firstPageId == NULL_PAGE_ID); 00064 LinearViewSegment *pLinearViewSegment = 00065 SegmentFactory::dynamicCast<LinearViewSegment *>(pLinearSegment); 00066 assert(pLinearViewSegment); 00067 firstPageId = pLinearViewSegment->getFirstPageId(); 00068 } 00069 }; 00070 00071 FENNEL_UNIT_TEST_SUITE(LinearViewSegmentTest); 00072 00073 // End LinearViewSegmentTest.cpp