11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled(); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci// A test to ensure that cluster properly interoperates with the 61cb0ef41Sopenharmony_ci// --inspect-brk option. 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst assert = require('assert'); 91cb0ef41Sopenharmony_ciconst cluster = require('cluster'); 101cb0ef41Sopenharmony_ciconst debuggerPort = common.PORT; 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciif (cluster.isPrimary) { 131cb0ef41Sopenharmony_ci function test(execArgv) { 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci cluster.setupPrimary({ 161cb0ef41Sopenharmony_ci execArgv: execArgv, 171cb0ef41Sopenharmony_ci stdio: ['pipe', 'pipe', 'pipe', 'ipc', 'pipe'] 181cb0ef41Sopenharmony_ci }); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci const worker = cluster.fork(); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci // Debugger listening on port [port]. 231cb0ef41Sopenharmony_ci worker.process.stderr.once('data', common.mustCall(function() { 241cb0ef41Sopenharmony_ci worker.process.kill('SIGTERM'); 251cb0ef41Sopenharmony_ci })); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci worker.process.on('exit', common.mustCall(function(code, signal) { 281cb0ef41Sopenharmony_ci assert.strictEqual(signal, 'SIGTERM'); 291cb0ef41Sopenharmony_ci })); 301cb0ef41Sopenharmony_ci } 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci test(['--inspect-brk']); 331cb0ef41Sopenharmony_ci test([`--inspect-brk=${debuggerPort}`]); 341cb0ef41Sopenharmony_ci} else { 351cb0ef41Sopenharmony_ci // Cluster worker is at a breakpoint, should not reach here. 361cb0ef41Sopenharmony_ci assert.fail('Test failed: cluster worker should be at a breakpoint.'); 371cb0ef41Sopenharmony_ci} 38