From 22d20582ccfbb9077c72c196340b21ef6f1aa624 Mon Sep 17 00:00:00 2001 From: Timothy J Fontaine Date: Sat, 10 Jan 2015 21:36:16 +0100 Subject: [PATCH] test: check for multi-localhost support Cherry-picked-from: https://github.com/joyent/node/commit/2b7c8a2f02c2e132c2dbc59bd05e0e7246e10196 --- test/common.js | 8 ++++++++ test/parallel/test-http-localaddress.js | 2 +- test/parallel/test-https-localaddress.js | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/common.js b/test/common.js index 1d9d7b775c5bdf..b9b03c738f7657 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 8edc21c29186a1..3cd821315253c9 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 420d24911bf473..9eeebef95f4e3f 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(); }