Skip to content

Commit 69d10ed

Browse files
legendecasaduh95
authored andcommitted
src,test: disable trace events tests when perfetto is enabled
Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net> PR-URL: #64721Fixes: nodejs/diagnostics#654 Refs: #64565 Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent a8ec5a9 commit 69d10ed

34 files changed

Lines changed: 99 additions & 3 deletions

‎benchmark/misc/trace.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ const bench = common.createBenchmark(main, {
1414
});
1515

1616
const{
17-
TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN: kBeforeEvent,
17+
TRACE_EVENT_PHASE_BEGIN: kBeginEvent,
1818
}=common.binding('constants').trace;
1919

2020
functiondoTrace(n,trace){
2121
bench.start();
2222
for(leti=0;i<n;i++){
23-
trace(kBeforeEvent,'foo','test',0,'test');
23+
trace(kBeginEvent,'foo','test',0,'test');
2424
}
2525
bench.end(n);
2626
}

‎src/debug_utils.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ void NODE_EXTERN_PRIVATE FWrite(FILE* file, const std::string& str);
6161
V(MODULE) \
6262
V(MKSNAPSHOT) \
6363
V(SNAPSHOT_SERDES) \
64+
V(PERFETTO) \
6465
V(PERMISSION_MODEL) \
6566
V(PLATFORM_MINIMAL) \
6667
V(PLATFORM_VERBOSE) \

‎src/tracing/agent_perfetto.cc‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,30 @@ std::set<std::string> flatten(
3030
return result;
3131
}
3232

33+
voidperfetto_log_callback(perfetto::LogMessageCallbackArgs args) {
34+
constchar* level_str = "UNKNOWN";
35+
switch (args.level) {
36+
case perfetto::base::kLogDebug:
37+
level_str = "DEBUG";
38+
break;
39+
case perfetto::base::kLogInfo:
40+
level_str = "INFO";
41+
break;
42+
case perfetto::base::kLogImportant:
43+
level_str = "IMPORTANT";
44+
break;
45+
case perfetto::base::kLogError:
46+
level_str = "ERROR";
47+
break;
48+
}
49+
per_process::Debug(DebugCategory::PERFETTO,
50+
"[%s] %s:%d: %s\n",
51+
level_str,
52+
args.filename,
53+
args.line,
54+
args.message);
55+
}
56+
3357
} // namespace
3458

3559
// Writes trace chunks to a file, rotating by size. It deliberately uses the
@@ -252,6 +276,7 @@ PerfettoTracingAgent::PerfettoTracingAgent() {
252276
// Set up the in-process backend that the tracing controller will connect
253277
// to.
254278
perfetto::TracingInitArgs init_args;
279+
init_args.log_message_callback = perfetto_log_callback;
255280
init_args.backends = perfetto::BackendType::kInProcessBackend;
256281
perfetto::Tracing::Initialize(init_args);
257282

‎test/common/index.js‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const hasCrypto = Boolean(process.versions.openssl) &&
7171
consthasInspector=Boolean(process.features.inspector);
7272
consthasSQLite=Boolean(process.versions.sqlite);
7373
consthasFFI=Boolean(process.config.variables.node_use_ffi);
74+
consthasPerfetto=Boolean(process.config.variables.v8_use_perfetto);
7475

7576
consthasQuic=hasCrypto&&!!process.features.quic;
7677

@@ -768,6 +769,18 @@ function skipIfFFIMissing() {
768769
}
769770
}
770771

772+
functionskipIfPerfettoEnabled(){
773+
if(hasPerfetto){
774+
skip('Perfetto is enabled');
775+
}
776+
}
777+
778+
functionskipIfPerfettoDisabled(){
779+
if(!hasPerfetto){
780+
skip('Perfetto is disabled');
781+
}
782+
}
783+
771784
functiongetArrayBufferViews(buf){
772785
const{ buffer, byteOffset, byteLength }=buf;
773786

@@ -1045,6 +1058,8 @@ const common = {
10451058
skipIfInspectorDisabled,
10461059
skipIfFFIMissing,
10471060
skipIfSQLiteMissing,
1061+
skipIfPerfettoEnabled,
1062+
skipIfPerfettoDisabled,
10481063
spawnPromisified,
10491064
sleepSync,
10501065
usesSharedLibrary,

‎test/common/index.mjs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const {
5252
skipIfEslintMissing,
5353
skipIfInspectorDisabled,
5454
skipIfSQLiteMissing,
55+
skipIfPerfettoEnabled,
5556
spawnPromisified,
5657
sleepSync,
5758
}=common;
@@ -109,6 +110,7 @@ export {
109110
skipIfEslintMissing,
110111
skipIfInspectorDisabled,
111112
skipIfSQLiteMissing,
113+
skipIfPerfettoEnabled,
112114
spawnPromisified,
113115
sleepSync,
114116
};

‎test/parallel/test-inspector-tracing-domain.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
constcommon=require('../common');
44

55
common.skipIfInspectorDisabled();
6+
common.skipIfPerfettoEnabled();
67

78
const{ isMainThread }=require('worker_threads');
89

‎test/parallel/test-module-print-timing.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{isWindows}from'../common/index.mjs';
1+
import{isWindows,skipIfPerfettoEnabled}from'../common/index.mjs';
22
importassertfrom'node:assert';
33
import{writeFileSync}from'node:fs';
44
import{readFile}from'node:fs/promises';
@@ -7,6 +7,7 @@ import tmpdir from '../common/tmpdir.js';
77
import{spawnSyncAndAssert}from'../common/child_process.js';
88
importfixturesfrom'../common/fixtures.js';
99

10+
skipIfPerfettoEnabled();
1011
tmpdir.refresh();
1112

1213
it('should print the timing information for cjs',()=>{

‎test/parallel/test-permission-fs-write-trace-events.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const common = require('../common');
55
const{ spawnSyncAndExitWithoutError }=require('../common/child_process');
66
const{ isMainThread }=require('worker_threads');
77

8+
common.skipIfPerfettoEnabled();
89
if(!isMainThread){
910
common.skip('This test only works on a main thread');
1011
}

‎test/parallel/test-trace-events-all.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const assert = require('assert');
44
constcp=require('child_process');
55
constfs=require('fs');
66

7+
common.skipIfPerfettoEnabled();
8+
79
constCODE=
810
'setTimeout(() => { for (let i = 0; i < 100000; i++) { "test" + i } }, 1)';
911

‎test/parallel/test-trace-events-api.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
constcommon=require('../common');
55
const{ isMainThread }=require('worker_threads');
66

7+
common.skipIfPerfettoEnabled();
8+
79
if(!isMainThread){
810
// https://github.com/nodejs/node/issues/22767
911
common.skip('This test only works on a main thread');

0 commit comments

Comments
 (0)