diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2009-05-28 20:15:51 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2009-05-28 20:15:51 +0100 |
commit | babc0846cc911b01a58a7385d30ad25889b7175a (patch) | |
tree | e8f67f7fc096185e0febbad35396ba3972eaa432 /perl | |
parent | c41fe04a652437c920acb0e820762c53bf44a139 (diff) | |
download | libguestfs-babc0846cc911b01a58a7385d30ad25889b7175a.tar.gz libguestfs-babc0846cc911b01a58a7385d30ad25889b7175a.tar.xz libguestfs-babc0846cc911b01a58a7385d30ad25889b7175a.zip |
Add tests for bindings parameters, fix several broken bindings.
Diffstat (limited to 'perl')
-rw-r--r-- | perl/Guestfs.xs | 6 | ||||
-rw-r--r-- | perl/Makefile.am | 7 | ||||
-rw-r--r-- | perl/bindtests.pl | 40 | ||||
-rwxr-xr-x | perl/run-bindtests | 23 | ||||
-rwxr-xr-x | perl/run-perl-tests | 4 |
5 files changed, 74 insertions, 6 deletions
diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs index fcf62f72..0f90affd 100644 --- a/perl/Guestfs.xs +++ b/perl/Guestfs.xs @@ -110,7 +110,7 @@ void test0 (g, str, optstr, strlist, b, integer, filein, fileout) guestfs_h *g; char *str; - char *optstr; + char *optstr = SvOK(ST(2)) ? SvPV_nolen(ST(2)) : NULL; char **strlist; int b; int integer; @@ -727,7 +727,7 @@ void config (g, qemuparam, qemuvalue) guestfs_h *g; char *qemuparam; - char *qemuvalue; + char *qemuvalue = SvOK(ST(2)) ? SvPV_nolen(ST(2)) : NULL; PREINIT: int r; PPCODE: @@ -1270,7 +1270,7 @@ SV * aug_defvar (g, name, expr) guestfs_h *g; char *name; - char *expr; + char *expr = SvOK(ST(2)) ? SvPV_nolen(ST(2)) : NULL; PREINIT: int nrnodes; CODE: diff --git a/perl/Makefile.am b/perl/Makefile.am index 52a6a094..5d661ced 100644 --- a/perl/Makefile.am +++ b/perl/Makefile.am @@ -22,6 +22,7 @@ EXTRA_DIST = \ examples/LICENSE \ examples/*.pl \ lib/Sys/Guestfs.pm \ + run-bindtests \ run-perl-tests \ t/*.t \ typemap @@ -31,7 +32,11 @@ if HAVE_PERL # Interfacing automake and ExtUtils::MakeMaker known to be # a nightmare, news at 11. -TESTS = run-perl-tests +TESTS = run-bindtests run-perl-tests + +TESTS_ENVIRONMENT = \ + LD_LIBRARY_PATH=../src/.libs \ + LIBGUESTFS_PATH=../appliance INSTALLDIRS = site diff --git a/perl/bindtests.pl b/perl/bindtests.pl new file mode 100644 index 00000000..76d76f9b --- /dev/null +++ b/perl/bindtests.pl @@ -0,0 +1,40 @@ +#!/usr/bin/perl -w +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'. +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# 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. + +use strict; + +use Sys::Guestfs; + +my $g = Sys::Guestfs->new (); +$g->test0 ("abc", "def", [], 0, 0, "123", "456"); +$g->test0 ("abc", undef, [], 0, 0, "123", "456"); +$g->test0 ("", "def", [], 0, 0, "123", "456"); +$g->test0 ("", "", [], 0, 0, "123", "456"); +$g->test0 ("abc", "def", ["1"], 0, 0, "123", "456"); +$g->test0 ("abc", "def", ["1","2"], 0, 0, "123", "456"); +$g->test0 ("abc", "def", ["1"], 1, 0, "123", "456"); +$g->test0 ("abc", "def", ["1"], 0, -1, "123", "456"); +$g->test0 ("abc", "def", ["1"], 0, -2, "123", "456"); +$g->test0 ("abc", "def", ["1"], 0, 1, "123", "456"); +$g->test0 ("abc", "def", ["1"], 0, 2, "123", "456"); +$g->test0 ("abc", "def", ["1"], 0, 4095, "123", "456"); +$g->test0 ("abc", "def", ["1"], 0, 0, "", ""); +print "EOF\n" diff --git a/perl/run-bindtests b/perl/run-bindtests new file mode 100755 index 00000000..d9d1ca38 --- /dev/null +++ b/perl/run-bindtests @@ -0,0 +1,23 @@ +#!/bin/sh - +# libguestfs Perl 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +set -e + +export PERL5LIB=$(pwd)/blib/lib:$(pwd)/blib/arch +perl bindtests.pl > bindtests.tmp +diff -u ../bindtests bindtests.tmp diff --git a/perl/run-perl-tests b/perl/run-perl-tests index e3f315e9..c290742d 100755 --- a/perl/run-perl-tests +++ b/perl/run-perl-tests @@ -16,6 +16,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -export LD_LIBRARY_PATH=../src/.libs -export LIBGUESTFS_PATH=../appliance +set -e + make -f Makefile-pl test "$@" |