]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Made "make check" happier by syncing test case with Store API changes
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 19 Dec 2013 23:13:24 +0000 (16:13 -0700)
committerAlex Rousskov <rousskov@measurement-factory.com>
Thu, 19 Dec 2013 23:13:24 +0000 (16:13 -0700)
and making StoreEntry::hashDelete() more forgiving.

src/Makefile.am
src/repl/heap/store_heap_replacement.cc
src/store.cc
src/tests/stub_MemObject.cc
src/tests/stub_store.cc
src/tests/testStoreController.cc
src/tests/testStoreEntryStream.cc
src/tests/testStoreHashIndex.cc

index 87d14167afa3606d07abfbf53dd6f60846560a13..6cba03201ace0109ce439e17972c7dba0f3f89c8 100644 (file)
@@ -1420,6 +1420,7 @@ tests_testCacheManager_SOURCES = \
        client_side_request.cc \
        ClientInfo.h \
        clientStream.cc \
+       tests/stub_CollapsedForwarding.cc \
        ConfigOption.cc \
        ConfigParser.cc \
        CpuAffinityMap.cc \
@@ -1630,6 +1631,7 @@ tests_testDiskIO_SOURCES = \
        cbdata.cc \
        client_db.h \
        ClientInfo.h \
+       tests/stub_CollapsedForwarding.cc \
        ConfigOption.cc \
        ConfigParser.cc \
        $(DELAY_POOL_SOURCE) \
@@ -1710,6 +1712,7 @@ tests_testDiskIO_SOURCES = \
        StrList.h \
        StrList.cc \
        tests/stub_SwapDir.cc \
+       Transients.cc \
        log/access_log.h \
        tests/stub_access_log.cc \
        tests/stub_acl.cc \
@@ -1828,6 +1831,7 @@ tests_testEvent_SOURCES = \
        client_side_request.cc \
        ClientInfo.h \
        clientStream.cc \
+       tests/stub_CollapsedForwarding.cc \
        ConfigOption.cc \
        ConfigParser.cc \
        CpuAffinityMap.cc \
@@ -2075,6 +2079,7 @@ tests_testEventLoop_SOURCES = \
        client_side_request.cc \
        ClientInfo.h \
        clientStream.cc \
+       tests/stub_CollapsedForwarding.cc \
        ConfigOption.cc \
        ConfigParser.cc \
        CpuAffinityMap.cc \
@@ -2321,6 +2326,7 @@ tests_test_http_range_SOURCES = \
        client_side_request.cc \
        ClientInfo.h \
        clientStream.cc \
+       tests/stub_CollapsedForwarding.cc \
        ConfigOption.cc \
        ConfigParser.cc \
        CpuAffinityMap.cc \
@@ -2470,6 +2476,7 @@ tests_test_http_range_SOURCES = \
        StrList.h \
        StrList.cc \
        tests/stub_SwapDir.cc \
+       Transients.cc \
        tests/test_http_range.cc \
        tests/stub_external_acl.cc \
        tests/stub_ipc_Forwarder.cc \
@@ -2541,17 +2548,24 @@ tests_testHttpParser_SOURCES = \
        HttpParser.h \
        MemBuf.cc \
        MemBuf.h \
+       tests/stub_MemObject.cc \
        Mem.h \
        tests/stub_mem.cc \
        String.cc \
        cache_cf.h \
        YesNoNone.h \
+       $(SBUF_SOURCE) \
+       tests/stub_SBufDetailedStats.cc \
        tests/stub_cache_cf.cc \
        tests/stub_cache_manager.cc \
+       tests/stub_comm.cc \
+       tests/stub_cbdata.cc \
        tests/stub_debug.cc \
        tests/stub_event.cc \
        tests/stub_HelperChildConfig.cc \
+       tests/stub_stmem.cc \
        tests/stub_store.cc \
+       tests/stub_store_stats.cc \
        tools.h \
        tests/stub_tools.cc \
        tests/testHttpParser.cc \
@@ -2623,6 +2637,7 @@ tests_testHttpRequest_SOURCES = \
        client_side_request.cc \
        ClientInfo.h \
        clientStream.cc \
+       tests/stub_CollapsedForwarding.cc \
        ConfigOption.cc \
        ConfigParser.cc \
        CpuAffinityMap.cc \
@@ -2824,6 +2839,7 @@ tests_testStore_SOURCES= \
        tests/stub_CacheDigest.cc \
        cbdata.cc \
        ClientInfo.h \
+       tests/stub_CollapsedForwarding.cc \
        ConfigOption.cc \
        ConfigParser.cc \
        $(DELAY_POOL_SOURCE) \
@@ -2933,6 +2949,7 @@ tests_testStore_SOURCES= \
        tests/stub_store_rebuild.cc \
        tests/stub_store_swapout.cc \
        tools.h \
+       Transients.cc \
        tests/stub_tools.cc \
        tests/stub_UdsOp.cc \
        tests/testMain.cc \
@@ -3049,6 +3066,7 @@ tests_testUfs_SOURCES = \
        tests/testUfs.h \
        tests/stub_cache_manager.cc \
        tests/stub_client_db.cc \
+       tests/stub_CollapsedForwarding.cc \
        tests/stub_HelperChildConfig.cc \
        tests/stub_icp.cc \
        tests/stub_ipc.cc \
@@ -3085,6 +3103,7 @@ tests_testUfs_SOURCES = \
        RequestFlags.cc \
        SquidList.h \
        SquidList.cc \
+       Transients.cc \
        MasterXaction.cc \
        MasterXaction.h \
        MemObject.cc \
@@ -3422,6 +3441,7 @@ tests_testURL_SOURCES = \
        client_side_request.cc \
        ClientInfo.h \
        clientStream.cc \
+       tests/stub_CollapsedForwarding.cc \
        ConfigOption.cc \
        ConfigParser.cc \
        CpuAffinityMap.cc \
index 168687a0f0750f91d39acbcac78800ffe99c1c3e..a9e95da12115074c60fef2e2c53c1d7986271fc3 100644 (file)
@@ -90,8 +90,8 @@ HeapKeyGen_StoreEntry_LFUDA(void *entry, double heap_age)
            " refcnt=" << e->refcount << " lastref=" << e->lastref <<
            " heap_age=" << heap_age << " tie=" << tie << " -> " << key);
 
-    if (e->mem_obj && e->mem_obj->url)
-        debugs(81, 3, "HeapKeyGen_StoreEntry_LFUDA: url=" << e->mem_obj->url);
+    if (e->mem_obj)
+        debugs(81, 3, "storeId=" << e->mem_obj->storeId());
 
     return (double) key;
 }
@@ -128,8 +128,8 @@ HeapKeyGen_StoreEntry_GDSF(void *entry, double heap_age)
            e->lastref << " heap_age=" << heap_age << " tie=" << tie <<
            " -> " << key);
 
-    if (e->mem_obj && e->mem_obj->url)
-        debugs(81, 3, "HeapKeyGen_StoreEntry_GDSF: url=" << e->mem_obj->url);
+    if (e->mem_obj)
+        debugs(81, 3, "storeId=" << e->mem_obj->storeId());
 
     return key;
 }
@@ -149,8 +149,8 @@ HeapKeyGen_StoreEntry_LRU(void *entry, double heap_age)
            e->getMD5Text() << " heap_age=" << heap_age <<
            " lastref=" << (double) e->lastref  );
 
-    if (e->mem_obj && e->mem_obj->url)
-        debugs(81, 3, "HeapKeyGen_StoreEntry_LRU: url=" << e->mem_obj->url);
+    if (e->mem_obj)
+        debugs(81, 3, "storeId=" << e->mem_obj->storeId());
 
     return (heap_key) e->lastref;
 }
index 69c0a0403d9f4208111b7979ad2818066bc90130..683deff73e1b005811aa11994a15feca83d6c6f5 100644 (file)
@@ -476,9 +476,11 @@ StoreEntry::hashInsert(const cache_key * someKey)
 void
 StoreEntry::hashDelete()
 {
-    hash_remove_link(store_table, this);
-    storeKeyFree((const cache_key *)key);
-    key = NULL;
+    if (key) { // some test cases do not create keys and do not hashInsert()
+        hash_remove_link(store_table, this);
+        storeKeyFree((const cache_key *)key);
+        key = NULL;
+    }
 }
 
 /* -------------------------------------------------------------------------- */
index 57e8a4223c9e8262693506ff3bde1479b1e411d3..fb4a2f0e5f6e9d6e4997ff3125ed68d60558e65e 100644 (file)
@@ -21,14 +21,12 @@ MemObject::endOffset() const
 void MemObject::trimSwappable() STUB
 void MemObject::trimUnSwappable() STUB
 int64_t MemObject::policyLowestOffsetToKeep(bool swap) const STUB_RETVAL(-1)
-MemObject::MemObject(char const *, char const *) :
-        url(NULL),
+MemObject::MemObject() :
         inmem_lo(0),
         nclients(0),
         request(NULL),
         ping_reply_callback(NULL),
         ircb_data(NULL),
-        log_url(NULL),
         id(0),
         object_sz(-1),
         swap_hdr_sz(0),
@@ -45,6 +43,7 @@ HttpReply const * MemObject::getReply() const
     // XXX: required by testStore
     return NULL;
 }
+void MemObject::setUris(char const *aStoreId, char const *aLogUri, const HttpRequestMethod &aMethod) STUB
 void MemObject::reset() STUB
 void MemObject::delayRead(DeferredRead const &aRead) STUB
 bool MemObject::readAheadPolicyCanRead() const STUB_RETVAL(false)
@@ -62,7 +61,6 @@ void MemObject::kickReads() STUB
 int64_t MemObject::objectBytesOnDisk() const STUB_RETVAL(0)
 bool MemObject::isContiguous() const STUB_RETVAL(false)
 int64_t MemObject::expectedReplySize() const STUB_RETVAL(0)
-void MemObject::resetUrls(char const*, char const*) STUB
 void MemObject::markEndOfReplyHeaders() STUB
 size_t MemObject::inUseCount() STUB_RETVAL(0)
 int64_t MemObject::availableForSwapOut() const STUB_RETVAL(0)
index 8aba8dc916e439b0636271da78493f65245d39c6..ccb13faacc39ee64ce57d56eb27c5af4914adc45 100644 (file)
@@ -21,7 +21,6 @@ StoreIoStats store_io_stats;
 bool StoreEntry::checkDeferRead(int fd) const STUB_RETVAL(false)
 const char *StoreEntry::getMD5Text() const STUB_RETVAL(NULL)
 StoreEntry::StoreEntry() STUB
-StoreEntry::StoreEntry(const char *, const char *) STUB
 StoreEntry::~StoreEntry() STUB
 HttpReply const *StoreEntry::getReply() const STUB_RETVAL(NULL)
 void StoreEntry::write(StoreIOBuffer) STUB
@@ -53,7 +52,7 @@ int StoreEntry::checkNegativeHit() const STUB_RETVAL(0)
 int StoreEntry::locked() const STUB_RETVAL(0)
 int StoreEntry::validToSend() const STUB_RETVAL(0)
 bool StoreEntry::memoryCachable() const STUB_RETVAL(false)
-void StoreEntry::makeMemObject() STUB
+MemObject *StoreEntry::makeMemObject() STUB_RETVAL(NULL)
 void StoreEntry::createMemObject(const char *, const char *, const HttpRequestMethod &aMethod) STUB
 void StoreEntry::dump(int debug_lvl) const STUB
 void StoreEntry::hashDelete() STUB
@@ -139,6 +138,13 @@ void destroyStoreEntry(void *) STUB
 // in Packer.cc !? void packerToStoreInit(Packer * p, StoreEntry * e) STUB
 void storeGetMemSpace(int size) STUB
 
-#if !_USE_INLINE_
-#include "Store.cci"
-#endif
+#if !_USE_INLINE_ /* stubs for Store.cci */
+bool StoreEntry::isEmpty () const STUB_RETVAL(true)
+HttpReply const *NullStoreEntry::getReply() const STUB_RETVAL(NULL)
+
+Store &Store::Root()
+{
+    CPPUNIT_ASSERT(CurrentRoot != NULL);
+    return *CurrentRoot;
+}
+#endif /* !_USE_INLINE_ */
index 2a97a21dfa8b91320bb67f8e05ff3a0b2fe3cd0c..a40c15a0c38d879b69590a49dcc3ecff8ba85e1b 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "squid.h"
 #include "Mem.h"
+#include "MemObject.h"
 #include "SquidConfig.h"
 #include "SquidTime.h"
 #include "Store.h"
@@ -23,7 +24,9 @@ addSwapDir(TestSwapDirPointer aStore)
 void
 testStoreController::testStats()
 {
-    StoreEntry * logEntry = new StoreEntry("dummy_url", "dummy_log_url");
+    StoreEntry *logEntry = new StoreEntry;
+    logEntry->makeMemObject();
+    logEntry->mem_obj->setUris("dummy_storeId", NULL, HttpRequestMethod());
     logEntry->store_status = STORE_PENDING;
     StorePointer aRoot (new StoreController);
     Store::Root(aRoot);
@@ -63,7 +66,9 @@ void
 testStoreController::testMaxSize()
 {
     commonInit();
-    StoreEntry * logEntry = new StoreEntry("dummy_url", "dummy_log_url");
+    StoreEntry *logEntry = new StoreEntry;
+    logEntry->makeMemObject();
+    logEntry->mem_obj->setUris("dummy_storeId", NULL, HttpRequestMethod());
     logEntry->store_status = STORE_PENDING;
     StorePointer aRoot (new StoreController);
     Store::Root(aRoot);
@@ -99,7 +104,6 @@ addedEntry(StorePointer hashStore,
 
     CPPUNIT_ASSERT (e->swap_dirn != -1);
     e->swap_file_sz = 0; /* garh lower level */
-    e->lock_count = 0;
     e->lastref = squid_curtime;
     e->timestamp = squid_curtime;
     e->expires = squid_curtime;
index 28e0818a8de9c49db9f079340b8b4a184c425799..2b2a6372ba3fa0b5ed17d77092029ebd80bbf0bf 100644 (file)
@@ -32,7 +32,7 @@ testStoreEntryStream::testGetStream()
 
     CapturingStoreEntry * anEntry = new CapturingStoreEntry();
     {
-        StoreEntryStream stream(anEntry);
+        StoreEntryStream stream(anEntry); // locks and unlocks/deletes anEntry
         CPPUNIT_ASSERT_EQUAL(1, anEntry->_buffer_calls);
         CPPUNIT_ASSERT_EQUAL(0, anEntry->_flush_calls);
 
@@ -53,8 +53,5 @@ testStoreEntryStream::testGetStream()
         CPPUNIT_ASSERT_EQUAL(String("12345677.7 some text   !."),
                              anEntry->_appended_text);
     }
-
-    delete anEntry;
-
     Store::Root(NULL);
 }
index d525b0cd79e1b86b58cfa5251cc02d9e677c3257..1a82b86421e086a701454fb60279f8f702e530b3 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "squid.h"
 #include "Mem.h"
+#include "MemObject.h"
 #include "SquidConfig.h"
 #include "SquidTime.h"
 #include "Store.h"
@@ -24,7 +25,9 @@ addSwapDir(TestSwapDirPointer aStore)
 void
 testStoreHashIndex::testStats()
 {
-    StoreEntry * logEntry = new StoreEntry("dummy_url", "dummy_log_url");
+    StoreEntry *logEntry = new StoreEntry;
+    logEntry->makeMemObject();
+    logEntry->mem_obj->setUris("dummy_storeId", NULL, HttpRequestMethod());
     logEntry->store_status = STORE_PENDING;
     StorePointer aRoot (new StoreHashIndex());
     Store::Root(aRoot);
@@ -44,7 +47,9 @@ testStoreHashIndex::testStats()
 void
 testStoreHashIndex::testMaxSize()
 {
-    StoreEntry * logEntry = new StoreEntry("dummy_url", "dummy_log_url");
+    StoreEntry *logEntry = new StoreEntry;
+    logEntry->makeMemObject();
+    logEntry->mem_obj->setUris("dummy_storeId", NULL, HttpRequestMethod());
     logEntry->store_status = STORE_PENDING;
     StorePointer aRoot (new StoreHashIndex());
     Store::Root(aRoot);
@@ -80,7 +85,6 @@ addedEntry(StorePointer hashStore,
 
     CPPUNIT_ASSERT (e->swap_dirn != -1);
     e->swap_file_sz = 0; /* garh lower level */
-    e->lock_count = 0;
     e->lastref = squid_curtime;
     e->timestamp = squid_curtime;
     e->expires = squid_curtime;