Skip to content

tools: fix flakiness in test-tick-processor #2694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ test-tls-ticket-cluster : PASS,FLAKY
[$system==linux]
test-cluster-worker-forced-exit : PASS,FLAKY
test-http-client-timeout-event : PASS,FLAKY
test-tick-processor : PASS,FLAKY
test-tls-no-sslv3 : PASS,FLAKY
test-child-process-buffering : PASS,FLAKY
test-child-process-exit-code : PASS,FLAKY
Expand Down
50 changes: 33 additions & 17 deletions test/parallel/test-tick-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,48 @@ var cp = require('child_process');
var common = require('../common');

common.refreshTmpDir();

process.chdir(common.tmpDir);
cp.execFileSync(process.execPath, ['-prof', '-pe',
'function foo(n) {' +
'require(\'vm\').runInDebugContext(\'Debug\');' +
'return n < 2 ? n : setImmediate(function() { foo(n-1) + foo(n-2);}); };' +
'setTimeout(function() { process.exit(0); }, 2000);' +
'foo(40);']);
var matches = fs.readdirSync(common.tmpDir).filter(function(file) {
return /^isolate-/.test(file);
});
if (matches.length != 1) {
assert.fail('There should be a single log file.');
}
var log = matches[0];
var processor =
path.join(common.testDir, '..', 'tools', 'v8-prof', getScriptName());
var out = cp.execSync(processor + ' ' + log, {encoding: 'utf8'});
assert(out.match(/LazyCompile.*foo/));
// Unknown checked for to prevent flakiness, if pattern is not found,
// then a large number of unknown ticks should be present
runTest(/LazyCompile.*\[eval\]:1|.*% UNKNOWN/,
`function f() {
for (var i = 0; i < 1000000; i++) {
i++;
}
setImmediate(function() { f(); });
};
setTimeout(function() { process.exit(0); }, 2000);
f();`);
if (process.platform === 'win32' ||
process.platform === 'sunos' ||
process.platform === 'freebsd') {
console.log('1..0 # Skipped: C++ symbols are not mapped for this os.');
return;
}
assert(out.match(/RunInDebugContext/));
runTest(/RunInDebugContext/,
`function f() {
require(\'vm\').runInDebugContext(\'Debug\');
setImmediate(function() { f(); });
};
setTimeout(function() { process.exit(0); }, 2000);
f();`);

function runTest(pattern, code) {
cp.execFileSync(process.execPath, ['-prof', '-pe', code]);
var matches = fs.readdirSync(common.tmpDir).filter(function(file) {
return /^isolate-/.test(file);
});
if (matches.length != 1) {
assert.fail('There should be a single log file.');
}
var log = matches[0];
var out = cp.execSync(processor + ' --call-graph-size=10 ' + log,
{encoding: 'utf8'});
assert(out.match(pattern));
fs.unlinkSync(log);
}

function getScriptName() {
switch (process.platform) {
Expand Down
1 change: 1 addition & 0 deletions tools/v8-prof/polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function read(fileName) {
return fs.readFileSync(fileName, 'utf8');
}
arguments = process.argv.slice(2);
var quit = process.exit;

// Polyfill "readline()".
var fd = fs.openSync(arguments[arguments.length - 1], 'r');
Expand Down