node/test/parallel/test-net-server-listen-path.js
Timothy Gu fdbc668ea3 test: fix incorrect file mode check
PR-URL: https://github.com/nodejs/node/pull/22023
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-08-03 08:26:05 -07:00

72 lines
1.4 KiB
JavaScript

'use strict';
const common = require('../common');
const net = require('net');
const assert = require('assert');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
function closeServer() {
return common.mustCall(function() {
this.close();
});
}
let counter = 0;
// Avoid conflict with listen-handle
function randomPipePath() {
return `${common.PIPE}-listen-path-${counter++}`;
}
// Test listen(path)
{
const handlePath = randomPipePath();
net.createServer()
.listen(handlePath)
.on('listening', closeServer());
}
// Test listen({path})
{
const handlePath = randomPipePath();
net.createServer()
.listen({ path: handlePath })
.on('listening', closeServer());
}
// Test listen(path, cb)
{
const handlePath = randomPipePath();
net.createServer()
.listen(handlePath, closeServer());
}
// Test listen(path, cb)
{
const handlePath = randomPipePath();
net.createServer()
.listen({ path: handlePath }, closeServer());
}
// Test pipe chmod
{
const handlePath = randomPipePath();
const srv = net.createServer()
.listen({
path: handlePath,
readableAll: true,
writableAll: true
}, common.mustCall(() => {
if (process.platform !== 'win32') {
const mode = fs.statSync(handlePath).mode;
assert.notStrictEqual(mode & fs.constants.S_IROTH, 0);
assert.notStrictEqual(mode & fs.constants.S_IWOTH, 0);
}
srv.close();
}));
}