Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
shared_mem_cache_data_test_base.h
Go to the documentation of this file.
1 // Copyright 2011 Google Inc.
16 
17 #ifndef PAGESPEED_KERNEL_SHAREDMEM_SHARED_MEM_CACHE_DATA_TEST_BASE_H_
18 #define PAGESPEED_KERNEL_SHAREDMEM_SHARED_MEM_CACHE_DATA_TEST_BASE_H_
19 
20 #include <vector>
21 
29 
30 namespace net_instaweb {
31 
32 class ThreadSystem;
33 
34 class SharedMemCacheDataTestBase : public testing::Test {
35  protected:
36  typedef void (SharedMemCacheDataTestBase::*TestMethod)();
37  enum { kBlockSize = 512 };
38 
40  explicit SharedMemCacheDataTestBase(SharedMemTestEnv* test_env);
41 
42  void TestFreeList();
43  void TestLRU();
44  void TestBlockLists();
45 
46  private:
47  bool CreateChild(TestMethod method);
48 
49  void SanityCheckBlockVector(const SharedMemCacheData::BlockVector& blocks,
50  int min_valid, int max_valid);
51 
52  void ExtractAndSanityCheckLRU(
54  std::vector<SharedMemCacheData::EntryNum>* out_lru);
55 
56  void TestFreeListChild();
57 
58  bool ParentInit(AbstractSharedMemSegment** out_seg,
60 
61  bool ChildInit(AbstractSharedMemSegment** out_seg,
63 
64  void ParentCleanup();
65 
67  scoped_ptr<AbstractSharedMem> shmem_runtime_;
68  scoped_ptr<ThreadSystem> thread_system_;
69  MockMessageHandler handler_;
70 
71 
72 };
73 
74 template<typename ConcreteTestEnv>
76  public:
78  : SharedMemCacheDataTestBase(new ConcreteTestEnv) {
79  }
80 };
81 
82 TYPED_TEST_CASE_P(SharedMemCacheDataTestTemplate);
83 
84 TYPED_TEST_P(SharedMemCacheDataTestTemplate, TestFreeList) {
85  SharedMemCacheDataTestBase::TestFreeList();
86 }
87 
88 TYPED_TEST_P(SharedMemCacheDataTestTemplate, TestLRU) {
89  SharedMemCacheDataTestBase::TestLRU();
90 }
91 
92 TYPED_TEST_P(SharedMemCacheDataTestTemplate, TestBlockLists) {
93  SharedMemCacheDataTestBase::TestBlockLists();
94 }
95 
96 REGISTER_TYPED_TEST_CASE_P(SharedMemCacheDataTestTemplate, TestFreeList,
97  TestLRU, TestBlockLists);
98 
99 }
100 
101 #endif
Definition: shared_mem_cache_data.h:121
Definition: shared_mem_cache_data_test_base.h:75
Definition: mock_message_handler.h:39
Definition: scoped_ptr.h:30
Definition: shared_mem_cache_data_test_base.h:34
Definition: shared_mem_test_base.h:33
Definition: abstract_shared_mem.h:31
SharedMemCacheDataTestBase(SharedMemTestEnv *test_env)
passed to EXPECT_EQ