tools/ocaml: Gitlab CI test for bindings

... as building and interpreting Ocaml objects in C is rather fragile.

For C producing objects for Ocaml to consume, one trick to check validity is
Gc.compact() which forces a major sweep, walking all objects.  If this doesn't
segfault, then we at least got the pointer <-> integer aspects right.

For now, start with a very simple version call.  (Re)introduce
tools/ocaml/tests and add test-ocaml-bindings which is installed into
$(DESTDIR)$(LIBEXEC)/tests to be picked up automatically with the other dom0
tests.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Andrii Sultanov <andriy.sultanov@vates.tech>
This commit is contained in:
Andrew Cooper committed 2026-10-26 18:36:52 +00:00
1 parent 7f18907452
commit d97847e858
5 files changed
+63

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
XEN_ROOT = $(CURDIR)/../../../..
OCAML_TOPLEVEL = $(CURDIR)/../..
include $(OCAML_TOPLEVEL)/common.make
OBJS = main
OCAMLINCLUDE += \
-I $(OCAML_TOPLEVEL)/libs/xb \
-I $(OCAML_TOPLEVEL)/libs/mmap \
-I $(OCAML_TOPLEVEL)/libs/xc \
-I $(OCAML_TOPLEVEL)/libs/eventchn
LIBS = \
unix.cmxa \
-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/mmap $(OCAML_TOPLEVEL)/libs/mmap/xenmmap.cmxa \
-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/eventchn $(OCAML_TOPLEVEL)/libs/eventchn/xeneventchn.cmxa \
-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xc $(OCAML_TOPLEVEL)/libs/xc/xenctrl.cmxa \
-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xb $(OCAML_TOPLEVEL)/libs/xb/xenbus.cmxa \
-ccopt -L -ccopt $(XEN_ROOT)/tools/libs/ctrl
PROGRAMS = test-ocaml-bindings
OCAML_PROGRAM = test-ocaml-bindings
test-ocaml-bindings_LIBS = $(LIBS)
test-ocaml-bindings_MLSORTED = $(shell $(OCAMLDEP) -sort $(OBJS:=.ml))
test-ocaml-bindings_OBJS = $(test-ocaml-bindings_MLSORTED:.ml=)
all: test-ocaml-bindings
install: all
$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)/tests
$(INSTALL_PROG) test-ocaml-bindings $(DESTDIR)$(LIBEXEC)/tests
include $(OCAML_TOPLEVEL)/Makefile.rules
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.