mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
ruby: Standardize test names and numbering.
This commit is contained in:
@@ -32,11 +32,11 @@ EXTRA_DIST = \
|
||||
lib/guestfs.rb \
|
||||
run-bindtests \
|
||||
run-ruby-tests \
|
||||
tests/tc_*.rb
|
||||
t/tc_*.rb
|
||||
|
||||
CLEANFILES = \
|
||||
lib/*~ \
|
||||
tests/*~ \
|
||||
t/*~ \
|
||||
ext/guestfs/*~ \
|
||||
ext/guestfs/extconf.h \
|
||||
ext/guestfs/_guestfs.o \
|
||||
|
||||
@@ -70,7 +70,7 @@ desc "Build the native library"
|
||||
task :build => GUESTFS_MODULE
|
||||
|
||||
Rake::TestTask.new(:test) do |t|
|
||||
t.test_files = FileList['tests/tc_*.rb']
|
||||
t.test_files = FileList['t/tc_*.rb']
|
||||
t.libs = [ 'lib', 'ext/guestfs' ]
|
||||
end
|
||||
task :test => :build
|
||||
@@ -100,7 +100,7 @@ PKG_FILES = FileList[
|
||||
"Rakefile", "COPYING", "README", "NEWS", "@srcdir@/README.rdoc",
|
||||
"lib/**/*.rb",
|
||||
"ext/**/*.[ch]", "ext/**/MANIFEST", "ext/**/extconf.rb",
|
||||
"tests/**/*",
|
||||
"t/**/*",
|
||||
"spec/**/*"
|
||||
]
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ set -e
|
||||
# Run them one at a time, otherwise rake runs them in parallel (which
|
||||
# is bound to fail because they all use a single test image file).
|
||||
|
||||
for f in tests/tc_*.rb; do
|
||||
for f in t/tc_*.rb; do
|
||||
echo $RAKE test "$@" TEST="$f"
|
||||
$RAKE test "$@" TEST="$f"
|
||||
done
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# libguestfs Ruby bindings -*- ruby -*-
|
||||
# Copyright (C) 2009 Red Hat Inc.
|
||||
# Copyright (C) 2009-2013 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
|
||||
@@ -22,7 +22,5 @@ require 'guestfs'
|
||||
|
||||
class TestLoad < Test::Unit::TestCase
|
||||
def test_load
|
||||
g = Guestfs::create()
|
||||
assert_not_nil (g)
|
||||
end
|
||||
end
|
||||
28
ruby/t/tc_020_create.rb
Normal file
28
ruby/t/tc_020_create.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
# libguestfs Ruby bindings -*- ruby -*-
|
||||
# Copyright (C) 2009-2013 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.
|
||||
|
||||
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_create
|
||||
g = Guestfs::create()
|
||||
assert_not_nil (g)
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
# libguestfs Ruby bindings -*- ruby -*-
|
||||
# Copyright (C) 2009 Red Hat Inc.
|
||||
# Copyright (C) 2009-2013 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
|
||||
@@ -21,7 +21,7 @@ $:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs"))
|
||||
require 'guestfs'
|
||||
|
||||
class TestLoad < Test::Unit::TestCase
|
||||
def test_lvcreate
|
||||
def test_launch
|
||||
g = Guestfs::create()
|
||||
|
||||
File.open("test.img", "w") {
|
||||
43
ruby/t/tc_410_close_event.rb
Normal file
43
ruby/t/tc_410_close_event.rb
Normal file
@@ -0,0 +1,43 @@
|
||||
# libguestfs Ruby bindings -*- ruby -*-
|
||||
# Copyright (C) 2011-2013 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.
|
||||
|
||||
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_events
|
||||
g = Guestfs::create()
|
||||
|
||||
close_invoked = 0
|
||||
close = Proc.new {| event, event_handle, buf, array |
|
||||
close_invoked += 1
|
||||
}
|
||||
|
||||
# Check that the close event is called.
|
||||
g.set_event_callback(close, Guestfs::EVENT_CLOSE)
|
||||
|
||||
if close_invoked != 0
|
||||
raise "close_invoked should be 0"
|
||||
end
|
||||
g.close()
|
||||
if close_invoked != 1
|
||||
raise "close_invoked should be 1"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
# libguestfs Ruby bindings -*- ruby -*-
|
||||
# Copyright (C) 2011 Red Hat Inc.
|
||||
# Copyright (C) 2011-2013 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
|
||||
@@ -24,7 +24,9 @@ class TestLoad < Test::Unit::TestCase
|
||||
def test_events
|
||||
g = Guestfs::create()
|
||||
|
||||
log_invoked = 0
|
||||
log = Proc.new {| event, event_handle, buf, array |
|
||||
log_invoked += 1
|
||||
if event == Guestfs::EVENT_APPLIANCE
|
||||
buf.chomp!
|
||||
end
|
||||
@@ -32,20 +34,11 @@ class TestLoad < Test::Unit::TestCase
|
||||
puts "ruby event logged: event=#{event_string} eh=#{event_handle} buf='#{buf}' array=#{array}"
|
||||
}
|
||||
|
||||
close_invoked = 0
|
||||
close = Proc.new {| event, event_handle, buf, array |
|
||||
close_invoked += 1
|
||||
log.call(event, event_handle, buf, array)
|
||||
}
|
||||
|
||||
# Grab log, trace and daemon messages into our custom callback.
|
||||
event_bitmask = Guestfs::EVENT_APPLIANCE | Guestfs::EVENT_LIBRARY |
|
||||
Guestfs::EVENT_TRACE
|
||||
g.set_event_callback(log, event_bitmask)
|
||||
|
||||
# Check that the close event is called.
|
||||
g.set_event_callback(close, Guestfs::EVENT_CLOSE)
|
||||
|
||||
# Make sure we see some messages.
|
||||
g.set_trace(1)
|
||||
g.set_verbose(1)
|
||||
@@ -54,12 +47,9 @@ class TestLoad < Test::Unit::TestCase
|
||||
g.add_drive_ro("/dev/null")
|
||||
g.set_autosync(1)
|
||||
|
||||
if close_invoked != 0
|
||||
raise "close_invoked should be 0"
|
||||
end
|
||||
g.close()
|
||||
if close_invoked != 1
|
||||
raise "close_invoked should be 1"
|
||||
if log_invoked == 0
|
||||
raise "log_invoked should be > 0"
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user