mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
4f434187ff
PR-URL: https://github.com/nodejs/node/pull/30125 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
24 lines
976 B
JavaScript
24 lines
976 B
JavaScript
'use strict';
|
|
const common = require('../../common');
|
|
|
|
if (common.isWindows)
|
|
common.skip('dlopen global symbol loading is not supported on this os.');
|
|
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
const os = require('os');
|
|
|
|
const bindingPath = require.resolve(`./build/${common.buildType}/binding`);
|
|
console.log('process.dlopen:', bindingPath);
|
|
process.dlopen(module, bindingPath,
|
|
os.constants.dlopen.RTLD_NOW | os.constants.dlopen.RTLD_GLOBAL);
|
|
console.log('module.exports.load:', `${path.dirname(bindingPath)}/ping.so`);
|
|
module.exports.load(`${path.dirname(bindingPath)}/ping.so`);
|
|
assert.strictEqual(module.exports.ping(), 'pong');
|
|
|
|
// Check that after the addon is loaded with
|
|
// process.dlopen() a require() call fails.
|
|
console.log('require:', `./build/${common.buildType}/binding`);
|
|
const re = /^Error: Module did not self-register: '.*[\\/]binding\.node'\.$/;
|
|
assert.throws(() => require(`./build/${common.buildType}/binding`), re);
|