src,test: disable trace events tests when perfetto is enabled

Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net>
PR-URL: https://github.com/nodejs/node/pull/64721
Fixes: https://github.com/nodejs/diagnostics/issues/654
Refs: https://github.com/nodejs/node/pull/64565
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Chengzhong Wu authored and Antoine du Hamel committed 2026-08-05 11:15:07 +02:00
1 parent a8ec5a9df7
commit 69d10ed021
34 files changed
+99 -3

No files matched your search

+2 -2
View File
@@ -14,13 +14,13 @@ const bench = common.createBenchmark(main, {
});
const {
TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN: kBeforeEvent,
TRACE_EVENT_PHASE_BEGIN: kBeginEvent,
} = common.binding('constants').trace;
function doTrace(n, trace) {
bench.start();
for (let i = 0; i < n; i++) {
trace(kBeforeEvent, 'foo', 'test', 0, 'test');
trace(kBeginEvent, 'foo', 'test', 0, 'test');
}
bench.end(n);
}
+1
View File
@@ -61,6 +61,7 @@ void NODE_EXTERN_PRIVATE FWrite(FILE* file, const std::string& str);
V(MODULE) \
V(MKSNAPSHOT) \
V(SNAPSHOT_SERDES) \
V(PERFETTO) \
V(PERMISSION_MODEL) \
V(PLATFORM_MINIMAL) \
V(PLATFORM_VERBOSE) \
+25
View File
@@ -30,6 +30,30 @@ std::set<std::string> flatten(
return result;
}
void perfetto_log_callback(perfetto::LogMessageCallbackArgs args) {
const char* level_str = "UNKNOWN";
switch (args.level) {
case perfetto::base::kLogDebug:
level_str = "DEBUG";
break;
case perfetto::base::kLogInfo:
level_str = "INFO";
break;
case perfetto::base::kLogImportant:
level_str = "IMPORTANT";
break;
case perfetto::base::kLogError:
level_str = "ERROR";
break;
}
per_process::Debug(DebugCategory::PERFETTO,
"[%s] %s:%d: %s\n",
level_str,
args.filename,
args.line,
args.message);
}
} // namespace
// Writes trace chunks to a file, rotating by size. It deliberately uses the
@@ -252,6 +276,7 @@ PerfettoTracingAgent::PerfettoTracingAgent() {
// Set up the in-process backend that the tracing controller will connect
// to.
perfetto::TracingInitArgs init_args;
init_args.log_message_callback = perfetto_log_callback;
init_args.backends = perfetto::BackendType::kInProcessBackend;
perfetto::Tracing::Initialize(init_args);
+15
View File
@@ -71,6 +71,7 @@ const hasCrypto = Boolean(process.versions.openssl) &&
const hasInspector = Boolean(process.features.inspector);
const hasSQLite = Boolean(process.versions.sqlite);
const hasFFI = Boolean(process.config.variables.node_use_ffi);
const hasPerfetto = Boolean(process.config.variables.v8_use_perfetto);
const hasQuic = hasCrypto && !!process.features.quic;
@@ -768,6 +769,18 @@ function skipIfFFIMissing() {
}
}
function skipIfPerfettoEnabled() {
if (hasPerfetto) {
skip('Perfetto is enabled');
}
}
function skipIfPerfettoDisabled() {
if (!hasPerfetto) {
skip('Perfetto is disabled');
}
}
function getArrayBufferViews(buf) {
const { buffer, byteOffset, byteLength } = buf;
@@ -1045,6 +1058,8 @@ const common = {
skipIfInspectorDisabled,
skipIfFFIMissing,
skipIfSQLiteMissing,
skipIfPerfettoEnabled,
skipIfPerfettoDisabled,
spawnPromisified,
sleepSync,
usesSharedLibrary,
+2
View File
@@ -52,6 +52,7 @@ const {
skipIfEslintMissing,
skipIfInspectorDisabled,
skipIfSQLiteMissing,
skipIfPerfettoEnabled,
spawnPromisified,
sleepSync,
} = common;
@@ -109,6 +110,7 @@ export {
skipIfEslintMissing,
skipIfInspectorDisabled,
skipIfSQLiteMissing,
skipIfPerfettoEnabled,
spawnPromisified,
sleepSync,
};
@@ -3,6 +3,7 @@
const common = require('../common');
common.skipIfInspectorDisabled();
common.skipIfPerfettoEnabled();
const { isMainThread } = require('worker_threads');
+2 -1
View File
@@ -1,4 +1,4 @@
import { isWindows } from '../common/index.mjs';
import { isWindows, skipIfPerfettoEnabled } from '../common/index.mjs';
import assert from 'node:assert';
import { writeFileSync } from 'node:fs';
import { readFile } from 'node:fs/promises';
@@ -7,6 +7,7 @@ import tmpdir from '../common/tmpdir.js';
import { spawnSyncAndAssert } from '../common/child_process.js';
import fixtures from '../common/fixtures.js';
skipIfPerfettoEnabled();
tmpdir.refresh();
it('should print the timing information for cjs', () => {
@@ -5,6 +5,7 @@ const common = require('../common');
const { spawnSyncAndExitWithoutError } = require('../common/child_process');
const { isMainThread } = require('worker_threads');
common.skipIfPerfettoEnabled();
if (!isMainThread) {
common.skip('This test only works on a main thread');
}
+2
View File
@@ -4,6 +4,8 @@ const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
common.skipIfPerfettoEnabled();
const CODE =
'setTimeout(() => { for (let i = 0; i < 100000; i++) { "test" + i } }, 1)';
+2
View File
@@ -4,6 +4,8 @@
const common = require('../common');
const { isMainThread } = require('worker_threads');
common.skipIfPerfettoEnabled();
if (!isMainThread) {
// https://github.com/nodejs/node/issues/22767
common.skip('This test only works on a main thread');
@@ -10,6 +10,8 @@ try {
common.skip('missing trace events');
}
common.skipIfPerfettoEnabled();
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
@@ -10,6 +10,8 @@ try {
common.skip('missing trace events');
}
common.skipIfPerfettoEnabled();
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
@@ -5,6 +5,8 @@ const cp = require('child_process');
const fs = require('fs');
const util = require('util');
common.skipIfPerfettoEnabled();
const CODE =
'setTimeout(() => { for (let i = 0; i < 100000; i++) { "test" + i } }, 1)';
@@ -4,6 +4,8 @@ const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
common.skipIfPerfettoEnabled();
const CODE = `
const { internalBinding } = require('internal/test/binding');
const { trace } = internalBinding('trace_events');
@@ -5,6 +5,8 @@ const cp = require('child_process');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
common.skipIfPerfettoEnabled();
const names = [
'environment',
'nodeStart',
@@ -5,6 +5,8 @@ const cp = require('child_process');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
common.skipIfPerfettoEnabled();
// Tests that node.console trace events for counters and time methods are
// emitted as expected.
@@ -4,6 +4,7 @@
const common = require('../common');
common.skipIfInspectorDisabled();
common.skipIfPerfettoEnabled();
const { isMainThread } = require('worker_threads');
@@ -7,6 +7,8 @@ const cp = require('child_process');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
common.skipIfPerfettoEnabled();
// This tests the emission of node.environment trace events
const names = new Set([
@@ -5,6 +5,8 @@ const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
common.skipIfPerfettoEnabled();
tmpdir.refresh();
const CODE =
@@ -5,6 +5,8 @@ const cp = require('child_process');
const fs = require('fs');
const util = require('util');
common.skipIfPerfettoEnabled();
const tests = { __proto__: null };
let gid = 1;
@@ -5,6 +5,8 @@ const cp = require('child_process');
const fs = require('fs');
const util = require('util');
common.skipIfPerfettoEnabled();
const tests = { __proto__: null };
let gid = 1;
@@ -10,6 +10,8 @@ try {
common.skip('missing trace events');
}
common.skipIfPerfettoEnabled();
const { createTracing, getEnabledCategories } = require('trace_events');
const assert = require('assert');
+2
View File
@@ -5,6 +5,8 @@ const cp = require('child_process');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
common.skipIfPerfettoEnabled();
const CODE = `
const http = require('http');
const server = http.createServer((req, res) => {
@@ -4,6 +4,8 @@ const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
common.skipIfPerfettoEnabled();
const CODE =
'setTimeout(() => { for (let i = 0; i < 100000; i++) { "test" + i } }, 1);' +
'process.title = "foo"';
@@ -6,6 +6,7 @@ const fs = require('fs');
const tmpdir = require('../common/tmpdir');
if (!common.isLinux) common.skip();
common.skipIfPerfettoEnabled();
const CODE = `
const net = require('net');
+2
View File
@@ -5,6 +5,8 @@ const cp = require('child_process');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
common.skipIfPerfettoEnabled();
const CODE = `
const net = require('net');
const socket = net.connect('${common.PIPE}');
+2
View File
@@ -4,6 +4,8 @@ const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
common.skipIfPerfettoEnabled();
const CODE =
'setTimeout(() => { for (let i = 0; i < 100000; i++) { "test" + i } }, 1)';
@@ -4,6 +4,8 @@ const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
common.skipIfPerfettoEnabled();
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const FILE_NAME = tmpdir.resolve('node_trace.1.log');
@@ -5,6 +5,8 @@ const cp = require('child_process');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
common.skipIfPerfettoEnabled();
if (process.argv[2] === 'child') {
const p = Promise.reject(1); // Handled later
Promise.reject(2); // Unhandled
@@ -6,6 +6,8 @@ const fs = require('fs');
const tmpdir = require('../common/tmpdir');
const { scheduler } = require('timers/promises');
common.skipIfPerfettoEnabled();
if (!common.hasCrypto)
common.skip('missing crypto');
+2
View File
@@ -4,6 +4,8 @@ const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
common.skipIfPerfettoEnabled();
const CODE =
'setTimeout(() => { for (let i = 0; i < 100000; i++) { "test" + i } }, 1)';
+2
View File
@@ -5,6 +5,8 @@ const cp = require('child_process');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
common.skipIfPerfettoEnabled();
const names = [
'ContextifyScript::New',
'RunInContext',
@@ -5,6 +5,8 @@ const cp = require('child_process');
const fs = require('fs');
const { isMainThread } = require('worker_threads');
common.skipIfPerfettoEnabled();
if (isMainThread) {
const CODE = 'const { Worker } = require(\'worker_threads\'); ' +
`new Worker(${JSON.stringify(__filename)}, { name: 'foo' })`;
@@ -5,6 +5,8 @@ const cp = require('child_process');
const fs = require('fs');
const { isMainThread } = require('worker_threads');
common.skipIfPerfettoEnabled();
if (isMainThread) {
const CODE = 'const { Worker } = require(\'worker_threads\'); ' +
`new Worker(${JSON.stringify(__filename)})`;