mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net> PR-URL: https://github.com/nodejs/node/pull/66068 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
'use strict';
|
|
// Flags: --expose-internals
|
|
|
|
const common = require('../common');
|
|
const { it } = require('node:test');
|
|
|
|
try {
|
|
require('trace_events');
|
|
} catch {
|
|
common.skip('missing trace events');
|
|
}
|
|
|
|
// Perfetto aborts on a category that is not in its static registry, and its
|
|
// enabled flag does not follow createTracing().enable().
|
|
common.skipIfPerfettoEnabled();
|
|
|
|
const { createTracing, getEnabledCategories } = require('trace_events');
|
|
const assert = require('assert');
|
|
|
|
const { categoryEnabledChecker } = require('internal/trace_events');
|
|
|
|
it('should track enabled/disabled categories', () => {
|
|
const random = Math.random().toString().slice(2);
|
|
const category = `node.${random}`;
|
|
|
|
const isEnabled = categoryEnabledChecker(category);
|
|
|
|
const tracing = createTracing({
|
|
categories: [category],
|
|
});
|
|
|
|
assert.strictEqual(isEnabled(), false);
|
|
|
|
tracing.enable();
|
|
|
|
let currentCategories = getEnabledCategories();
|
|
|
|
assert.ok(currentCategories.includes(category), `the getEnabledCategories should include ${category}, got: ${currentCategories}`);
|
|
assert.strictEqual(isEnabled(), true);
|
|
|
|
tracing.disable();
|
|
|
|
currentCategories = getEnabledCategories();
|
|
assert.ok(currentCategories === undefined, `the getEnabledCategories should return undefined, got: ${currentCategories}`);
|
|
assert.strictEqual(isEnabled(), false);
|
|
});
|