diff --git a/tools/ocaml/Makefile b/tools/ocaml/Makefile index 7252eb23d7..e570e30a6e 100644 --- a/tools/ocaml/Makefile +++ b/tools/ocaml/Makefile @@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk SUBDIRS := libs SUBDIRS += xenstored +SUBDIRS += tests .NOTPARALLEL: # targets here must be run in order, otherwise we can try diff --git a/tools/ocaml/tests/Makefile b/tools/ocaml/tests/Makefile new file mode 100644 index 0000000000..e9f3557f12 --- /dev/null +++ b/tools/ocaml/tests/Makefile @@ -0,0 +1,8 @@ +XEN_ROOT = $(CURDIR)/../../.. +include $(XEN_ROOT)/tools/Rules.mk + +SUBDIRS-y := +SUBDIRS-y += bindings + +.PHONY: all clean install distclean uninstall +all clean distclean install uninstall: %: subdirs-% diff --git a/tools/ocaml/tests/bindings/.gitignore b/tools/ocaml/tests/bindings/.gitignore new file mode 100644 index 0000000000..6e9a7f429b --- /dev/null +++ b/tools/ocaml/tests/bindings/.gitignore @@ -0,0 +1 @@ +test-ocaml-bindings diff --git a/tools/ocaml/tests/bindings/Makefile b/tools/ocaml/tests/bindings/Makefile new file mode 100644 index 0000000000..75f8babbaf --- /dev/null +++ b/tools/ocaml/tests/bindings/Makefile @@ -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 diff --git a/tools/ocaml/tests/bindings/main.ml b/tools/ocaml/tests/bindings/main.ml new file mode 100644 index 0000000000..785837e270 --- /dev/null +++ b/tools/ocaml/tests/bindings/main.ml @@ -0,0 +1,19 @@ +open Printf + +let xch = Xenctrl.interface_open () + +let test_xenversion () = + let ver = Xenctrl.version xch in + printf "Xen version: %d.%d%s\n" ver.major ver.minor ver.extra + + +let () = + printf "Test Ocaml Bindings\n%!"; + + test_xenversion (); + + printf "Starting GC.compact()\n%!"; + Gc.compact (); + printf "GC done\n"; + + ()