0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/common/shared-lib-util.js
Yihong Wang b325b5b435
test: fix test-abort-backtrace in shared lib build
When using shared lib build, the binary path in the stack frames points
to shared lib. Change the checking criteria in the test case to match
that.

Refs: https://github.com/nodejs/node/issues/18535

Signed-off-by: Yihong Wang <yh.wang@ibm.com>

PR-URL: https://github.com/nodejs/node/pull/19213
Refs: https://github.com/nodejs/node/issues/18535
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-11 04:04:14 +01:00

50 lines
1.5 KiB
JavaScript

'use strict';
const common = require('../common');
const path = require('path');
// If node executable is linked to shared lib, need to take care about the
// shared lib path.
exports.addLibraryPath = function(env) {
if (!process.config.variables.node_shared) {
return;
}
env = env || process.env;
env.LD_LIBRARY_PATH =
(env.LD_LIBRARY_PATH ? env.LD_LIBRARY_PATH + path.delimiter : '') +
path.join(path.dirname(process.execPath), 'lib.target');
// For AIX.
env.LIBPATH =
(env.LIBPATH ? env.LIBPATH + path.delimiter : '') +
path.join(path.dirname(process.execPath), 'lib.target');
// For Mac OSX.
env.DYLD_LIBRARY_PATH =
(env.DYLD_LIBRARY_PATH ? env.DYLD_LIBRARY_PATH + path.delimiter : '') +
path.dirname(process.execPath);
// For Windows.
env.PATH =
(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}`);
}
};
// Get the binary path of stack frames.
exports.getBinaryPath = function() {
return process.config.variables.node_shared ?
exports.getSharedLibPath() : process.execPath;
};