Bug 1036894 part 6 - Emit SimplePrograms for CPP_UNIT_TESTs, and make the corresponding moz.build config look like that of SIMPLE_PROGRAMS. r=gps

This commit is contained in:
Mike Hommey 2014-07-23 13:29:44 +09:00
parent 0013fab872
commit af37eab57f
30 changed files with 183 additions and 141 deletions

View File

@ -81,19 +81,17 @@ ifdef COMPILE_ENVIRONMENT
# 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)
CPP_UNIT_TEST_BINS := $(CPP_UNIT_TESTS:.cpp=$(BIN_SUFFIX))
SIMPLE_PROGRAMS += $(CPP_UNIT_TEST_BINS)
SIMPLE_PROGRAMS += $(CPP_UNIT_TESTS)
INCLUDES += -I$(DIST)/include/testing
LIBS += $(XPCOM_GLUE_LDOPTS) $(NSPR_LIBS)
ifndef MOZ_PROFILE_GENERATE
libs:: $(CPP_UNIT_TEST_BINS) $(call mkdir_deps,$(DIST)/cppunittests)
$(NSINSTALL) $(CPP_UNIT_TEST_BINS) $(DIST)/cppunittests
libs:: $(CPP_UNIT_TESTS) $(call mkdir_deps,$(DIST)/cppunittests)
$(NSINSTALL) $(CPP_UNIT_TESTS) $(DIST)/cppunittests
endif
run-cppunittests::
@$(PYTHON) $(topsrcdir)/testing/runcppunittests.py --xre-path=$(DIST)/bin --symbols-path=$(DIST)/crashreporter-symbols $(subst .cpp,$(BIN_SUFFIX),$(CPP_UNIT_TESTS))
@$(PYTHON) $(topsrcdir)/testing/runcppunittests.py --xre-path=$(DIST)/bin --symbols-path=$(DIST)/crashreporter-symbols $(CPP_UNIT_TESTS)
cppunittests-remote: DM_TRANS?=adb
cppunittests-remote:
@ -103,7 +101,7 @@ cppunittests-remote:
--localLib=$(DEPTH)/dist/$(MOZ_APP_NAME) \
--dm_trans=$(DM_TRANS) \
--deviceIP=${TEST_DEVICE} \
$(subst .cpp,$(BIN_SUFFIX),$(CPP_UNIT_TESTS)) $(EXTRA_TEST_ARGS); \
$(CPP_UNIT_TESTS) $(EXTRA_TEST_ARGS); \
else \
echo 'please prepare your host with environment variables for TEST_DEVICE'; \
fi

View File

@ -16,12 +16,14 @@ if CONFIG['OS_ARCH'] != 'Darwin':
XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini']
CPP_UNIT_TESTS += [
'TestCSPParser.cpp',
'TestGetURL.cpp',
'TestNativeXMLHttpRequest.cpp',
'TestPlainTextSerializer.cpp',
'TestCSPParser',
'TestGetURL',
'TestNativeXMLHttpRequest',
'TestPlainTextSerializer',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
MOCHITEST_MANIFESTS += [
'chrome/mochitest.ini',
'mochitest.ini',

View File

@ -5,9 +5,11 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
CPP_UNIT_TESTS += [
'TestWebGLElementArrayCache.cpp',
'TestWebGLElementArrayCache',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
FAIL_ON_WARNINGS = True
LOCAL_INCLUDES += [

View File

@ -5,9 +5,11 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
CPP_UNIT_TESTS += [
'TestAudioMixer.cpp',
'TestAudioMixer',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
FAIL_ON_WARNINGS = True
LOCAL_INCLUDES += [

View File

@ -5,9 +5,11 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
CPP_UNIT_TESTS += [
'TestAudioEventTimeline.cpp',
'TestAudioEventTimeline',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
FAIL_ON_WARNINGS = True
LOCAL_INCLUDES += [

View File

@ -5,9 +5,11 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
CPP_UNIT_TESTS += [
'TestAudioChannelService.cpp',
'TestAudioChannelService',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
if CONFIG['OS_ARCH'] == 'WINNT':
DEFINES['NOMINMAX'] = True

View File

@ -5,8 +5,10 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
CPP_UNIT_TESTS += [
'TestTXMgr.cpp',
'TestTXMgr',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
FAIL_ON_WARNINGS = True

View File

@ -5,9 +5,11 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
CPP_UNIT_TESTS += [
'TestLineBreak.cpp',
'TestLineBreak',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
LOCAL_INCLUDES += [
'../public',
]

View File

@ -5,16 +5,18 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
CPP_UNIT_TESTS += [
'test_tone.cpp'
'test_tone'
]
if CONFIG['OS_TARGET'] != 'Android':
CPP_UNIT_TESTS += [
'test_audio.cpp',
'test_latency.cpp',
'test_sanity.cpp'
'test_audio',
'test_latency',
'test_sanity'
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
LOCAL_INCLUDES += [
'../include'
]

View File

@ -6,23 +6,25 @@
if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
CPP_UNIT_TESTS += [
'buffered_stun_socket_unittest.cpp',
'ice_unittest.cpp',
'nrappkit_unittest.cpp',
'rlogringbuffer_unittest.cpp',
'runnable_utils_unittest.cpp',
'simpletokenbucket_unittest.cpp',
'sockettransportservice_unittest.cpp',
'TestSyncRunnable.cpp',
'transport_unittests.cpp',
'turn_unittest.cpp',
'buffered_stun_socket_unittest',
'ice_unittest',
'nrappkit_unittest',
'rlogringbuffer_unittest',
'runnable_utils_unittest',
'simpletokenbucket_unittest',
'sockettransportservice_unittest',
'TestSyncRunnable',
'transport_unittests',
'turn_unittest',
]
if CONFIG['MOZ_SCTP']:
CPP_UNIT_TESTS += [
'sctp_unittest.cpp',
'sctp_unittest',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
FAIL_ON_WARNINGS = True
for var in ('HAVE_STRDUP', 'NR_SOCKET_IS_VOID_PTR', 'SCTP_DEBUG', 'INET'):

View File

@ -6,11 +6,14 @@
if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
CPP_UNIT_TESTS += [
'mediaconduit_unittests.cpp',
'mediapipeline_unittest.cpp',
'sdp_unittests.cpp',
'signaling_unittests.cpp',
'mediaconduit_unittests',
'mediapipeline_unittest',
'sdp_unittests',
'signaling_unittests',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
include('/ipc/chromium/chromium-config.mozbuild')
if CONFIG['OS_TARGET'] in ('Darwin', 'Android'):

View File

@ -5,5 +5,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
CPP_UNIT_TESTS += [
'TestVolatileBuffer.cpp',
'TestVolatileBuffer',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)

View File

@ -5,35 +5,37 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
CPP_UNIT_TESTS += [
'TestArrayUtils.cpp',
'TestAtomics.cpp',
'TestBinarySearch.cpp',
'TestBloomFilter.cpp',
'TestCasting.cpp',
'TestCeilingFloor.cpp',
'TestCheckedInt.cpp',
'TestCountPopulation.cpp',
'TestCountZeroes.cpp',
'TestEndian.cpp',
'TestEnumSet.cpp',
'TestFloatingPoint.cpp',
'TestIntegerPrintfMacros.cpp',
'TestMacroArgs.cpp',
'TestMacroForEach.cpp',
'TestPair.cpp',
'TestRollingMean.cpp',
'TestSHA1.cpp',
'TestTypedEnum.cpp',
'TestTypeTraits.cpp',
'TestUniquePtr.cpp',
'TestWeakPtr.cpp',
'TestArrayUtils',
'TestAtomics',
'TestBinarySearch',
'TestBloomFilter',
'TestCasting',
'TestCeilingFloor',
'TestCheckedInt',
'TestCountPopulation',
'TestCountZeroes',
'TestEndian',
'TestEnumSet',
'TestFloatingPoint',
'TestIntegerPrintfMacros',
'TestMacroArgs',
'TestMacroForEach',
'TestPair',
'TestRollingMean',
'TestSHA1',
'TestTypedEnum',
'TestTypeTraits',
'TestUniquePtr',
'TestWeakPtr',
]
if not CONFIG['MOZ_ASAN']:
CPP_UNIT_TESTS += [
'TestPoisonArea.cpp',
'TestPoisonArea',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
# Since we link directly with MFBT object files, define IMPL_MFBT
DEFINES['IMPL_MFBT'] = True

View File

@ -52,10 +52,12 @@ SOURCES += [
]
CPP_UNIT_TESTS += [
'TestSTSParser.cpp',
'TestUDPSocket.cpp',
'TestSTSParser',
'TestUDPSocket',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
RESOURCE_FILES += [
'urlparse.dat',
'urlparse_unx.dat',

View File

@ -436,7 +436,7 @@ class RecursiveMakeBackend(CommonBackend):
self._process_linked_libraries(obj, backend_file)
elif isinstance(obj, SimpleProgram):
self._process_simple_program(obj.program, backend_file)
self._process_simple_program(obj, backend_file)
self._process_linked_libraries(obj, backend_file)
elif isinstance(obj, HostSimpleProgram):
@ -1017,8 +1017,11 @@ class RecursiveMakeBackend(CommonBackend):
def _process_host_program(self, program, backend_file):
backend_file.write('HOST_PROGRAM = %s\n' % program)
def _process_simple_program(self, program, backend_file):
backend_file.write('SIMPLE_PROGRAMS += %s\n' % program)
def _process_simple_program(self, obj, backend_file):
if obj.is_unit_test:
backend_file.write('CPP_UNIT_TESTS += %s\n' % obj.program)
else:
backend_file.write('SIMPLE_PROGRAMS += %s\n' % obj.program)
def _process_host_simple_program(self, program, backend_file):
backend_file.write('HOST_SIMPLE_PROGRAMS += %s\n' % program)

View File

@ -362,13 +362,14 @@ class BaseProgram(Linkable):
"""
__slots__ = ('program')
def __init__(self, sandbox, program):
def __init__(self, sandbox, program, is_unit_test=False):
Linkable.__init__(self, sandbox)
bin_suffix = sandbox['CONFIG'].get(self.SUFFIX_VAR, '')
if not program.endswith(bin_suffix):
program += bin_suffix
self.program = program
self.is_unit_test = is_unit_test
class Program(BaseProgram):

View File

@ -324,7 +324,6 @@ class TreeMetadataEmitter(LoggingMixin):
varlist = [
'ANDROID_GENERATED_RESFILES',
'ANDROID_RES_DIRS',
'CPP_UNIT_TESTS',
'DISABLE_STL_WRAPPING',
'EXTRA_ASSEMBLER_FLAGS',
'EXTRA_COMPILE_FLAGS',
@ -449,6 +448,7 @@ class TreeMetadataEmitter(LoggingMixin):
for kind, cls in [
('SIMPLE_PROGRAMS', SimpleProgram),
('CPP_UNIT_TESTS', SimpleProgram),
('HOST_SIMPLE_PROGRAMS', HostSimpleProgram)]:
for program in sandbox[kind]:
if program in self._binaries:
@ -456,9 +456,11 @@ class TreeMetadataEmitter(LoggingMixin):
'Cannot use "%s" in %s, '
'because it is already used in %s' % (program, kind,
self._binaries[program].relativedir), sandbox)
self._binaries[program] = cls(sandbox, program)
self._binaries[program] = cls(sandbox, program,
is_unit_test=kind == 'CPP_UNIT_TESTS')
self._linkage.append((sandbox, self._binaries[program],
kind.replace('SIMPLE_PROGRAM', 'USE_LIBS')))
'HOST_USE_LIBS' if kind == 'HOST_SIMPLE_PROGRAMS'
else 'USE_LIBS'))
test_js_modules = sandbox.get('TESTING_JS_MODULES')
if test_js_modules:

View File

@ -234,10 +234,14 @@ VARIABLES = {
""", 'binaries'),
'CPP_UNIT_TESTS': (StrictOrderingOnAppendList, list,
"""C++ source files for unit tests.
"""Compile a list of C++ unit test names.
This is a list of C++ unit test sources. Entries must be files that
exist. These generally have ``.cpp`` extensions.
Each name in this variable corresponds to an executable built from the
corresponding source file with the same base name.
If the configuration token ``BIN_SUFFIX`` is set, its value will be
automatically appended to each name. If a name already ends with
``BIN_SUFFIX``, the name will remain unchanged.
""", 'binaries'),
'FAIL_ON_WARNINGS': (bool, bool,

View File

@ -10,8 +10,6 @@ EXTRA_PP_COMPONENTS = ['bar.pp.js', 'foo.pp.js']
EXTRA_JS_MODULES = ['bar.jsm', 'foo.jsm']
EXTRA_PP_JS_MODULES = ['bar.pp.jsm', 'foo.pp.jsm']
CPP_UNIT_TESTS = ['foo.cpp']
HOST_SOURCES += ['bar.cpp', 'foo.cpp']
HOST_SOURCES += ['bar.c', 'foo.c']

View File

@ -262,9 +262,6 @@ class TestRecursiveMakeBackend(BackendTester):
'CMMSRCS += bar.mm',
'CMMSRCS += foo.mm',
],
'CPP_UNIT_TESTS': [
'CPP_UNIT_TESTS += foo.cpp',
],
'CSRCS': [
'CSRCS += bar.c',
'CSRCS += foo.c',

View File

@ -10,8 +10,6 @@ EXTRA_PP_COMPONENTS=['fans.pp.js', 'tans.pp.js']
EXTRA_JS_MODULES = ['bar.jsm', 'foo.jsm']
EXTRA_PP_JS_MODULES = ['bar.pp.jsm', 'foo.pp.jsm']
CPP_UNIT_TESTS = ['foo.cpp']
HOST_SOURCES += ['fans.cpp', 'tans.cpp']
HOST_SOURCES += ['fans.c', 'tans.c']

View File

@ -158,7 +158,6 @@ class TestEmitterBasic(unittest.TestCase):
ASFILES=['fans.asm', 'tans.s'],
CMMSRCS=['fans.mm', 'tans.mm'],
CSRCS=['fans.c', 'tans.c'],
CPP_UNIT_TESTS=['foo.cpp'],
DISABLE_STL_WRAPPING=True,
EXTRA_COMPONENTS=['fans.js', 'tans.js'],
EXTRA_PP_COMPONENTS=['fans.pp.js', 'tans.pp.js'],

View File

@ -5,5 +5,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
CPP_UNIT_TESTS += [
'TestCertDB.cpp',
'TestCertDB',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)

View File

@ -5,9 +5,11 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
CPP_UNIT_TESTS += [
'TestStartupCache.cpp',
'TestStartupCache',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
EXTRA_COMPONENTS += [
'TestStartupCacheTelemetry.js',
'TestStartupCacheTelemetry.manifest',

View File

@ -7,27 +7,29 @@
XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
CPP_UNIT_TESTS += [
'test_AsXXX_helpers.cpp',
'test_async_callbacks_with_spun_event_loops.cpp',
'test_asyncStatementExecution_transaction.cpp',
'test_binding_params.cpp',
'test_file_perms.cpp',
'test_mutex.cpp',
'test_service_init_background_thread.cpp',
'test_statement_scoper.cpp',
'test_StatementCache.cpp',
'test_transaction_helper.cpp',
'test_true_async.cpp',
'test_unlock_notify.cpp',
'test_AsXXX_helpers',
'test_async_callbacks_with_spun_event_loops',
'test_asyncStatementExecution_transaction',
'test_binding_params',
'test_file_perms',
'test_mutex',
'test_service_init_background_thread',
'test_statement_scoper',
'test_StatementCache',
'test_transaction_helper',
'test_true_async',
'test_unlock_notify',
]
if CONFIG['MOZ_DEBUG'] and CONFIG['OS_ARCH'] not in ('WINNT', 'Darwin'):
# FIXME bug 523392: test_deadlock_detector doesn't like Windows
# FIXME bug 523378: also fails on OS X
CPP_UNIT_TESTS += [
'test_deadlock_detector.cpp',
'test_deadlock_detector',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
LOCAL_INCLUDES += [
'../src',
]

View File

@ -5,8 +5,10 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
CPP_UNIT_TESTS += [
'test_IHistory.cpp',
'test_IHistory',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
FAIL_ON_WARNINGS = True

View File

@ -15,5 +15,7 @@ JAR_MANIFESTS += ['jar.mn']
# XXX Get this to work in libxul builds.
## simple c++ tests (no xpcom)
#CPP_UNIT_TESTS += [ \
# 'TestUrlClassifierUtils.cpp', \
# 'TestUrlClassifierUtils', \
#]
#
#SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)

View File

@ -9,7 +9,7 @@ MOCHITEST_MANIFESTS += ['mochitest.ini']
MOCHITEST_CHROME_MANIFESTS += ['chrome.ini']
CPP_UNIT_TESTS += [
'TestAppShellSteadyState.cpp',
'TestAppShellSteadyState',
]
FAIL_ON_WARNINGS = True
@ -18,8 +18,10 @@ FAIL_ON_WARNINGS = True
# if CONFIG['NS_ENABLE_TSF']:
# Test disabled because it uses the internal string APIs incorrectly
# (see bug 582863)
# CPP_UNIT_TESTS += ['TestWinTSF.cpp']
# CPP_UNIT_TESTS += ['TestWinTSF']
#
# Test disabled because it requires the internal API. Re-enabling this test
# is bug 652123.
# CPP_UNIT_TESTS += ['TestChromeMargin.cpp']
# CPP_UNIT_TESTS += ['TestChromeMargin']
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)

View File

@ -55,65 +55,67 @@ SOURCES += [
XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
CPP_UNIT_TESTS += [
'ShowAlignments.cpp',
'TestAutoPtr.cpp',
'TestAutoRef.cpp',
'TestCOMArray.cpp',
'TestCOMPtr.cpp',
'TestCOMPtrEq.cpp',
'TestDeque.cpp',
'TestFile.cpp',
'TestHashtables.cpp',
'TestID.cpp',
'TestObserverArray.cpp',
'TestObserverService.cpp',
'TestPipe.cpp',
'TestPLDHash.cpp',
'TestRefPtr.cpp',
'TestStringAPI.cpp',
'TestTArray.cpp',
'TestTextFormatter.cpp',
'TestThreadUtils.cpp'
'ShowAlignments',
'TestAutoPtr',
'TestAutoRef',
'TestCOMArray',
'TestCOMPtr',
'TestCOMPtrEq',
'TestDeque',
'TestFile',
'TestHashtables',
'TestID',
'TestObserverArray',
'TestObserverService',
'TestPipe',
'TestPLDHash',
'TestRefPtr',
'TestStringAPI',
'TestTArray',
'TestTextFormatter',
'TestThreadUtils'
]
if CONFIG['MOZ_MEMORY']:
CPP_UNIT_TESTS += [
'TestJemalloc.cpp',
'TestJemalloc',
]
# XXX Make these tests work in libxul builds.
#CPP_UNIT_TESTS += [
# 'TestArray.cpp',
# 'TestCRT.cpp',
# 'TestEncoding.cpp',
# 'TestExpirationTracker.cpp',
# 'TestPipes.cpp',
# 'TestPriorityQueue.cpp',
# 'TestStorageStream.cpp',
# 'TestStrings.cpp',
# 'TestSynchronization.cpp',
# 'TestTArray.cpp',
# 'TestThreadPool.cpp',
# 'TestThreads.cpp',
# 'TestTimeStamp.cpp',
# 'TestXPIDLString.cpp',
# 'TestUTF.cpp',
# 'TestAtoms.cpp',
# 'TestArray',
# 'TestCRT',
# 'TestEncoding',
# 'TestExpirationTracker',
# 'TestPipes',
# 'TestPriorityQueue',
# 'TestStorageStream',
# 'TestStrings',
# 'TestSynchronization',
# 'TestTArray',
# 'TestThreadPool',
# 'TestThreads',
# 'TestTimeStamp',
# 'TestXPIDLString',
# 'TestUTF',
# 'TestAtoms',
#]
# FIXME: bug 577500 TestStaticAtoms fails when run in dist/bin
#CPP_UNIT_TESTS += [
# 'TestStaticAtoms.cpp',
# 'TestStaticAtoms',
#]
if CONFIG['MOZ_DEBUG'] and CONFIG['OS_ARCH'] not in ('WINNT', 'Darwin'):
# FIXME bug 523392: TestDeadlockDetector doesn't like Windows
# FIXME bug 523378: also fails on OS X
CPP_UNIT_TESTS += [
'TestDeadlockDetector.cpp',
'TestDeadlockDetectorScalability.cpp',
'TestDeadlockDetector',
'TestDeadlockDetectorScalability',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
LOCAL_INCLUDES += [
'../ds',
]

View File

@ -5,7 +5,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
CPP_UNIT_TESTS += [
'TestCOM.cpp',
'TestNtPathToDosPath.cpp',
'TestCOM',
'TestNtPathToDosPath',
]
SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)