]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixed "make check".
authorFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 14 Jul 2008 17:08:55 +0000 (19:08 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 14 Jul 2008 17:08:55 +0000 (19:08 +0200)
src/Makefile.am
src/tests/stub_cache_manager.cc
src/tests/testCacheManager.cc

index c3a7bbe2ebd9fcd8924b52c1a369b3e6392e451b..6b25ca4698f5d9a541a9fe28510cef2eaa3a3cb5 100644 (file)
@@ -1175,8 +1175,7 @@ TEST_CALL_SOURCES = \
        AsyncCall.cc
 
 
-check_PROGRAMS+= testHeaders \
-       tests/testAuth \
+check_PROGRAMS+= tests/testAuth \
        tests/testACLMaxUserIP \
        tests/testBoilerplate \
        tests/testCacheManager \
@@ -1511,7 +1510,9 @@ tests_testDiskIO_SOURCES= \
        $(SWAP_TEST_SOURCES) \
        tests/testDiskIO.cc \
        tests/testDiskIO.h \
-       tests/testMain.cc
+       tests/testMain.cc \
+       tests/stub_cache_manager.cc
+
 tests_testDiskIO_LDADD= \
        $(SWAP_TEST_LDADD) \
        libsquid.la \
@@ -2230,6 +2231,7 @@ tests_testStore_SOURCES= \
        tests/TestSwapDir.h \
        tests/stub_fd.cc \
        tests/stub_HttpReply.cc \
+       tests/stub_cache_manager.cc \
        $(STORE_TEST_SOURCES)
 
 tests_testStore_LDADD= \
@@ -2250,6 +2252,7 @@ tests_testString_SOURCES= \
        tests/testMain.cc \
        tests/testString.cc \
        tests/testString.h \
+       tests/stub_cache_manager.cc \
        $(TESTSOURCES) \
        time.cc 
 
@@ -2318,6 +2321,7 @@ SWAP_TEST_DS =\
 tests_testUfs_SOURCES= tests/testUfs.cc \
        tests/testMain.cc \
        tests/testUfs.h \
+       tests/stub_cache_manager.cc \
        $(SWAP_TEST_SOURCES)
 tests_testUfs_LDADD= \
        libsquid.la \
@@ -2330,6 +2334,7 @@ tests_testUfs_DEPENDENCIES = \
 tests_testCoss_SOURCES= tests/testCoss.cc \
        tests/testMain.cc \
        tests/testCoss.h \
+       tests/stub_cache_manager.cc \
        $(SWAP_TEST_SOURCES)
 tests_testCoss_LDADD= \
        libsquid.la \
index 40ee815ce1bf36ea2aa94492ef0c9cb1a51528e9..e9ec9261c7a3cb324fdf21ad55668cbab2d7dbf7 100644 (file)
@@ -32,6 +32,8 @@
 #include "CacheManager.h"
 #include "squid.h"
 
+static CacheManager *cm=0;
+
 CacheManager::CacheManager()
 {
 }
@@ -39,32 +41,32 @@ CacheManager::CacheManager()
 void
 CacheManager::registerAction(char const * action, char const * desc, OBJH * handler, int pw_req_flag, int atomic)
 {
-       fatal("Not implemented");
+    return;
 }
 
 void
 CacheManager::registerAction(CacheManagerAction *anAction)
 {
-       fatal("Not implemented");
+    return;
 }
 
 CacheManagerAction *
 CacheManager::findAction(char const * action)
 {
-       fatal("Not implemented");
-       return 0; //notreached
+    return 0;
 }
 
 void
 CacheManager::Start(int fd, HttpRequest * request, StoreEntry * entry)
 {
-       fatal("Not implemented");
+    return;
 }
 
 CacheManager*
-CacheManager::GetInstance()
+CacheManager::GetInstance(void)
 {
-       fatal("Not implemented");
-       return 0; //notreached
+    if (!cm)
+        cm=new CacheManager();
+    return cm;
 }
 
index 2de748ba4b8b3bd98fa5424f14d2707434e6a538..21e9857cb772197ef2a9586687a445ec0a3aba9b 100644 (file)
@@ -4,6 +4,7 @@
 #include "Mem.h"
 #include "testCacheManager.h"
 #include "CacheManager.h"
+#include "Store.h"
 
 
 CPPUNIT_TEST_SUITE_REGISTRATION( testCacheManager );
@@ -32,13 +33,15 @@ void testCacheManager::setUp()
 void
 testCacheManager::testCreate()
 {
-    CacheManager()::GetInstance(); //it's a singleton..
+    CacheManager::GetInstance(); //it's a singleton..
 }
 
 /* an action to register */
 static void
 dummy_action(StoreEntry * sentry)
-{}
+{
+    sentry->flags=1;
+}
 
 /*
  * registering an action makes it findable.
@@ -46,12 +49,17 @@ dummy_action(StoreEntry * sentry)
 void
 testCacheManager::testRegister()
 {
-    CacheManager manager;
-    manager.registerAction("sample", "my sample", &dummy_action, false, false);
-    CacheManagerAction *anAction = manager.findAction("sample");
-    CPPUNIT_ASSERT_EQUAL(String("sample"), String(anAction->action));
-    CPPUNIT_ASSERT_EQUAL(String("my sample"), String(anAction->desc));
-    CPPUNIT_ASSERT_EQUAL(&dummy_action, anAction->handler);
+    CacheManager *manager=CacheManager::GetInstance();
+
+    manager->registerAction("sample", "my sample", &dummy_action, false, false);
+    CacheManagerAction *anAction = manager->findAction("sample");
+
     CPPUNIT_ASSERT_EQUAL(0, (int)anAction->flags.pw_req);
     CPPUNIT_ASSERT_EQUAL(0, (int)anAction->flags.atomic);
+    CPPUNIT_ASSERT_EQUAL(String("sample"), String(anAction->action));
+
+    StoreEntry *sentry=new StoreEntry();
+    sentry->flags=0x25; //arbitrary test value
+    anAction->run(sentry);
+    CPPUNIT_ASSERT_EQUAL(1,(int)sentry->flags);
 }