diff options
author | Matthew Booth <mbooth@redhat.com> | 2012-01-17 16:41:07 +0000 |
---|---|---|
committer | Matthew Booth <mbooth@redhat.com> | 2012-01-20 18:42:40 +0000 |
commit | e99a6a84834d924095a873514a159304091f2b1f (patch) | |
tree | a965331e98711aeacdc18bc69e9579e1acd17bd5 | |
parent | cce1bbb345978ac9e1813745cfee19bb3ce661e7 (diff) | |
download | libguestfs-e99a6a84834d924095a873514a159304091f2b1f.tar.gz libguestfs-e99a6a84834d924095a873514a159304091f2b1f.tar.xz libguestfs-e99a6a84834d924095a873514a159304091f2b1f.zip |
gobject: Add basic bindtests
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | generator/generator_bindtests.ml | 34 | ||||
-rw-r--r-- | generator/generator_main.ml | 1 | ||||
-rw-r--r-- | gobject/Makefile.am | 11 | ||||
-rwxr-xr-x | gobject/run-bindtests | 27 |
6 files changed, 78 insertions, 2 deletions
@@ -120,6 +120,7 @@ generator/stamp-generator .git-module-status /gnulib /GNUmakefile +gobject/bindtests.js gobject/Guestfs-1.0.gir gobject/Guestfs-1.0.typelib gobject/guestfs-gobject.c diff --git a/configure.ac b/configure.ac index 2ca0c475..63086aaa 100644 --- a/configure.ac +++ b/configure.ac @@ -1017,6 +1017,12 @@ AS_IF( ) AM_CONDITIONAL([HAVE_GOBJECT],[test "x$GOBJECT_LIBS" != "x"]) +AC_CHECK_PROG([GJS],[gjs],[gjs]) +AS_IF( + [test "x$GJS" = "x"], + [AC_MSG_WARN([gjs not found, gobject bindtests will not run])] +) + dnl gobject introspection GOBJECT_INTROSPECTION_CHECK([1.30.0]) diff --git a/generator/generator_bindtests.ml b/generator/generator_bindtests.ml index 8a36e756..e64afffc 100644 --- a/generator/generator_bindtests.ml +++ b/generator/generator_bindtests.ml @@ -425,6 +425,40 @@ main = do pr " putStrLn \"EOF\"\n" +and generate_gobject_js_bindtests () = + generate_header CPlusPlusStyle GPLv2plus; + + pr "\ +const Guestfs = imports.gi.Guestfs; + +var g = new Guestfs.Session(); + +"; + + let mkargs args = + String.concat ", " ( + (List.map ( + function + | CallString s -> "\"" ^ s ^ "\"" + | CallOptString None -> "null" + | CallOptString (Some s) -> "\"" ^ s ^ "\"" + | CallStringList xs -> + "[" ^ String.concat "," (List.map (sprintf "\"%s\"") xs) ^ "]" + | CallInt i -> string_of_int i + | CallInt64 i -> Int64.to_string i + | CallBool true -> "true" + | CallBool false -> "false" + | CallBuffer s -> "\"" ^ c_quote s ^ "\"" + ) args) + @ ["null"] + ) + in + generate_lang_bindtests ( + fun f args -> pr "g.%s(%s);\n" f (mkargs args) + ); + + pr "\nprint(\"EOF\");\n" + (* Language-independent bindings tests - we do it this way to * ensure there is parity in testing bindings across all languages. *) diff --git a/generator/generator_main.ml b/generator/generator_main.ml index c7ee041a..5be8c2e7 100644 --- a/generator/generator_main.ml +++ b/generator/generator_main.ml @@ -137,6 +137,7 @@ Run it from the top source directory using the command output_to "php/extension/guestfs_php.c" generate_php_c; output_to "erlang/guestfs.erl" generate_erlang_erl; output_to "erlang/erl-guestfs.c" generate_erlang_c; + output_to "gobject/bindtests.js" generate_gobject_js_bindtests; output_to "gobject/guestfs-gobject.h" generate_gobject_header; output_to "gobject/guestfs-gobject.c" generate_gobject_c; diff --git a/gobject/Makefile.am b/gobject/Makefile.am index 25441cf9..1b239b49 100644 --- a/gobject/Makefile.am +++ b/gobject/Makefile.am @@ -15,8 +15,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -BUILT_SOURCES = guestfs-gobject.h guestfs-gobject.c -EXTRA_DIST = $(BUILT_SOURCES) +BUILT_SOURCES = guestfs-gobject.h guestfs-gobject.c bindtests.js +EXTRA_DIST = \ + $(BUILT_SOURCES) \ + run-bindtests libname = libguestfs-gobject-1.0.la @@ -54,5 +56,10 @@ gir_DATA = $(INTROSPECTION_GIRS) typelibdir = $(libdir)/girepository-1.0 typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) +TESTS = run-bindtests +TESTS_ENVIRONMENT = GJS=$(GJS) + +$(TESTS): $(typelib_DATA) + CLEANFILES = $(gir_DATA) $(typelib_DATA) endif diff --git a/gobject/run-bindtests b/gobject/run-bindtests new file mode 100755 index 00000000..3d27c144 --- /dev/null +++ b/gobject/run-bindtests @@ -0,0 +1,27 @@ +#!/bin/sh - +# libguestfs GObject bindings +# Copyright (C) 2012 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 + +if [ -z "$GJS" ]; then + echo "GObject bind tests skipped: gjs is missing" + exit 0 +fi + +../run $GJS bindtests.js > bindtests.tmp +diff -u ${srcdir}/../bindtests bindtests.tmp |