PagingTestBase.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/test/PagingTestBase.h#12 $
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 #ifndef Fennel_PagingTestBase_Included
00025 #define Fennel_PagingTestBase_Included
00026 
00027 #include "fennel/test/CacheTestBase.h"
00028 #include "fennel/test/ThreadedTestBase.h"
00029 #include "fennel/synch/SXMutex.h"
00030 
00031 #include <vector>
00032 
00033 FENNEL_BEGIN_NAMESPACE
00034 
00035 class CachePage;
00036 
00041 class FENNEL_TEST_EXPORT PagingTestBase
00042     : virtual public CacheTestBase,
00043         virtual public ThreadedTestBase
00044 {
00045 protected:
00049     uint cbPageUsable;
00050 
00054     uint nRandomOps;
00055 
00059     uint nSecondsBetweenCheckpoints;
00060 
00064     StrictMutex logMutex;
00065 
00069     SXMutex checkpointMutex;
00070 
00075     bool bTestResize;
00076 
00077     uint generateRandomNumber(uint iMax);
00078 
00079 public:
00083     enum OpType {
00084         OP_READ_SEQ,
00085         OP_WRITE_SEQ,
00086         OP_READ_RAND,
00087         OP_WRITE_RAND,
00088         OP_READ_NOWAIT,
00089         OP_WRITE_NOWAIT,
00090         OP_WRITE_SKIP,
00091         OP_SCRATCH,
00092         OP_PREFETCH,
00093         OP_PREFETCH_BATCH,
00094         OP_ALLOCATE,
00095         OP_DEALLOCATE,
00096         OP_CHECKPOINT,
00097         OP_RESIZE_CACHE,
00098         OP_MAX
00099     };
00100 
00101     explicit PagingTestBase();
00102 
00103     virtual ~PagingTestBase();
00104 
00109     virtual void fillPage(CachePage &page,uint x);
00110 
00114     virtual void verifyPage(CachePage &page,uint x);
00115 
00116     virtual CachePage *lockPage(OpType opType,uint iPage) = 0;
00117     virtual void unlockPage(CachePage &page,LockMode lockMode) = 0;
00118     virtual void prefetchPage(uint iPage) = 0;
00119     virtual void prefetchBatch(uint iPage,uint nPagesPerBatch) = 0;
00120 
00135     bool testOp(OpType opType,uint iPage,bool bNice);
00136 
00140     char const *getOpName(OpType opType);
00141 
00145     LockMode getLockMode(OpType opType);
00146 
00153     void testSequentialOp(OpType opType);
00154 
00160     void testRandomOp(OpType opType);
00161 
00169     void testSkipOp(OpType opType, uint n);
00170 
00176     void testScratch();
00177 
00182     void testPrefetch();
00183 
00188     void testPrefetchBatch();
00189 
00193     virtual void testCheckpoint();
00194 
00199     virtual void testAllocateAll();
00200 
00204     void testSequentialRead();
00205 
00209     void testSequentialWrite();
00210 
00214     void testRandomRead();
00215 
00219     void testRandomWrite();
00220 
00226     void testSkipWrite(uint n);
00227 
00228     virtual void testAllocate();
00229 
00230     virtual void testDeallocate();
00231 
00232     void testCheckpointGuarded();
00233 
00234     void testCacheResize();
00235 
00239     void testMultipleThreads();
00240 
00241     virtual void threadInit();
00242 
00243     virtual void threadTerminate();
00244 
00245     virtual bool testThreadedOp(int iOp);
00246 };
00247 
00248 FENNEL_END_NAMESPACE
00249 
00250 #endif
00251 
00252 // End PagingTestBase.h

Generated on Mon Jun 22 04:00:20 2009 for Fennel by  doxygen 1.5.1