From 3eb9373095ceca3246f62353378957eb57f05d65 Mon Sep 17 00:00:00 2001 From: jBarz Date: Mon, 12 Dec 2016 23:56:24 -0500 Subject: [PATCH] os: fix os.release() for aix and add test PR-URL: https://github.com/nodejs/node/pull/10245 Reviewed-By: Michael Dawson Reviewed-By: Gibson Fahnestock Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- src/node_os.cc | 7 +++++++ test/parallel/test-os.js | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/node_os.cc b/src/node_os.cc index d8276f463d6625..f8b53e45d8e669 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -85,7 +85,14 @@ static void GetOSRelease(const FunctionCallbackInfo& args) { if (uname(&info) < 0) { return env->ThrowErrnoException(errno, "uname"); } +# ifdef _AIX + char release[256]; + snprintf(release, sizeof(release), + "%s.%s", info.version, info.release); + rval = release; +# else rval = info.release; +# endif #else // Windows char release[256]; OSVERSIONINFOW info; diff --git a/test/parallel/test-os.js b/test/parallel/test-os.js index fa78b9dc988e8f..5a0a9f6ad14cbc 100644 --- a/test/parallel/test-os.js +++ b/test/parallel/test-os.js @@ -77,6 +77,9 @@ const release = os.release(); console.log('release = ', release); is.string(release); assert.ok(release.length > 0); +//TODO: Check format on more than just AIX +if (common.isAix) + assert.ok(/^\d+\.\d+$/.test(release)); const platform = os.platform(); console.log('platform = ', platform);