From: Alex Rousskov Date: Thu, 19 Dec 2013 23:13:24 +0000 (-0700) Subject: Made "make check" happier by syncing test case with Store API changes X-Git-Tag: SQUID_3_5_0_1~444^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb868059b3379cca0fd9aeeed91eacd048777585;p=thirdparty%2Fsquid.git Made "make check" happier by syncing test case with Store API changes and making StoreEntry::hashDelete() more forgiving. --- diff --git a/src/Makefile.am b/src/Makefile.am index 87d14167af..6cba03201a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 \ diff --git a/src/repl/heap/store_heap_replacement.cc b/src/repl/heap/store_heap_replacement.cc index 168687a0f0..a9e95da121 100644 --- a/src/repl/heap/store_heap_replacement.cc +++ b/src/repl/heap/store_heap_replacement.cc @@ -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; } diff --git a/src/store.cc b/src/store.cc index 69c0a0403d..683deff73e 100644 --- a/src/store.cc +++ b/src/store.cc @@ -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; + } } /* -------------------------------------------------------------------------- */ diff --git a/src/tests/stub_MemObject.cc b/src/tests/stub_MemObject.cc index 57e8a4223c..fb4a2f0e5f 100644 --- a/src/tests/stub_MemObject.cc +++ b/src/tests/stub_MemObject.cc @@ -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) diff --git a/src/tests/stub_store.cc b/src/tests/stub_store.cc index 8aba8dc916..ccb13faacc 100644 --- a/src/tests/stub_store.cc +++ b/src/tests/stub_store.cc @@ -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_ */ diff --git a/src/tests/testStoreController.cc b/src/tests/testStoreController.cc index 2a97a21dfa..a40c15a0c3 100644 --- a/src/tests/testStoreController.cc +++ b/src/tests/testStoreController.cc @@ -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; diff --git a/src/tests/testStoreEntryStream.cc b/src/tests/testStoreEntryStream.cc index 28e0818a8d..2b2a6372ba 100644 --- a/src/tests/testStoreEntryStream.cc +++ b/src/tests/testStoreEntryStream.cc @@ -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); } diff --git a/src/tests/testStoreHashIndex.cc b/src/tests/testStoreHashIndex.cc index d525b0cd79..1a82b86421 100644 --- a/src/tests/testStoreHashIndex.cc +++ b/src/tests/testStoreHashIndex.cc @@ -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;