mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
lua: Add bindtests.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -216,6 +216,7 @@ Makefile.in
|
||||
/libtool
|
||||
/local*
|
||||
/ltmain.sh
|
||||
/lua/bindtests.lua
|
||||
/lua/examples/guestfs-lua.3
|
||||
/lua/examples/stamp-guestfs-lua.pod
|
||||
/lua/guestfs.so
|
||||
|
||||
@@ -739,6 +739,62 @@ and generate_erlang_bindtests () =
|
||||
pr " ok = file:write(File, \"EOF\\n\"),\n";
|
||||
pr " ok = file:close(File).\n"
|
||||
|
||||
and generate_lua_bindtests () =
|
||||
generate_header LuaStyle GPLv2plus;
|
||||
|
||||
pr "require \"guestfs\"\n";
|
||||
pr "\n";
|
||||
pr "g = Guestfs.create ()\n";
|
||||
pr "\n";
|
||||
|
||||
generate_lang_bindtests (
|
||||
fun f args optargs ->
|
||||
pr "g:%s (" f;
|
||||
let needs_comma = ref false in
|
||||
List.iter (
|
||||
fun arg ->
|
||||
if !needs_comma then pr ", ";
|
||||
needs_comma := true;
|
||||
|
||||
match arg with
|
||||
| CallString s -> pr "\"%s\"" s
|
||||
| CallOptString None -> pr "nil"
|
||||
| CallOptString (Some s) -> pr "\"%s\"" s
|
||||
| CallStringList xs ->
|
||||
pr "{%s}" (String.concat "," (List.map (sprintf "\"%s\"") xs))
|
||||
| CallInt i -> pr "%d" i
|
||||
| CallInt64 i -> pr "\"%Ld\"" i
|
||||
| CallBool b -> pr "%b" b
|
||||
| CallBuffer s -> pr "\"%s\"" (c_quote s)
|
||||
) args;
|
||||
(match optargs with
|
||||
| None -> ()
|
||||
| Some optargs ->
|
||||
if !needs_comma then pr ", ";
|
||||
|
||||
pr "{";
|
||||
needs_comma := false;
|
||||
List.iter (
|
||||
fun optarg ->
|
||||
if !needs_comma then pr ", ";
|
||||
needs_comma := true;
|
||||
match optarg with
|
||||
| CallOBool (n, v) -> pr "%s = %b" n v
|
||||
| CallOInt (n, v) -> pr "%s = %d" n v
|
||||
| CallOInt64 (n, v) -> pr "%s = \"%Ld\"" n v
|
||||
| CallOString (n, v) -> pr "%s = \"%s\"" n v
|
||||
| CallOStringList (n, xs) ->
|
||||
pr "%s = {%s}" n
|
||||
(String.concat "," (List.map (sprintf "\"%s\"") xs))
|
||||
) optargs;
|
||||
pr "}";
|
||||
);
|
||||
pr ")\n"
|
||||
);
|
||||
|
||||
pr "\n";
|
||||
pr "print (\"EOF\")\n"
|
||||
|
||||
(* Language-independent bindings tests - we do it this way to
|
||||
* ensure there is parity in testing bindings across all languages.
|
||||
*)
|
||||
|
||||
@@ -154,6 +154,7 @@ Run it from the top source directory using the command
|
||||
output_to "erlang/erl-guestfs.c" generate_erlang_c;
|
||||
output_to ~perm:0o555 "erlang/bindtests.erl" generate_erlang_bindtests;
|
||||
output_to "lua/lua-guestfs.c" generate_lua_c;
|
||||
output_to "lua/bindtests.lua" generate_lua_bindtests;
|
||||
|
||||
output_to "gobject/bindtests.js" generate_gobject_js_bindtests;
|
||||
output_to "gobject/Makefile.inc" generate_gobject_makefile;
|
||||
|
||||
@@ -20,10 +20,12 @@ include $(top_srcdir)/subdir-rules.mk
|
||||
lualibdir = $(libdir)/lua/$(LUA_VERSION)
|
||||
|
||||
generator_built = \
|
||||
bindtests.lua \
|
||||
lua-guestfs.c
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(generator_built)
|
||||
$(generator_built) \
|
||||
run-bindtests
|
||||
|
||||
CLEANFILES = *~ guestfs.so
|
||||
|
||||
@@ -50,6 +52,7 @@ guestfs.so: libluaguestfs.la
|
||||
# Tests.
|
||||
TESTS_ENVIRONMENT = $(top_builddir)/run --test
|
||||
TESTS = \
|
||||
run-bindtests \
|
||||
tests/010-load.lua \
|
||||
tests/015-globals.lua \
|
||||
tests/020-create.lua \
|
||||
|
||||
20
lua/run-bindtests
Executable file
20
lua/run-bindtests
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh -
|
||||
# libguestfs Lua 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.
|
||||
|
||||
lua bindtests.lua > bindtests.tmp
|
||||
diff -u $srcdir/../bindtests bindtests.tmp
|
||||
Reference in New Issue
Block a user