diff --git a/test/common.js b/test/common.js index cf90634c46e..92a4183944c 100644 --- a/test/common.js +++ b/test/common.js @@ -210,3 +210,11 @@ exports.mustCall = function(fn, expected) { return fn.apply(this, arguments); }; }; + +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; +}; diff --git a/test/simple/test-http-localaddress.js b/test/simple/test-http-localaddress.js index d5778e09b05..27172e33a95 100644 --- a/test/simple/test-http-localaddress.js +++ b/test/simple/test-http-localaddress.js @@ -23,7 +23,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/simple/test-https-localaddress.js b/test/simple/test-https-localaddress.js index f577af3ac8d..6388c5baa29 100644 --- a/test/simple/test-https-localaddress.js +++ b/test/simple/test-https-localaddress.js @@ -24,7 +24,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(); }