test: check for multi-localhost support
authorTimothy J Fontaine <tjfontaine@gmail.com>
Sat, 10 Jan 2015 20:36:16 +0000 (21:36 +0100)
committerBert Belder <bertbelder@gmail.com>
Tue, 13 Jan 2015 02:28:31 +0000 (03:28 +0100)
Cherry-picked-from: https://github.com/joyent/node/commit/2b7c8a2f02c2e132c2dbc59bd05e0e7246e10196

test/common.js
test/parallel/test-http-localaddress.js
test/parallel/test-https-localaddress.js

index 1d9d7b7..b9b03c7 100644 (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(
index 8edc21c..3cd8213 100644 (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();
 }
index 420d249..9eeebef 100644 (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();
 }