Skip to content

Commit

Permalink
test: check for multi-localhost support
Browse files Browse the repository at this point in the history
  • Loading branch information
tjfontaine authored and piscisaureus committed Jan 13, 2015
1 parent dc42e1f commit 22d2058
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ exports.getServiceName = function getServiceName(port, protocol) {
return serviceName;
}

exports.hasMultiLocalhost = function hasMultiLocalhost() {
var TCP = process.binding('tcp_wrap').TCP;
var t = new TCP();
var ret = t.bind('127.0.0.2', exports.PORT);
t.close();
return ret === 0;
};

exports.isValidHostname = function(str) {
// See http://stackoverflow.com/a/3824105
var re = new RegExp(
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-localaddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var common = require('../common');
var http = require('http'),
assert = require('assert');

if (['linux', 'win32'].indexOf(process.platform) == -1) {
if (!common.hasMultiLocalhost()) {
console.log('Skipping platform-specific test.');
process.exit();
}
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-https-localaddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var https = require('https'),
fs = require('fs'),
assert = require('assert');

if (['linux', 'win32'].indexOf(process.platform) == -1) {
if (!common.hasMultiLocalhost()) {
console.log('Skipping platform-specific test.');
process.exit();
}
Expand Down

0 comments on commit 22d2058

Please sign in to comment.