Bug 1521223, part 2 - Update the leakcheck test to work on a real leak log. r=ahal
authorAndrew McCreight <continuation@gmail.com>
Wed, 23 Jan 2019 17:03:20 +0000
changeset 512253 0b9c766c352f08a251449e8ab8a20e4cbf1c1d96
parent 512252 7955097a8041bb803edeade4af995c9b5393c791
child 512254 70d0497c3cb6aecba82408e9067c13d74fa04de7
push id10566
push userarchaeopteryx@coole-files.de
push dateMon, 28 Jan 2019 12:41:12 +0000
treeherdermozilla-beta@69a3d7c8d04b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1521223
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1521223, part 2 - Update the leakcheck test to work on a real leak log. r=ahal Depends on D17310 Differential Revision: https://phabricator.services.mozilla.com/D17311
testing/mochitest/tests/python/files/leaks.log
testing/mochitest/tests/python/files/test_leak.html
testing/mochitest/tests/python/test_basic_mochitest_plain.py
deleted file mode 100644
--- a/testing/mochitest/tests/python/files/leaks.log
+++ /dev/null
@@ -1,73 +0,0 @@
-== BloatView: ALL (cumulative) LEAK AND BLOAT STATISTICS, default process 1148
-     |<----------------Class--------------->|<-----Bytes------>|<----Objects---->|
-     |                                      | Per-Inst   Leaked|   Total      Rem|
-   0 |TOTAL                                 |       19    19915|16007885      378|
-  68 |CacheEntry                            |      208      208|     521        1|
-  71 |CacheEntryHandle                      |       16       16|    7692        1|
-  72 |CacheFile                             |      264      264|     521        1|
-  80 |CacheFileMetadata                     |      176      176|     521        1|
-  81 |CacheFileOutputStream                 |       64       64|     463        1|
-  90 |CacheStorageService                   |      256      256|       1        1|
-  97 |CancelableRunnable                    |       24       24|   45614        1|
- 103 |ChannelEventQueue                     |       96       96|     996        1|
- 131 |CondVar                               |       36      360|     822       10|
- 148 |ConsoleReportCollector                |       60      120|    1380        2|
- 150 |ContentParent                         |     1712     1712|       2        1|
- 188 |DataStorage                           |      284      852|       3        3|
- 320 |HttpBaseChannel                       |     1368     1368|    1143        1|
- 321 |HttpChannelParent                     |      176      176|     996        1|
- 322 |HttpChannelParentListener             |       48       48|     961        1|
- 342 |IdlePeriod                            |       12       36|     166        3|
- 369 |InterceptedChannelBase                |      240      240|      18        1|
- 389 |LoadContext                           |       72      144|    1023        2|
- 391 |LoadInfo                              |      144      144|    3903        1|
- 427 |Mutex                                 |       44     1012|   14660       23|
- 439 |NullPrincipalURI                      |       80       80|     421        1|
- 468 |PBrowserParent                        |      312      312|      21        1|
- 479 |PContentParent                        |     1428     1428|       2        1|
- 486 |PHttpChannelParent                    |       24       24|     996        1|
- 527 |PollableEvent                         |       12       12|       1        1|
- 576 |ReentrantMonitor                      |       24       72|    6922        3|
- 577 |RefCountedMonitor                     |       84       84|     154        1|
- 583 |RequestContextService                 |       60       60|       1        1|
- 592 |Runnable                              |       20       40|  178102        2|
- 627 |Service                               |      128      128|       1        1|
- 646 |SharedMemory                          |       16       16|    1636        1|
- 675 |StringAdopt                           |        1        3|   17087        3|
- 688 |TabParent                             |      976      976|      21        1|
- 699 |ThirdPartyUtil                        |       16       16|       1        1|
- 875 |ipc::MessageChannel                   |      208      208|     166        1|
- 920 |nsAuthURLParser                       |       12       12|       2        1|
- 974 |nsCategoryObserver                    |       72       72|       8        1|
- 976 |nsChannelClassifier                   |       28       28|     918        1|
-1004 |nsCookiePermission                    |       40       40|       1        1|
-1005 |nsCookieService                       |       80       80|       1        1|
-1010 |nsDNSService                          |      140      140|       1        1|
-1066 |nsEffectiveTLDService                 |       20       20|       1        1|
-1134 |nsHttpAuthCache::OriginClearObserver  |       16       32|       2        2|
-1135 |nsHttpChannel                         |     1816     1816|    1143        1|
-1136 |nsHttpChannelAuthProvider             |      148      148|    1012        1|
-1138 |nsHttpConnectionInfo                  |      128      128|    1021        1|
-1139 |nsHttpConnectionMgr                   |      304      304|       1        1|
-1141 |nsHttpHandler                         |      544      544|       1        1|
-1142 |nsHttpRequestHead                     |       92       92|    1190        1|
-1145 |nsIDNService                          |       56       56|       1        1|
-1146 |nsIOService                           |      176      176|       1        1|
-1176 |nsJSPrincipals                        |       16       64|   12583        4|
-1186 |nsLocalFile                           |       88      264|   13423        3|
-1192 |nsMainThreadPtrHolder<T>              |       20       80|    2253        4|
-1222 |nsNodeWeakReference                   |       16       16|     919        1|
-1223 |nsNotifyAddrListener                  |      112      112|       1        1|
-1241 |nsPermissionManager                   |      136      136|       1        1|
-1248 |nsPrefBranch                          |       76       76|      63        1|
-1257 |nsProxyInfo                           |       72       72|    1098        1|
-1265 |nsRedirectHistoryEntry                |       32       32|      69        1|
-1307 |nsSiteSecurityService                 |       56       56|       1        1|
-1311 |nsSocketTransportService              |      208      208|       1        1|
-1313 |nsStandardURL                         |      196     1372|   59651        7|
-1319 |nsStreamConverterService              |       48       48|       1        1|
-1324 |nsStringBuffer                        |        8     1688|  722245      211|
-1371 |nsTArray_base                         |        4      136| 3419841       34|
-1380 |nsThread                              |      304      912|     165        3|
-1416 |nsWeakReference                       |       20      180|    1388        9|
-nsTraceRefcnt::DumpStatistics: 1489 entries
new file mode 100644
--- /dev/null
+++ b/testing/mochitest/tests/python/files/test_leak.html
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1521223
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test Pass</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript">
+    SpecialPowers.Cu.intentionallyLeak();
+    ok(true, "Test is ok");
+  </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1521223">Mozilla Bug 1521223</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
--- a/testing/mochitest/tests/python/test_basic_mochitest_plain.py
+++ b/testing/mochitest/tests/python/test_basic_mochitest_plain.py
@@ -96,35 +96,36 @@ def test_output_assertion(runtests):
     assert test_end[0]['status'] == 'OK'
 
     assertions = filter_action('assertion_count', lines)
     assert len(assertions) == 1
     assert assertions[0]['count'] == 1
 
 
 @pytest.mark.skip_mozinfo("!debug")
-def test_output_leak(monkeypatch, runtests):
-    # Monkeypatch mozleak so we always process a failing leak log
-    # instead of the actual one.
-    import mozleak
-    old_process_leak_log = mozleak.process_leak_log
-
-    def process_leak_log(*args, **kwargs):
-        return old_process_leak_log(os.path.join(here, 'files', 'leaks.log'), *args[1:], **kwargs)
-
-    monkeypatch.setattr('mozleak.process_leak_log', process_leak_log)
-
-    status, lines = runtests('test_pass.html')
+def test_output_leak(runtests):
+    status, lines = runtests('test_leak.html')
     # TODO: mochitest should return non-zero here
     assert status == 0
 
     tbpl_status, log_level, summary = get_mozharness_status(lines, status)
     assert tbpl_status == TBPL_WARNING
     assert log_level == WARNING
 
-    leaks = filter_action('mozleak_total', lines)
-    assert len(leaks) == 1
-    assert leaks[0]['process'] == "default"
-    assert leaks[0]['bytes'] == 19915
+    leak_totals = filter_action('mozleak_total', lines)
+    found_leaks = False
+    for lt in leak_totals:
+        if lt['bytes'] == 0:
+            # No leaks in this process.
+            assert len(lt['objects']) == 0
+            continue
+
+        assert not found_leaks, "Only one process should have leaked"
+        found_leaks = True
+        assert lt['process'] == "tab"
+        assert lt['bytes'] == 1
+        assert lt['objects'] == ['IntentionallyLeakedObject']
+
+    assert found_leaks, "At least one process should have leaked"
 
 
 if __name__ == '__main__':
     mozunit.main()