forked from mirrors/gecko-dev
Bug 1561435 - Format memory/, a=automatic-formatting
# ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D35912 --HG-- extra : source : ae1388f34f73a8628d46d49ca0de9577a20bf650
This commit is contained in:
parent
379161a602
commit
feaa92296b
3 changed files with 49 additions and 45 deletions
|
|
@ -45,7 +45,6 @@ module.exports = {
|
||||||
"overrides": [{
|
"overrides": [{
|
||||||
"files": [
|
"files": [
|
||||||
"devtools/**",
|
"devtools/**",
|
||||||
"memory/**",
|
|
||||||
"mfbt/**",
|
"mfbt/**",
|
||||||
"mobile/**",
|
"mobile/**",
|
||||||
"modules/**",
|
"modules/**",
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ toolkit/components/telemetry/datareporting-prefs.js
|
||||||
toolkit/components/telemetry/healthreport-prefs.js
|
toolkit/components/telemetry/healthreport-prefs.js
|
||||||
|
|
||||||
# Ignore all top-level directories for now.
|
# Ignore all top-level directories for now.
|
||||||
memory/**
|
|
||||||
mfbt/**
|
mfbt/**
|
||||||
mobile/**
|
mobile/**
|
||||||
modules/**
|
modules/**
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,15 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const {FileUtils} = ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
|
const { FileUtils } = ChromeUtils.import(
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
"resource://gre/modules/FileUtils.jsm"
|
||||||
|
);
|
||||||
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
// The xpcshell test harness sets PYTHON so we can read it here.
|
// The xpcshell test harness sets PYTHON so we can read it here.
|
||||||
var gEnv = Cc["@mozilla.org/process/environment;1"]
|
var gEnv = Cc["@mozilla.org/process/environment;1"].getService(
|
||||||
.getService(Ci.nsIEnvironment);
|
Ci.nsIEnvironment
|
||||||
|
);
|
||||||
var gPythonName = gEnv.get("PYTHON");
|
var gPythonName = gEnv.get("PYTHON");
|
||||||
|
|
||||||
// If we're testing locally, the executable file is in "CurProcD". Otherwise,
|
// If we're testing locally, the executable file is in "CurProcD". Otherwise,
|
||||||
|
|
@ -37,10 +40,12 @@ var gDmdScriptFile = getExecutable("dmd.py");
|
||||||
var gScanTestFile = FileUtils.getFile("CurWorkD", ["scan-test.py"]);
|
var gScanTestFile = FileUtils.getFile("CurWorkD", ["scan-test.py"]);
|
||||||
|
|
||||||
function readFile(aFile) {
|
function readFile(aFile) {
|
||||||
let fstream = Cc["@mozilla.org/network/file-input-stream;1"]
|
let fstream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(
|
||||||
.createInstance(Ci.nsIFileInputStream);
|
Ci.nsIFileInputStream
|
||||||
let cstream = Cc["@mozilla.org/intl/converter-input-stream;1"]
|
);
|
||||||
.createInstance(Ci.nsIConverterInputStream);
|
let cstream = Cc["@mozilla.org/intl/converter-input-stream;1"].createInstance(
|
||||||
|
Ci.nsIConverterInputStream
|
||||||
|
);
|
||||||
fstream.init(aFile, -1, 0, 0);
|
fstream.init(aFile, -1, 0, 0);
|
||||||
cstream.init(fstream, "UTF-8", 0, 0);
|
cstream.init(fstream, "UTF-8", 0, 0);
|
||||||
|
|
||||||
|
|
@ -58,10 +63,9 @@ function readFile(aFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function runProcess(aExeFile, aArgs) {
|
function runProcess(aExeFile, aArgs) {
|
||||||
let process = Cc["@mozilla.org/process/util;1"]
|
let process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
|
||||||
.createInstance(Ci.nsIProcess);
|
|
||||||
process.init(aExeFile);
|
process.init(aExeFile);
|
||||||
process.run(/* blocking = */true, aArgs, aArgs.length);
|
process.run(/* blocking = */ true, aArgs, aArgs.length);
|
||||||
return process.exitValue;
|
return process.exitValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,14 +73,15 @@ function test(aPrefix, aArgs) {
|
||||||
// DMD writes the JSON files to CurWorkD, so we do likewise here with
|
// DMD writes the JSON files to CurWorkD, so we do likewise here with
|
||||||
// |actualFile| for consistency. It is removed once we've finished.
|
// |actualFile| for consistency. It is removed once we've finished.
|
||||||
let expectedFile = FileUtils.getFile("CurWorkD", [aPrefix + "-expected.txt"]);
|
let expectedFile = FileUtils.getFile("CurWorkD", [aPrefix + "-expected.txt"]);
|
||||||
let actualFile = FileUtils.getFile("CurWorkD", [aPrefix + "-actual.txt"]);
|
let actualFile = FileUtils.getFile("CurWorkD", [aPrefix + "-actual.txt"]);
|
||||||
|
|
||||||
// Run dmd.py on the JSON file, producing |actualFile|.
|
// Run dmd.py on the JSON file, producing |actualFile|.
|
||||||
|
|
||||||
let args = [
|
let args = [
|
||||||
gDmdScriptFile.path,
|
gDmdScriptFile.path,
|
||||||
"--filter-stacks-for-testing",
|
"--filter-stacks-for-testing",
|
||||||
"-o", actualFile.path,
|
"-o",
|
||||||
|
actualFile.path,
|
||||||
].concat(aArgs);
|
].concat(aArgs);
|
||||||
|
|
||||||
runProcess(new FileUtils.File(gPythonName), args);
|
runProcess(new FileUtils.File(gPythonName), args);
|
||||||
|
|
@ -88,12 +93,15 @@ function test(aPrefix, aArgs) {
|
||||||
|
|
||||||
let success;
|
let success;
|
||||||
try {
|
try {
|
||||||
let rv = runProcess(new FileUtils.File("/usr/bin/diff"),
|
let rv = runProcess(new FileUtils.File("/usr/bin/diff"), [
|
||||||
["-u", expectedFile.path, actualFile.path]);
|
"-u",
|
||||||
|
expectedFile.path,
|
||||||
|
actualFile.path,
|
||||||
|
]);
|
||||||
success = rv == 0;
|
success = rv == 0;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
let expectedData = readFile(expectedFile);
|
let expectedData = readFile(expectedFile);
|
||||||
let actualData = readFile(actualFile);
|
let actualData = readFile(actualFile);
|
||||||
success = expectedData === actualData;
|
success = expectedData === actualData;
|
||||||
if (!success) {
|
if (!success) {
|
||||||
expectedData = expectedData.split("\n");
|
expectedData = expectedData.split("\n");
|
||||||
|
|
@ -114,10 +122,7 @@ function test(aPrefix, aArgs) {
|
||||||
|
|
||||||
// Run scan-test.py on the JSON file and see if it succeeds.
|
// Run scan-test.py on the JSON file and see if it succeeds.
|
||||||
function scanTest(aJsonFilePath, aExtraArgs) {
|
function scanTest(aJsonFilePath, aExtraArgs) {
|
||||||
let args = [
|
let args = [gScanTestFile.path, aJsonFilePath].concat(aExtraArgs);
|
||||||
gScanTestFile.path,
|
|
||||||
aJsonFilePath,
|
|
||||||
].concat(aExtraArgs);
|
|
||||||
|
|
||||||
return runProcess(new FileUtils.File(gPythonName), args) == 0;
|
return runProcess(new FileUtils.File(gPythonName), args) == 0;
|
||||||
}
|
}
|
||||||
|
|
@ -165,7 +170,10 @@ function run_test() {
|
||||||
let is64Bit = Services.appinfo.is64Bit;
|
let is64Bit = Services.appinfo.is64Bit;
|
||||||
let basicScanFileName = "basic-scan-" + (is64Bit ? "64" : "32");
|
let basicScanFileName = "basic-scan-" + (is64Bit ? "64" : "32");
|
||||||
test(basicScanFileName, ["--clamp-contents", jsonFile.path]);
|
test(basicScanFileName, ["--clamp-contents", jsonFile.path]);
|
||||||
ok(scanTest(jsonFile.path, ["--clamp-contents"]), "Scan with address clamping");
|
ok(
|
||||||
|
scanTest(jsonFile.path, ["--clamp-contents"]),
|
||||||
|
"Scan with address clamping"
|
||||||
|
);
|
||||||
|
|
||||||
// Run the generic test a second time to ensure that the first time produced
|
// Run the generic test a second time to ensure that the first time produced
|
||||||
// valid JSON output. "--clamp-contents" is passed in so we don't have to have
|
// valid JSON output. "--clamp-contents" is passed in so we don't have to have
|
||||||
|
|
@ -182,41 +190,39 @@ function run_test() {
|
||||||
// appropriately. The number of records in the output is different for each
|
// appropriately. The number of records in the output is different for each
|
||||||
// of the tested values.
|
// of the tested values.
|
||||||
jsonFile = FileUtils.getFile("CurWorkD", ["script-max-frames.json"]);
|
jsonFile = FileUtils.getFile("CurWorkD", ["script-max-frames.json"]);
|
||||||
test("script-max-frames-8",
|
test("script-max-frames-8", [jsonFile.path]); // --max-frames=8 is the default
|
||||||
[jsonFile.path]); // --max-frames=8 is the default
|
test("script-max-frames-3", [
|
||||||
test("script-max-frames-3",
|
"--max-frames=3",
|
||||||
["--max-frames=3", "--no-fix-stacks", jsonFile.path]);
|
"--no-fix-stacks",
|
||||||
test("script-max-frames-1",
|
jsonFile.path,
|
||||||
["--max-frames=1", jsonFile.path]);
|
]);
|
||||||
|
test("script-max-frames-1", ["--max-frames=1", jsonFile.path]);
|
||||||
|
|
||||||
// This file has three records that are shown in a different order for each
|
// This file has three records that are shown in a different order for each
|
||||||
// of the different sort values. It also tests the handling of gzipped JSON
|
// of the different sort values. It also tests the handling of gzipped JSON
|
||||||
// files.
|
// files.
|
||||||
jsonFile = FileUtils.getFile("CurWorkD", ["script-sort-by.json.gz"]);
|
jsonFile = FileUtils.getFile("CurWorkD", ["script-sort-by.json.gz"]);
|
||||||
test("script-sort-by-usable",
|
test("script-sort-by-usable", ["--sort-by=usable", jsonFile.path]);
|
||||||
["--sort-by=usable", jsonFile.path]);
|
test("script-sort-by-req", [
|
||||||
test("script-sort-by-req",
|
"--sort-by=req",
|
||||||
["--sort-by=req", "--no-fix-stacks", jsonFile.path]);
|
"--no-fix-stacks",
|
||||||
test("script-sort-by-slop",
|
jsonFile.path,
|
||||||
["--sort-by=slop", jsonFile.path]);
|
]);
|
||||||
test("script-sort-by-num-blocks",
|
test("script-sort-by-slop", ["--sort-by=slop", jsonFile.path]);
|
||||||
["--sort-by=num-blocks", jsonFile.path]);
|
test("script-sort-by-num-blocks", ["--sort-by=num-blocks", jsonFile.path]);
|
||||||
|
|
||||||
// This file has several real stack traces taken from Firefox execution, each
|
// This file has several real stack traces taken from Firefox execution, each
|
||||||
// of which tests a different allocator function (or functions).
|
// of which tests a different allocator function (or functions).
|
||||||
jsonFile = FileUtils.getFile("CurWorkD", ["script-ignore-alloc-fns.json"]);
|
jsonFile = FileUtils.getFile("CurWorkD", ["script-ignore-alloc-fns.json"]);
|
||||||
test("script-ignore-alloc-fns",
|
test("script-ignore-alloc-fns", ["--ignore-alloc-fns", jsonFile.path]);
|
||||||
["--ignore-alloc-fns", jsonFile.path]);
|
|
||||||
|
|
||||||
// This tests "live"-mode diffs.
|
// This tests "live"-mode diffs.
|
||||||
jsonFile = FileUtils.getFile("CurWorkD", ["script-diff-live1.json"]);
|
jsonFile = FileUtils.getFile("CurWorkD", ["script-diff-live1.json"]);
|
||||||
jsonFile2 = FileUtils.getFile("CurWorkD", ["script-diff-live2.json"]);
|
jsonFile2 = FileUtils.getFile("CurWorkD", ["script-diff-live2.json"]);
|
||||||
test("script-diff-live",
|
test("script-diff-live", [jsonFile.path, jsonFile2.path]);
|
||||||
[jsonFile.path, jsonFile2.path]);
|
|
||||||
|
|
||||||
// This tests "dark-matter"-mode diffs.
|
// This tests "dark-matter"-mode diffs.
|
||||||
jsonFile = FileUtils.getFile("CurWorkD", ["script-diff-dark-matter1.json"]);
|
jsonFile = FileUtils.getFile("CurWorkD", ["script-diff-dark-matter1.json"]);
|
||||||
jsonFile2 = FileUtils.getFile("CurWorkD", ["script-diff-dark-matter2.json"]);
|
jsonFile2 = FileUtils.getFile("CurWorkD", ["script-diff-dark-matter2.json"]);
|
||||||
test("script-diff-dark-matter",
|
test("script-diff-dark-matter", [jsonFile.path, jsonFile2.path]);
|
||||||
[jsonFile.path, jsonFile2.path]);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue