node/test/sequential/test-cpu-prof-kill.js
Joyee Cheung 7e5e1c2515
test: move --cpu-prof tests to sequential
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>
2019-06-16 23:42:58 +08:00

42 lines
1.0 KiB
JavaScript

'use strict';
// This tests that --cpu-prof generates CPU profile when
// process.kill(process.pid, "SIGINT"); exits the process.
const common = require('../common');
const fixtures = require('../common/fixtures');
common.skipIfInspectorDisabled();
const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const {
getCpuProfiles,
kCpuProfInterval,
env,
verifyFrames
} = require('../common/cpu-prof');
{
tmpdir.refresh();
const output = spawnSync(process.execPath, [
'--cpu-prof',
'--cpu-prof-interval',
kCpuProfInterval,
fixtures.path('workload', 'fibonacci-sigint.js'),
], {
cwd: tmpdir.path,
env
});
if (!common.isWindows) {
if (output.signal !== 'SIGINT') {
console.log(output.stderr.toString());
}
assert.strictEqual(output.signal, 'SIGINT');
}
const profiles = getCpuProfiles(tmpdir.path);
assert.strictEqual(profiles.length, 1);
verifyFrames(output, profiles[0], 'fibonacci-sigint.js');
}