Skip to content
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

test: introduce a broadcast helper #2851

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 22 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -107,6 +108,27 @@ Object.defineProperty(exports, 'localhostIPv4', {
}
});

Object.defineProperty(exports, 'broadcastIPv4', {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: rm blank line for consistency with the other similar blocks.

get: function() {
if (broadcastIPv4 !== null) return broadcastIPv4;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is it declared?


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;
Expand Down
2 changes: 1 addition & 1 deletion test/internet/test-dgram-broadcast-multi-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down