diff options
author | cjihrig <cjihrig@gmail.com> | 2019-07-23 19:13:30 -0400 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2019-08-03 07:25:52 -1000 |
commit | 1592d0ab737f6537bd57cfed31277715afdf609c (patch) | |
tree | 68aa8fcd29ed16658b28a6da30a57249235ee8da /test/common/report.js | |
parent | 747ddd5fac191d018c6e9720f21d3ea66872d667 (diff) | |
download | node-new-1592d0ab737f6537bd57cfed31277715afdf609c.tar.gz |
report: include network interfaces in report
PR-URL: https://github.com/nodejs/node/pull/28911
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'test/common/report.js')
-rw-r--r-- | test/common/report.js | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/test/common/report.js b/test/common/report.js index be1da58ff9..fdb15924ca 100644 --- a/test/common/report.js +++ b/test/common/report.js @@ -2,6 +2,7 @@ 'use strict'; const assert = require('assert'); const fs = require('fs'); +const net = require('net'); const os = require('os'); const path = require('path'); const util = require('util'); @@ -73,7 +74,7 @@ function _validateContent(report) { 'componentVersions', 'release', 'osName', 'osRelease', 'osVersion', 'osMachine', 'cpus', 'host', 'glibcVersionRuntime', 'glibcVersionCompiler', 'cwd', - 'reportVersion']; + 'reportVersion', 'networkInterfaces']; checkForUnknownFields(header, headerFields); assert.strictEqual(header.reportVersion, 1); // Increment as needed. assert.strictEqual(typeof header.event, 'string'); @@ -112,6 +113,28 @@ function _validateContent(report) { return c.model === cpu.model; })); }); + + assert(Array.isArray(header.networkInterfaces)); + header.networkInterfaces.forEach((iface) => { + assert.strictEqual(typeof iface.name, 'string'); + assert.strictEqual(typeof iface.internal, 'boolean'); + assert(/^([0-9A-F][0-9A-F]:){5}[0-9A-F]{2}$/i.test(iface.mac)); + + if (iface.family === 'IPv4') { + assert.strictEqual(net.isIPv4(iface.address), true); + assert.strictEqual(net.isIPv4(iface.netmask), true); + assert.strictEqual(iface.scopeid, undefined); + } else if (iface.family === 'IPv6') { + assert.strictEqual(net.isIPv6(iface.address), true); + assert.strictEqual(net.isIPv6(iface.netmask), true); + assert(Number.isInteger(iface.scopeid)); + } else { + assert.strictEqual(iface.family, 'unknown'); + assert.strictEqual(iface.address, undefined); + assert.strictEqual(iface.netmask, undefined); + assert.strictEqual(iface.scopeid, undefined); + } + }); assert.strictEqual(header.host, os.hostname()); // Verify the format of the javascriptStack section. |