xref: /haiku/src/tests/kits/support/bblockcache/BlockCacheExerciseTest.h (revision 571d840abfdf03de583b26fefd2066ee75b25cf4)
1bfdb37ccSIngo Weinhold /*
2*571d840aSOliver Tappe 	$Id: BlockCacheExerciseTest.h 4522 2003-09-07 11:53:03Z bonefish $
3bfdb37ccSIngo Weinhold 
4bfdb37ccSIngo Weinhold 	This file defines a class for performing tests on the BBlockCache class.
5bfdb37ccSIngo Weinhold 
6bfdb37ccSIngo Weinhold 	*/
7bfdb37ccSIngo Weinhold 
8bfdb37ccSIngo Weinhold 
9bfdb37ccSIngo Weinhold #ifndef BlockCacheExerciseTest_H
10bfdb37ccSIngo Weinhold #define BlockCacheExerciseTest_H
11bfdb37ccSIngo Weinhold 
12bfdb37ccSIngo Weinhold 
13bfdb37ccSIngo Weinhold #include "cppunit/TestCase.h"
14bfdb37ccSIngo Weinhold #include <List.h>
15bfdb37ccSIngo Weinhold 
16bfdb37ccSIngo Weinhold 
17bfdb37ccSIngo Weinhold class BBlockCache;
18bfdb37ccSIngo Weinhold 
19bfdb37ccSIngo Weinhold 
20bfdb37ccSIngo Weinhold class BlockCacheExerciseTest : public CppUnit::TestCase {
21bfdb37ccSIngo Weinhold 
22bfdb37ccSIngo Weinhold private:
23bfdb37ccSIngo Weinhold 	BBlockCache *theCache;
24bfdb37ccSIngo Weinhold 	int numBlocksInCache;
25bfdb37ccSIngo Weinhold 	size_t sizeOfBlocksInCache;
26bfdb37ccSIngo Weinhold 	size_t sizeOfNonCacheBlocks;
27bfdb37ccSIngo Weinhold 
28bfdb37ccSIngo Weinhold 	bool isMallocTest;
29bfdb37ccSIngo Weinhold 
30bfdb37ccSIngo Weinhold 	BList freeList;
31bfdb37ccSIngo Weinhold 	BList usedList;
32bfdb37ccSIngo Weinhold 	BList nonCacheList;
33bfdb37ccSIngo Weinhold 
34bfdb37ccSIngo Weinhold 	void BuildLists(void);
35bfdb37ccSIngo Weinhold 	void *GetBlock(size_t blockSize);
36bfdb37ccSIngo Weinhold 	void SaveBlock(void *, size_t blockSize);
37bfdb37ccSIngo Weinhold 	void FreeBlock(void *, size_t blockSize);
38bfdb37ccSIngo Weinhold 	void TestBlockCache(void);
39bfdb37ccSIngo Weinhold 
40bfdb37ccSIngo Weinhold protected:
41bfdb37ccSIngo Weinhold 
42bfdb37ccSIngo Weinhold public:
43bfdb37ccSIngo Weinhold 	static CppUnit::Test *suite(void);
44bfdb37ccSIngo Weinhold 	BlockCacheExerciseTest(std::string = "");
45bfdb37ccSIngo Weinhold 	virtual ~BlockCacheExerciseTest();
46bfdb37ccSIngo Weinhold 	virtual void PerformTest(void);
47bfdb37ccSIngo Weinhold };
48bfdb37ccSIngo Weinhold 
49bfdb37ccSIngo Weinhold #endif
50