From 8bad4d1c4765fd997511a505cdb2a860148ae16d Mon Sep 17 00:00:00 2001 From: Matthew Booth Date: Wed, 25 Jan 2012 15:10:01 +0000 Subject: gobject: Add an explicit close call This change binds guestfs_close(). It consequently results in RConstOptString being able to throw an error. --- gobject/Makefile.am | 5 +++-- gobject/run-bindtests | 28 ---------------------------- gobject/run-tests | 29 +++++++++++++++++++++++++++++ gobject/tests-misc.js | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 30 deletions(-) delete mode 100755 gobject/run-bindtests create mode 100755 gobject/run-tests create mode 100644 gobject/tests-misc.js (limited to 'gobject') diff --git a/gobject/Makefile.am b/gobject/Makefile.am index 5ea44883..71de7cce 100644 --- a/gobject/Makefile.am +++ b/gobject/Makefile.am @@ -22,7 +22,8 @@ BUILT_SOURCES = \ EXTRA_DIST = \ $(BUILT_SOURCES) \ bindtests-manual.js \ - run-bindtests + tests-misc.js \ + run-tests libname = libguestfs-gobject-1.0.la @@ -60,7 +61,7 @@ gir_DATA = $(INTROSPECTION_GIRS) typelibdir = $(libdir)/girepository-1.0 typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) -TESTS = run-bindtests +TESTS = run-tests TESTS_ENVIRONMENT = GJS=$(GJS) $(TESTS): $(typelib_DATA) diff --git a/gobject/run-bindtests b/gobject/run-bindtests deleted file mode 100755 index 55c489cf..00000000 --- a/gobject/run-bindtests +++ /dev/null @@ -1,28 +0,0 @@ -#!/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 $srcdir/bindtests.js > bindtests.tmp -diff -u ${srcdir}/../bindtests bindtests.tmp -../run $GJS $srcdir/bindtests-manual.js 2>/dev/null diff --git a/gobject/run-tests b/gobject/run-tests new file mode 100755 index 00000000..d2ce0a60 --- /dev/null +++ b/gobject/run-tests @@ -0,0 +1,29 @@ +#!/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 $srcdir/bindtests.js > bindtests.tmp +diff -u ${srcdir}/../bindtests bindtests.tmp +../run $GJS $srcdir/bindtests-manual.js 2>/dev/null +../run $GJS $srcdir/tests-misc.js 2>/dev/null diff --git a/gobject/tests-misc.js b/gobject/tests-misc.js new file mode 100644 index 00000000..aadc2f39 --- /dev/null +++ b/gobject/tests-misc.js @@ -0,0 +1,41 @@ +// libguestfs miscellaneous gobject binding tests +// 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. + +const Guestfs = imports.gi.Guestfs; + +var fail = false; + +var g = new Guestfs.Session(); + +// Test close() +g.close(); +var threw = false; +try { + var v = g.test0rconstoptstring('1'); +} catch (error) { + threw = true; + if (!error.message.match(/closed/)) { + print("call after close threw unexpected error: " + error.message); + fail = true; + } +} +if (!threw) { + print("call after closed failed to throw an error"); + fail = true; +} + +fail ? 1 : 0; -- cgit