17 #ifndef PAGESPEED_KERNEL_SHAREDMEM_SHARED_MEM_CACHE_TEST_BASE_H_
18 #define PAGESPEED_KERNEL_SHAREDMEM_SHARED_MEM_CACHE_TEST_BASE_H_
35 namespace net_instaweb {
37 class SharedMemCacheDump;
43 static const int kBlockSize = 512;
47 virtual void TearDown();
50 virtual void SanityCheck();
54 void TestReplacement();
55 void TestReaderWriter();
59 void TestRegisterSnapshotFileCache();
60 void TestCheckpointAndRestore();
65 bool CreateChild(TestMethod method);
67 void CheckDumpsEqual(
const SharedMemCacheDump& a,
68 const SharedMemCacheDump& b,
69 const char* test_label);
72 void CheckDelete(
const char* key);
73 void TestReaderWriterChild();
86 bool sanity_checks_enabled_;
98 worker_.reset(
new SlowWorker(
"slow worker", thread_system));
100 FileCache::InitStats(stats_.get());
103 path, filesystem_.get(), thread_system, worker_.get(),
108 stats_.get(), handler));
112 FileCache* file_cache() {
113 return file_cache_.get();
115 MemFileSystem* filesystem() {
116 return filesystem_.get();
120 scoped_ptr<MemFileSystem> filesystem_;
121 scoped_ptr<SlowWorker> worker_;
122 scoped_ptr<SimpleStats> stats_;
123 scoped_ptr<MD5Hasher> hasher_;
124 scoped_ptr<FileCache> file_cache_;
127 template<
typename ConcreteTestEnv>
138 SharedMemCacheTestBase::TestBasic();
141 TYPED_TEST_P(SharedMemCacheTestTemplate, TestReinsert) {
142 SharedMemCacheTestBase::TestReinsert();
145 TYPED_TEST_P(SharedMemCacheTestTemplate, TestReplacement) {
146 SharedMemCacheTestBase::TestReplacement();
149 TYPED_TEST_P(SharedMemCacheTestTemplate, TestReaderWriter) {
150 SharedMemCacheTestBase::TestReaderWriter();
153 TYPED_TEST_P(SharedMemCacheTestTemplate, TestConflict) {
154 SharedMemCacheTestBase::TestConflict();
157 TYPED_TEST_P(SharedMemCacheTestTemplate, TestEvict) {
158 SharedMemCacheTestBase::TestEvict();
161 TYPED_TEST_P(SharedMemCacheTestTemplate, TestSnapshot) {
162 SharedMemCacheTestBase::TestSnapshot();
165 TYPED_TEST_P(SharedMemCacheTestTemplate, TestRegisterSnapshotFileCache) {
166 SharedMemCacheTestBase::TestRegisterSnapshotFileCache();
169 TYPED_TEST_P(SharedMemCacheTestTemplate, TestCheckpointAndRestore) {
170 SharedMemCacheTestBase::TestCheckpointAndRestore();
173 REGISTER_TYPED_TEST_CASE_P(SharedMemCacheTestTemplate, TestBasic, TestReinsert,
174 TestReplacement, TestReaderWriter, TestConflict,
175 TestEvict, TestSnapshot,
176 TestRegisterSnapshotFileCache,
177 TestCheckpointAndRestore);
Definition: mock_timer.h:33
Definition: md5_hasher.h:28
Definition: mock_message_handler.h:39
Definition: shared_mem_cache_test_base.h:40
Definition: scoped_ptr.h:30
Simple name/value pair statistics implementation.
Definition: simple_stats.h:55
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Definition: file_cache.h:44
FileCacheTestWrapper(const GoogleString &path, ThreadSystem *thread_system, Timer *timer, MessageHandler *handler)
Definition: shared_mem_cache_test_base.h:93
Definition: shared_mem_cache_test_base.h:91
Definition: thread_system.h:40
Abstract interface for a cache.
Definition: shared_mem_cache.h:46
Definition: message_handler.h:39
Definition: mem_file_system.h:48
Definition: shared_mem_test_base.h:33
Definition: cache_test_base.h:39
Simple C++ implementation of file cache.
Definition: file_cache.h:42
Timer interface, made virtual so it can be mocked for tests.
Definition: timer.h:27
See file comment.
Definition: slow_worker.h:35
Definition: shared_mem_cache_test_base.h:128