--- .gitignore | 1 + generator/generator_bindtests.ml | 34 ++++++++++++++++++++++++++++++++++ generator/generator_main.ml | 1 + gobject/Makefile.am | 9 +++++++-- gobject/run-bindtests | 22 ++++++++++++++++++++++ 5 files changed, 65 insertions(+), 2 deletions(-) create mode 100755 gobject/run-bindtests
diff --git a/.gitignore b/.gitignore index b970108..b75cafb 100644 --- a/.gitignore +++ b/.gitignore @@ -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/generator/generator_bindtests.ml b/generator/generator_bindtests.ml index f2dc0de..1328b96 100644 --- a/generator/generator_bindtests.ml +++ b/generator/generator_bindtests.ml @@ -421,6 +421,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 c7ee041..5be8c2e 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 6543ca8..12505b4 100644 --- a/gobject/Makefile.am +++ b/gobject/Makefile.am @@ -1,5 +1,7 @@ -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 @@ -37,5 +39,8 @@ gir_DATA = $(INTROSPECTION_GIRS) typelibdir = $(libdir)/girepository-1.0 typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) +TESTS = run-bindtests +$(TESTS): $(typelib_DATA) + CLEANFILES = $(gir_DATA) $(typelib_DATA) endif diff --git a/gobject/run-bindtests b/gobject/run-bindtests new file mode 100755 index 0000000..f344002 --- /dev/null +++ b/gobject/run-bindtests @@ -0,0 +1,22 @@ +#!/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 + +../run gjs bindtests.js > bindtests.tmp +diff -u ${srcdir}/../bindtests bindtests.tmp -- 1.7.7.5 _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs