Skip to content
This repository was archived by the owner on Jun 18, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/node_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,13 @@ static void PrintVersionInformation(std::ostream& out) {
// Print operating system and machine information (Unix/OSX)
struct utsname os_info;
if (uname(&os_info) == 0) {
#if defined(_AIX)
out << "\nOS version: " << os_info.sysname << " " << os_info.version << "."
<< os_info.release << "\n";
#else
out << "\nOS version: " << os_info.sysname << " " << os_info.release << " "
<< os_info.version << "\n";
#endif
#if defined(__GLIBC__)
out << "(glibc: "<< __GLIBC__ << "." << __GLIBC_MINOR__ << ")\n";
#endif
Expand Down
33 changes: 33 additions & 0 deletions test/test-os-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';

// Testcase for validating reported OS version

const common = require('./common.js');
const nodereport = require('../');
const os = require('os');
const tap = require('tap');

const os_map = {
'aix': 'AIX',
'darwin': 'Darwin',
'linux': 'Linux',
'win32': 'Windows',
};
const os_name = os_map[os.platform()];
const report_str = nodereport.getReport();
const version_str = report_str.match(/OS version: .*(?:\r*\n)/);
if (common.isWindows()) {
tap.match(version_str,
new RegExp('OS version: ' + os_name), 'Checking OS version');
} else if (common.isAIX() && !os.release().includes('.')) {
// For Node.js prior to os.release() fix for AIX:
// https://github.com/nodejs/node/pull/10245
tap.match(version_str,
new RegExp('OS version: ' + os_name + ' \\d+.' + os.release()),
'Checking OS version');
} else {
tap.match(version_str,
new RegExp('OS version: ' + os_name + ' .*' + os.release()),
'Checking OS version');
}