File: 0002-Allow-to-set-URI-via-environment-variable.patch

package info (click to toggle)
ruby-libvirt 0.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,292 kB
  • ctags: 1,033
  • sloc: ansic: 8,675; ruby: 2,836; makefile: 7
file content (183 lines) | stat: -rw-r--r-- 7,559 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
From: =?utf-8?q?Guido_G=C3=BCnther?= <agx@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'