mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
gobject: Add basic bindtests
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -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
|
||||
|
||||
@@ -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])
|
||||
|
||||
|
||||
@@ -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.
|
||||
*)
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
27
gobject/run-bindtests
Executable file
27
gobject/run-bindtests
Executable file
@@ -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
|
||||
Reference in New Issue
Block a user