2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2013-07-28 14:50:03 +02:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
|
|
|
var cluster = require('cluster');
|
|
|
|
var net = require('net');
|
|
|
|
|
2015-07-29 17:18:04 +05:30
|
|
|
if (common.isWindows) {
|
2015-07-06 03:24:12 +00:00
|
|
|
console.log('1..0 # Skipped: not reliable on Windows');
|
2015-07-07 20:55:55 +05:30
|
|
|
return;
|
2013-07-28 14:50:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (process.getuid() === 0) {
|
2015-07-06 03:24:12 +00:00
|
|
|
console.log('1..0 # Skipped: as this test should not be run as `root`');
|
2015-07-07 20:55:55 +05:30
|
|
|
return;
|
2013-07-28 14:50:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cluster.isMaster) {
|
|
|
|
// Master opens and binds the socket and shares it with the worker.
|
|
|
|
cluster.schedulingPolicy = cluster.SCHED_NONE;
|
|
|
|
cluster.fork().on('exit', common.mustCall(function(exitCode) {
|
|
|
|
assert.equal(exitCode, 0);
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
else {
|
2015-10-20 11:40:54 -07:00
|
|
|
var s = net.createServer(common.fail);
|
|
|
|
s.listen(42, common.fail.bind(null, 'listen should have failed'));
|
2013-07-28 14:50:03 +02:00
|
|
|
s.on('error', common.mustCall(function(err) {
|
|
|
|
assert.equal(err.code, 'EACCES');
|
|
|
|
process.disconnect();
|
|
|
|
}));
|
|
|
|
}
|