From adee99883a63d475d0239724b4d580eab7736bd6 Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Wed, 2 Oct 2019 14:47:08 -0700 Subject: [PATCH] test: debug output for dlopen-ping-pong test Make test failures easier to diagnose through progress logging, and reporting of dlerror(). PR-URL: https://github.com/nodejs/node/pull/29818 Reviewed-By: Rich Trott Reviewed-By: Richard Lau Reviewed-By: Christian Clauss Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater Reviewed-By: Ben Noordhuis --- test/addons/dlopen-ping-pong/binding.cc | 1 + test/addons/dlopen-ping-pong/test.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/test/addons/dlopen-ping-pong/binding.cc b/test/addons/dlopen-ping-pong/binding.cc index 6a6c297b52fff9..ecdabd5e0f4eef 100644 --- a/test/addons/dlopen-ping-pong/binding.cc +++ b/test/addons/dlopen-ping-pong/binding.cc @@ -26,6 +26,7 @@ static ping ping_func; void LoadLibrary(const FunctionCallbackInfo& args) { const String::Utf8Value filename(args.GetIsolate(), args[0]); void* handle = dlopen(*filename, RTLD_LAZY); + if (handle == nullptr) fprintf(stderr, "%s\n", dlerror()); assert(handle != nullptr); ping_func = reinterpret_cast(dlsym(handle, "dlopen_ping")); assert(ping_func != nullptr); diff --git a/test/addons/dlopen-ping-pong/test.js b/test/addons/dlopen-ping-pong/test.js index c533593496090a..c5b8c16493f60f 100644 --- a/test/addons/dlopen-ping-pong/test.js +++ b/test/addons/dlopen-ping-pong/test.js @@ -9,12 +9,15 @@ 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\.$/; assert.throws(() => require(`./build/${common.buildType}/binding`), re);