Skip to content

Instantly share code, notes, and snippets.

@tjfontaine
Created October 3, 2014 22:04
Show Gist options
  • Save tjfontaine/b7118531d70e9dda58fa to your computer and use it in GitHub Desktop.
Save tjfontaine/b7118531d70e9dda58fa to your computer and use it in GitHub Desktop.
diff --git a/test/common.js b/test/common.js
index cf90634..92a4183 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 d5778e0..27172e3 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 f577af3..6388c5b 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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment