diff --git a/test/common.js b/test/common.js index 9859db24cd7882..a3c74d9587c5b4 100644 --- a/test/common.js +++ b/test/common.js @@ -68,6 +68,7 @@ exports.tmpDir = path.join(exports.testDir, exports.tmpDirName); var opensslCli = null; var inFreeBSDJail = null; var localhostIPv4 = null; +var broadcastIPv4 = null; Object.defineProperty(exports, 'inFreeBSDJail', { get: function() { @@ -107,6 +108,27 @@ Object.defineProperty(exports, 'localhostIPv4', { } }); +Object.defineProperty(exports, 'broadcastIPv4', { + + get: function() { + if (broadcastIPv4 !== null) return broadcastIPv4; + + if (exports.inFreeBSDJail) { + if (process.env.BROADCAST) { + broadcastIPv4 = process.env.BROADCAST; + } else { + // shorter error than above since you'd probably be seeing both + console.error('In a FreeBSD jail. Pass broadcast as \'BROADCAST=\' ' + + 'to avoid test failures.'); + } + } + + if (broadcastIPv4 === null) broadcastIPv4 = '255.255.255.255'; + + return broadcastIPv4; + } +}); + // opensslCli defined lazily to reduce overhead of spawnSync Object.defineProperty(exports, 'opensslCli', {get: function() { if (opensslCli !== null) return opensslCli; diff --git a/test/internet/test-dgram-broadcast-multi-process.js b/test/internet/test-dgram-broadcast-multi-process.js index 9df217710eaf9b..ca110ec0a91344 100644 --- a/test/internet/test-dgram-broadcast-multi-process.js +++ b/test/internet/test-dgram-broadcast-multi-process.js @@ -6,7 +6,7 @@ var common = require('../common'), networkInterfaces = require('os').networkInterfaces(), Buffer = require('buffer').Buffer, fork = require('child_process').fork, - LOCAL_BROADCAST_HOST = '255.255.255.255', + LOCAL_BROADCAST_HOST = common.broadcastIPv4, TIMEOUT = common.platformTimeout(5000), messages = [ new Buffer('First message to send'),