Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
don't test fd on windows
  • Loading branch information
joyeecheung committed Mar 10, 2017
commit 445a68b6a2538164fefa6a6ba00b16fc3effcd12
16 changes: 11 additions & 5 deletions test/parallel/test-net-server-listen-handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ function randomHandle(type) {
if (errno < 0) { // uv.errname requires err < 0
assert(errno >= 0, `unable to bind ${handleName}: ${uv.errname(errno)}`);
}
// err >= 0 but fd = -1, should not happen
assert(handle.fd !== -1, `Bound ${handleName} has fd -1 and errno ${errno}`);
if (!common.isWindows) { // fd doesn't work on windows
// err >= 0 but fd = -1, should not happen
assert.notStrictEqual(handle.fd, -1,
`Bound ${handleName} has fd -1 and errno ${errno}`);
}
return handle;
}

Expand All @@ -74,7 +77,7 @@ function randomPipes(number) {
}

// Not a public API, used by child_process
{
if (!common.isWindows) { // Windows doesn't support {fd: <n>}
const handles = randomPipes(2); // generate pipes in advance
// Test listen(pipe)
net.createServer()
Expand All @@ -100,6 +103,9 @@ function randomPipes(number) {
net.createServer()
.listen({_handle: randomHandle('tcp')})
.on('listening', closeServer());
}

if (!common.isWindows) { // Windows doesn't support {fd: <n>}
// Test listen({fd: tcp.fd}, cb)
net.createServer()
.listen({fd: randomHandle('tcp').fd}, closeServer());
Expand All @@ -109,7 +115,7 @@ function randomPipes(number) {
.on('listening', closeServer());
}

{
if (!common.isWindows) { // Windows doesn't support {fd: <n>}
const handles = randomPipes(6); // generate pipes in advance
// Test listen({handle: pipe}, cb)
net.createServer()
Expand All @@ -134,7 +140,7 @@ function randomPipes(number) {
.on('listening', closePipeServer(handles[5]));
}

{
if (!common.isWindows) { // Windows doesn't support {fd: <n>}
// Test invalid fd
const fd = fs.openSync(__filename, 'r');
net.createServer()
Expand Down