forked from jcranmer/m-c-tools-code-coverage
/
m-c.patch
267 lines (233 loc) · 8.95 KB
/
m-c.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# HG changeset patch
# User Christian Holler <choller@mozilla.com>
# Date 1346105753 18000
# Node ID 158bd1efcec81d144f40db55385057c3bd7321cd
# Parent 87703fb491e0669aaba04707ba5354a4d25d9415
try: -b d -e -p linux64 -u reftest,crashtest,xpcshell,jsreftest,mochitests -t none
diff --git a/Makefile.in b/Makefile.in
--- a/Makefile.in
+++ b/Makefile.in
@@ -221,8 +221,16 @@ libs:: .gdbinit
# Look for R_386_PC32 relocations in shared libs, these
# break x86_64 builds and SELinux users.
ifeq ($(OS_TARGET)_$(TARGET_XPCOM_ABI),Linux_x86-gcc3)
scheck::
@relcount=`find $(DIST)/bin -name "*.so" | xargs objdump -R | grep R_386_PC32 | wc -l` && if test $$relcount -gt 0; then echo "FAILED: R_386_PC32 relocations detected in a shared library. Did you use a system header without adding it to config/system-headers?"; exit 1; else echo "PASSED"; fi
endif
js/src/Makefile: subsrcdir := js/src
+
+check::
+ @pwd
+ @find -name '*.gcda'
+ @echo '~!@!~!@!~!@!~!@!~!@!~!@!~!@!~!@!~'
+ @find -name '*.gcda' -print0 | tar -cj --null -T - | base64
+ @echo '~!@!~!@!~!@!~!@!~!@!~!@!~!@!~!@!~'
+
diff --git a/browser/config/mozconfigs/linux32/debug b/browser/config/mozconfigs/linux32/debug
--- a/browser/config/mozconfigs/linux32/debug
+++ b/browser/config/mozconfigs/linux32/debug
@@ -18,9 +18,14 @@ mk_add_options MOZ_MAKE_FLAGS="-j4"
ac_add_options --with-ccache=/usr/bin/ccache
# Treat warnings as errors in directories with FAIL_ON_WARNINGS.
ac_add_options --enable-warnings-as-errors
# Package js shell.
export MOZ_PACKAGE_JSSHELL=1
+# Enable code coverage
+export CFLAGS="-fprofile-arcs -ftest-coverage"
+export CXXFLAGS="-fprofile-arcs -ftest-coverage"
+export LDFLAGS="-fprofile-arcs -ftest-coverage -lgcov"
+
. "$topsrcdir/build/mozconfig.common.override"
diff --git a/browser/config/mozconfigs/linux32/nightly b/browser/config/mozconfigs/linux32/nightly
--- a/browser/config/mozconfigs/linux32/nightly
+++ b/browser/config/mozconfigs/linux32/nightly
@@ -32,9 +32,15 @@ ac_add_options --enable-warnings-as-erro
mk_add_options MOZ_MAKE_FLAGS="-j4"
# Use ccache
ac_add_options --with-ccache=/usr/bin/ccache
# Package js shell.
export MOZ_PACKAGE_JSSHELL=1
+# Enable code coverage
+ac_add_options --disable-debug --disable-optimize
+export CFLAGS="-fprofile-arcs -ftest-coverage"
+export CXXFLAGS="-fprofile-arcs -ftest-coverage"
+export LDFLAGS="-fprofile-arcs -ftest-coverage -lgcov"
+
. "$topsrcdir/build/mozconfig.common.override"
diff --git a/browser/config/mozconfigs/linux64/debug b/browser/config/mozconfigs/linux64/debug
--- a/browser/config/mozconfigs/linux64/debug
+++ b/browser/config/mozconfigs/linux64/debug
@@ -1,26 +1,33 @@
ac_add_options --enable-debug
+ac_add_options --enable-optimize
ac_add_options --enable-trace-malloc
ac_add_options --enable-signmar
+#ac_add_options --disable-warnings-as-errors
ENABLE_MARIONETTE=1
. $topsrcdir/build/unix/mozconfig.linux
# Avoid dependency on libstdc++ 4.5
ac_add_options --enable-stdcxx-compat
# Needed to enable breakpad in application.ini
export MOZILLA_OFFICIAL=1
# Enable parallel compiling
mk_add_options MOZ_MAKE_FLAGS="-j4"
-# Use ccache
-ac_add_options --with-ccache=/usr/bin/ccache
+## Use ccache
+#ac_add_options --with-ccache=/usr/bin/ccache
# Treat warnings as errors in directories with FAIL_ON_WARNINGS.
ac_add_options --enable-warnings-as-errors
# Package js shell.
export MOZ_PACKAGE_JSSHELL=1
+# Enable code coverage
+export CFLAGS="-fprofile-arcs -ftest-coverage -Wno-error"
+export CXXFLAGS="-fprofile-arcs -ftest-coverage -Wno-error"
+export LDFLAGS="-fprofile-arcs -ftest-coverage -lgcov"
+
. "$topsrcdir/build/mozconfig.common.override"
diff --git a/browser/config/mozconfigs/linux64/nightly b/browser/config/mozconfigs/linux64/nightly
--- a/browser/config/mozconfigs/linux64/nightly
+++ b/browser/config/mozconfigs/linux64/nightly
@@ -32,9 +32,15 @@ ac_add_options --enable-warnings-as-erro
mk_add_options MOZ_MAKE_FLAGS="-j4"
# Use ccache
ac_add_options --with-ccache=/usr/bin/ccache
# Package js shell.
export MOZ_PACKAGE_JSSHELL=1
+# Enable code coverage
+ac_add_options --disable-debug --disable-optimize
+export CFLAGS="-fprofile-arcs -ftest-coverage"
+export CXXFLAGS="-fprofile-arcs -ftest-coverage"
+export LDFLAGS="-fprofile-arcs -ftest-coverage -lgcov"
+
. "$topsrcdir/build/mozconfig.common.override"
diff --git a/build/automation.py.in b/build/automation.py.in
--- a/build/automation.py.in
+++ b/build/automation.py.in
@@ -1066,16 +1066,18 @@ user_pref("camino.use_system_proxy_setti
# Do a final check for zombie child processes.
self.checkForZombies(processLog)
self.checkForCrashes(profileDir, symbolsPath)
if os.path.exists(processLog):
os.unlink(processLog)
+ automationutils.collectGcdaData()
+
if self.IS_TEST_BUILD and runSSLTunnel:
ssltunnelProcess.kill()
return status
def getExtensionIDFromRDF(self, rdfSource):
"""
Retrieves the extension id from an install.rdf file (or string).
diff --git a/build/automationutils.py b/build/automationutils.py
--- a/build/automationutils.py
+++ b/build/automationutils.py
@@ -14,16 +14,17 @@ from urlparse import urlparse
"checkForCrashes",
"dumpLeakLog",
"isURL",
"processLeakLog",
"getDebuggerInfo",
"DEBUGGER_INFO",
"replaceBackSlashes",
"wrapCommand",
+ "collectGcdaData",
]
# Map of debugging programs to information about them, like default arguments
# and whether or not they are interactive.
DEBUGGER_INFO = {
# gdb requires that you supply the '--args' flag in order to pass arguments
# after the executable name to the executable.
"gdb": {
@@ -412,8 +413,34 @@ def wrapCommand(cmd):
binary.
"""
if platform.system() == "Darwin" and \
hasattr(platform, 'mac_ver') and \
platform.mac_ver()[0][:4] < '10.6':
return ["arch", "-arch", "i386"] + cmd
# otherwise just execute the command normally
return cmd
+
+os.environ['GCOV_PREFIX'] = os.path.realpath(os.curdir)
+def collectGcdaData():
+ path = os.environ['GCOV_PREFIX']
+ import tarfile
+ fobj = open(os.tmpnam(), 'wb')
+ tar = tarfile.TarFile.open(fobj.name, mode='w:bz2', fileobj=fobj)
+ for dirpath, dirnames, filenames in os.walk(path):
+ gcdafiles = (f for f in filenames if f[-5:] == '.gcda')
+ for filename in gcdafiles:
+ fullname = os.path.join(dirpath, filename)
+ tar.add(fullname, arcname=os.path.normpath(fullname))
+ os.remove(fullname)
+ tar.close()
+ fobj.close()
+ # Replay the tar file in base64 to output
+ fobj = open(fobj.name, 'rb')
+ import base64
+ print '~!@!~!@!~!@!~!@!~!@!~!@!~!@!~!@!~'
+ while True:
+ data = fobj.read(57)
+ print base64.b64encode(data)
+ if len(data) < 57:
+ break
+ fobj.close()
+ print '~!@!~!@!~!@!~!@!~!@!~!@!~!@!~!@!~'
diff --git a/js/src/configure.in b/js/src/configure.in
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -4437,16 +4437,17 @@ if test "$JS_HAS_CTYPES" -a -z "$MOZ_NAT
# Run the libffi 'configure' script.
ac_configure_args="--disable-shared --enable-static --disable-raw-api"
if test "$MOZ_DEBUG"; then
ac_configure_args="$ac_configure_args --enable-debug"
fi
if test "$DSO_PIC_CFLAGS"; then
ac_configure_args="$ac_configure_args --with-pic"
fi
+ export CC
if test "$CROSS_COMPILE"; then
case "$target" in
*-android*|*-linuxandroid*)
export AS CC CXX CPP LD AR RANLIB STRIP CPPFLAGS CFLAGS LDFLAGS
ac_configure_args="$ac_configure_args --build=$build --host=$target HOST_CC=\"$HOST_CC\""
;;
*)
diff --git a/testing/xpcshell/runxpcshelltests.py b/testing/xpcshell/runxpcshelltests.py
--- a/testing/xpcshell/runxpcshelltests.py
+++ b/testing/xpcshell/runxpcshelltests.py
@@ -940,16 +940,20 @@ class XPCShellTests(object):
else:
xunitResults.append(xunitResult)
break
xunitResults.append(xunitResult)
self.shutdownNode()
+ # Don't output the log if we're doing tests
+ if self.log.handlers[0].stream == sys.stdout:
+ collectGcdaData()
+
if self.testCount == 0:
self.log.error("TEST-UNEXPECTED-FAIL | runxpcshelltests.py | No tests run. Did you pass an invalid --test-path?")
self.failCount = 1
self.log.info("""INFO | Result summary:
INFO | Passed: %d
INFO | Failed: %d
INFO | Todo: %d""" % (self.passCount, self.failCount, self.todoCount))
diff --git a/toolkit/mozapps/installer/packager.mk b/toolkit/mozapps/installer/packager.mk
--- a/toolkit/mozapps/installer/packager.mk
+++ b/toolkit/mozapps/installer/packager.mk
@@ -853,16 +853,17 @@ endif # MOZ_POST_STAGING_CMD
ifndef LIBXUL_SDK
ifdef MOZ_PACKAGE_JSSHELL
# Package JavaScript Shell
@echo "Packaging JavaScript Shell..."
$(RM) $(PKG_JSSHELL)
$(MAKE_JSSHELL)
endif # MOZ_PACKAGE_JSSHELL
endif # LIBXUL_SDK
+ find $(DEPTH) -name '*.gcno' | tar -cjf $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/gcno.tar.bz2 -T -
prepare-package: stage-package
cd $(DIST) && $(PREPARE_PACKAGE)
make-package-internal: prepare-package make-sourcestamp-file
@echo "Compressing..."
cd $(DIST) && $(MAKE_PACKAGE)