test: check for multi-localhost support

Cherry-picked-from: 2b7c8a2f02
This commit is contained in:
Timothy J Fontaine 2015-01-10 21:36:16 +01:00 committed by Bert Belder
parent dc42e1faaf
commit 22d20582cc
3 changed files with 10 additions and 2 deletions

View File

@ -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(

View File

@ -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();
}

View File

@ -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();
}