Backed out changeset 88a91e1e9a3f
authorReed Loden <reed@reedloden.com>
Sat, 12 Jul 2008 16:32:25 -0500
changeset 15887 6a0468794f61f74346cfe957289e840e29b7669f
parent 15886 88a91e1e9a3f4c869f336f28983b3ce82712d0ce
child 15888 5fba7bea3723222de0b35ce703abeca927d6707d
push id577
push userreed@reedloden.com
push dateSat, 12 Jul 2008 21:32:24 +0000
treeherderautoland@6a0468794f61 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.1a1pre
backs out88a91e1e9a3f4c869f336f28983b3ce82712d0ce
Backed out changeset 88a91e1e9a3f
config/rules.mk
content/base/test/Makefile.in
content/base/test/TestNativeXMLHttpRequest.cpp
content/base/test/TestPlainTextSerializer.cpp
xpcom/tests/Makefile.in
xpcom/tests/TestPipe.cpp
xpcom/tests/TestTextFormatter.cpp
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -112,114 +112,16 @@ EXPAND_LIBNAME = $(addprefix -l,$(1))
 EXPAND_LIBNAME_PATH = -L$(2) $(addprefix -l,$(1))
 EXPAND_MOZLIBNAME = $(addprefix -l,$(1))
 endif
 
 ifdef EXTRA_DSO_LIBS
 EXTRA_DSO_LIBS	:= $(call EXPAND_MOZLIBNAME,$(EXTRA_DSO_LIBS))
 endif
 
-################################################################################
-# Testing frameworks support
-################################################################################
-
-ifdef ENABLE_TESTS
-
-ifdef XPCSHELL_TESTS
-ifndef MODULE
-$(error Must define MODULE when defining XPCSHELL_TESTS.)
-endif
-
-# Test file installation
-libs::
-	@$(EXIT_ON_ERROR) \
-	for testdir in $(XPCSHELL_TESTS); do \
-	  $(INSTALL) \
-	    $(srcdir)/$$testdir/*.js \
-	    $(DEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir; \
-	done
-
-# Path formats on Windows are hard.  We require a topsrcdir formatted so that
-# it may be passed to nsILocalFile.initWithPath (in other words, an absolute
-# path of the form X:\path\to\topsrcdir), which we store in NATIVE_TOPSRCDIR.
-# We require a forward-slashed path to topsrcdir so that it may be combined
-# with a relative forward-slashed path for loading scripts, both dynamically
-# and statically for head/test/tail JS files.  Of course, on non-Windows none
-# of this matters, and things will work correctly because everything's
-# forward-slashed, everywhere, always.
-ifdef CYGWIN_WRAPPER
-NATIVE_TOPSRCDIR   := `cygpath -wa $(topsrcdir)`
-FWDSLASH_TOPSRCDIR := `cygpath -ma $(topsrcdir)`
-else
-FWDSLASH_TOPSRCDIR := $(topsrcdir)
-ifeq ($(HOST_OS_ARCH),WINNT)
-NATIVE_TOPSRCDIR   := $(subst /,\\,$(WIN_TOP_SRC))
-else 
-NATIVE_TOPSRCDIR   := $(topsrcdir)
-endif
-endif # CYGWIN_WRAPPER
-
-# Test execution
-check::
-	@$(EXIT_ON_ERROR) \
-	for testdir in $(XPCSHELL_TESTS); do \
-	  $(RUN_TEST_PROGRAM) \
-	    $(topsrcdir)/tools/test-harness/xpcshell-simple/test_all.sh \
-	      $(DIST)/bin/xpcshell \
-	      $(FWDSLASH_TOPSRCDIR) \
-	      $(NATIVE_TOPSRCDIR) \
-	      $(DEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir; \
-	done
-
-# Test execution
-check-interactive::
-	@$(EXIT_ON_ERROR) \
-	$(RUN_TEST_PROGRAM) \
-	  $(topsrcdir)/tools/test-harness/xpcshell-simple/test_one.sh \
-	    $(DIST)/bin/xpcshell \
-	    $(FWDSLASH_TOPSRCDIR) \
-	    $(NATIVE_TOPSRCDIR) \
-	    $(DEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir \
-	    $(SOLO_FILE) 1;
-
-# Test execution
-check-one::
-	@$(EXIT_ON_ERROR) \
-	$(RUN_TEST_PROGRAM) \
-	  $(topsrcdir)/tools/test-harness/xpcshell-simple/test_one.sh \
-	    $(DIST)/bin/xpcshell \
-	    $(FWDSLASH_TOPSRCDIR) \
-	    $(NATIVE_TOPSRCDIR) \
-	    $(DEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir \
-	    $(SOLO_FILE) 0;
-
-endif # XPCSHELL_TESTS
-
-ifdef CPP_UNIT_TESTS
-
-# Compile the tests to $(DIST)/bin.  Make lots of niceties available by default
-# through TestHarness.h, by modifying the list of includes and the libs against
-# which stuff links.
-CPPSRCS += $(CPP_UNIT_TESTS)
-SIMPLE_PROGRAMS += $(CPP_UNIT_TESTS:.cpp=$(BIN_SUFFIX))
-REQUIRES += testing xpcom
-LIBS += $(XPCOM_LIBS) $(XPCOM_GLUE_LDOPTS) $(NSPR_LIBS)
-
-# ...and run them the usual way
-check::
-	@$(EXIT_ON_ERROR) \
-	  for f in $(subst .cpp,,$(CPP_UNIT_TESTS)); do \
-	    XPCOM_DEBUG_BREAK=stack-and-abort $(RUN_TEST_PROGRAM) $(DIST)/bin/$$f; \
-	  done
-
-endif # CPP_UNIT_TESTS
-
-endif # ENABLE_TESTS
-
-
 #
 # Library rules
 #
 # If BUILD_STATIC_LIBS or FORCE_STATIC_LIB is set, build a static library.
 # Otherwise, build a shared library.
 #
 
 ifndef LIBRARY
@@ -1981,16 +1883,95 @@ REGCHROME = $(PERL) -I$(MOZILLA_DIR)/con
 	$(_JAR_REGCHROME_DISABLE_JAR)
 
 REGCHROME_INSTALL = $(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/add-chrome.pl \
 	$(if $(filter gtk2,$(MOZ_WIDGET_TOOLKIT)),-x) \
 	$(if $(CROSS_COMPILE),-o $(OS_ARCH)) $(DESTDIR)$(mozappdir)/chrome/installed-chrome.txt \
 	$(_JAR_REGCHROME_DISABLE_JAR)
 
 
+################################################################################
+# Testing frameworks support
+################################################################################
+
+ifdef ENABLE_TESTS
+
+ifdef XPCSHELL_TESTS
+ifndef MODULE
+$(error Must define MODULE when defining XPCSHELL_TESTS.)
+endif
+
+# Test file installation
+libs::
+	@$(EXIT_ON_ERROR) \
+	for testdir in $(XPCSHELL_TESTS); do \
+	  $(INSTALL) \
+	    $(srcdir)/$$testdir/*.js \
+	    $(DEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir; \
+	done
+
+# Path formats on Windows are hard.  We require a topsrcdir formatted so that
+# it may be passed to nsILocalFile.initWithPath (in other words, an absolute
+# path of the form X:\path\to\topsrcdir), which we store in NATIVE_TOPSRCDIR.
+# We require a forward-slashed path to topsrcdir so that it may be combined
+# with a relative forward-slashed path for loading scripts, both dynamically
+# and statically for head/test/tail JS files.  Of course, on non-Windows none
+# of this matters, and things will work correctly because everything's
+# forward-slashed, everywhere, always.
+ifdef CYGWIN_WRAPPER
+NATIVE_TOPSRCDIR   := `cygpath -wa $(topsrcdir)`
+FWDSLASH_TOPSRCDIR := `cygpath -ma $(topsrcdir)`
+else
+FWDSLASH_TOPSRCDIR := $(topsrcdir)
+ifeq ($(HOST_OS_ARCH),WINNT)
+NATIVE_TOPSRCDIR   := $(subst /,\\,$(WIN_TOP_SRC))
+else 
+NATIVE_TOPSRCDIR   := $(topsrcdir)
+endif
+endif # CYGWIN_WRAPPER
+
+# Test execution
+check::
+	@$(EXIT_ON_ERROR) \
+	for testdir in $(XPCSHELL_TESTS); do \
+	  $(RUN_TEST_PROGRAM) \
+	    $(topsrcdir)/tools/test-harness/xpcshell-simple/test_all.sh \
+	      $(DIST)/bin/xpcshell \
+	      $(FWDSLASH_TOPSRCDIR) \
+	      $(NATIVE_TOPSRCDIR) \
+	      $(DEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir; \
+	done
+
+# Test execution
+check-interactive::
+	@$(EXIT_ON_ERROR) \
+	$(RUN_TEST_PROGRAM) \
+	  $(topsrcdir)/tools/test-harness/xpcshell-simple/test_one.sh \
+	    $(DIST)/bin/xpcshell \
+	    $(FWDSLASH_TOPSRCDIR) \
+	    $(NATIVE_TOPSRCDIR) \
+	    $(DEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir \
+	    $(SOLO_FILE) 1;
+
+# Test execution
+check-one::
+	@$(EXIT_ON_ERROR) \
+	$(RUN_TEST_PROGRAM) \
+	  $(topsrcdir)/tools/test-harness/xpcshell-simple/test_one.sh \
+	    $(DIST)/bin/xpcshell \
+	    $(FWDSLASH_TOPSRCDIR) \
+	    $(NATIVE_TOPSRCDIR) \
+	    $(DEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir \
+	    $(SOLO_FILE) 0;
+
+endif # XPCSHELL_TESTS
+
+endif # ENABLE_TESTS
+
+
 #############################################################################
 # Dependency system
 #############################################################################
 ifdef COMPILER_DEPEND
 depend::
 	@echo "$(MAKE): No need to run depend target.\
 			Using compiler-based depend." 1>&2
 ifeq ($(GNU_CC)$(GNU_CXX),)
--- a/content/base/test/Makefile.in
+++ b/content/base/test/Makefile.in
@@ -58,16 +58,25 @@ REQUIRES += \
   js \
   netwerk \
   string \
   xpcom \
   xpconnect \
   htmlparser \
   $(NULL)
 
+CPPSRCS += $(CPP_UNIT_TESTS)
+
+SIMPLE_PROGRAMS += $(CPP_UNIT_TESTS:.cpp=$(BIN_SUFFIX))
+
+LIBS += \
+  $(XPCOM_GLUE_LDOPTS) \
+  $(NSPR_LIBS) \
+  $(NULL)
+
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES = 	test_bug5141.html \
 		test_bug51034.html \
 		test_bug199959.html \
 		test_bug218236.html \
 		file_bug218236_multipart.txt \
 		file_bug218236_multipart.txt^headers^ \
@@ -174,8 +183,14 @@ include $(topsrcdir)/config/rules.mk
 		test_bug438519.html \
 		test_text_replaceWholeText.html \
 		test_text_wholeText.html \
 		wholeTexty-helper.xml \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
+
+check::
+	@$(EXIT_ON_ERROR) \
+	for f in $(subst .cpp,,$(CPP_UNIT_TESTS)); do \
+	  XPCOM_DEBUG_BREAK=stack-and-abort $(RUN_TEST_PROGRAM) $(DIST)/bin/$$f; \
+	done
--- a/content/base/test/TestNativeXMLHttpRequest.cpp
+++ b/content/base/test/TestNativeXMLHttpRequest.cpp
@@ -36,22 +36,32 @@
 
 #include "TestHarness.h"
 
 #include "nsIDOMDocument.h"
 #include "nsIPrincipal.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIXMLHttpRequest.h"
 
+#include "nsServiceManagerUtils.h"
+#include "nsStringGlue.h"
+
+#define REPORT_ERROR(_msg)                  \
+  printf("FAIL " _msg "\n")
+
+#define TEST_FAIL(_msg)                     \
+  PR_BEGIN_MACRO                            \
+    REPORT_ERROR(_msg);                     \
+    return NS_ERROR_FAILURE;                \
+  PR_END_MACRO
 
 #define TEST_ENSURE_BASE(_test, _msg)       \
   PR_BEGIN_MACRO                            \
     if (_test) {                            \
-      fail(_msg);                           \
-      return NS_ERROR_FAILURE;              \
+      TEST_FAIL(_msg);                      \
     }                                       \
   PR_END_MACRO
 
 #define TEST_ENSURE_SUCCESS(_rv, _msg)      \
   TEST_ENSURE_BASE(NS_FAILED(_rv), _msg)
 
 #define TEST_ENSURE_FAILED(_rv, _msg)       \
   TEST_ENSURE_BASE(NS_SUCCEEDED(_rv), _msg)
@@ -98,30 +108,28 @@ nsresult TestNativeXMLHttpRequest()
   rv = xhr->Send(nsnull);
   TEST_ENSURE_SUCCESS(rv, "Send failed!");
 
   nsAutoString response;
   rv = xhr->GetResponseText(response);
   TEST_ENSURE_SUCCESS(rv, "GetResponse failed!");
 
   if (!response.EqualsLiteral(TEST_URL_CONTENT)) {
-    fail("Response text does not match!");
-    return NS_ERROR_FAILURE;
+    TEST_FAIL("Response text does not match!");
   }
 
   nsCOMPtr<nsIDOMDocument> dom;
   rv = xhr->GetResponseXML(getter_AddRefs(dom));
   TEST_ENSURE_SUCCESS(rv, "GetResponseXML failed!");
 
   if (!dom) {
-    fail("No DOM document constructed!");
-    return NS_ERROR_FAILURE;
+    TEST_FAIL("No DOM document constructed!");
   }
 
-  passed("Native XMLHttpRequest");
+  printf("Native XMLHttpRequest PASSED!\n");
   return NS_OK;
 }
 
 int main(int argc, char** argv)
 {
   ScopedXPCOM xpcom("XMLHttpRequest");
   if (xpcom.failed())
     return 1;
--- a/content/base/test/TestPlainTextSerializer.cpp
+++ b/content/base/test/TestPlainTextSerializer.cpp
@@ -41,16 +41,25 @@
 #include "nsIHTMLToTextSink.h"
 #include "nsIParser.h"
 #include "nsIContentSink.h"
 #include "nsIParserService.h"
 #include "nsServiceManagerUtils.h"
 #include "nsStringGlue.h"
 #include "nsParserCIID.h"
 
+#define REPORT_ERROR(_msg)                  \
+  printf("FAIL " _msg "\n")
+
+#define TEST_FAIL(_msg)                     \
+  PR_BEGIN_MACRO                            \
+    REPORT_ERROR(_msg);                     \
+    return NS_ERROR_FAILURE;                \
+  PR_END_MACRO
+
 static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
 
 void
 ConvertBufToPlainText(nsString &aConBuf)
 {
   nsCOMPtr<nsIParser> parser = do_CreateInstance(kCParserCID);
   if (parser) {
     nsCOMPtr<nsIContentSink> sink;
@@ -71,21 +80,19 @@ ConvertBufToPlainText(nsString &aConBuf)
 nsresult
 TestPlainTextSerializer()
 {
   nsString test;
   test.AppendLiteral("<html><base>base</base><head><span>span</span></head>"
                      "<body>body</body></html>");
   ConvertBufToPlainText(test);
   if (!test.EqualsLiteral("basespanbody")) {
-    fail("Wrong html to text serialization");
-    return NS_ERROR_FAILURE;
+    TEST_FAIL("Wrong html to text serialization");
   }
-
-  passed("HTML to text serialization test");
+  printf("HTML to text serialization test PASSED!\n");
 
   // Add new tests here...
   return NS_OK;
 }
 
 int main(int argc, char** argv)
 {
   ScopedXPCOM xpcom("PlainTextSerializer");
--- a/xpcom/tests/Makefile.in
+++ b/xpcom/tests/Makefile.in
@@ -60,114 +60,151 @@ endif
 REQUIRES	= \
 		  string \
 		  $(NULL)
 
 CPPSRCS		= \
 		nsIFileEnumerator.cpp \
 		nsIFileTest.cpp \
 		TestCallTemplates.cpp \
+		TestCOMPtr.cpp \
+		TestCOMPtrEq.cpp \
+		TestFactory.cpp \
+		TestHashtables.cpp \
+		TestID.cpp \
 		TestINIParser.cpp \
+		TestObserverService.cpp \
+		TestServMgr.cpp \
+		TestAutoPtr.cpp \
 		TestVersionComparator.cpp \
+		TestTextFormatter.cpp \
+		TestPipe.cpp \
 		TestRegistrationOrder.cpp \
+		TestProxies.cpp \
 		$(NULL)
 
 ifndef MOZ_ENABLE_LIBXUL
 CPPSRCS += \
+		TestArray.cpp \
+		TestTArray.cpp \
 		TestAtoms.cpp \
+		TestAutoLock.cpp \
+		TestCRT.cpp \
+		TestEncoding.cpp \
 		TestPermanentAtoms.cpp \
+		TestPipes.cpp \
+		TestThreads.cpp \
+		TestThreadPool.cpp \
+		TestXPIDLString.cpp \
+		TestDeque.cpp \
+		TestStrings.cpp \
+		TestStorageStream.cpp \
+		TestExpirationTracker.cpp \
 		$(NULL)
 endif
 
-SIMPLE_PROGRAMS	:= $(CPPSRCS:.cpp=$(BIN_SUFFIX))
-
-CPP_UNIT_TESTS = \
-                 TestAutoPtr.cpp \
-                 TestCOMPtr.cpp \
-                 TestCOMPtrEq.cpp \
-                 TestFactory.cpp \
-                 TestHashtables.cpp \
-                 TestID.cpp \
-                 TestObserverService.cpp \
-                 TestPipe.cpp \
-                 TestServMgr.cpp \
-                 TestTextFormatter.cpp \
-                 $(NULL)
-
-ifndef MOZ_ENABLE_LIBXUL
-CPP_UNIT_TESTS += \
-                  TestArray.cpp \
-                  TestAutoLock.cpp \
-                  TestCRT.cpp \
-                  TestEncoding.cpp \
-                  TestExpirationTracker.cpp \
-                  TestPipes.cpp \
-                  TestProxies.cpp \
-                  TestThreads.cpp \
-                  TestThreadPool.cpp \
-                  TestXPIDLString.cpp \
-                  TestDeque.cpp \
-                  TestStrings.cpp \
-                  TestStorageStream.cpp \
-                  TestTArray.cpp \
-                  $(NULL)
+ifndef MOZILLA_INTERNAL_API
+CPPSRCS += \
+		TestStringAPI.cpp \
+		$(NULL)
 endif
 
-ifndef MOZILLA_INTERNAL_API
-CPP_UNIT_TESTS += \
-                  TestStringAPI.cpp \
-                  $(NULL)
-endif
+SIMPLE_PROGRAMS	= $(CPPSRCS:.cpp=$(BIN_SUFFIX))
 
 include $(topsrcdir)/config/config.mk
 
 ifndef MOZILLA_INTERNAL_API
 LIBS +=	$(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX)
 endif
 
+LIBS		+= \
+		$(XPCOM_LIBS) \
+		$(NSPR_LIBS) \
+		$(NULL)
+
 # Needed to resolve __yylex (?)
 ifeq ($(OS_ARCH)$(OS_RELEASE),FreeBSD2)
 LIBS		+= -lpcap
 endif
 
 ENABLE_CXX_EXCEPTIONS = 1
 
 XPCSHELL_TESTS = unit
 
+CPP_UNIT_TESTS = \
+  TestAutoPtr \
+  TestCOMPtr \
+  TestCOMPtrEq \
+  TestFactory \
+  TestHashtables \
+  TestID \
+  TestObserverService \
+  TestPipe \
+  TestServMgr \
+  TestTextFormatter \
+  $(NULL)
+
+ifndef MOZ_ENABLE_LIBXUL
+CPP_UNIT_TESTS += \
+  TestArray \
+  TestAutoLock \
+  TestCRT \
+  TestEncoding \
+  TestExpirationTracker \
+  TestPipes \
+  TestProxies \
+  TestThreads \
+  TestThreadPool \
+  TestXPIDLString \
+  TestDeque \
+  TestStrings \
+  TestStorageStream \
+  TestTArray \
+  $(NULL)
+endif
+
+ifndef MOZILLA_INTERNAL_API
+CPP_UNIT_TESTS += \
+  TestStringAPI \
+  $(NULL)
+endif
+
 include $(topsrcdir)/config/rules.mk
 
 LOCAL_INCLUDES	= \
                 -I$(srcdir)/../ds \
 		-I$(srcdir)/services \
 		$(NULL)
 
 libs::
 	$(INSTALL) $(srcdir)/test.properties $(DIST)/bin/res
 
-# Copy TestHarness.h into its own module, for ease of setting up includes
-# correctly.
-export::
-	$(NSINSTALL) -D $(DIST)/include/testing
-	$(INSTALL) $(srcdir)/TestHarness.h $(DIST)/include/testing
-
 install::
 	$(SYSINSTALL) $(IFLAGS1) $(srcdir)/test.properties $(DESTDIR)$(mozappdir)/res
 
 ifeq (,$(filter-out WINNT WINCE, $(HOST_OS_ARCH)))
 swapslashes = $(shell echo $(1) | sed -e 's|/|\\|g')
 getnativepath = $(call swapslashes,$(call normalizepath,$(1)))
 else
 getnativepath = $(1)
 endif
 
 abs_srcdir = $(shell cd $(srcdir) && pwd)
 
 check::
 	@echo "Running TestVersionComparator tests"
 	@$(PERL) -w $(srcdir)/TestVersionComparatorRunner.pl "$(RUN_TEST_PROGRAM) $(FINAL_TARGET)/TestVersionComparator$(BIN_SUFFIX)"
+	@echo "Running nsTextFormatter tests"
+	@$(RUN_TEST_PROGRAM) $(FINAL_TARGET)/TestTextFormatter$(BIN_SUFFIX)
+	@$(EXIT_ON_ERROR) \
+	for f in $(CPP_UNIT_TESTS); do \
+	  echo Running $$f; \
+	  XPCOM_DEBUG_BREAK=stack-and-abort $(RUN_TEST_PROGRAM) $(DIST)/bin/$$f; \
+	  echo Finished running $$f; \
+	done
 	@echo "Running XPIDL tests"
 	$(XPIDL_COMPILE) -m header $(srcdir)/TestScriptable.idl
 	@if grep Notscriptable TestScriptable.h | grep -q NS_SCRIPTABLE ; then \
 		echo "Nonscriptable object marked scriptable by xpidl"; \
 		exit 1; \
 	fi
 	@if test $$( grep 'NS_IMETHOD[^I].*Scriptable' TestScriptable.h | grep -v -c NS_SCRIPTABLE ) != 0 ; then \
 		echo "Scriptable object marked nonscriptable by xpidl"; \
--- a/xpcom/tests/TestPipe.cpp
+++ b/xpcom/tests/TestPipe.cpp
@@ -108,24 +108,24 @@ class BackwardsAllocator : public nsIMem
 };
 
 NS_IMPL_ISUPPORTS1(BackwardsAllocator, nsIMemory)
 
 nsresult BackwardsAllocator::Init(PRUint32 count, size_t size)
 {
   if (mMemory)
   {
-    fail("allocator already initialized!");
+    printf("FAIL allocator already initialized!\n");
     return NS_ERROR_ALREADY_INITIALIZED;
   }
 
   mMemory = new PRUint8[count * size + count];
   if (!mMemory)
   {
-    fail("failed to allocate mMemory!");
+    printf("FAIL failed to allocate mMemory!\n");
     return NS_ERROR_OUT_OF_MEMORY;
   }
   memset(mMemory, 0, count * size + count);
 
   mIndex = 0;
   mCount = count;
   mSize = size;
 
@@ -183,33 +183,33 @@ NS_IMETHODIMP BackwardsAllocator::IsLowM
 nsresult TestBackwardsAllocator()
 {
   const PRUint32 SEGMENT_COUNT = 10;
   const size_t SEGMENT_SIZE = 10;
 
   nsRefPtr<BackwardsAllocator> allocator = new BackwardsAllocator();
   if (!allocator)
   {
-    fail("Allocation of BackwardsAllocator failed!");
+    printf("Allocation of BackwardsAllocator failed!\n");
     return NS_ERROR_OUT_OF_MEMORY;
   }
   nsresult rv = allocator->Init(SEGMENT_COUNT, SEGMENT_SIZE);
   if (NS_FAILED(rv))
     return rv;
 
   nsCOMPtr<nsIAsyncInputStream> input;
   nsCOMPtr<nsIAsyncOutputStream> output;
   rv = NS_NewPipe2(getter_AddRefs(input),
                    getter_AddRefs(output),
                    PR_FALSE,
                    PR_FALSE,
                    SEGMENT_SIZE, SEGMENT_COUNT, allocator); 
   if (NS_FAILED(rv))
   {
-    fail("NS_NewPipe2 failed: %x", rv);
+    printf("FAIL NS_NewPipe2 failed: %x\n", rv);
     return rv;
   }
 
   const PRUint32 BUFFER_LENGTH = 100;
   const char written[] =
     "0123456789"
     "1123456789"
     "2123456789"
@@ -217,46 +217,46 @@ nsresult TestBackwardsAllocator()
     "4123456789"
     "5123456789"
     "6123456789"
     "7123456789"
     "8123456789"
     "9123456789"; // not just a memset, to ensure the allocator works correctly
   if (sizeof(written) < BUFFER_LENGTH)
   {
-    fail("test error with string size");
+    printf("FAIL test error with string size\n");
     return NS_ERROR_FAILURE;
   }
 
   PRUint32 writeCount;
   rv = output->Write(written, BUFFER_LENGTH, &writeCount);
   if (NS_FAILED(rv) || writeCount != BUFFER_LENGTH)
   {
-    fail("writing %d bytes (wrote %d bytes) to output failed: %x",
-         BUFFER_LENGTH, writeCount, rv);
+    printf("FAIL writing %d bytes (wrote %d bytes) to output failed: %x\n",
+           BUFFER_LENGTH, writeCount, rv);
     return rv;
   }
 
   char read[BUFFER_LENGTH];
   PRUint32 readCount;
   rv = input->Read(read, BUFFER_LENGTH, &readCount);
   if (NS_FAILED(rv) || readCount != BUFFER_LENGTH)
   {
-    fail("reading %d bytes (got %d bytes) from input failed: %x",
-         BUFFER_LENGTH, readCount,  rv);
+    printf("FAIL reading %d bytes (got %d bytes) from input failed: %x\n",
+           BUFFER_LENGTH, readCount,  rv);
     return rv;
   }
 
   if (0 != memcmp(written, read, BUFFER_LENGTH))
   {
-    fail("didn't read the written data correctly!");
+    printf("FAIL didn't read the written data correctly!\n");
     return NS_ERROR_FAILURE;
   }
 
-  passed("TestBackwardsAllocator");
+  printf("TestBackwardsAllocator PASSED!\n");
   return NS_OK;
 }
 
 int main(int argc, char** argv)
 {
   ScopedXPCOM xpcom("nsPipe");
   if (xpcom.failed())
     return 1;
--- a/xpcom/tests/TestTextFormatter.cpp
+++ b/xpcom/tests/TestTextFormatter.cpp
@@ -31,58 +31,38 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "TestHarness.h"
+#include <nsTextFormatter.h>
+#include <nsStringGlue.h>
+#include <stdio.h>
 
-#include <nsTextFormatter.h>
+int main() 
+{  
+  int test_ok = true;
 
-nsresult TestSnprintf()
-{
   nsAutoString fmt(NS_LITERAL_STRING("%3$s %4$S %1$d %2$d")); 
   char utf8[] = "Hello"; 
-  PRUnichar ucs2[] = {'W', 'o', 'r', 'l', 'd', 0x4e00, 0xAc00, 0xFF45, 0x0103, 0x00}; 
-  int d = 3; 
+  PRUnichar ucs2[]={'W', 'o', 'r', 'l', 'd', 0x4e00, 0xAc00, 0xFF45, 0x0103, 0x00}; 
+  int d=3; 
 
   PRUnichar buf[256]; 
   nsTextFormatter::snprintf(buf, 256, fmt.get(), d, 333, utf8, ucs2); 
   nsAutoString out(buf); 
-  if (strcmp("Hello World", NS_LossyConvertUTF16toASCII(out).get()))
-  {
-    fail("Unexpected string created by nsTextFormatter::snprintf!");
-    return NS_ERROR_FAILURE;
-  }
+  if(strcmp("Hello World", NS_LossyConvertUTF16toASCII(out).get()))
+    test_ok = false;
 
+  const PRUnichar *uout = out.get(); 
   const PRUnichar expected[] = {0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20,
                                 0x57, 0x6F, 0x72, 0x6C, 0x64, 0x4E00,
                                 0xAC00, 0xFF45, 0x0103, 0x20, 0x33,
                                 0x20, 0x33, 0x33, 0x33};
-  for (PRUint32 i = 0; i < out.Length(); i++)
-  {
-    if(out[i] != expected[i])
-    {
-      fail("Unexpected character at index %u", i);
-      return NS_ERROR_FAILURE;
-    }
-  }
-
-  passed("TestSnprintf");
-  return NS_OK;
+  for(PRUint32 i=0;i<out.Length();i++) 
+    if(uout[i] != expected[i]) 
+      test_ok = false;
+  printf(test_ok? "nsTextFormatter: OK\n": "nsTextFormatter: FAIL\n");
 }
 
-int main() 
-{  
-  ScopedXPCOM xpcom("TextFormatter");
-  if (xpcom.failed())
-    return 1;
-
-  int rv = 0;
-
-  if (NS_FAILED(TestSnprintf()))
-    rv = 1;
-
-  return rv;
-}