From 534db1ae6b3719fe389105b89dc93d6e62ebca7e Mon Sep 17 00:00:00 2001 From: legendecas Date: Tue, 11 May 2021 23:38:49 +0800 Subject: [PATCH 01/10] src: write named pipe info in diagnostic report Writes pipe handles with `uv_pipe_getsockname()` and `uv_pipe_getpeername()`. --- src/node_report_utils.cc | 38 ++++ ...st-report-uncaught-exception-primitives.js | 2 +- .../test-report-uncaught-exception-symbols.js | 2 +- test/report/test-report-uv-handles.js | 170 +++++++++++++----- 4 files changed, 168 insertions(+), 44 deletions(-) diff --git a/src/node_report_utils.cc b/src/node_report_utils.cc index abbf6d529d0ef7..aae05c290dadd7 100644 --- a/src/node_report_utils.cc +++ b/src/node_report_utils.cc @@ -7,6 +7,7 @@ namespace report { using node::JSONWriter; using node::MallocedBuffer; +using node::MaybeStackBuffer; static constexpr auto null = JSONWriter::Null{}; @@ -82,6 +83,40 @@ static void ReportEndpoints(uv_handle_t* h, JSONWriter* writer) { ReportEndpoint(h, rc == 0 ? addr : nullptr, "remoteEndpoint", writer); } +// Utility function to format libuv pipe information. +static void ReportPipeEndpoints(uv_handle_t* h, JSONWriter* writer) { + uv_any_handle* handle = reinterpret_cast(h); + MaybeStackBuffer buffer; + size_t buffer_size = buffer.capacity(); + int rc = -1; + + rc = uv_pipe_getsockname(&handle->pipe, buffer.out(), &buffer_size); + if (rc == UV_ENOBUFS) { + // Buffer is not large enough, reallocate to the updated buffer_size + // and fetch the value again. + buffer.AllocateSufficientStorage(buffer_size); + rc = uv_pipe_getsockname(&handle->pipe, buffer.out(), &buffer_size); + } + if (rc == 0 && buffer_size != 0) { + writer->json_keyvalue("localEndpointName", buffer.out()); + } else { + writer->json_keyvalue("localEndpointName", null); + } + + rc = uv_pipe_getpeername(&handle->pipe, buffer.out(), &buffer_size); + if (rc == UV_ENOBUFS) { + // Buffer is not large enough, reallocate to the updated buffer_size + // and fetch the value again. + buffer.AllocateSufficientStorage(buffer_size); + rc = uv_pipe_getpeername(&handle->pipe, buffer.out(), &buffer_size); + } + if (rc == 0 && buffer_size != 0) { + writer->json_keyvalue("remoteEndpointName", buffer.out()); + } else { + writer->json_keyvalue("remoteEndpointName", null); + } +} + // Utility function to format libuv path information. static void ReportPath(uv_handle_t* h, JSONWriter* writer) { MallocedBuffer buffer(0); @@ -147,6 +182,9 @@ void WalkHandle(uv_handle_t* h, void* arg) { case UV_UDP: ReportEndpoints(h, writer); break; + case UV_NAMED_PIPE: + ReportPipeEndpoints(h, writer); + break; case UV_TIMER: { uint64_t due = handle->timer.timeout; uint64_t now = uv_now(handle->timer.loop); diff --git a/test/report/test-report-uncaught-exception-primitives.js b/test/report/test-report-uncaught-exception-primitives.js index 75a05f335cf2e2..8de67eeb6a2747 100644 --- a/test/report/test-report-uncaught-exception-primitives.js +++ b/test/report/test-report-uncaught-exception-primitives.js @@ -15,7 +15,7 @@ process.on('uncaughtException', common.mustCall((err) => { assert.strictEqual(err, exception); const reports = helper.findReports(process.pid, tmpdir.path); assert.strictEqual(reports.length, 1); - console.log(reports[0]); + helper.validate(reports[0], [ ['header.event', 'Exception'], ['javascriptStack.message', `${exception}`], diff --git a/test/report/test-report-uncaught-exception-symbols.js b/test/report/test-report-uncaught-exception-symbols.js index 5997d0e0898ac0..b1656172851f66 100644 --- a/test/report/test-report-uncaught-exception-symbols.js +++ b/test/report/test-report-uncaught-exception-symbols.js @@ -15,7 +15,7 @@ process.on('uncaughtException', common.mustCall((err) => { assert.strictEqual(err, exception); const reports = helper.findReports(process.pid, tmpdir.path); assert.strictEqual(reports.length, 1); - console.log(reports[0]); + helper.validate(reports[0], [ ['header.event', 'Exception'], ['javascriptStack.message', 'Symbol(foobar)'], diff --git a/test/report/test-report-uv-handles.js b/test/report/test-report-uv-handles.js index 32140cf887f919..add70ae1f8fe64 100644 --- a/test/report/test-report-uv-handles.js +++ b/test/report/test-report-uv-handles.js @@ -2,18 +2,13 @@ // Testcase to check reporting of uv handles. const common = require('../common'); +const tmpdir = require('../common/tmpdir'); +const path = require('path'); if (common.isIBMi) common.skip('IBMi does not support fs.watch()'); -if (process.argv[2] === 'child') { - // Exit on loss of parent process - const exit = () => process.exit(2); - process.on('disconnect', exit); - +function createFsHandle(childData) { const fs = require('fs'); - const http = require('http'); - const spawn = require('child_process').spawn; - // Watching files should result in fs_event/fs_poll uv handles. let watcher; try { @@ -22,54 +17,127 @@ if (process.argv[2] === 'child') { // fs.watch() unavailable } fs.watchFile(__filename, () => {}); + childData.skip_fs_watch = watcher === undefined; + + return () => { + if (watcher) watcher.close(); + fs.unwatchFile(__filename); + }; +} +function createChildProcessHandle(childData) { + const spawn = require('child_process').spawn; // Child should exist when this returns as child_process.pid must be set. - const child_process = spawn(process.execPath, - ['-e', "process.stdin.on('data', (x) => " + - 'console.log(x.toString()));']); + const cp = spawn(process.execPath, + ['-e', "process.stdin.on('data', (x) => " + + 'console.log(x.toString()));']); + childData.pid = cp.pid; + + return () => { + cp.kill(); + }; +} +function createTimerHandle() { const timeout = setInterval(() => {}, 1000); // Make sure the timer doesn't keep the test alive and let // us check we detect unref'd handles correctly. timeout.unref(); + return () => { + clearInterval(timeout); + }; +} + +function createTcpHandle(childData) { + const http = require('http'); + + return new Promise((resolve) => { + // Simple server/connection to create tcp uv handles. + const server = http.createServer((req, res) => { + req.on('end', () => { + resolve(() => { + res.writeHead(200, { 'Content-Type': 'text/plain' }); + res.end(); + server.close(); + }); + }); + req.resume(); + }); + server.listen(() => { + childData.tcp_address = server.address(); + http.get({ port: server.address().port }); + }); + }); +} +function createUdpHandle(childData) { // Datagram socket for udp uv handles. const dgram = require('dgram'); - const udp_socket = dgram.createSocket('udp4'); - const connected_udp_socket = dgram.createSocket('udp4'); - udp_socket.bind({}, common.mustCall(() => { - connected_udp_socket.connect(udp_socket.address().port); - })); + const udpSocket = dgram.createSocket('udp4'); + const connectedUdpSocket = dgram.createSocket('udp4'); + + return new Promise((resolve) => { + udpSocket.bind({}, common.mustCall(() => { + connectedUdpSocket.connect(udpSocket.address().port); - // Simple server/connection to create tcp uv handles. - const server = http.createServer((req, res) => { - req.on('end', () => { - // Generate the report while the connection is active. - console.log(JSON.stringify(process.report.getReport(), null, 2)); - child_process.kill(); - - res.writeHead(200, { 'Content-Type': 'text/plain' }); - res.end(); - - // Tidy up to allow process to exit cleanly. - server.close(() => { - if (watcher) watcher.close(); - fs.unwatchFile(__filename); - connected_udp_socket.close(); - udp_socket.close(); - process.removeListener('disconnect', exit); + childData.udp_address = udpSocket.address(); + resolve(() => { + connectedUdpSocket.close(); + udpSocket.close(); + }); + })); + }); +} + +function createNamedPipeHandle(childData) { + const net = require('net'); + const fs = require('fs'); + fs.mkdirSync(tmpdir.path, { recursive: true }); + const sockPath = path.join(tmpdir.path, 'test-report-uv-handles.sock'); + return new Promise((resolve) => { + const server = net.createServer((socket) => { + childData.pipe_sock_path = server.address(); + resolve(() => { + socket.end(); + server.close(); }); }); - req.resume(); + server.listen( + sockPath, + () => { + net.connect(sockPath, (socket) => {}); + }); }); - server.listen(() => { - const data = { pid: child_process.pid, - tcp_address: server.address(), - udp_address: udp_socket.address(), - skip_fs_watch: (watcher === undefined) }; - process.send(data); - http.get({ port: server.address().port }); +} + +async function child() { + // Exit on loss of parent process + const exit = () => process.exit(2); + process.on('disconnect', exit); + + const childData = {}; + const disposes = await Promise.all([ + createFsHandle(childData), + createChildProcessHandle(childData), + createTimerHandle(childData), + createTcpHandle(childData), + createUdpHandle(childData), + createNamedPipeHandle(childData), + ]); + process.send(childData); + + // Generate the report while the connection is active. + console.log(JSON.stringify(process.report.getReport(), null, 2)); + + // Tidy up to allow process to exit cleanly. + disposes.forEach((it) => { + it(); }); + process.removeListener('disconnect', exit); +} + +if (process.argv[2] === 'child') { + child(); } else { const helper = require('../common/report.js'); const fork = require('child_process').fork; @@ -116,6 +184,7 @@ if (process.argv[2] === 'child') { const expected_filename = `${prefix}${__filename}`; const found_tcp = []; const found_udp = []; + const found_named_pipe = []; // Functions are named to aid debugging when they are not called. const validators = { fs_event: common.mustCall(function fs_event_validator(handle) { @@ -133,6 +202,20 @@ if (process.argv[2] === 'child') { }), pipe: common.mustCallAtLeast(function pipe_validator(handle) { assert(handle.is_referenced); + // Pipe handles. The report should contain three pipes: + // 1. The server's listening pipe. + // 2. The inbound pipe making the request. + // 3. The outbound pipe sending the response. + const sockPath = child_data.pipe_sock_path; + if (handle.localEndpointName === sockPath) { + if (handle.writable === false) { + found_named_pipe.push('listening'); + } else { + found_named_pipe.push('inbound'); + } + } else if (handle.remoteEndpointName === sockPath) { + found_named_pipe.push('outbound'); + } }), process: common.mustCall(function process_validator(handle) { assert.strictEqual(handle.pid, child_data.pid); @@ -172,7 +255,7 @@ if (process.argv[2] === 'child') { assert(handle.is_referenced); }, 2), }; - console.log(report.libuv); + for (const entry of report.libuv) { if (validators[entry.type]) validators[entry.type](entry); } @@ -182,6 +265,9 @@ if (process.argv[2] === 'child') { for (const socket of ['connected', 'unconnected']) { assert(found_udp.includes(socket), `${socket} UDP socket was not found`); } + for (const socket of ['listening', 'inbound', 'outbound']) { + assert(found_named_pipe.includes(socket), `${socket} Named pipe socket was not found`); + } // Common report tests. helper.validateContent(stdout); From 74b1e3e5ff4d9345fa746aaecff070913c8a5642 Mon Sep 17 00:00:00 2001 From: legendecas Date: Wed, 12 May 2021 23:34:00 +0800 Subject: [PATCH 02/10] fixup! src: write named pipe info in diagnostic report --- src/node_report_utils.cc | 31 ++++++++++++--------------- test/report/test-report-uv-handles.js | 4 ++-- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/node_report_utils.cc b/src/node_report_utils.cc index aae05c290dadd7..eea4bf0fb7f0d3 100644 --- a/src/node_report_utils.cc +++ b/src/node_report_utils.cc @@ -7,7 +7,6 @@ namespace report { using node::JSONWriter; using node::MallocedBuffer; -using node::MaybeStackBuffer; static constexpr auto null = JSONWriter::Null{}; @@ -86,34 +85,32 @@ static void ReportEndpoints(uv_handle_t* h, JSONWriter* writer) { // Utility function to format libuv pipe information. static void ReportPipeEndpoints(uv_handle_t* h, JSONWriter* writer) { uv_any_handle* handle = reinterpret_cast(h); - MaybeStackBuffer buffer; - size_t buffer_size = buffer.capacity(); + MallocedBuffer buffer(0); + size_t buffer_size = 0; int rc = -1; - rc = uv_pipe_getsockname(&handle->pipe, buffer.out(), &buffer_size); + // First call to get required buffer size. + rc = uv_pipe_getsockname(&handle->pipe, buffer.data, &buffer_size); if (rc == UV_ENOBUFS) { - // Buffer is not large enough, reallocate to the updated buffer_size - // and fetch the value again. - buffer.AllocateSufficientStorage(buffer_size); - rc = uv_pipe_getsockname(&handle->pipe, buffer.out(), &buffer_size); + buffer = MallocedBuffer(buffer_size); + rc = uv_pipe_getsockname(&handle->pipe, buffer.data, &buffer_size); } if (rc == 0 && buffer_size != 0) { - writer->json_keyvalue("localEndpointName", buffer.out()); + writer->json_keyvalue("localEndpoint", buffer.data); } else { - writer->json_keyvalue("localEndpointName", null); + writer->json_keyvalue("localEndpoint", null); } - rc = uv_pipe_getpeername(&handle->pipe, buffer.out(), &buffer_size); + // First call to get required buffer size. + rc = uv_pipe_getpeername(&handle->pipe, buffer.data, &buffer_size); if (rc == UV_ENOBUFS) { - // Buffer is not large enough, reallocate to the updated buffer_size - // and fetch the value again. - buffer.AllocateSufficientStorage(buffer_size); - rc = uv_pipe_getpeername(&handle->pipe, buffer.out(), &buffer_size); + buffer = MallocedBuffer(buffer_size); + rc = uv_pipe_getpeername(&handle->pipe, buffer.data, &buffer_size); } if (rc == 0 && buffer_size != 0) { - writer->json_keyvalue("remoteEndpointName", buffer.out()); + writer->json_keyvalue("remoteEndpoint", buffer.data); } else { - writer->json_keyvalue("remoteEndpointName", null); + writer->json_keyvalue("remoteEndpoint", null); } } diff --git a/test/report/test-report-uv-handles.js b/test/report/test-report-uv-handles.js index add70ae1f8fe64..87ebac025d4dca 100644 --- a/test/report/test-report-uv-handles.js +++ b/test/report/test-report-uv-handles.js @@ -207,13 +207,13 @@ if (process.argv[2] === 'child') { // 2. The inbound pipe making the request. // 3. The outbound pipe sending the response. const sockPath = child_data.pipe_sock_path; - if (handle.localEndpointName === sockPath) { + if (handle.localEndpoint === sockPath) { if (handle.writable === false) { found_named_pipe.push('listening'); } else { found_named_pipe.push('inbound'); } - } else if (handle.remoteEndpointName === sockPath) { + } else if (handle.remoteEndpoint === sockPath) { found_named_pipe.push('outbound'); } }), From 5dd91857a6a8890ec0467ce566f9ac84d94666b4 Mon Sep 17 00:00:00 2001 From: legendecas Date: Thu, 13 May 2021 00:07:43 +0800 Subject: [PATCH 03/10] fixup! src: write named pipe info in diagnostic report --- test/report/test-report-uv-handles.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/report/test-report-uv-handles.js b/test/report/test-report-uv-handles.js index 87ebac025d4dca..6cfc14aef36ac3 100644 --- a/test/report/test-report-uv-handles.js +++ b/test/report/test-report-uv-handles.js @@ -142,7 +142,6 @@ if (process.argv[2] === 'child') { const helper = require('../common/report.js'); const fork = require('child_process').fork; const assert = require('assert'); - const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); const options = { encoding: 'utf8', silent: true, cwd: tmpdir.path }; const child = fork(__filename, ['child'], options); @@ -266,7 +265,7 @@ if (process.argv[2] === 'child') { assert(found_udp.includes(socket), `${socket} UDP socket was not found`); } for (const socket of ['listening', 'inbound', 'outbound']) { - assert(found_named_pipe.includes(socket), `${socket} Named pipe socket was not found`); + assert(found_named_pipe.includes(socket), `${socket} named pipe socket was not found`); } // Common report tests. From 477e50f39103030208899c0e690b7f00bd231ab3 Mon Sep 17 00:00:00 2001 From: legendecas Date: Sun, 16 May 2021 16:32:30 +0800 Subject: [PATCH 04/10] fixup! src: write named pipe info in diagnostic report --- src/node_report_utils.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/node_report_utils.cc b/src/node_report_utils.cc index eea4bf0fb7f0d3..82ed385ad176bd 100644 --- a/src/node_report_utils.cc +++ b/src/node_report_utils.cc @@ -93,9 +93,11 @@ static void ReportPipeEndpoints(uv_handle_t* h, JSONWriter* writer) { rc = uv_pipe_getsockname(&handle->pipe, buffer.data, &buffer_size); if (rc == UV_ENOBUFS) { buffer = MallocedBuffer(buffer_size); - rc = uv_pipe_getsockname(&handle->pipe, buffer.data, &buffer_size); + if (buffer.data != nullptr) { + rc = uv_pipe_getsockname(&handle->pipe, buffer.data, &buffer_size); + } } - if (rc == 0 && buffer_size != 0) { + if (rc == 0 && buffer_size != 0 && buffer.data != nullptr) { writer->json_keyvalue("localEndpoint", buffer.data); } else { writer->json_keyvalue("localEndpoint", null); @@ -105,9 +107,11 @@ static void ReportPipeEndpoints(uv_handle_t* h, JSONWriter* writer) { rc = uv_pipe_getpeername(&handle->pipe, buffer.data, &buffer_size); if (rc == UV_ENOBUFS) { buffer = MallocedBuffer(buffer_size); - rc = uv_pipe_getpeername(&handle->pipe, buffer.data, &buffer_size); + if (buffer.data != nullptr) { + rc = uv_pipe_getpeername(&handle->pipe, buffer.data, &buffer_size); + } } - if (rc == 0 && buffer_size != 0) { + if (rc == 0 && buffer_size != 0 && buffer.data != nullptr) { writer->json_keyvalue("remoteEndpoint", buffer.data); } else { writer->json_keyvalue("remoteEndpoint", null); From 0efa117b3fb641913d94a3bae3a0da3e1b7ae5cd Mon Sep 17 00:00:00 2001 From: legendecas Date: Tue, 18 May 2021 00:09:29 +0800 Subject: [PATCH 05/10] fixup! test: windows fanned test failed --- test/report/test-report-uv-handles.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/report/test-report-uv-handles.js b/test/report/test-report-uv-handles.js index 6cfc14aef36ac3..3c4a1e822d4424 100644 --- a/test/report/test-report-uv-handles.js +++ b/test/report/test-report-uv-handles.js @@ -153,11 +153,11 @@ if (process.argv[2] === 'child') { const report_msg = 'Report files were written: unexpectedly'; child.stdout.on('data', (chunk) => { stdout += chunk; }); child.on('exit', common.mustCall((code, signal) => { + assert.strictEqual(stderr.trim(), ''); assert.deepStrictEqual(code, 0, 'Process exited unexpectedly with code: ' + `${code}`); assert.deepStrictEqual(signal, null, 'Process should have exited cleanly,' + ` but did not: ${signal}`); - assert.strictEqual(stderr.trim(), ''); const reports = helper.findReports(child.pid, tmpdir.path); assert.deepStrictEqual(reports, [], report_msg, reports); From 69d3ea5b768a8e25f938d26ce029c862ef45a5f2 Mon Sep 17 00:00:00 2001 From: legendecas Date: Tue, 18 May 2021 00:57:41 +0800 Subject: [PATCH 06/10] fixup! test: windows fanned test failed --- test/report/test-report-uv-handles.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/report/test-report-uv-handles.js b/test/report/test-report-uv-handles.js index 3c4a1e822d4424..c1669c8fe0b5a6 100644 --- a/test/report/test-report-uv-handles.js +++ b/test/report/test-report-uv-handles.js @@ -3,7 +3,6 @@ // Testcase to check reporting of uv handles. const common = require('../common'); const tmpdir = require('../common/tmpdir'); -const path = require('path'); if (common.isIBMi) common.skip('IBMi does not support fs.watch()'); @@ -91,9 +90,7 @@ function createUdpHandle(childData) { function createNamedPipeHandle(childData) { const net = require('net'); - const fs = require('fs'); - fs.mkdirSync(tmpdir.path, { recursive: true }); - const sockPath = path.join(tmpdir.path, 'test-report-uv-handles.sock'); + const sockPath = `${common.PIPE}-listen-path-test-report-uv-handles`; return new Promise((resolve) => { const server = net.createServer((socket) => { childData.pipe_sock_path = server.address(); From 6451d802c490d328f23df4a4a6c3f61b2b1ff371 Mon Sep 17 00:00:00 2001 From: legendecas Date: Wed, 19 May 2021 00:20:10 +0800 Subject: [PATCH 07/10] fixup! test: windows fanned test failed --- test/report/test-report-uv-handles.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/report/test-report-uv-handles.js b/test/report/test-report-uv-handles.js index c1669c8fe0b5a6..4bbac0898abdb7 100644 --- a/test/report/test-report-uv-handles.js +++ b/test/report/test-report-uv-handles.js @@ -251,7 +251,7 @@ if (process.argv[2] === 'child') { assert(handle.is_referenced); }, 2), }; - + console.log(report.libuv); for (const entry of report.libuv) { if (validators[entry.type]) validators[entry.type](entry); } From 0112fba04111e4218045b3e47c5dc95fe5150429 Mon Sep 17 00:00:00 2001 From: legendecas Date: Wed, 19 May 2021 09:03:43 +0800 Subject: [PATCH 08/10] fixup! test: windows fanned test failed --- test/report/test-report-uv-handles.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/test/report/test-report-uv-handles.js b/test/report/test-report-uv-handles.js index 4bbac0898abdb7..952eb55bef32cc 100644 --- a/test/report/test-report-uv-handles.js +++ b/test/report/test-report-uv-handles.js @@ -3,9 +3,17 @@ // Testcase to check reporting of uv handles. const common = require('../common'); const tmpdir = require('../common/tmpdir'); +const path = require('path'); if (common.isIBMi) common.skip('IBMi does not support fs.watch()'); +function pipeName(windowsExtended) { + const localRelative = path.relative(process.cwd(), `${tmpdir.path}/`); + const pipePrefix = common.isWindows ? `\\\\${windowsExtended ? '?' : '.'}\\pipe\\` : localRelative; + const filename = `node-test.${process.pid}.sock`; + return path.join(pipePrefix, filename); +} + function createFsHandle(childData) { const fs = require('fs'); // Watching files should result in fs_event/fs_poll uv handles. @@ -90,7 +98,7 @@ function createUdpHandle(childData) { function createNamedPipeHandle(childData) { const net = require('net'); - const sockPath = `${common.PIPE}-listen-path-test-report-uv-handles`; + const sockPath = `${pipeName(true)}-listen-path-test-report-uv-handles`; return new Promise((resolve) => { const server = net.createServer((socket) => { childData.pipe_sock_path = server.address(); @@ -202,15 +210,16 @@ if (process.argv[2] === 'child') { // 1. The server's listening pipe. // 2. The inbound pipe making the request. // 3. The outbound pipe sending the response. + // + // There is no way to distinguish inbound and outbound in a cross + // platform manner, so we just check inbound here. const sockPath = child_data.pipe_sock_path; if (handle.localEndpoint === sockPath) { if (handle.writable === false) { found_named_pipe.push('listening'); - } else { - found_named_pipe.push('inbound'); } } else if (handle.remoteEndpoint === sockPath) { - found_named_pipe.push('outbound'); + found_named_pipe.push('inbound'); } }), process: common.mustCall(function process_validator(handle) { @@ -251,7 +260,7 @@ if (process.argv[2] === 'child') { assert(handle.is_referenced); }, 2), }; - console.log(report.libuv); + for (const entry of report.libuv) { if (validators[entry.type]) validators[entry.type](entry); } @@ -261,7 +270,7 @@ if (process.argv[2] === 'child') { for (const socket of ['connected', 'unconnected']) { assert(found_udp.includes(socket), `${socket} UDP socket was not found`); } - for (const socket of ['listening', 'inbound', 'outbound']) { + for (const socket of ['listening', 'inbound']) { assert(found_named_pipe.includes(socket), `${socket} named pipe socket was not found`); } From 14e0b9add48b25754db3cfc6af3259eaff54fdae Mon Sep 17 00:00:00 2001 From: legendecas Date: Wed, 19 May 2021 22:59:10 +0800 Subject: [PATCH 09/10] fixup! merge with common.PIPE --- test/common/index.js | 2 +- test/report/test-report-uv-handles.js | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/test/common/index.js b/test/common/index.js index d67baa5caf0ad1..b6d05f7b1ae9da 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -199,7 +199,7 @@ const localIPv6Hosts = const PIPE = (() => { const localRelative = path.relative(process.cwd(), `${tmpdir.path}/`); - const pipePrefix = isWindows ? '\\\\.\\pipe\\' : localRelative; + const pipePrefix = isWindows ? '\\\\?\\pipe\\' : localRelative; const pipeName = `node-test.${process.pid}.sock`; return path.join(pipePrefix, pipeName); })(); diff --git a/test/report/test-report-uv-handles.js b/test/report/test-report-uv-handles.js index 952eb55bef32cc..98406a2d1b60d8 100644 --- a/test/report/test-report-uv-handles.js +++ b/test/report/test-report-uv-handles.js @@ -3,17 +3,9 @@ // Testcase to check reporting of uv handles. const common = require('../common'); const tmpdir = require('../common/tmpdir'); -const path = require('path'); if (common.isIBMi) common.skip('IBMi does not support fs.watch()'); -function pipeName(windowsExtended) { - const localRelative = path.relative(process.cwd(), `${tmpdir.path}/`); - const pipePrefix = common.isWindows ? `\\\\${windowsExtended ? '?' : '.'}\\pipe\\` : localRelative; - const filename = `node-test.${process.pid}.sock`; - return path.join(pipePrefix, filename); -} - function createFsHandle(childData) { const fs = require('fs'); // Watching files should result in fs_event/fs_poll uv handles. @@ -98,7 +90,7 @@ function createUdpHandle(childData) { function createNamedPipeHandle(childData) { const net = require('net'); - const sockPath = `${pipeName(true)}-listen-path-test-report-uv-handles`; + const sockPath = common.PIPE; return new Promise((resolve) => { const server = net.createServer((socket) => { childData.pipe_sock_path = server.address(); From d5d6ee71b152c9e3f943f5d5cb030b4a04b30d7d Mon Sep 17 00:00:00 2001 From: legendecas Date: Thu, 20 May 2021 00:14:50 +0800 Subject: [PATCH 10/10] fixup! test: windows fanned test failed various pipe connect API failed in parallel/test-net-connect-options-path. --- test/common/index.js | 2 +- test/report/test-report-uv-handles.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/test/common/index.js b/test/common/index.js index b6d05f7b1ae9da..d67baa5caf0ad1 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -199,7 +199,7 @@ const localIPv6Hosts = const PIPE = (() => { const localRelative = path.relative(process.cwd(), `${tmpdir.path}/`); - const pipePrefix = isWindows ? '\\\\?\\pipe\\' : localRelative; + const pipePrefix = isWindows ? '\\\\.\\pipe\\' : localRelative; const pipeName = `node-test.${process.pid}.sock`; return path.join(pipePrefix, pipeName); })(); diff --git a/test/report/test-report-uv-handles.js b/test/report/test-report-uv-handles.js index 98406a2d1b60d8..6a60aa4c4bcc84 100644 --- a/test/report/test-report-uv-handles.js +++ b/test/report/test-report-uv-handles.js @@ -3,9 +3,19 @@ // Testcase to check reporting of uv handles. const common = require('../common'); const tmpdir = require('../common/tmpdir'); +const path = require('path'); if (common.isIBMi) common.skip('IBMi does not support fs.watch()'); +// This is quite similar to common.PIPE except that it uses an extended prefix +// of "\\?\pipe" on windows. +const PIPE = (() => { + const localRelative = path.relative(process.cwd(), `${tmpdir.path}/`); + const pipePrefix = common.isWindows ? '\\\\?\\pipe\\' : localRelative; + const pipeName = `node-test.${process.pid}.sock`; + return path.join(pipePrefix, pipeName); +})(); + function createFsHandle(childData) { const fs = require('fs'); // Watching files should result in fs_event/fs_poll uv handles. @@ -90,7 +100,7 @@ function createUdpHandle(childData) { function createNamedPipeHandle(childData) { const net = require('net'); - const sockPath = common.PIPE; + const sockPath = PIPE; return new Promise((resolve) => { const server = net.createServer((socket) => { childData.pipe_sock_path = server.address();