From 3c341a11ab7b8f3fd18afcf3f50af6dfafa632c2 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 8 Jan 2013 00:25:07 -0800
Subject: SH-3468 WIP add memory tracking base class more fixes for unit test
 crashes added llcommon initialization/teardown for unit tests that indirectly
 trigger lltrace changed access of atomic refcount to use
 preincrement/decrement operators to reflect desired semantics always call
 apr_initialize in LLCommon::initClass, even if already initialized...apr does
 internal reference counting to keep things straight

---
 indra/test/io.cpp                 | 11 ++++++++++-
 indra/test/llhttpdate_tut.cpp     |  9 +++++++++
 indra/test/lliohttpserver_tut.cpp |  7 +++++++
 indra/test/test.cpp               |  2 +-
 4 files changed, 27 insertions(+), 2 deletions(-)

(limited to 'indra/test')

diff --git a/indra/test/io.cpp b/indra/test/io.cpp
index ce747f667d..f2b4a5339c 100644
--- a/indra/test/io.cpp
+++ b/indra/test/io.cpp
@@ -44,6 +44,7 @@
 #include "llsdrpcclient.h"
 #include "llsdrpcserver.h"
 #include "llsdserialize.h"
+#include "llcommon.h"
 #include "lluuid.h"
 #include "llinstantmessage.h"
 
@@ -830,6 +831,7 @@ namespace tut
 	public:
 		PumpAndChainTestData()
 		{
+			LLCommon::initClass();
 			apr_pool_create(&mPool, NULL);
 			mPump = new LLPumpIO(mPool);
 		}
@@ -839,6 +841,7 @@ namespace tut
 			mChain.clear();
 			delete mPump;
 			apr_pool_destroy(mPool);
+			LLCommon::cleanupClass();
 		}
 	};
 	typedef test_group<PumpAndChainTestData>	PumpAndChainTestGroup;
@@ -909,6 +912,7 @@ namespace tut
 		
 		pipe_and_pump_fitness()
 		{
+			LLCommon::initClass();
 			LLFrameTimer::updateFrameTime();
 			apr_pool_create(&mPool, NULL);
 			mPump = new LLPumpIO(mPool);
@@ -923,6 +927,7 @@ namespace tut
 			mSocket.reset();
 			delete mPump;
 			apr_pool_destroy(mPool);
+			LLCommon::cleanupClass();
 		}
 
 	protected:
@@ -1186,8 +1191,12 @@ namespace tut
 			LLSimpleRPCResponse(LLSD* response) :
 				mResponsePtr(response)
 			{
+				LLCommon::initClass();
+			}
+			~LLSimpleRPCResponse() 
+			{
+				LLCommon::cleanupClass();
 			}
-			~LLSimpleRPCResponse() {}
 			virtual bool response(LLPumpIO* pump)
 			{
 				*mResponsePtr = mReturnValue;
diff --git a/indra/test/llhttpdate_tut.cpp b/indra/test/llhttpdate_tut.cpp
index 46684bb9dc..d6f0ba5e66 100644
--- a/indra/test/llhttpdate_tut.cpp
+++ b/indra/test/llhttpdate_tut.cpp
@@ -29,6 +29,7 @@
 #include "lltut.h"
 
 #include "lldate.h"
+#include "llcommon.h"
 #include "llframetimer.h"
 
 #include <time.h>
@@ -38,6 +39,14 @@ namespace tut
 {
     struct httpdate_data
     {
+		httpdate_data() 
+		{ 
+			LLCommon::initClass();
+		}
+		~httpdate_data() 
+		{ 
+			LLCommon::cleanupClass();
+		}
         LLDate some_date;
     };
     typedef test_group<httpdate_data> httpdate_test;
diff --git a/indra/test/lliohttpserver_tut.cpp b/indra/test/lliohttpserver_tut.cpp
index 2fdc455f45..e7af09f80b 100644
--- a/indra/test/lliohttpserver_tut.cpp
+++ b/indra/test/lliohttpserver_tut.cpp
@@ -31,6 +31,7 @@
 #include "lliohttpserver.h"
 #include "llsdhttpserver.h"
 #include "llsdserialize.h"
+#include "llcommon.h"
 
 #include "llpipeutil.h"
 
@@ -76,11 +77,17 @@ namespace tut
 		HTTPServiceTestData()
 			: mResponse(NULL)
 		{
+			LLCommon::initClass();
 			LLHTTPStandardServices::useServices();
 			LLHTTPRegistrar::buildAllServices(mRoot);
 			mRoot.addNode("/delayed/echo", new DelayedEcho(this));
 			mRoot.addNode("/wire/hello", new LLHTTPNodeForPipe<WireHello>);
 		}
+
+		~HTTPServiceTestData()
+		{
+			LLCommon::cleanupClass();
+		}
 		
 		LLHTTPNode mRoot;
 		LLHTTPNode::ResponsePtr mResponse;
diff --git a/indra/test/test.cpp b/indra/test/test.cpp
index d75040393c..8bd302ce7a 100644
--- a/indra/test/test.cpp
+++ b/indra/test/test.cpp
@@ -643,7 +643,7 @@ int main(int argc, char **argv)
 		s.close();
 	}
 
-	ll_cleanup_apr(false);
+	ll_cleanup_apr();
 
 	int retval = (success ? 0 : 1);
 	return retval;
-- 
cgit v1.2.3