testStore.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #include "squid.h"
10 #include "Store.h"
11 #include "testStore.h"
12 #include "unitTestMain.h"
13 
15 
16 int
18 {
19  return 1;
20 }
21 
24 {
25  return NULL;
26 }
27 
28 void
29 TestStore::get(String, void (*)(StoreEntry*, void*), void*)
30 {}
31 
32 void
34 {}
35 
36 uint64_t
38 {
39  return 3;
40 }
41 
42 uint64_t
44 {
45  return 1;
46 }
47 
48 uint64_t
50 {
51  return 2;
52 }
53 
54 uint64_t
56 {
57  return 2;
58 }
59 
60 int64_t
62 {
63  return 1;
64 }
65 
66 void
68 {
69 }
70 
71 void
73 {
74  const_cast<TestStore *>(this)->statsCalled = true;
75 }
76 
79 {
80  return NULL;
81 }
82 
83 void
85 {
86  Store::Controller *aStore(new TestStore);
87  Store::Init(aStore);
88 
89  CPPUNIT_ASSERT_EQUAL(&Store::Root(), aStore);
91 }
92 
93 void
95 {
96  Store::Controller *aStore(new TestStore);
97  Store::Controller *aStore2(new TestStore);
98  Store::Init(aStore);
100  Store::Init(aStore2);
101  CPPUNIT_ASSERT_EQUAL(&Store::Root(),aStore2);
103 }
104 
105 void
107 {
108  TestStore *aStore(new TestStore);
109  Store::Init(aStore);
110  CPPUNIT_ASSERT_EQUAL(false, aStore->statsCalled);
112  CPPUNIT_ASSERT_EQUAL(true, aStore->statsCalled);
114 }
115 
116 void
118 {
119  Store::Controller *aStore(new TestStore);
120  Store::Init(aStore);
121  CPPUNIT_ASSERT_EQUAL(static_cast<uint64_t>(3), aStore->maxSize());
123 }
124 
void Init(Controller *root=nullptr)
initialize the storage module; a custom root is used by unit tests only
Definition: Controller.cc:626
allows testing of methods without having all the other components live
Definition: testStore.h:40
virtual uint64_t minSize() const
the minimum size the store will shrink to via normal housekeeping
Definition: testStore.cc:43
virtual void stat(StoreEntry &) const
Definition: testStore.cc:72
void testStats()
Definition: testStore.cc:106
virtual int callback()
called once every main loop iteration; TODO: Move to UFS code.
Definition: testStore.cc:17
unsigned char cache_key
Store key.
Definition: forward.h:29
void Stats(StoreEntry *output)
Definition: store.cc:115
void testSetRoot()
Definition: testStore.cc:84
Controller & Root()
safely access controller singleton
Definition: Controller.cc:619
virtual uint64_t currentSize() const
current size
Definition: testStore.cc:49
High-level store statistics used by mgr:info action. Used inside PODs!
Definition: StoreStats.h:13
virtual uint64_t maxSize() const override
Definition: Controller.cc:153
virtual void getStats(StoreInfoStats &) const
collect statistics
Definition: testStore.cc:67
static NullStoreEntry * getInstance()
Definition: store.cc:2149
void testUnsetRoot()
Definition: testStore.cc:94
virtual StoreSearch * search()
Definition: testStore.cc:78
virtual void init()
Definition: testStore.cc:33
virtual int64_t maxObjectSize() const
the maximum size of a storable object; -1 if unlimited
Definition: testStore.cc:61
virtual uint64_t maxSize() const
Definition: testStore.cc:37
virtual StoreEntry * get(const cache_key *)
Retrieve a store entry from the store (blocking)
Definition: testStore.cc:23
void FreeMemory()
undo Init()
Definition: Controller.cc:632
bool statsCalled
Definition: testStore.h:46
void testMaxSize()
Definition: testStore.cc:117
CPPUNIT_TEST_SUITE_REGISTRATION(testStore)
virtual uint64_t currentCount() const
the total number of objects stored right now
Definition: testStore.cc:55
#define NULL
Definition: types.h:166

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors