mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1368932 - Add a testcase for a replace-malloc library that doesn't implement all functions. r=njn
--HG-- rename : memory/replace/logalloc/moz.build => memory/replace/logalloc/logalloc.mozbuild rename : memory/replace/logalloc/replay/replay.log => memory/replace/logalloc/replay/expected_output_minimal.log extra : rebase_source : 94f8fb4444e2e0ecda61e5ffd283ab560d1e9dfe
This commit is contained in:
parent
4ae1509807
commit
1b12c351f2
@ -186,6 +186,7 @@ replace_malloc(size_t aSize)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#ifndef LOGALLOC_MINIMAL
|
||||
int
|
||||
replace_posix_memalign(void** aPtr, size_t aAlignment, size_t aSize)
|
||||
{
|
||||
@ -209,6 +210,7 @@ replace_aligned_alloc(size_t aAlignment, size_t aSize)
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
void*
|
||||
replace_calloc(size_t aNum, size_t aSize)
|
||||
@ -256,6 +258,7 @@ replace_memalign(size_t aAlignment, size_t aSize)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#ifndef LOGALLOC_MINIMAL
|
||||
void*
|
||||
replace_valloc(size_t aSize)
|
||||
{
|
||||
@ -266,6 +269,7 @@ replace_valloc(size_t aSize)
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
replace_jemalloc_stats(jemalloc_stats_t* aStats)
|
||||
|
35
memory/replace/logalloc/logalloc.mozbuild
Normal file
35
memory/replace/logalloc/logalloc.mozbuild
Normal file
@ -0,0 +1,35 @@
|
||||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
SOURCES += [
|
||||
'FdPrintf.cpp',
|
||||
'LogAlloc.cpp',
|
||||
]
|
||||
|
||||
DISABLE_STL_WRAPPING = True
|
||||
USE_STATIC_LIBS = True
|
||||
DEFINES['MOZ_NO_MOZALLOC'] = True
|
||||
# Avoid Lock_impl code depending on mozilla::Logger.
|
||||
DEFINES['NDEBUG'] = True
|
||||
DEFINES['DEBUG'] = False
|
||||
|
||||
# Use locking code from the chromium stack.
|
||||
if CONFIG['OS_TARGET'] == 'WINNT':
|
||||
SOURCES += [
|
||||
'../../../ipc/chromium/src/base/lock_impl_win.cc',
|
||||
]
|
||||
else:
|
||||
SOURCES += [
|
||||
'../../../ipc/chromium/src/base/lock_impl_posix.cc',
|
||||
]
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
||||
# Android doesn't have pthread_atfork, but we have our own in mozglue.
|
||||
if CONFIG['OS_TARGET'] == 'Android':
|
||||
USE_LIBS += [
|
||||
'mozglue',
|
||||
]
|
11
memory/replace/logalloc/minimal/moz.build
Normal file
11
memory/replace/logalloc/minimal/moz.build
Normal file
@ -0,0 +1,11 @@
|
||||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
SharedLibrary('logalloc_minimal')
|
||||
|
||||
include('../logalloc.mozbuild')
|
||||
|
||||
DEFINES['LOGALLOC_MINIMAL'] = True
|
@ -6,36 +6,9 @@
|
||||
|
||||
SharedLibrary('logalloc')
|
||||
|
||||
SOURCES += [
|
||||
'FdPrintf.cpp',
|
||||
'LogAlloc.cpp',
|
||||
]
|
||||
|
||||
DISABLE_STL_WRAPPING = True
|
||||
USE_STATIC_LIBS = True
|
||||
DEFINES['MOZ_NO_MOZALLOC'] = True
|
||||
# Avoid Lock_impl code depending on mozilla::Logger.
|
||||
DEFINES['NDEBUG'] = True
|
||||
DEFINES['DEBUG'] = False
|
||||
|
||||
# Use locking code from the chromium stack.
|
||||
if CONFIG['OS_TARGET'] == 'WINNT':
|
||||
SOURCES += [
|
||||
'../../../ipc/chromium/src/base/lock_impl_win.cc',
|
||||
]
|
||||
else:
|
||||
SOURCES += [
|
||||
'../../../ipc/chromium/src/base/lock_impl_posix.cc',
|
||||
]
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
||||
# Android doesn't have pthread_atfork, but we have our own in mozglue.
|
||||
if CONFIG['OS_TARGET'] == 'Android':
|
||||
USE_LIBS += [
|
||||
'mozglue',
|
||||
]
|
||||
include('logalloc.mozbuild')
|
||||
|
||||
DIRS += [
|
||||
'minimal',
|
||||
'replay',
|
||||
]
|
||||
|
@ -7,21 +7,24 @@ include $(topsrcdir)/mozglue/build/replace_malloc.mk
|
||||
ifndef CROSS_COMPILE
|
||||
|
||||
ifeq ($(OS_TARGET),WINNT)
|
||||
LOGALLOC = MOZ_REPLACE_MALLOC_LIB=$(CURDIR)/../logalloc.dll
|
||||
LOGALLOC_VAR = MOZ_REPLACE_MALLOC_LIB
|
||||
else
|
||||
ifeq ($(OS_TARGET),Darwin)
|
||||
LOGALLOC = DYLD_INSERT_LIBRARIES=$(CURDIR)/../liblogalloc.dylib
|
||||
LOGALLOC_VAR = DYLD_INSERT_LIBRARIES
|
||||
else
|
||||
LOGALLOC = LD_PRELOAD=$(CURDIR)/../$(DLL_PREFIX)logalloc$(DLL_SUFFIX)
|
||||
LOGALLOC_VAR = LD_PRELOAD
|
||||
endif
|
||||
endif
|
||||
|
||||
LOGALLOC = $(LOGALLOC_VAR)=$(CURDIR)/../$(DLL_PREFIX)logalloc$(DLL_SUFFIX)
|
||||
LOGALLOC_MINIMAL = $(LOGALLOC_VAR)=$(CURDIR)/../minimal/$(DLL_PREFIX)logalloc_minimal$(DLL_SUFFIX)
|
||||
|
||||
expected_output.log: $(srcdir)/replay.log
|
||||
# The logalloc-replay program will only replay entries from the first pid,
|
||||
# so the expected output only contains entries beginning with "1 "
|
||||
grep "^1 " $< > $@
|
||||
|
||||
check:: $(srcdir)/replay.log expected_output.log
|
||||
check:: $(srcdir)/replay.log expected_output.log $(srcdir)/expected_output_minimal.log
|
||||
# Test with MALLOC_LOG as a file descriptor number
|
||||
# We filter out anything happening before the first jemalloc_stats (first
|
||||
# command in replay.log) because starting with libstdc++ 5, a static
|
||||
@ -33,4 +36,6 @@ check:: $(srcdir)/replay.log expected_output.log
|
||||
MALLOC_LOG=test_output.log $(LOGALLOC) ./$(PROGRAM) < $<
|
||||
sed -n '/jemalloc_stats/,$$p' test_output.log | $(PYTHON) $(srcdir)/logalloc_munge.py | diff -w - expected_output.log
|
||||
|
||||
MALLOC_LOG=1 $(LOGALLOC_MINIMAL) ./$(PROGRAM) < $< | sed -n '/jemalloc_stats/,$$p' | $(PYTHON) $(srcdir)/logalloc_munge.py | diff -w - $(srcdir)/expected_output_minimal.log
|
||||
|
||||
endif
|
||||
|
17
memory/replace/logalloc/replay/expected_output_minimal.log
Normal file
17
memory/replace/logalloc/replay/expected_output_minimal.log
Normal file
@ -0,0 +1,17 @@
|
||||
1 1 jemalloc_stats()
|
||||
1 1 malloc(42)=#1
|
||||
1 1 malloc(24)=#2
|
||||
1 1 free(#1)
|
||||
1 1 memalign(4096,1024)=#1
|
||||
1 1 calloc(4,42)=#3
|
||||
1 1 free(#2)
|
||||
1 1 realloc(#3,84)=#2
|
||||
1 1 memalign(256,1024)=#3
|
||||
1 1 memalign(512,1024)=#4
|
||||
1 1 memalign(4096,1024)=#5
|
||||
1 1 jemalloc_stats()
|
||||
1 1 free(#5)
|
||||
1 1 free(#4)
|
||||
1 1 free(#3)
|
||||
1 1 free(#2)
|
||||
1 1 free(#1)
|
@ -7,7 +7,7 @@
|
||||
1 1 calloc(4,42)=#3
|
||||
1 1 free(#2)
|
||||
1 1 realloc(#3,84)=#2
|
||||
1 1 aligned_alloc(512,1024)=#3
|
||||
1 1 aligned_alloc(256,1024)=#3
|
||||
1 1 memalign(512,1024)=#4
|
||||
1 1 valloc(1024)=#5
|
||||
1 1 jemalloc_stats()
|
||||
|
Loading…
Reference in New Issue
Block a user