@@ -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
@@ -542,6 +545,29 @@ else
542545build-sqlite-tests :
543546endif
544547
548+ FFI_BINDING_GYPS := $(wildcard test/ffi/* /binding.gyp)
549+
550+ FFI_BINDING_SOURCES := \
551+ $(wildcard test/ffi/* /* .c) \
552+ $(wildcard test/ffi/* /* .def)
553+
554+ ifndef NOFFI
555+ # Depends on $(NODE_EXE) as order-only to avoid ETXTBSY on AIX when make
556+ # tries to execute node while it is still being linked in parallel.
557+ test/ffi/.buildstamp : $(ADDONS_PREREQS ) \
558+ $(FFI_BINDING_GYPS ) $(FFI_BINDING_SOURCES ) | $(NODE_EXE )
559+ @$(call run_build_addons,"$$PWD/test/ffi",$@ )
560+ else
561+ test/ffi/.buildstamp :
562+ endif
563+
564+ .PHONY : build-ffi-tests
565+ ifndef NOFFI
566+ build-ffi-tests : | test/ffi/.buildstamp # # Build FFI tests.
567+ else
568+ build-ffi-tests :
569+ endif
570+
545571.PHONY : clear-stalled
546572clear-stalled : # # Clear any stalled processes.
547573 $(info Clean up any leftover processes but don't error if found.)
@@ -552,7 +578,7 @@ clear-stalled: ## Clear any stalled processes.
552578 fi
553579
554580.PHONY : test-build
555- test-build : | all build-addons build-js-native-api-tests build-node-api-tests build-sqlite-tests # # Build all tests.
581+ test-build : | all build-addons build-js-native-api-tests build-node-api-tests build-sqlite-tests build-ffi-tests # # Build all tests.
556582
557583.PHONY : test-build-js-native-api
558584test-build-js-native-api : all build-js-native-api-tests # # Build JS Native-API tests.
@@ -563,6 +589,8 @@ test-build-node-api: all build-node-api-tests ## Build Node-API tests.
563589.PHONY : test-build-sqlite
564590test-build-sqlite : all build-sqlite-tests # # Build SQLite tests.
565591
592+ .PHONY : test-build-ffi
593+ test-build-ffi : all build-ffi-tests # # Build FFI tests.
566594
567595.PHONY : test-all
568596test-all : test-build # # Run default tests with both Debug and Release builds.
@@ -591,7 +619,7 @@ endif
591619
592620# Related CI job: node-test-commit-arm-fanned
593621test-ci-native : LOGLEVEL := info # # Build and test addons without building anything else.
594- test-ci-native : | benchmark/napi/.buildstamp test/addons/.buildstamp test/js-native-api/.buildstamp test/node-api/.buildstamp test/sqlite/.buildstamp
622+ test-ci-native : | benchmark/napi/.buildstamp test/addons/.buildstamp test/js-native-api/.buildstamp test/node-api/.buildstamp test/sqlite/.buildstamp test/ffi/.buildstamp
595623 $(PYTHON ) tools/test.py $(PARALLEL_ARGS ) -p tap --logfile test.tap \
596624 --mode=$(BUILDTYPE_LOWER ) --flaky-tests=$(FLAKY_TESTS ) \
597625 $(TEST_CI_ARGS ) $(CI_NATIVE_SUITES )
@@ -614,7 +642,7 @@ test-ci-js: | clear-stalled ## Build and test JavaScript with building anything
614642.PHONY : test-ci
615643# Related CI jobs: most CI tests, excluding node-test-commit-arm-fanned
616644test-ci : LOGLEVEL := info # # Build and test everything (CI).
617- test-ci : | clear-stalled bench-addons-build build-addons build-js-native-api-tests build-node-api-tests build-sqlite-tests doc-only
645+ test-ci : | clear-stalled bench-addons-build build-addons build-js-native-api-tests build-node-api-tests build-sqlite-tests build-ffi-tests doc-only
618646 out/Release/cctest --gtest_output=xml:out/junit/cctest.xml
619647 $(PYTHON ) tools/test.py $(PARALLEL_ARGS ) -p tap --logfile test.tap \
620648 --mode=$(BUILDTYPE_LOWER ) --flaky-tests=$(FLAKY_TESTS ) \
@@ -632,6 +660,7 @@ test-ci: | clear-stalled bench-addons-build build-addons build-js-native-api-tes
632660build-ci : # # Build everything (CI).
633661 $(PYTHON ) ./configure --verbose $(CONFIG_FLAGS )
634662 $(MAKE )
663+ $(MAKE ) build-ffi-tests
635664
636665.PHONY : run-ci
637666# Run by CI tests, exceptions:
@@ -734,6 +763,16 @@ test-sqlite-clean: ## Remove SQLite testing artifacts.
734763 $(RM ) -r test/sqlite/* /build
735764 $(RM ) test/sqlite/.buildstamp
736765
766+ .PHONY : test-ffi
767+ test-ffi : test-build-ffi # # Run FFI tests.
768+ $(PYTHON ) tools/test.py $(PARALLEL_ARGS ) --mode=$(BUILDTYPE_LOWER ) ffi
769+
770+ .PHONY : test-ffi-clean
771+ .NOTPARALLEL : test-ffi-clean
772+ test-ffi-clean : # # Remove FFI testing artifacts.
773+ $(RM ) -r test/ffi/* /build
774+ $(RM ) test/ffi/.buildstamp
775+
737776.PHONY : test-addons
738777test-addons : test-build test-js-native-api test-node-api # # Run addon tests.
739778 $(PYTHON ) tools/test.py $(PARALLEL_ARGS ) --mode=$(BUILDTYPE_LOWER ) addons
@@ -1228,6 +1267,7 @@ ifeq ($(SKIP_SHARED_DEPS), 1)
12281267 $(RM) -r $(TARNAME)/deps/icu-small
12291268 $(RM) -r $(TARNAME)/deps/icu-tmp
12301269 $(RM) -r $(TARNAME)/deps/LIEF
1270+ $(RM) -r $(TARNAME)/deps/libffi
12311271 $(RM) -r $(TARNAME)/deps/llhttp
12321272 $(RM) -r $(TARNAME)/deps/merve
12331273 $(RM) -r $(TARNAME)/deps/nbytes
@@ -1502,6 +1542,7 @@ LINT_CPP_FILES = $(filter-out $(LINT_CPP_EXCLUDE), $(wildcard \
15021542 test/embedding/* .cc \
15031543 test/embedding/* .h \
15041544 test/sqlite/* /* .c \
1545+ test/ffi/* /* .c \
15051546 test/fixtures/* .c \
15061547 test/js-native-api/* /* .cc \
15071548 test/node-api/* /* .cc \
@@ -1526,6 +1567,7 @@ FORMAT_CPP_FILES += $(wildcard \
15261567 test/node-api/* /* .c \
15271568 test/node-api/* /* .h \
15281569 test/sqlite/* /* .c \
1570+ test/ffi/* /* .c \
15291571 )
15301572
15311573# Code blocks don't have newline at the end,
0 commit comments