diff --git a/test/common.js b/test/common.js index 1d9d7b775c5..b9b03c738f7 100644 --- a/test/common.js +++ b/test/common.js @@ -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( diff --git a/test/parallel/test-http-localaddress.js b/test/parallel/test-http-localaddress.js index 8edc21c2918..3cd82131525 100644 --- a/test/parallel/test-http-localaddress.js +++ b/test/parallel/test-http-localaddress.js @@ -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(); } diff --git a/test/parallel/test-https-localaddress.js b/test/parallel/test-https-localaddress.js index 420d24911bf..9eeebef95f4 100644 --- a/test/parallel/test-https-localaddress.js +++ b/test/parallel/test-https-localaddress.js @@ -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(); }