---------------------
PatchSet 10828 
Date: 2007/05/23 20:59:14
Author: hno
Branch: HEAD
Tag: (none) 
Log:
Fix the cppunit tests to use setUp() rather than an static constructor to
initialize memory pools etc.

Static constructors is dangerous in that you don't know for sure
in which order they will be called. The recent String pool change
where the object size is dynamically calculated on startup is and
example, where the requested pool size had not yet been calculated
before the pools was created.

Members: 
	src/gopher.cc:1.205->1.206 
	src/protos.h:1.543->1.544 
	src/url.cc:1.158->1.159 
	src/tests/testCacheManager.cc:1.2->1.3 
	src/tests/testCacheManager.h:1.1->1.2 
	src/tests/testDiskIO.cc:1.1->1.2 
	src/tests/testDiskIO.h:1.1->1.2 
	src/tests/testEvent.cc:1.4->1.5 
	src/tests/testEvent.h:1.1->1.2 
	src/tests/testEventLoop.cc:1.4->1.5 
	src/tests/testEventLoop.h:1.3->1.4 
	src/tests/testHttpRequest.cc:1.2->1.3 
	src/tests/testHttpRequest.h:1.1->1.2 
	src/tests/testStoreEntryStream.cc:1.3->1.4 
	src/tests/testStoreEntryStream.h:1.1->1.2 
	src/tests/testString.cc:1.4->1.5 
	src/tests/testString.h:1.3->1.4 
	src/tests/testURL.cc:1.2->1.3 
	src/tests/testURL.h:1.1->1.2 

Index: squid3/src/gopher.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/gopher.cc,v
retrieving revision 1.205
retrieving revision 1.206
diff -u -r1.205 -r1.206
--- squid3/src/gopher.cc	18 May 2007 06:41:24 -0000	1.205
+++ squid3/src/gopher.cc	23 May 2007 20:59:14 -0000	1.206
@@ -1,6 +1,6 @@
 
 /*
- * $Id: gopher.cc,v 1.205 2007/05/18 06:41:24 amosjeffries Exp $
+ * $Id: gopher.cc,v 1.206 2007/05/23 20:59:14 hno Exp $
  *
  * DEBUG: section 10    Gopher
  * AUTHOR: Harvest Derived
@@ -248,7 +248,7 @@
     if (request) {
         xstrncpy(request, path + 1, MAX_URL);
         /* convert %xx to char */
-        url_convert_hex(request, 0);
+        rfc1738_unescape(request);
     }
 }
 
Index: squid3/src/protos.h
===================================================================
RCS file: /cvsroot/squid/squid3/src/protos.h,v
retrieving revision 1.543
retrieving revision 1.544
diff -u -r1.543 -r1.544
--- squid3/src/protos.h	18 May 2007 06:41:25 -0000	1.543
+++ squid3/src/protos.h	23 May 2007 20:59:14 -0000	1.544
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.543 2007/05/18 06:41:25 amosjeffries Exp $
+ * $Id: protos.h,v 1.544 2007/05/23 20:59:14 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -624,8 +624,6 @@
 SQUIDCEXTERN void unlinkdUnlink(const char *);
 #endif
 
-SQUIDCEXTERN char *url_convert_hex(char *org_url, int allocate);
-SQUIDCEXTERN char *url_escape(const char *url);
 SQUIDCEXTERN protocol_t urlParseProtocol(const char *, const char *e = NULL);
 SQUIDCEXTERN void urlInitialize(void);
 SQUIDCEXTERN HttpRequest *urlParse(method_t, char *, HttpRequest *request = NULL);
Index: squid3/src/url.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/url.cc,v
retrieving revision 1.158
retrieving revision 1.159
diff -u -r1.158 -r1.159
--- squid3/src/url.cc	18 May 2007 06:41:25 -0000	1.158
+++ squid3/src/url.cc	23 May 2007 20:59:14 -0000	1.159
@@ -1,6 +1,6 @@
 
 /*
- * $Id: url.cc,v 1.158 2007/05/18 06:41:25 amosjeffries Exp $
+ * $Id: url.cc,v 1.159 2007/05/23 20:59:14 hno Exp $
  *
  * DEBUG: section 23    URL Parsing
  * AUTHOR: Duane Wessels
@@ -49,38 +49,6 @@
     "0123456789-."
     ;
 
-/* convert %xx in url string to a character
- * Allocate a new string and return a pointer to converted string */
-
-char *
-url_convert_hex(char *org_url, int allocate)
-{
-    static char code[] = "00";
-    char *url = NULL;
-    char *s = NULL;
-    char *t = NULL;
-    url = allocate ? (char *) xstrdup(org_url) : org_url;
-
-    if ((int) strlen(url) < 3 || !strchr(url, '%'))
-        return url;
-
-    for (s = t = url; *s; s++) {
-        if (*s == '%' && *(s + 1) && *(s + 2)) {
-            code[0] = *(++s);
-            code[1] = *(++s);
-            *t++ = (char) strtol(code, NULL, 16);
-        } else {
-            *t++ = *s;
-        }
-    }
-
-    do {
-        *t++ = *s;
-    } while (*s++);
-
-    return url;
-}
-
 void
 urlInitialize(void)
 {
Index: squid3/src/tests/testCacheManager.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/tests/testCacheManager.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- squid3/src/tests/testCacheManager.cc	18 May 2007 06:41:33 -0000	1.2
+++ squid3/src/tests/testCacheManager.cc	23 May 2007 20:59:15 -0000	1.3
@@ -17,12 +17,10 @@
 
 /* init memory pools */
 
-struct Initer
+void testCacheManager::setUp()
 {
-    Initer() {Mem::Init();}
-};
-
-static Initer ensure_mempools;
+    Mem::Init();
+}
 
 /*
  * Test creating a CacheManager
Index: squid3/src/tests/testCacheManager.h
===================================================================
RCS file: /cvsroot/squid/squid3/src/tests/testCacheManager.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- squid3/src/tests/testCacheManager.h	29 May 2006 00:15:09 -0000	1.1
+++ squid3/src/tests/testCacheManager.h	23 May 2007 20:59:15 -0000	1.2
@@ -16,6 +16,7 @@
     CPPUNIT_TEST_SUITE_END();
 
 public:
+    void setUp();
 
 protected:
     void testCreate();
Index: squid3/src/tests/testDiskIO.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/tests/testDiskIO.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- squid3/src/tests/testDiskIO.cc	14 Sep 2006 08:34:51 -0000	1.1
+++ squid3/src/tests/testDiskIO.cc	23 May 2007 20:59:15 -0000	1.2
@@ -16,14 +16,12 @@
 
 CPPUNIT_TEST_SUITE_REGISTRATION( testDiskIO );
 
-struct Initer {
-  Initer() {
+void
+testDiskIO::setUp()
+{
     Mem::Init();
     DiskIOModule::SetupAllModules();
-  };
-};
-
-Initer ensure_inited;
+}
 
 void
 testDiskIO::testFindDefault()
Index: squid3/src/tests/testDiskIO.h
===================================================================
RCS file: /cvsroot/squid/squid3/src/tests/testDiskIO.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- squid3/src/tests/testDiskIO.h	14 Sep 2006 08:34:51 -0000	1.1
+++ squid3/src/tests/testDiskIO.h	23 May 2007 20:59:15 -0000	1.2
@@ -15,6 +15,7 @@
     CPPUNIT_TEST_SUITE_END();
 
 public:
+    void setUp();
 
 protected:
     void testFindDefault();
Index: squid3/src/tests/testEvent.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/tests/testEvent.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- squid3/src/tests/testEvent.cc	18 May 2007 06:41:33 -0000	1.4
+++ squid3/src/tests/testEvent.cc	23 May 2007 20:59:15 -0000	1.5
@@ -19,16 +19,12 @@
 
 /* init legacy static-initialized modules */
 
-struct Initer
+void
+testEvent::setUp()
 {
-    Initer()
-    {
-        Mem::Init();
-        statInit();
-    }
-};
-
-static Initer ensure_mempools;
+    Mem::Init();
+    statInit();
+}
 
 /*
  * Test creating a EventDispatcher and Scheduler
Index: squid3/src/tests/testEvent.h
===================================================================
RCS file: /cvsroot/squid/squid3/src/tests/testEvent.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- squid3/src/tests/testEvent.h	7 Aug 2006 02:28:26 -0000	1.1
+++ squid3/src/tests/testEvent.h	23 May 2007 20:59:15 -0000	1.2
@@ -21,6 +21,7 @@
     CPPUNIT_TEST_SUITE_END();
 
 public:
+    void setUp();
 
 protected:
     void testCreate();
Index: squid3/src/tests/testEventLoop.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/tests/testEventLoop.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- squid3/src/tests/testEventLoop.cc	2 Sep 2006 19:26:46 -0000	1.4
+++ squid3/src/tests/testEventLoop.cc	23 May 2007 20:59:15 -0000	1.5
@@ -20,16 +20,12 @@
 
 /* init legacy static-initialized modules */
 
-struct Initer
+void
+testEventLoop::setUp()
 {
-    Initer()
-    {
-        Mem::Init();
-        statInit();
-    }
-};
-
-static Initer ensure_mempools;
+    Mem::Init();
+    statInit();
+}
 
 /*
  * Test creating a EventLoop
Index: squid3/src/tests/testEventLoop.h
===================================================================
RCS file: /cvsroot/squid/squid3/src/tests/testEventLoop.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- squid3/src/tests/testEventLoop.h	19 Aug 2006 12:31:26 -0000	1.3
+++ squid3/src/tests/testEventLoop.h	23 May 2007 20:59:16 -0000	1.4
@@ -22,6 +22,7 @@
     CPPUNIT_TEST_SUITE_END();
 
 public:
+    void setUp();
 
 protected:
     void testCreate();
Index: squid3/src/tests/testHttpRequest.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/tests/testHttpRequest.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- squid3/src/tests/testHttpRequest.cc	18 May 2007 06:41:33 -0000	1.2
+++ squid3/src/tests/testHttpRequest.cc	23 May 2007 20:59:16 -0000	1.3
@@ -17,12 +17,11 @@
 
 /* init memory pools */
 
-struct Initer
+void
+testHttpRequest::setUp()
 {
-    Initer() {Mem::Init();}
-};
-
-static Initer ensure_mempools;
+    Mem::Init();
+}
 
 /*
  * Test creating an HttpRequest object from a Url and method
Index: squid3/src/tests/testHttpRequest.h
===================================================================
RCS file: /cvsroot/squid/squid3/src/tests/testHttpRequest.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- squid3/src/tests/testHttpRequest.h	3 May 2006 14:04:45 -0000	1.1
+++ squid3/src/tests/testHttpRequest.h	23 May 2007 20:59:16 -0000	1.2
@@ -16,6 +16,7 @@
     CPPUNIT_TEST_SUITE_END();
 
 public:
+    void setUp();
 
 protected:
     void testCreateFromUrlAndMethod();
Index: squid3/src/tests/testStoreEntryStream.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/tests/testStoreEntryStream.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- squid3/src/tests/testStoreEntryStream.cc	18 May 2007 06:41:33 -0000	1.3
+++ squid3/src/tests/testStoreEntryStream.cc	23 May 2007 20:59:16 -0000	1.4
@@ -14,12 +14,10 @@
 
 /* init memory pools */
 
-struct Initer
+void testStoreEntryStream::setUp()
 {
-    Initer() {Mem::Init();}
-};
-
-static Initer ensure_mempools;
+    Mem::Init();
+}
 
 void
 testStoreEntryStream::testGetStream()
Index: squid3/src/tests/testStoreEntryStream.h
===================================================================
RCS file: /cvsroot/squid/squid3/src/tests/testStoreEntryStream.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- squid3/src/tests/testStoreEntryStream.h	3 May 2006 14:04:45 -0000	1.1
+++ squid3/src/tests/testStoreEntryStream.h	23 May 2007 20:59:16 -0000	1.2
@@ -15,6 +15,7 @@
     CPPUNIT_TEST_SUITE_END();
 
 public:
+    void setUp();
 
 protected:
     void testGetStream();
Index: squid3/src/tests/testString.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/tests/testString.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- squid3/src/tests/testString.cc	20 May 2007 08:29:44 -0000	1.4
+++ squid3/src/tests/testString.cc	23 May 2007 20:59:16 -0000	1.5
@@ -13,12 +13,11 @@
 
 /* init memory pools */
 
-struct Initer
+void
+testString::setUp()
 {
-    Initer() {Mem::Init();}
-};
-
-static Initer ensure_mempools;
+    Mem::Init();
+}
 
 void
 testString::testDefaults()
Index: squid3/src/tests/testString.h
===================================================================
RCS file: /cvsroot/squid/squid3/src/tests/testString.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- squid3/src/tests/testString.h	20 May 2007 08:29:44 -0000	1.3
+++ squid3/src/tests/testString.h	23 May 2007 20:59:16 -0000	1.4
@@ -26,6 +26,7 @@
     CPPUNIT_TEST_SUITE_END();
 
 public:
+    void setUp();
 
 protected:
 
Index: squid3/src/tests/testURL.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/tests/testURL.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- squid3/src/tests/testURL.cc	2 Sep 2006 03:54:27 -0000	1.2
+++ squid3/src/tests/testURL.cc	23 May 2007 20:59:16 -0000	1.3
@@ -18,12 +18,11 @@
 
 /* init memory pools */
 
-struct Initer
+void
+testURL::setUp()
 {
-    Initer() {Mem::Init();}
-};
-
-static Initer ensure_mempools;
+    Mem::Init();
+}
 
 /*
  * we can construct a URL with a URLScheme.
Index: squid3/src/tests/testURL.h
===================================================================
RCS file: /cvsroot/squid/squid3/src/tests/testURL.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- squid3/src/tests/testURL.h	8 May 2006 23:38:36 -0000	1.1
+++ squid3/src/tests/testURL.h	23 May 2007 20:59:16 -0000	1.2
@@ -16,6 +16,7 @@
     CPPUNIT_TEST_SUITE_END();
 
 public:
+    void setUp();
 
 protected:
 
