---
generator/tests.ml | 37 +++++++++++++++++++++
generator/tests_mk.ml | 14 ++++++--
ocaml/Makefile.am | 55 +++++--------------------------
ocaml/run-bindtests | 27 ----------------
ocaml/run-bindtests.sh | 26 +++++++++++++++
ocaml/tests.mk | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 169 insertions(+), 77 deletions(-)
delete mode 100755 ocaml/run-bindtests
create mode 100755 ocaml/run-bindtests.sh
create mode 100644 ocaml/tests.mk
diff --git a/generator/tests.ml b/generator/tests.ml
index dc833f2..2b2dd87 100644
--- a/generator/tests.ml
+++ b/generator/tests.ml
@@ -474,4 +474,41 @@ let tests = [
]
};
+ (* Test language bindings. *)
+
+ "ocaml", {
+ defaults with
+ check_fast = [
+ "run-bindtests.sh";
+ "t/guestfs_010_load.bc";
+ "t/guestfs_020_create.bc";
+ "t/guestfs_030_create_flags.bc";
+ "t/guestfs_040_create_multiple.bc";
+ "t/guestfs_050_handle_properties.bc";
+ "t/guestfs_060_explicit_close.bc";
+ "t/guestfs_070_optargs.bc";
+ "t/guestfs_410_close_event.bc";
+ "t/guestfs_420_log_messages.bc";
+ "t/guestfs_010_load.opt";
+ "t/guestfs_020_create.opt";
+ "t/guestfs_030_create_flags.opt";
+ "t/guestfs_040_create_multiple.opt";
+ "t/guestfs_050_handle_properties.opt";
+ "t/guestfs_060_explicit_close.opt";
+ "t/guestfs_070_optargs.opt";
+ "t/guestfs_410_close_event.opt";
+ "t/guestfs_420_log_messages.opt"
+ ];
+ check = [
+ "t/guestfs_100_launch.bc";
+ "t/guestfs_430_progress_messages.bc";
+ "t/guestfs_100_launch.opt";
+ "t/guestfs_430_progress_messages.opt";
+ ];
+ check_scripts = [
+ "bindtests.bc";
+ "bindtests.opt";
+ ];
+ };
+
]
diff --git a/generator/tests_mk.ml b/generator/tests_mk.ml
index e2705ce..7e98297 100644
--- a/generator/tests_mk.ml
+++ b/generator/tests_mk.ml
@@ -39,13 +39,21 @@ let generate_tests_mk dir tests () =
pr "\n";
);
- (* Only add *.sh and *.pl to localtests_SCRIPTS. Others are added to
- * localtests_PROGRAMS.
+ (* Certain extensions are treated as scripts and added to
+ * localtests_SCRIPTS. Others are added to localtests_PROGRAMS.
*)
+ let scripts_extensions = [
+ ".bc"; ".opt"; (* for OCaml *)
+ ".pl";
+ ".sh"
+ ] in
+
let test_scripts, test_programs =
List.partition (
fun file ->
- Filename.check_suffix file ".sh" || Filename.check_suffix file
".pl"
+ List.exists
+ (fun extn -> Filename.check_suffix file extn)
+ scripts_extensions
) (tests.check @ tests.check_fast @ tests.check_slow
@ tests.check_local_guests) in
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am
index db13a8f..6108eef 100644
--- a/ocaml/Makefile.am
+++ b/ocaml/Makefile.am
@@ -21,7 +21,8 @@ generator_built = \
guestfs.mli \
guestfs.ml \
guestfs-c-actions.c \
- $(srcdir)/bindtests.ml
+ $(srcdir)/bindtests.ml \
+ tests.mk
EXTRA_DIST = \
$(generator_built) \
@@ -100,50 +101,9 @@ html/index.html: $(srcdir)/guestfs.mli $(srcdir)/guestfs.ml
endif
-TESTS_ENVIRONMENT = $(top_builddir)/run --test $(VG)
+# Tests.
-test_progs_bc = \
- t/guestfs_010_load.bc \
- t/guestfs_020_create.bc \
- t/guestfs_030_create_flags.bc \
- t/guestfs_040_create_multiple.bc \
- t/guestfs_050_handle_properties.bc \
- t/guestfs_060_explicit_close.bc \
- t/guestfs_070_optargs.bc \
- t/guestfs_410_close_event.bc \
- t/guestfs_420_log_messages.bc
-
-test_progs_opt = \
- t/guestfs_010_load.opt \
- t/guestfs_020_create.opt \
- t/guestfs_030_create_flags.opt \
- t/guestfs_040_create_multiple.opt \
- t/guestfs_050_handle_properties.opt \
- t/guestfs_060_explicit_close.opt \
- t/guestfs_070_optargs.opt \
- t/guestfs_410_close_event.opt \
- t/guestfs_420_log_messages.opt
-
-if ENABLE_APPLIANCE
-test_progs_bc += \
- t/guestfs_100_launch.bc \
- t/guestfs_430_progress_messages.bc
-test_progs_opt += \
- t/guestfs_100_launch.opt \
- t/guestfs_430_progress_messages.opt
-endif
-
-test_progs_all = $(test_progs_bc)
-if HAVE_OCAMLOPT
-test_progs_all += $(test_progs_opt)
-endif
-
-TESTS = run-bindtests $(test_progs_all)
-
-noinst_DATA += bindtests.bc $(test_progs_all)
-if HAVE_OCAMLOPT
-noinst_DATA += bindtests.opt
-endif
+include $(srcdir)/tests.mk
%.bc: %.cmo mlguestfs.cma
$(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute
\
@@ -152,11 +112,12 @@ endif
if HAVE_OCAMLOPT
%.opt: %.cmx mlguestfs.cmxa
$(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -cclib -L$(top_builddir)/src/.libs -I . -package
unix -linkpkg mlguestfs.cmxa $< -o $@
+else
+%.opt:
+ echo 'exit 77' > $@
+ chmod 0755 $@
endif
-check-valgrind:
- $(MAKE) VG="$(top_builddir)/run @VG@" TESTS="$(test_progs_all)"
check
-
# Dependencies.
%.cmi: %.mli
$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -package unix -c $< -o $@
diff --git a/ocaml/run-bindtests b/ocaml/run-bindtests
deleted file mode 100755
index 1fa54ec..0000000
--- a/ocaml/run-bindtests
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh -
-# libguestfs OCaml bindings
-# Copyright (C) 2009 Red Hat Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-set -e
-
-./bindtests.bc > bindtests.tmp
-diff -u $srcdir/../bindtests bindtests.tmp
-
-test -x ./bindtests.opt || exit 0
-
-./bindtests.opt > bindtests.tmp
-diff -u $srcdir/../bindtests bindtests.tmp
diff --git a/ocaml/run-bindtests.sh b/ocaml/run-bindtests.sh
new file mode 100755
index 0000000..dfeb61a
--- /dev/null
+++ b/ocaml/run-bindtests.sh
@@ -0,0 +1,26 @@
+#!/bin/sh -
+# libguestfs OCaml bindings
+# Copyright (C) 2009-2014 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+set -e
+
+$builddir/bindtests.bc > bindtests.tmp
+diff -u $srcdir/../bindtests bindtests.tmp
+
+# Note next command will exit 77 if !HAVE_OCAMLOPT.
+$builddir/bindtests.opt > bindtests.tmp
+diff -u $srcdir/../bindtests bindtests.tmp
diff --git a/ocaml/tests.mk b/ocaml/tests.mk
new file mode 100644
index 0000000..817430b
--- /dev/null
+++ b/ocaml/tests.mk
@@ -0,0 +1,87 @@
+# libguestfs generated file
+# WARNING: THIS FILE IS GENERATED FROM:
+# generator/ *.ml
+# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
+#
+# Copyright (C) 2009-2015 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+localtestsdir = $(alltestsdir)/ocaml
+
+localtests_SCRIPTS = \
+ bindtests.bc \
+ bindtests.opt \
+ run-bindtests.sh \
+ t/guestfs_010_load.bc \
+ t/guestfs_010_load.opt \
+ t/guestfs_020_create.bc \
+ t/guestfs_020_create.opt \
+ t/guestfs_030_create_flags.bc \
+ t/guestfs_030_create_flags.opt \
+ t/guestfs_040_create_multiple.bc \
+ t/guestfs_040_create_multiple.opt \
+ t/guestfs_050_handle_properties.bc \
+ t/guestfs_050_handle_properties.opt \
+ t/guestfs_060_explicit_close.bc \
+ t/guestfs_060_explicit_close.opt \
+ t/guestfs_070_optargs.bc \
+ t/guestfs_070_optargs.opt \
+ t/guestfs_100_launch.bc \
+ t/guestfs_100_launch.opt \
+ t/guestfs_410_close_event.bc \
+ t/guestfs_410_close_event.opt \
+ t/guestfs_420_log_messages.bc \
+ t/guestfs_420_log_messages.opt \
+ t/guestfs_430_progress_messages.bc \
+ t/guestfs_430_progress_messages.opt
+
+# Note that we cannot create a simple 'check:' target since
+# automake will (silently) overrule it, so we do this instead:
+
+TESTS_ENVIRONMENT = $(top_builddir)/run
+TESTS = $(top_builddir)/test-harness
+
+check-valgrind:
+ $(top_builddir)/run $(top_builddir)/test-harness --valgrind
+
+check-direct:
+ $(top_builddir)/run $(top_builddir)/test-harness --direct
+
+check-valgrind-direct:
+ $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct
+
+check-libvirt:
+ $(top_builddir)/run $(top_builddir)/test-harness --libvirt
+
+check-valgrind-libvirt:
+ $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt
+
+check-uml:
+ $(top_builddir)/run $(top_builddir)/test-harness --uml
+
+check-valgrind-uml:
+ $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml
+
+check-with-upstream-qemu:
+ $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu
+
+check-with-upstream-libvirt:
+ $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt
+
+check-fast:
+ $(top_builddir)/run $(top_builddir)/test-harness --fast
+
+EXTRA_DIST += tests.mk
--
2.5.0