src: disable fast math on arm
[platform/upstream/nodejs.git] / test / parallel / test-debug-signal-cluster.js
1 var common = require('../common');
2 var assert = require('assert');
3 var spawn = require('child_process').spawn;
4
5 var port = common.PORT + 42;
6 var args = ['--debug-port=' + port,
7             common.fixturesDir + '/clustered-server/app.js'];
8 var options = { stdio: ['inherit', 'inherit', 'pipe', 'ipc'] };
9 var child = spawn(process.execPath, args, options);
10
11 var outputLines = [];
12 var outputTimerId;
13 var waitingForDebuggers = false;
14
15 var pids = null;
16
17 child.stderr.on('data', function(data) {
18   var lines = data.toString().replace(/\r/g, '').trim().split('\n');
19
20   lines.forEach(function(line) {
21     console.log('> ' + line);
22
23     if (line === 'all workers are running') {
24       child.on('message', function(msg) {
25         if (msg.type !== 'pids')
26           return;
27
28         pids = msg.pids;
29         console.error('got pids %j', pids);
30
31         waitingForDebuggers = true;
32         process._debugProcess(child.pid);
33       });
34
35       child.send({
36         type: 'getpids'
37       });
38     } else if (waitingForDebuggers) {
39       outputLines.push(line);
40     }
41
42   });
43   if (outputLines.length >= expectedLines.length)
44     onNoMoreLines();
45 });
46
47 function onNoMoreLines() {
48   assertOutputLines();
49   process.exit();
50 }
51
52 setTimeout(function testTimedOut() {
53   assert(false, 'test timed out.');
54 }, common.platformTimeout(3000)).unref();
55
56 process.on('exit', function onExit() {
57   // Kill processes in reverse order to avoid timing problems on Windows where
58   // the parent process is killed before the children.
59   pids.reverse().forEach(function(pid) {
60     process.kill(pid);
61   });
62 });
63
64 var expectedLines = [
65   'Starting debugger agent.',
66   'Debugger listening on port ' + (port + 0),
67   'Starting debugger agent.',
68   'Debugger listening on port ' + (port + 1),
69   'Starting debugger agent.',
70   'Debugger listening on port ' + (port + 2),
71 ];
72
73 function assertOutputLines() {
74   // Do not assume any particular order of output messages,
75   // since workers can take different amout of time to
76   // start up
77   outputLines.sort();
78   expectedLines.sort();
79
80   assert.equal(outputLines.length, expectedLines.length);
81   for (var i = 0; i < expectedLines.length; i++)
82     assert.equal(outputLines[i], expectedLines[i]);
83 }