summaryrefslogtreecommitdiffstats
path: root/ruby
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-03-28 10:03:16 +0100
committerRichard W.M. Jones <rjones@redhat.com>2011-03-28 10:03:16 +0100
commite751293e10d5ecbb2ef43a61b9c153a1fc4f0304 (patch)
tree4c1049f6ab884bff5d850004bcbd427cfaf85f13 /ruby
parenta0e3b2183733c7440ad017c4ffe361935672339b (diff)
downloadlibguestfs-e751293e10d5ecbb2ef43a61b9c153a1fc4f0304.tar.gz
libguestfs-e751293e10d5ecbb2ef43a61b9c153a1fc4f0304.tar.xz
libguestfs-e751293e10d5ecbb2ef43a61b9c153a1fc4f0304.zip
ruby: Don't segfault if callbacks throw exceptions (RHBZ#664558).
(Thanks Chris Lalancette). See: https://bugzilla.redhat.com/show_bug.cgi?id=664558#c6
Notes
Notes: Labels: bugfix, RHBZ#664558 Depends: 6a64114929a0b098f5a1e31e17e7802127925007
Diffstat (limited to 'ruby')
-rw-r--r--ruby/tests/tc_rhbz664558c6.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/ruby/tests/tc_rhbz664558c6.rb b/ruby/tests/tc_rhbz664558c6.rb
new file mode 100644
index 00000000..ec5cf49f
--- /dev/null
+++ b/ruby/tests/tc_rhbz664558c6.rb
@@ -0,0 +1,48 @@
+# libguestfs Ruby bindings -*- ruby -*-
+# Copyright (C) 2011 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.
+
+# Test that throwing an exception in a callback doesn't cause
+# the interpreter to segfault. See:
+# https://bugzilla.redhat.com/show_bug.cgi?id=664558#c6
+
+require 'test/unit'
+$:.unshift(File::join(File::dirname(__FILE__), "..", "lib"))
+$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs"))
+require 'guestfs'
+
+class TestLoad < Test::Unit::TestCase
+ def test_rhbz664558c6
+ g = Guestfs::create()
+
+ close_invoked = 0
+ close = Proc.new {| event, event_handle, buf, array |
+ close_invoked += 1
+ # Raising an exception used to cause the interpreter to
+ # segfault. It should just cause an error message to be
+ # printed on stderr.
+ raise "ignore this error"
+ }
+ g.set_event_callback(close, Guestfs::EVENT_CLOSE)
+
+ # This should call the close callback.
+ g.close()
+
+ if close_invoked != 1
+ raise "close_invoked should be 1"
+ end
+ end
+end