electron/spec/fixtures/native-addon/uv-dlopen/main.cpp
Jeremy Rose db7c92fd57
test: drop now-empty remote runner (#35343)
* test: drop the now-empty remote runner from CI

* move fixtures to spec-main

* remove remote runner

* fix stuff

* remove global-paths hack

* move ts-smoke to spec/

* fix test after merge

* rename spec-main to spec

* no need to ignore spec/node_modules twice

* simplify spec-runner a little

* no need to hash pj/yl twice

* undo lint change to verify-mksnapshot.py

* excessive ..

* update electron_woa_testing.yml

* don't search for test-results-remote.xml

it is never produced now
2022-08-16 15:23:13 -04:00

46 lines
No EOL
1.2 KiB
C++

#include <node_api.h>
#include <uv.h>
namespace test_module {
napi_value TestLoadLibrary(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value argv;
napi_status status;
status = napi_get_cb_info(env, info, &argc, &argv, NULL, NULL);
if (status != napi_ok)
napi_fatal_error(NULL, 0, NULL, 0);
char lib_path[256];
status = napi_get_value_string_utf8(env, argv, lib_path, 256, NULL);
if (status != napi_ok)
napi_fatal_error(NULL, 0, NULL, 0);
uv_lib_t lib;
auto uv_status = uv_dlopen(lib_path, &lib);
if (uv_status == 0) {
napi_value result;
status = napi_get_boolean(env, true, &result);
if (status != napi_ok)
napi_fatal_error(NULL, 0, NULL, 0);
return result;
} else {
status = napi_throw_error(env, NULL, uv_dlerror(&lib));
if (status != napi_ok)
napi_fatal_error(NULL, 0, NULL, 0);
}
}
napi_value Init(napi_env env, napi_value exports) {
napi_value method;
napi_status status;
status = napi_create_function(env, "testLoadLibrary", NAPI_AUTO_LENGTH,
TestLoadLibrary, NULL, &method);
if (status != napi_ok)
return NULL;
return method;
}
NAPI_MODULE(TestLoadLibrary, Init);
} // namespace test_module