node/test/addons/openssl-test-engine/testsetengine.cc
Michael Dawson 5f348b4572 test: move test-crypto-engine to addon
Fixes: https://github.com/nodejs/node/issues/41633
Fixes: https://github.com/nodejs/node/issues/40958

- move test-crypto-engine so that dummy engine
  is only built if tests are run

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: https://github.com/nodejs/node/pull/41830
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2022-02-07 17:29:54 -05:00

44 lines
941 B
C++

#include <openssl/engine.h>
#ifndef ENGINE_CMD_BASE
# error did not get engine.h
#endif
#define TEST_ENGINE_ID "testsetengine"
#define TEST_ENGINE_NAME "dummy test engine"
#ifdef _WIN32
# define DEFAULT_VISIBILITY __declspec(dllexport)
#else
# define DEFAULT_VISIBILITY __attribute__((visibility("default")))
#endif
namespace {
int EngineInit(ENGINE* engine) {
return 1;
}
int EngineFinish(ENGINE* engine) {
return 1;
}
int EngineDestroy(ENGINE* engine) {
return 1;
}
int bind_fn(ENGINE* engine, const char* id) {
ENGINE_set_id(engine, TEST_ENGINE_ID);
ENGINE_set_name(engine, TEST_ENGINE_NAME);
ENGINE_set_init_function(engine, EngineInit);
ENGINE_set_finish_function(engine, EngineFinish);
ENGINE_set_destroy_function(engine, EngineDestroy);
return 1;
}
extern "C" {
DEFAULT_VISIBILITY IMPLEMENT_DYNAMIC_CHECK_FN();
DEFAULT_VISIBILITY IMPLEMENT_DYNAMIC_BIND_FN(bind_fn);
}
} // anonymous namespace