mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
e266bb1722
PR-URL: https://github.com/nodejs/node/pull/50858 Reviewed-By: James M Snell <jasnell@gmail.com>
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const cp = require('child_process');
|
|
const fs = require('fs');
|
|
const tmpdir = require('../common/tmpdir');
|
|
|
|
if (!common.isLinux) common.skip();
|
|
|
|
const CODE = `
|
|
const net = require('net');
|
|
net.connect('${common.PIPE}').on('error', () => {});
|
|
net.connect('\\0${common.PIPE}').on('error', () => {});
|
|
`;
|
|
|
|
tmpdir.refresh();
|
|
const FILE_NAME = tmpdir.resolve('node_trace.1.log');
|
|
|
|
const proc = cp.spawn(process.execPath,
|
|
[ '--trace-events-enabled',
|
|
'--trace-event-categories', 'node.net.native',
|
|
'-e', CODE ],
|
|
{ cwd: tmpdir.path });
|
|
|
|
proc.once('exit', common.mustCall(() => {
|
|
assert(fs.existsSync(FILE_NAME));
|
|
fs.readFile(FILE_NAME, common.mustCall((err, data) => {
|
|
const traces = JSON.parse(data.toString()).traceEvents;
|
|
assert(traces.length > 0);
|
|
let count = 0;
|
|
traces.forEach((trace) => {
|
|
if (trace.cat === 'node,node.net,node.net.native' &&
|
|
trace.name === 'connect') {
|
|
count++;
|
|
if (trace.ph === 'b') {
|
|
assert.ok(!!trace.args.path_type);
|
|
assert.ok(!!trace.args.pipe_path);
|
|
}
|
|
}
|
|
});
|
|
assert.strictEqual(count, 4);
|
|
}));
|
|
}));
|