mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 15:41:06 +00:00

The tests still fail after being split into multiple files, (2 out of 30 runs in roughly 48 hours) and the causes are missing target frames in the samples. This patch moves them to sequential to observe if the flakiness can be fixed when the tests are run on a system with less load. If the flake ever shows up again even after the tests are moved to sequential, we should consider make the test conditions more lenient - that is, we would only assert that there are *some* frames in the generated CPU profile but do not look for the target function there. PR-URL: https://github.com/nodejs/node/pull/28210 Refs: https://github.com/nodejs/node/issues/27611 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
56 lines
1.5 KiB
JavaScript
56 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
// This tests that --cpu-prof-dir works for workers.
|
|
|
|
const common = require('../common');
|
|
const fixtures = require('../common/fixtures');
|
|
common.skipIfInspectorDisabled();
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { spawnSync } = require('child_process');
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
const {
|
|
getCpuProfiles,
|
|
kCpuProfInterval,
|
|
env,
|
|
getFrames
|
|
} = require('../common/cpu-prof');
|
|
|
|
// --cpu-prof-dir with worker
|
|
{
|
|
tmpdir.refresh();
|
|
const output = spawnSync(process.execPath, [
|
|
'--cpu-prof-interval',
|
|
kCpuProfInterval,
|
|
'--cpu-prof-dir',
|
|
'prof',
|
|
'--cpu-prof',
|
|
fixtures.path('workload', 'fibonacci-worker.js'),
|
|
], {
|
|
cwd: tmpdir.path,
|
|
env
|
|
});
|
|
if (output.status !== 0) {
|
|
console.log(output.stderr.toString());
|
|
}
|
|
assert.strictEqual(output.status, 0);
|
|
const dir = path.join(tmpdir.path, 'prof');
|
|
assert(fs.existsSync(dir));
|
|
const profiles = getCpuProfiles(dir);
|
|
assert.strictEqual(profiles.length, 2);
|
|
const profile1 = getFrames(profiles[0], 'fibonacci.js');
|
|
const profile2 = getFrames(profiles[1], 'fibonacci.js');
|
|
if (profile1.frames.length === 0 && profile2.frames.length === 0) {
|
|
// Show native debug output and the profile for debugging.
|
|
console.log(output.stderr.toString());
|
|
console.log('CPU path: ', profiles[0]);
|
|
console.log(profile1.nodes);
|
|
console.log('CPU path: ', profiles[1]);
|
|
console.log(profile2.nodes);
|
|
}
|
|
assert(profile1.frames.length > 0 || profile2.frames.length > 0);
|
|
}
|