From 17a1691af83f358b90d5d2ec202c81083fd78ade Mon Sep 17 00:00:00 2001 From: Yihong Wang Date: Thu, 15 Feb 2018 13:39:13 -0800 Subject: [PATCH] test: check symbols in shared lib When building the node with `--shared` option, we need to verify the symbols in shared lib instead of executable. Refs: https://github.com/nodejs/node/issues/18535 Signed-off-by: Yihong Wang PR-URL: https://github.com/nodejs/node/pull/18806 Refs: https://github.com/nodejs/node/issues/18535 Reviewed-By: Richard Lau Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gibson Fahnestock Reviewed-By: Yuta Hiroto Reviewed-By: Anna Henningsen --- test/common/shared-lib-util.js | 16 +++++++++++++++- test/parallel/test-postmortem-metadata.js | 8 +++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/test/common/shared-lib-util.js b/test/common/shared-lib-util.js index 5699c4f74c6463..963c6ee1391d8e 100644 --- a/test/common/shared-lib-util.js +++ b/test/common/shared-lib-util.js @@ -1,5 +1,5 @@ -/* eslint-disable node-core/required-modules */ 'use strict'; +const common = require('../common'); const path = require('path'); // If node executable is linked to shared lib, need to take care about the @@ -27,3 +27,17 @@ exports.addLibraryPath = function(env) { (env.PATH ? env.PATH + path.delimiter : '') + path.dirname(process.execPath); }; + +// Get the full path of shared lib +exports.getSharedLibPath = function() { + if (common.isWindows) { + return path.join(path.dirname(process.execPath), 'node.dll'); + } else if (common.isOSX) { + return path.join(path.dirname(process.execPath), + `libnode.${process.config.variables.shlib_suffix}`); + } else { + return path.join(path.dirname(process.execPath), + 'lib.target', + `libnode.${process.config.variables.shlib_suffix}`); + } +}; diff --git a/test/parallel/test-postmortem-metadata.js b/test/parallel/test-postmortem-metadata.js index 72a65d32a610bf..0438f7fccb71c1 100644 --- a/test/parallel/test-postmortem-metadata.js +++ b/test/parallel/test-postmortem-metadata.js @@ -7,7 +7,13 @@ const common = require('../common'); const assert = require('assert'); const { spawnSync } = require('child_process'); -const args = [process.execPath]; +const { getSharedLibPath } = require('../common/shared-lib-util.js'); + +// For shared lib case, check shared lib instead +const args = [ + process.config.variables.node_shared ? + getSharedLibPath() : process.execPath +]; if (common.isAIX) args.unshift('-Xany', '-B');