[Pkg-libvirt-commits] [ruby-libvirt] 02/03: Run some tests during build

Guido Guenther agx at moszumanska.debian.org
Tue Jan 7 21:22:16 UTC 2014


This is an automated email from the git hooks/post-receive script.

agx pushed a commit to annotated tag debian/0.5.1-2
in repository ruby-libvirt.

commit e0979924329d4c67f2983748f8f298fe2c8f41e0
Author: Guido Günther <agx at sigxcpu.org>
Date:   Tue Jan 7 21:48:00 2014 +0100

    Run some tests during build
    
    Making all tests usable with the testdriver will require some more work.
---
 debian/control                                     |   5 +-
 ...Allow-to-set-URI-via-environment-variable.patch | 183 +++++++++++++++++++++
 ...-Don-t-run-tests-that-require-qemu-system.patch |  28 ++++
 debian/patches/series                              |   2 +
 debian/rules                                       |   3 +
 5 files changed, 220 insertions(+), 1 deletion(-)

diff --git a/debian/control b/debian/control
index 07bbd8c..d4aa853 100644
--- a/debian/control
+++ b/debian/control
@@ -3,7 +3,10 @@ Section: ruby
 Priority: optional
 Maintainer: Debian Libvirt Maintainers <pkg-libvirt-maintainers at lists.alioth.debian.org>
 Uploaders: Guido Günther <agx at sigxcpu.org>
-Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= 0.6.0), libvirt-dev, pkg-config
+Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= 0.6.0), libvirt-dev, pkg-config,
+# for the tests
+ rake,
+ libvirt-bin
 Standards-Version: 3.9.2
 Vcs-Git: git://anonscm.debian.org/git/pkg-libvirt/ruby-libvirt.git
 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-libvirt/ruby-libvirt.git;a=summary
diff --git a/debian/patches/0002-Allow-to-set-URI-via-environment-variable.patch b/debian/patches/0002-Allow-to-set-URI-via-environment-variable.patch
new file mode 100644
index 0000000..82923fb
--- /dev/null
+++ b/debian/patches/0002-Allow-to-set-URI-via-environment-variable.patch
@@ -0,0 +1,183 @@
+From: =?utf-8?q?Guido_G=C3=BCnther?= <agx at sigxcpu.org>
+Date: Tue, 7 Jan 2014 21:35:39 +0100
+Subject: Allow to set URI via environment variable
+
+This allows us to run tests with the destdriver like:
+
+  RUBY_LIBVIRT_TEST_URI=test:///default \
+  RUBYLIB=lib/:ext/libvirt/ \
+  ruby tests/test_open.rb
+---
+ tests/test_nodedevice.rb |  2 +-
+ tests/test_open.rb       | 36 ++++++++++++++++++------------------
+ tests/test_stream.rb     |  2 +-
+ tests/test_utils.rb      |  2 ++
+ 4 files changed, 22 insertions(+), 20 deletions(-)
+
+diff --git a/tests/test_nodedevice.rb b/tests/test_nodedevice.rb
+index 7da1a5f..50a1304 100644
+--- a/tests/test_nodedevice.rb
++++ b/tests/test_nodedevice.rb
+@@ -9,7 +9,7 @@ require 'test_utils.rb'
+ 
+ set_test_object("nodedevice")
+ 
+-conn = Libvirt::open("qemu:///system")
++conn = Libvirt::open(URI)
+ 
+ # TESTGROUP: nodedevice.name
+ testnode = conn.lookup_nodedevice_by_name(conn.list_nodedevices[0])
+diff --git a/tests/test_open.rb b/tests/test_open.rb
+index 17baa93..c67eaab 100644
+--- a/tests/test_open.rb
++++ b/tests/test_open.rb
+@@ -21,49 +21,49 @@ expect_success(Libvirt, "nil arg", "version", nil) {|x| x.class == Array and x.l
+ expect_success(Libvirt, "Test arg", "version", "Test") {|x| x.class == Array and x.length == 2}
+ 
+ # TESTGROUP: Libvirt::open
+-expect_too_many_args(Libvirt, "open", "qemu:///system", 1)
++expect_too_many_args(Libvirt, "open", URI, 1)
+ expect_connect_error("open", "foo:///system")
+ conn = expect_success(Libvirt, "no args", "open") {|x| x.class == Libvirt::Connect }
+ conn.close
+-conn = expect_success(Libvirt, "qemu:///system", "open", "qemu:///system") {|x| x.class == Libvirt::Connect }
++conn = expect_success(Libvirt, URI, "open", URI) {|x| x.class == Libvirt::Connect }
+ conn.close
+ conn = expect_success(Libvirt, "nil arg", "open", nil) {|x| x.class == Libvirt::Connect }
+ conn.close
+ 
+ # TESTGROUP: Libvirt::open_read_only
+-expect_too_many_args(Libvirt, "open_read_only", "qemu:///system", 1)
++expect_too_many_args(Libvirt, "open_read_only", URI, 1)
+ expect_connect_error("open_read_only", "foo:///system")
+ conn = expect_success(Libvirt, "no args", "open_read_only") {|x| x.class == Libvirt::Connect }
+ conn.close
+-conn = expect_success(Libvirt, "qemu:///system", "open_read_only", "qemu:///system") {|x| x.class == Libvirt::Connect }
++conn = expect_success(Libvirt, URI, "open_read_only", URI) {|x| x.class == Libvirt::Connect }
+ conn.close
+ conn = expect_success(Libvirt, "nil arg", "open_read_only", nil) {|x| x.class == Libvirt::Connect }
+ conn.close
+ 
+ # TESTGROUP: Libvirt::open_auth
+-expect_too_many_args(Libvirt, "open_auth", "qemu:///system", [], "hello there", 1, 2)
++expect_too_many_args(Libvirt, "open_auth", URI, [], "hello there", 1, 2)
+ expect_connect_error("open_auth", "foo:///system")
+ expect_invalid_arg_type(Libvirt, "open_auth", 1)
+-expect_invalid_arg_type(Libvirt, "open_auth", "qemu:///system", [], "hello", "foo")
++expect_invalid_arg_type(Libvirt, "open_auth", URI, [], "hello", "foo")
+ 
+ conn = expect_success(Libvirt, "no args", "open_auth")  {|x| x.class == Libvirt::Connect }
+ conn.close
+ 
+-conn = expect_success(Libvirt, "uri arg", "open_auth", "qemu:///system") {|x| x.class == Libvirt::Connect }
++conn = expect_success(Libvirt, "uri arg", "open_auth", URI) {|x| x.class == Libvirt::Connect }
+ conn.close
+ 
+-conn = expect_success(Libvirt, "uri and empty cred args", "open_auth", "qemu:///system", []) {|x| x.class == Libvirt::Connect }
++conn = expect_success(Libvirt, "uri and empty cred args", "open_auth", URI, []) {|x| x.class == Libvirt::Connect }
+ conn.close
+ 
+-conn = expect_success(Libvirt, "uri and full cred args", "open_auth", "qemu:///system", [Libvirt::CRED_AUTHNAME, Libvirt::CRED_PASSPHRASE]) {|x| x.class == Libvirt::Connect }
++conn = expect_success(Libvirt, "uri and full cred args", "open_auth", URI, [Libvirt::CRED_AUTHNAME, Libvirt::CRED_PASSPHRASE]) {|x| x.class == Libvirt::Connect }
+ conn.close
+ 
+-conn = expect_success(Libvirt, "uri, full cred, and user args", "open_auth", "qemu:///system", [Libvirt::CRED_AUTHNAME, Libvirt::CRED_PASSPHRASE], "hello") {|x| x.class == Libvirt::Connect }
++conn = expect_success(Libvirt, "uri, full cred, and user args", "open_auth", URI, [Libvirt::CRED_AUTHNAME, Libvirt::CRED_PASSPHRASE], "hello") {|x| x.class == Libvirt::Connect }
+ conn.close
+ 
+ # equivalent to expect_invalid_arg_type
+ begin
+-  conn = Libvirt::open_auth("qemu:///system", {}) do |cred|
++  conn = Libvirt::open_auth(URI, {}) do |cred|
+   end
+ rescue TypeError => e
+   puts_ok "#{$test_object}.open_auth invalid arg type threw #{TypeError.to_s}"
+@@ -73,7 +73,7 @@ end
+ 
+ # equivalent to expect_invalid_arg_type
+ begin
+-  conn = Libvirt::open_auth("qemu:///system", 1) do |cred|
++  conn = Libvirt::open_auth(URI, 1) do |cred|
+   end
+ rescue TypeError => e
+   puts_ok "#{$test_object}.open_auth invalid arg type threw #{TypeError.to_s}"
+@@ -83,7 +83,7 @@ end
+ 
+ # equivalent to expect_invalid_arg_type
+ begin
+-  conn = Libvirt::open_auth("qemu:///system", 'foo') do |cred|
++  conn = Libvirt::open_auth(URI, 'foo') do |cred|
+   end
+ rescue TypeError => e
+   puts_ok "#{$test_object}.open_auth invalid arg type threw #{TypeError.to_s}"
+@@ -93,7 +93,7 @@ end
+ 
+ # equivalent to "expect_success"
+ begin
+-  conn = Libvirt::open_auth("qemu:///system", [Libvirt::CRED_AUTHNAME, Libvirt::CRED_PASSPHRASE], "hello") do |cred|
++  conn = Libvirt::open_auth(URI, [Libvirt::CRED_AUTHNAME, Libvirt::CRED_PASSPHRASE], "hello") do |cred|
+     if not cred["userdata"].nil?
+       puts "userdata is #{cred["userdata"]}"
+     end
+@@ -122,7 +122,7 @@ end
+ 
+ # equivalent to "expect_success"
+ begin
+-  conn = Libvirt::open_auth("qemu:///system") do |cred|
++  conn = Libvirt::open_auth(URI) do |cred|
+   end
+ 
+   puts_ok "Libvirt.open_auth uri, succeeded"
+@@ -135,7 +135,7 @@ end
+ 
+ # equivalent to "expect_success"
+ begin
+-  conn = Libvirt::open_auth("qemu:///system", [Libvirt::CRED_AUTHNAME, Libvirt::CRED_PASSPHRASE], "hello", Libvirt::CONNECT_RO) do |cred|
++  conn = Libvirt::open_auth(URI, [Libvirt::CRED_AUTHNAME, Libvirt::CRED_PASSPHRASE], "hello", Libvirt::CONNECT_RO) do |cred|
+     if not cred["userdata"].nil?
+       puts "userdata is #{cred["userdata"]}"
+     end
+@@ -163,7 +163,7 @@ rescue => e
+ end
+ 
+ # TESTGROUP: Libvirt::event_invoke_handle_callback
+-conn = Libvirt::open("qemu:///system")
++conn = Libvirt::open(URI)
+ 
+ expect_too_many_args(Libvirt, "event_invoke_handle_callback", 1, 2, 3, 4, 5)
+ expect_too_few_args(Libvirt, "event_invoke_handle_callback")
+@@ -188,7 +188,7 @@ expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", 1, 1, 1, { "lib
+ conn.close
+ 
+ # TESTGROUP: Libvirt::event_invoke_timeout_callback
+-conn = Libvirt::open("qemu:///system")
++conn = Libvirt::open(URI)
+ 
+ expect_too_many_args(Libvirt, "event_invoke_timeout_callback", 1, 2, 3)
+ expect_too_few_args(Libvirt, "event_invoke_timeout_callback")
+diff --git a/tests/test_stream.rb b/tests/test_stream.rb
+index 07ec222..e272104 100644
+--- a/tests/test_stream.rb
++++ b/tests/test_stream.rb
+@@ -9,7 +9,7 @@ require 'test_utils.rb'
+ 
+ set_test_object("stream")
+ 
+-conn = Libvirt::open("qemu:///system")
++conn = Libvirt::open(URI)
+ 
+ # TESTGROUP: stream.send
+ st = conn.stream
+diff --git a/tests/test_utils.rb b/tests/test_utils.rb
+index 1bac1cc..519de27 100644
+--- a/tests/test_utils.rb
++++ b/tests/test_utils.rb
+@@ -2,6 +2,8 @@ $FAIL = 0
+ $SUCCESS = 0
+ $SKIPPED = 0
+ 
++URI = ENV['RUBY_LIBVIRT_TEST_URI'] || "qemu:///system"
++
+ $GUEST_BASE = '/var/lib/libvirt/images/ruby-libvirt-tester'
+ $GUEST_DISK = $GUEST_BASE + '.qcow2'
+ $GUEST_SAVE = $GUEST_BASE + '.save'
diff --git a/debian/patches/0003-Don-t-run-tests-that-require-qemu-system.patch b/debian/patches/0003-Don-t-run-tests-that-require-qemu-system.patch
new file mode 100644
index 0000000..0710f8b
--- /dev/null
+++ b/debian/patches/0003-Don-t-run-tests-that-require-qemu-system.patch
@@ -0,0 +1,28 @@
+From: =?utf-8?q?Guido_G=C3=BCnther?= <agx at sigxcpu.org>
+Date: Tue, 7 Jan 2014 21:46:18 +0100
+Subject: Don't run tests that require qemu:///system
+
+We only want to run tests for now that work with the testdriver
+---
+ Rakefile | 8 +++-----
+ 1 file changed, 3 insertions(+), 5 deletions(-)
+
+diff --git a/Rakefile b/Rakefile
+index 753a096..3a2b99b 100644
+--- a/Rakefile
++++ b/Rakefile
+@@ -75,11 +75,9 @@ task :build => LIBVIRT_MODULE
+ #
+ 
+ Rake::TestTask.new(:test) do |t|
+-    t.test_files = [ 'tests/test_conn.rb', 'tests/test_domain.rb',
+-                     'tests/test_interface.rb', 'tests/test_network.rb',
+-                     'tests/test_nodedevice.rb', 'tests/test_nwfilter.rb',
+-                     'tests/test_open.rb', 'tests/test_secret.rb',
+-                     'tests/test_storage.rb', 'tests/test_stream.rb' ]
++    t.test_files = [ 'tests/test_nodedevice.rb',
++                     'tests/test_open.rb',
++                     'tests/test_stream.rb' ]
+     t.libs = [ 'lib', 'ext/libvirt' ]
+ end
+ task :test => :build
diff --git a/debian/patches/series b/debian/patches/series
index 753357e..cc73464 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,3 @@
 0001-Don-t-free-more-entries-than-we-retrieved.patch
+0002-Allow-to-set-URI-via-environment-variable.patch
+0003-Don-t-run-tests-that-require-qemu-system.patch
diff --git a/debian/rules b/debian/rules
index 5df7f46..eb62130 100755
--- a/debian/rules
+++ b/debian/rules
@@ -3,3 +3,6 @@
 
 %:
 	dh $@ --buildsystem=ruby --with ruby
+
+override_dh_auto_test:
+	RUBY_LIBVIRT_TEST_URI=test:///default rake test

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/ruby-libvirt.git



More information about the Pkg-libvirt-commits mailing list