Skip to content

Commit a032ade

Browse files
committed
test: fixed failures
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
1 parent e04304c commit a032ade

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ v8: ## Build deps/v8.
318318
tools/make-v8.sh $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS)
319319

320320
.PHONY: jstest
321-
jstest: build-addons build-js-native-api-tests build-node-api-tests build-sqlite-tests ## Run addon tests and JS tests.
321+
jstest: build-addons build-js-native-api-tests build-node-api-tests build-sqlite-tests build-ffi-tests ## Run addon tests and JS tests.
322322
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) \
323323
$(TEST_CI_ARGS) \
324324
--skip-tests=$(CI_SKIP_TESTS) \
@@ -344,6 +344,7 @@ test: all ## Run default tests and build docs.
344344
$(MAKE) -s build-js-native-api-tests
345345
$(MAKE) -s build-node-api-tests
346346
$(MAKE) -s build-sqlite-tests
347+
$(MAKE) -s build-ffi-tests
347348
$(MAKE) -s cctest
348349
$(MAKE) -s jstest
349350

@@ -353,6 +354,7 @@ test-only: all ## Run default tests without building the docs.
353354
$(MAKE) build-js-native-api-tests
354355
$(MAKE) build-node-api-tests
355356
$(MAKE) build-sqlite-tests
357+
$(MAKE) build-ffi-tests
356358
$(MAKE) cctest
357359
$(MAKE) jstest
358360
$(MAKE) tooltest
@@ -364,6 +366,7 @@ test-cov: all ## Run coverage tests.
364366
$(MAKE) build-js-native-api-tests
365367
$(MAKE) build-node-api-tests
366368
$(MAKE) build-sqlite-tests
369+
$(MAKE) build-ffi-tests
367370
$(MAKE) cctest
368371
CI_SKIP_TESTS=$(COV_SKIP_TESTS) $(MAKE) jstest
369372

src/node_ffi.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -346,14 +346,21 @@ void DynamicLibrary::InvokeCallback(ffi_cif* cif,
346346
// It is unsupported and dangerous for a callback to unregister itself or
347347
// close its owning library while executing. The current invocation must
348348
// return before teardown APIs are used.
349-
350349
if (cb->owner->handle_ == nullptr || cb->ptr == nullptr) {
351350
if (ret != nullptr && cb->return_type->size > 0) {
352351
std::memset(ret, 0, GetFFIReturnValueStorageSize(cb->return_type));
353352
}
354353
return;
355354
}
356355

356+
if (std::this_thread::get_id() != cb->thread_id) {
357+
FPrintF(stderr,
358+
"Callbacks can only be invoked on the system thread they were "
359+
"created on\n");
360+
ABORT();
361+
}
362+
363+
357364
Environment* env = cb->env;
358365
Isolate* isolate = env->isolate();
359366

@@ -367,13 +374,6 @@ void DynamicLibrary::InvokeCallback(ffi_cif* cif,
367374
return;
368375
}
369376

370-
if (std::this_thread::get_id() != cb->thread_id) {
371-
FPrintF(stderr,
372-
"Callbacks can only be invoked on the system thread they were "
373-
"created on\n");
374-
ABORT();
375-
}
376-
377377
size_t expected_args = cb->args.size();
378378
LocalVector<Value> callback_args(isolate, expected_args);
379379

0 commit comments

Comments
 (0)