test: check ipv6 support before testing it
fix #7983 fix #8049 Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
This commit is contained in:
parent
f5f5bd76e6
commit
c7b42fe2e5
@ -22,6 +22,7 @@
|
|||||||
var path = require('path');
|
var path = require('path');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
|
var os = require('os');
|
||||||
|
|
||||||
exports.testDir = path.dirname(__filename);
|
exports.testDir = path.dirname(__filename);
|
||||||
exports.fixturesDir = path.join(exports.testDir, 'fixtures');
|
exports.fixturesDir = path.join(exports.testDir, 'fixtures');
|
||||||
@ -46,6 +47,13 @@ if (process.platform === 'win32') {
|
|||||||
"faketime");
|
"faketime");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ifaces = os.networkInterfaces();
|
||||||
|
exports.hasIPv6 = Object.keys(ifaces).some(function(name) {
|
||||||
|
return /lo/.test(name) && ifaces[name].some(function(info) {
|
||||||
|
return info.family === 'IPv6';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
for (var i in util) exports[i] = util[i];
|
for (var i in util) exports[i] = util[i];
|
||||||
//for (var i in exports) global[i] = exports[i];
|
//for (var i in exports) global[i] = exports[i];
|
||||||
|
@ -29,6 +29,11 @@ dgram.createSocket('udp4').bind(common.PORT + 0, common.mustCall(function() {
|
|||||||
this.close();
|
this.close();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
if (!common.hasIPv6) {
|
||||||
|
console.error('Skipping udp6 part of test, no IPv6 support');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dgram.createSocket('udp6').bind(common.PORT + 1, common.mustCall(function() {
|
dgram.createSocket('udp6').bind(common.PORT + 1, common.mustCall(function() {
|
||||||
assert.equal(this.address().port, common.PORT + 1);
|
assert.equal(this.address().port, common.PORT + 1);
|
||||||
var address = this.address().address;
|
var address = this.address().address;
|
||||||
|
@ -24,6 +24,11 @@ var assert = require('assert');
|
|||||||
var net = require('net');
|
var net = require('net');
|
||||||
var dns = require('dns');
|
var dns = require('dns');
|
||||||
|
|
||||||
|
if (!common.hasIPv6) {
|
||||||
|
console.error('Skipping test, no IPv6 support');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var serverGotEnd = false;
|
var serverGotEnd = false;
|
||||||
var clientGotEnd = false;
|
var clientGotEnd = false;
|
||||||
|
|
||||||
|
@ -135,9 +135,13 @@ console.log(common.PIPE);
|
|||||||
pingPongTest(common.PIPE);
|
pingPongTest(common.PIPE);
|
||||||
pingPongTest(common.PORT);
|
pingPongTest(common.PORT);
|
||||||
pingPongTest(common.PORT + 1, 'localhost');
|
pingPongTest(common.PORT + 1, 'localhost');
|
||||||
pingPongTest(common.PORT + 2, '::1');
|
if (common.hasIPv6)
|
||||||
|
pingPongTest(common.PORT + 2, '::1');
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', function() {
|
||||||
|
if (common.hasIPv6)
|
||||||
assert.equal(4, tests_run);
|
assert.equal(4, tests_run);
|
||||||
|
else
|
||||||
|
assert.equal(3, tests_run);
|
||||||
console.log('done');
|
console.log('done');
|
||||||
});
|
});
|
||||||
|
@ -57,6 +57,11 @@ server_ipv6.listen(common.PORT, localhost_ipv6, function() {
|
|||||||
server_ipv6.close();
|
server_ipv6.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!common.hasIPv6) {
|
||||||
|
console.error('Skipping ipv6 part of test, no IPv6 support');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Test without hostname or ip
|
// Test without hostname or ip
|
||||||
var anycast_ipv6 = '::';
|
var anycast_ipv6 = '::';
|
||||||
var server1 = net.createServer();
|
var server1 = net.createServer();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user