Bug 1587722 - Tests for memory statistics on crashes;r=gsvelto

Depends on D55457

Differential Revision: https://phabricator.services.mozilla.com/D55933

--HG--
rename : toolkit/crashreporter/test/unit/test_oom_annotation_windows.js => toolkit/crashreporter/test/unit/test_oom_annotation.js
extra : moz-landing-system : lando
This commit is contained in:
David Teller 2019-12-10 08:44:26 +00:00
Родитель 5175676550
Коммит ff689ffe19
3 изменённых файлов: 69 добавлений и 30 удалений

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

@ -0,0 +1,68 @@
add_task(async function run_test() {
if (!("@mozilla.org/toolkit/crash-reporter;1" in Cc)) {
dump(
"INFO | test_crash_oom.js | Can't test crashreporter in a non-libxul build.\n"
);
return;
}
await do_crash(
function() {
crashType = CrashTestUtils.CRASH_OOM;
crashReporter.annotateCrashReport("TestKey", "Yes");
},
function(mdump, extra) {
ChromeUtils.import("resource://gre/modules/AppConstants.jsm", this);
Assert.equal(extra.TestKey, "Yes");
// A list of pairs [annotation name, must be > 0]
let annotations;
switch (AppConstants.platform) {
case "win":
annotations = [
["OOMAllocationSize", true],
["SystemMemoryUsePercentage", false],
["TotalVirtualMemory", true],
["AvailableVirtualMemory", false],
["TotalPageFile", false],
["AvailablePageFile", false],
["TotalPhysicalMemory", true],
["AvailablePhysicalMemory", false],
];
break;
case "linux":
annotations = [
["AvailablePageFile", false],
["AvailablePhysicalMemory", false],
["AvailableSwapMemory", false],
["AvailableVirtualMemory", false],
["TotalPageFile", false],
["TotalPhysicalMemory", true],
];
break;
case "macosx":
annotations = [
["AvailablePhysicalMemory", false],
["AvailableSwapMemory", false],
["PurgeablePhysicalMemory", false],
["TotalPhysicalMemory", true],
];
break;
default:
annotations = [];
}
for (let [label, shouldBeGreaterThanZero] of annotations) {
Assert.ok(label in extra, `Annotation ${label} is present`);
// All these annotations should represent non-negative numbers.
// A few of them (e.g. physical memory) are guaranteed to be positive.
if (shouldBeGreaterThanZero) {
Assert.ok(Number(extra[label]) > 0);
} else {
Assert.ok(Number(extra[label]) >= 0);
}
}
},
true
);
});

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

@ -1,28 +0,0 @@
add_task(async function run_test() {
if (!("@mozilla.org/toolkit/crash-reporter;1" in Cc)) {
dump(
"INFO | test_crash_oom.js | Can't test crashreporter in a non-libxul build.\n"
);
return;
}
await do_crash(
function() {
crashType = CrashTestUtils.CRASH_OOM;
crashReporter.annotateCrashReport("TestKey", "Yes");
},
function(mdump, extra) {
Assert.equal(extra.TestKey, "Yes");
Assert.ok("OOMAllocationSize" in extra);
Assert.ok(Number(extra.OOMAllocationSize) > 0);
Assert.ok("SystemMemoryUsePercentage" in extra);
Assert.ok("TotalVirtualMemory" in extra);
Assert.ok("AvailableVirtualMemory" in extra);
Assert.ok("TotalPageFile" in extra);
Assert.ok("AvailablePageFile" in extra);
Assert.ok("TotalPhysicalMemory" in extra);
Assert.ok("AvailablePhysicalMemory" in extra);
},
true
);
});

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

@ -15,8 +15,7 @@ support-files =
[test_crash_after_js_large_allocation_failure.js] [test_crash_after_js_large_allocation_failure.js]
[test_crash_after_js_large_allocation_failure_reporting.js] [test_crash_after_js_large_allocation_failure_reporting.js]
[test_crash_oom.js] [test_crash_oom.js]
[test_oom_annotation_windows.js] [test_oom_annotation.js]
skip-if = os != 'win'
[test_crash_abort.js] [test_crash_abort.js]
skip-if = os == 'win' skip-if = os == 'win'