Bug 397227 - Reduce the effort needed to write C++ tests. r=ted

This commit is contained in:
Jeff Walden 2008-12-03 22:25:00 -08:00
Родитель 2208596029
Коммит ea921d740c
8 изменённых файлов: 267 добавлений и 315 удалений

Просмотреть файл

@ -113,6 +113,104 @@ 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
#
@ -1910,85 +2008,6 @@ REGCHROME_INSTALL = $(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/add-ch
$(_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
#############################################################################

Просмотреть файл

@ -49,7 +49,10 @@ DIRS += \
MODULE = content
CPP_UNIT_TESTS += TestNativeXMLHttpRequest.cpp TestPlainTextSerializer.cpp
CPP_UNIT_TESTS = \
TestNativeXMLHttpRequest.cpp \
TestPlainTextSerializer.cpp \
$(NULL)
LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/tests
@ -65,15 +68,6 @@ REQUIRES += \
htmlparser \
$(NULL)
CPPSRCS += $(CPP_UNIT_TESTS)
SIMPLE_PROGRAMS += $(CPP_UNIT_TESTS:.cpp=$(BIN_SUFFIX))
LIBS += \
$(XPCOM_GLUE_LDOPTS) \
$(NSPR_LIBS) \
$(NULL)
XPCSHELL_TESTS = \
unit \
$(NULL)
@ -277,9 +271,3 @@ _TEST_FILES = test_bug5141.html \
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

Просмотреть файл

@ -41,22 +41,12 @@
#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) { \
TEST_FAIL(_msg); \
fail(_msg); \
return NS_ERROR_FAILURE; \
} \
PR_END_MACRO
@ -113,7 +103,8 @@ nsresult TestNativeXMLHttpRequest()
TEST_ENSURE_SUCCESS(rv, "GetResponse failed!");
if (!response.EqualsLiteral(TEST_URL_CONTENT)) {
TEST_FAIL("Response text does not match!");
fail("Response text does not match!");
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDOMDocument> dom;
@ -121,10 +112,11 @@ nsresult TestNativeXMLHttpRequest()
TEST_ENSURE_SUCCESS(rv, "GetResponseXML failed!");
if (!dom) {
TEST_FAIL("No DOM document constructed!");
fail("No DOM document constructed!");
return NS_ERROR_FAILURE;
}
printf("Native XMLHttpRequest PASSED!\n");
passed("Native XMLHttpRequest");
return NS_OK;
}

Просмотреть файл

@ -46,15 +46,6 @@
#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
@ -85,9 +76,11 @@ TestPlainTextSerializer()
"<body>body</body></html>");
ConvertBufToPlainText(test);
if (!test.EqualsLiteral("basespanbody")) {
TEST_FAIL("Wrong html to text serialization");
fail("Wrong html to text serialization");
return NS_ERROR_FAILURE;
}
printf("HTML to text serialization test PASSED!\n");
passed("HTML to text serialization test");
// Add new tests here...
return NS_OK;

Просмотреть файл

@ -113,6 +113,104 @@ 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
#
@ -1910,85 +2008,6 @@ REGCHROME_INSTALL = $(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/add-ch
$(_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
#############################################################################

Просмотреть файл

@ -65,22 +65,10 @@ 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 \
TestPipes.cpp \
TestRacingServiceManager.cpp \
TestRegistrationOrder.cpp \
TestProxies.cpp \
TestThreadPoolListener.cpp \
TestTimers.cpp \
TestOOM.cpp \
@ -88,42 +76,57 @@ CPPSRCS = \
ifndef MOZ_ENABLE_LIBXUL
CPPSRCS += \
TestArray.cpp \
TestTArray.cpp \
TestAtoms.cpp \
TestAutoLock.cpp \
TestCRT.cpp \
TestEncoding.cpp \
TestPermanentAtoms.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)
endif
ifndef MOZILLA_INTERNAL_API
CPPSRCS += \
TestStringAPI.cpp \
$(NULL)
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
@ -133,47 +136,6 @@ ENABLE_CXX_EXCEPTIONS = 1
XPCSHELL_TESTS = unit
CPP_UNIT_TESTS = \
TestAutoPtr \
TestCOMPtr \
TestCOMPtrEq \
TestFactory \
TestHashtables \
TestID \
TestObserverService \
TestPipe \
TestPipes \
TestRacingServiceManager \
TestServMgr \
TestTextFormatter \
TestThreadPoolListener \
TestTimers \
$(NULL)
ifndef MOZ_ENABLE_LIBXUL
CPP_UNIT_TESTS += \
TestArray \
TestAutoLock \
TestCRT \
TestEncoding \
TestExpirationTracker \
TestProxies \
TestThreads \
TestThreadPool \
TestXPIDLString \
TestDeque \
TestStrings \
TestStorageStream \
TestTArray \
$(NULL)
endif
ifndef MOZILLA_INTERNAL_API
CPP_UNIT_TESTS += \
TestStringAPI \
$(NULL)
endif
# Make sure we have symbols in case we need to debug these.
MOZ_DEBUG_SYMBOLS = 1
@ -187,6 +149,12 @@ LOCAL_INCLUDES = \
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
@ -202,14 +170,6 @@ 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 \

Просмотреть файл

@ -113,14 +113,14 @@ nsresult BackwardsAllocator::Init(PRUint32 count, size_t size)
{
if (mMemory)
{
printf("FAIL allocator already initialized!\n");
fail("allocator already initialized!");
return NS_ERROR_ALREADY_INITIALIZED;
}
mMemory = new PRUint8[count * size + count];
if (!mMemory)
{
printf("FAIL failed to allocate mMemory!\n");
fail("failed to allocate mMemory!");
return NS_ERROR_OUT_OF_MEMORY;
}
memset(mMemory, 0, count * size + count);
@ -188,7 +188,7 @@ nsresult TestBackwardsAllocator()
nsRefPtr<BackwardsAllocator> allocator = new BackwardsAllocator();
if (!allocator)
{
printf("Allocation of BackwardsAllocator failed!\n");
fail("Allocation of BackwardsAllocator failed!");
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult rv = allocator->Init(SEGMENT_COUNT, SEGMENT_SIZE);
@ -222,7 +222,7 @@ nsresult TestBackwardsAllocator()
"9123456789"; // not just a memset, to ensure the allocator works correctly
if (sizeof(written) < BUFFER_LENGTH)
{
printf("FAIL test error with string size\n");
fail("test error with string size");
return NS_ERROR_FAILURE;
}
@ -230,8 +230,8 @@ nsresult TestBackwardsAllocator()
rv = output->Write(written, BUFFER_LENGTH, &writeCount);
if (NS_FAILED(rv) || writeCount != BUFFER_LENGTH)
{
printf("FAIL writing %d bytes (wrote %d bytes) to output failed: %x\n",
BUFFER_LENGTH, writeCount, rv);
fail("writing %d bytes (wrote %d bytes) to output failed: %x",
BUFFER_LENGTH, writeCount, rv);
return rv;
}
@ -240,18 +240,18 @@ nsresult TestBackwardsAllocator()
rv = input->Read(read, BUFFER_LENGTH, &readCount);
if (NS_FAILED(rv) || readCount != BUFFER_LENGTH)
{
printf("FAIL reading %d bytes (got %d bytes) from input failed: %x\n",
BUFFER_LENGTH, readCount, rv);
fail("reading %d bytes (got %d bytes) from input failed: %x",
BUFFER_LENGTH, readCount, rv);
return rv;
}
if (0 != memcmp(written, read, BUFFER_LENGTH))
{
printf("FAIL didn't read the written data correctly!\n");
fail("didn't read the written data correctly!");
return NS_ERROR_FAILURE;
}
printf("TestBackwardsAllocator PASSED!\n");
passed("TestBackwardsAllocator");
return NS_OK;
}

Просмотреть файл

@ -49,35 +49,16 @@ REQUIRES = \
xpcom \
$(NULL)
CPPSRCS = \
TestCOM.cpp \
TestNTFSPermissions.cpp \
$(NULL)
SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=$(BIN_SUFFIX))
include $(topsrcdir)/config/config.mk
CPP_UNIT_TESTS = \
TestCOM \
$(NULL)
TestCOM.cpp \
$(NULL)
# TestNTFSPermissions is causing oranges because it's creating directories
# multiple times, and then leaving them in a state where they can't be cleaned
# TestNTFSPermissions \
#CPP_UNIT_TESTS += TestNTFSPermissions.cpp
include $(topsrcdir)/config/rules.mk
OS_LIBS = $(call EXPAND_LIBNAME,rpcrt4 uuid advapi32)
LIBS = \
$(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
$(XPCOM_LIBS) \
$(NSPR_LIBS) \
$(NULL)
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