2018-03-06 18:42:37 +00:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const cp = require('child_process');
|
|
|
|
const fs = require('fs');
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
|
|
|
|
|
|
const names = [
|
|
|
|
'environment',
|
|
|
|
'nodeStart',
|
|
|
|
'v8Start',
|
|
|
|
'loopStart',
|
|
|
|
'loopExit',
|
2021-03-26 15:51:08 +00:00
|
|
|
'bootstrapComplete',
|
2018-03-06 18:42:37 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
if (process.argv[2] === 'child') {
|
2020-11-24 13:11:20 +00:00
|
|
|
1 + 1; // eslint-disable-line no-unused-expressions
|
2018-03-06 18:42:37 +00:00
|
|
|
} else {
|
|
|
|
tmpdir.refresh();
|
|
|
|
|
|
|
|
const proc = cp.fork(__filename,
|
|
|
|
[ 'child' ], {
|
2018-10-16 17:28:52 +00:00
|
|
|
cwd: tmpdir.path,
|
2018-03-06 18:42:37 +00:00
|
|
|
execArgv: [
|
|
|
|
'--trace-event-categories',
|
2021-03-26 15:51:08 +00:00
|
|
|
'node.bootstrap',
|
2018-03-06 18:42:37 +00:00
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
proc.once('exit', common.mustCall(() => {
|
2023-08-15 13:45:34 +00:00
|
|
|
const file = tmpdir.resolve('node_trace.1.log');
|
2018-03-06 18:42:37 +00:00
|
|
|
|
2018-08-06 13:47:11 +00:00
|
|
|
assert(fs.existsSync(file));
|
2023-09-25 12:24:14 +00:00
|
|
|
fs.readFile(file, common.mustSucceed((data) => {
|
2018-05-15 18:52:18 +00:00
|
|
|
const traces = JSON.parse(data.toString()).traceEvents
|
|
|
|
.filter((trace) => trace.cat !== '__metadata');
|
2018-03-06 18:42:37 +00:00
|
|
|
traces.forEach((trace) => {
|
|
|
|
assert.strictEqual(trace.pid, proc.pid);
|
|
|
|
assert(names.includes(trace.name));
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}
|