forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
report: add
--report-network-disabled
option
Adds a new option `process.report.networkDisabled` and cli option `--report-network-disabled` which will disable any netowkring operations for the `report` generation. Fixes: nodejs#46060
- Loading branch information
1 parent
68885d5
commit 2d5fb4e
Showing
10 changed files
with
123 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "node.h" | ||
#include "node_report.h" | ||
|
||
#include <string> | ||
#include "gtest/gtest.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict'; | ||
require('../common'); | ||
const assert = require('node:assert'); | ||
const { spawnSync } = require('node:child_process'); | ||
const tmpdir = require('../common/tmpdir'); | ||
const { describe, it, before } = require('node:test'); | ||
const fs = require('node:fs'); | ||
const helper = require('../common/report'); | ||
|
||
function validate(pid) { | ||
const reports = helper.findReports(pid, tmpdir.path); | ||
assert.strictEqual(reports.length, 1); | ||
let report = fs.readFileSync(reports[0], { encoding: 'utf8' }); | ||
report = JSON.parse(report); | ||
assert.strictEqual(report.header.networkInterfaces, undefined); | ||
fs.unlinkSync(reports[0]); | ||
} | ||
|
||
describe('report network disabled option', () => { | ||
before(() => { | ||
tmpdir.refresh(); | ||
process.report.directory = tmpdir.path; | ||
}); | ||
|
||
it('should be configurable with --report-network-disabled', () => { | ||
const args = ['--report-network-disabled', '-e', 'process.report.writeReport()']; | ||
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path }); | ||
assert.strictEqual(child.status, 0); | ||
assert.strictEqual(child.signal, null); | ||
validate(child.pid); | ||
}); | ||
|
||
it('should be configurable with report.networkDisabled', () => { | ||
process.report.networkDisabled = true; | ||
process.report.writeReport(); | ||
validate(process.pid); | ||
|
||
const report = process.report.getReport(); | ||
assert.strictEqual(report.header.networkInterfaces, undefined); | ||
}); | ||
}); |
Large diffs are not rendered by default.
Oops, something went wrong.