ruby-libvirt 0.8.2 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,13 +9,15 @@ require 'test_utils.rb'
9
9
 
10
10
  set_test_object("interface")
11
11
 
12
- conn = Libvirt::open("qemu:///system")
12
+ conn = Libvirt::open(URI)
13
13
 
14
14
  # test setup
15
- begin
16
- `rm -f /etc/sysconfig/network-scripts/ifcfg-rb-libvirt-test`
17
- `brctl delbr rb-libvirt-test >& /dev/null`
18
- rescue
15
+ if !test_default_uri?
16
+ begin
17
+ `rm -f /etc/sysconfig/network-scripts/ifcfg-rb-libvirt-test`
18
+ `brctl delbr rb-libvirt-test >& /dev/null`
19
+ rescue
20
+ end
19
21
  end
20
22
 
21
23
  # TESTGROUP: iface.undefine
@@ -9,7 +9,7 @@ require 'test_utils.rb'
9
9
 
10
10
  set_test_object("network")
11
11
 
12
- conn = Libvirt::open("qemu:///system")
12
+ conn = Libvirt::open(URI)
13
13
 
14
14
  cleanup_test_network(conn)
15
15
 
@@ -9,49 +9,59 @@ require 'test_utils.rb'
9
9
 
10
10
  set_test_object("nwfilter")
11
11
 
12
- conn = Libvirt::open("qemu:///system")
12
+ conn = Libvirt::open(URI)
13
13
 
14
14
  # TESTGROUP: nwfilter.undefine
15
- newnw = conn.define_nwfilter_xml($new_nwfilter_xml)
15
+ if !test_default_uri?
16
+ newnw = conn.define_nwfilter_xml($new_nwfilter_xml)
16
17
 
17
- expect_too_many_args(newnw, "undefine", 1)
18
+ expect_too_many_args(newnw, "undefine", 1)
18
19
 
19
- expect_success(newnw, "no args", "undefine")
20
+ expect_success(newnw, "no args", "undefine")
21
+ end
20
22
 
21
23
  # TESTGROUP: nwfilter.name
22
- newnw = conn.define_nwfilter_xml($new_nwfilter_xml)
24
+ if !test_default_uri?
25
+ newnw = conn.define_nwfilter_xml($new_nwfilter_xml)
23
26
 
24
- expect_too_many_args(newnw, "name", 1)
27
+ expect_too_many_args(newnw, "name", 1)
25
28
 
26
- expect_success(newnw, "no args", "name") {|x| x == "rb-libvirt-test"}
29
+ expect_success(newnw, "no args", "name") {|x| x == "rb-libvirt-test"}
27
30
 
28
- newnw.undefine
31
+ newnw.undefine
32
+ end
29
33
 
30
34
  # TESTGROUP: nwfilter.uuid
31
- newnw = conn.define_nwfilter_xml($new_nwfilter_xml)
35
+ if !test_default_uri?
36
+ newnw = conn.define_nwfilter_xml($new_nwfilter_xml)
32
37
 
33
- expect_too_many_args(newnw, "uuid", 1)
38
+ expect_too_many_args(newnw, "uuid", 1)
34
39
 
35
- expect_success(newnw, "no args", "uuid") {|x| x == $NWFILTER_UUID}
40
+ expect_success(newnw, "no args", "uuid") {|x| x == $NWFILTER_UUID}
36
41
 
37
- newnw.undefine
42
+ newnw.undefine
43
+ end
38
44
 
39
45
  # TESTGROUP: nwfilter.xml_desc
40
- newnw = conn.define_nwfilter_xml($new_nwfilter_xml)
46
+ if !test_default_uri?
47
+ newnw = conn.define_nwfilter_xml($new_nwfilter_xml)
41
48
 
42
- expect_too_many_args(newnw, "xml_desc", 1, 2)
43
- expect_invalid_arg_type(newnw, "xml_desc", "foo")
49
+ expect_too_many_args(newnw, "xml_desc", 1, 2)
50
+ expect_invalid_arg_type(newnw, "xml_desc", "foo")
44
51
 
45
- expect_success(newnw, "no args", "xml_desc")
52
+ expect_success(newnw, "no args", "xml_desc")
46
53
 
47
- newnw.undefine
54
+ newnw.undefine
55
+ end
48
56
 
49
57
  # TESTGROUP: nwfilter.free
50
- newnw = conn.define_nwfilter_xml($new_nwfilter_xml)
51
- newnw.undefine
52
- expect_too_many_args(newnw, "free", 1)
58
+ if !test_default_uri?
59
+ newnw = conn.define_nwfilter_xml($new_nwfilter_xml)
60
+ newnw.undefine
61
+ expect_too_many_args(newnw, "free", 1)
53
62
 
54
- expect_success(newnw, "no args", "free")
63
+ expect_success(newnw, "no args", "free")
64
+ end
55
65
 
56
66
  # END TESTS
57
67
 
data/tests/test_open.rb CHANGED
@@ -21,229 +21,241 @@ expect_success(Libvirt, "nil arg", "version", nil) {|x| x.class == Array and x.l
21
21
  expect_success(Libvirt, "Test arg", "version", "Test") {|x| x.class == Array and x.length == 2}
22
22
 
23
23
  # TESTGROUP: Libvirt::open
24
- expect_too_many_args(Libvirt, "open", URI, 1)
25
- expect_connect_error("open", "foo:///system")
26
- conn = expect_success(Libvirt, "no args", "open") {|x| x.class == Libvirt::Connect }
27
- conn.close
28
- conn = expect_success(Libvirt, URI, "open", URI) {|x| x.class == Libvirt::Connect }
29
- conn.close
30
- conn = expect_success(Libvirt, "nil arg", "open", nil) {|x| x.class == Libvirt::Connect }
31
- conn.close
24
+ if !test_default_uri?
25
+ expect_too_many_args(Libvirt, "open", URI, 1)
26
+ expect_connect_error("open", "foo:///system")
27
+ conn = expect_success(Libvirt, "no args", "open") {|x| x.class == Libvirt::Connect }
28
+ conn.close
29
+ conn = expect_success(Libvirt, URI, "open", URI) {|x| x.class == Libvirt::Connect }
30
+ conn.close
31
+ conn = expect_success(Libvirt, "nil arg", "open", nil) {|x| x.class == Libvirt::Connect }
32
+ conn.close
33
+ end
32
34
 
33
35
  # TESTGROUP: Libvirt::open_read_only
34
- expect_too_many_args(Libvirt, "open_read_only", URI, 1)
35
- expect_connect_error("open_read_only", "foo:///system")
36
- conn = expect_success(Libvirt, "no args", "open_read_only") {|x| x.class == Libvirt::Connect }
37
- conn.close
38
- conn = expect_success(Libvirt, URI, "open_read_only", URI) {|x| x.class == Libvirt::Connect }
39
- conn.close
40
- conn = expect_success(Libvirt, "nil arg", "open_read_only", nil) {|x| x.class == Libvirt::Connect }
41
- conn.close
36
+ if !test_default_uri?
37
+ expect_too_many_args(Libvirt, "open_read_only", URI, 1)
38
+ expect_connect_error("open_read_only", "foo:///system")
39
+ conn = expect_success(Libvirt, "no args", "open_read_only") {|x| x.class == Libvirt::Connect }
40
+ conn.close
41
+ conn = expect_success(Libvirt, URI, "open_read_only", URI) {|x| x.class == Libvirt::Connect }
42
+ conn.close
43
+ conn = expect_success(Libvirt, "nil arg", "open_read_only", nil) {|x| x.class == Libvirt::Connect }
44
+ conn.close
45
+ end
42
46
 
43
47
  # TESTGROUP: Libvirt::open_auth
44
- expect_too_many_args(Libvirt, "open_auth", URI, [], "hello there", 1, 2)
45
- expect_connect_error("open_auth", "foo:///system")
46
- expect_invalid_arg_type(Libvirt, "open_auth", 1)
47
- expect_invalid_arg_type(Libvirt, "open_auth", URI, [], "hello", "foo")
48
+ if !test_default_uri?
49
+ expect_too_many_args(Libvirt, "open_auth", URI, [], "hello there", 1, 2)
50
+ expect_connect_error("open_auth", "foo:///system")
51
+ expect_invalid_arg_type(Libvirt, "open_auth", 1)
52
+ expect_invalid_arg_type(Libvirt, "open_auth", URI, [], "hello", "foo")
48
53
 
49
- conn = expect_success(Libvirt, "no args", "open_auth") {|x| x.class == Libvirt::Connect }
50
- conn.close
54
+ conn = expect_success(Libvirt, "no args", "open_auth") {|x| x.class == Libvirt::Connect }
55
+ conn.close
51
56
 
52
- conn = expect_success(Libvirt, "uri arg", "open_auth", URI) {|x| x.class == Libvirt::Connect }
53
- conn.close
57
+ conn = expect_success(Libvirt, "uri arg", "open_auth", URI) {|x| x.class == Libvirt::Connect }
58
+ conn.close
54
59
 
55
- conn = expect_success(Libvirt, "uri and empty cred args", "open_auth", URI, []) {|x| x.class == Libvirt::Connect }
56
- conn.close
60
+ conn = expect_success(Libvirt, "uri and empty cred args", "open_auth", URI, []) {|x| x.class == Libvirt::Connect }
61
+ conn.close
57
62
 
58
- conn = expect_success(Libvirt, "uri and full cred args", "open_auth", URI, [Libvirt::CRED_AUTHNAME, Libvirt::CRED_PASSPHRASE]) {|x| x.class == Libvirt::Connect }
59
- conn.close
63
+ conn = expect_success(Libvirt, "uri and full cred args", "open_auth", URI, [Libvirt::CRED_AUTHNAME, Libvirt::CRED_PASSPHRASE]) {|x| x.class == Libvirt::Connect }
64
+ conn.close
60
65
 
61
- 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 }
62
- conn.close
66
+ 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 }
67
+ conn.close
63
68
 
64
- # equivalent to expect_invalid_arg_type
65
- begin
66
- conn = Libvirt::open_auth(URI, {}) do |cred|
69
+ # equivalent to expect_invalid_arg_type
70
+ begin
71
+ conn = Libvirt::open_auth(URI, {}) do |cred|
72
+ end
73
+ rescue TypeError => e
74
+ puts_ok "#{$test_object}.open_auth invalid arg type threw #{TypeError.to_s}"
75
+ else
76
+ puts_fail "#{$test_object}.open_auth invalid arg type expected to throw #{TypeError.to_s}, but threw nothing"
67
77
  end
68
- rescue TypeError => e
69
- puts_ok "#{$test_object}.open_auth invalid arg type threw #{TypeError.to_s}"
70
- else
71
- puts_fail "#{$test_object}.open_auth invalid arg type expected to throw #{TypeError.to_s}, but threw nothing"
72
- end
73
78
 
74
- # equivalent to expect_invalid_arg_type
75
- begin
76
- conn = Libvirt::open_auth(URI, 1) do |cred|
79
+ # equivalent to expect_invalid_arg_type
80
+ begin
81
+ conn = Libvirt::open_auth(URI, 1) do |cred|
82
+ end
83
+ rescue TypeError => e
84
+ puts_ok "#{$test_object}.open_auth invalid arg type threw #{TypeError.to_s}"
85
+ else
86
+ puts_fail "#{$test_object}.open_auth invalid arg type expected to throw #{TypeError.to_s}, but threw nothing"
77
87
  end
78
- rescue TypeError => e
79
- puts_ok "#{$test_object}.open_auth invalid arg type threw #{TypeError.to_s}"
80
- else
81
- puts_fail "#{$test_object}.open_auth invalid arg type expected to throw #{TypeError.to_s}, but threw nothing"
82
- end
83
88
 
84
- # equivalent to expect_invalid_arg_type
85
- begin
86
- conn = Libvirt::open_auth(URI, 'foo') do |cred|
89
+ # equivalent to expect_invalid_arg_type
90
+ begin
91
+ conn = Libvirt::open_auth(URI, 'foo') do |cred|
92
+ end
93
+ rescue TypeError => e
94
+ puts_ok "#{$test_object}.open_auth invalid arg type threw #{TypeError.to_s}"
95
+ else
96
+ puts_fail "#{$test_object}.open_auth invalid arg type expected to throw #{TypeError.to_s}, but threw nothing"
87
97
  end
88
- rescue TypeError => e
89
- puts_ok "#{$test_object}.open_auth invalid arg type threw #{TypeError.to_s}"
90
- else
91
- puts_fail "#{$test_object}.open_auth invalid arg type expected to throw #{TypeError.to_s}, but threw nothing"
92
- end
93
98
 
94
- # equivalent to "expect_success"
95
- begin
96
- conn = Libvirt::open_auth(URI, [Libvirt::CRED_AUTHNAME, Libvirt::CRED_PASSPHRASE], "hello") do |cred|
97
- if not cred["userdata"].nil?
98
- puts "userdata is #{cred["userdata"]}"
99
- end
100
- if cred["type"] == Libvirt::CRED_AUTHNAME
101
- print "#{cred['prompt']}: "
102
- res = gets
103
- # strip off the \n
104
- res = res[0..-2]
105
- elsif cred["type"] == Libvirt::CRED_PASSPHRASE
106
- print "#{cred['prompt']}: "
107
- res = gets
108
- res = res[0..-2]
109
- else
110
- raise "Unsupported credential #{cred['type']}"
99
+ # equivalent to "expect_success"
100
+ begin
101
+ conn = Libvirt::open_auth(URI, [Libvirt::CRED_AUTHNAME, Libvirt::CRED_PASSPHRASE], "hello") do |cred|
102
+ if not cred["userdata"].nil?
103
+ puts "userdata is #{cred["userdata"]}"
104
+ end
105
+ if cred["type"] == Libvirt::CRED_AUTHNAME
106
+ print "#{cred['prompt']}: "
107
+ res = gets
108
+ # strip off the \n
109
+ res = res[0..-2]
110
+ elsif cred["type"] == Libvirt::CRED_PASSPHRASE
111
+ print "#{cred['prompt']}: "
112
+ res = gets
113
+ res = res[0..-2]
114
+ else
115
+ raise "Unsupported credential #{cred['type']}"
116
+ end
117
+ res
111
118
  end
112
- res
119
+
120
+ puts_ok "Libvirt.open_auth uri, creds, userdata, auth block succeeded"
121
+ conn.close
122
+ rescue NoMethodError
123
+ puts_skipped "Libvirt.open_auth does not exist"
124
+ rescue => e
125
+ puts_fail "Libvirt.open_auth uri, creds, userdata, auth block expected to succeed, threw #{e.class.to_s}: #{e.to_s}"
113
126
  end
114
127
 
115
- puts_ok "Libvirt.open_auth uri, creds, userdata, auth block succeeded"
116
- conn.close
117
- rescue NoMethodError
118
- puts_skipped "Libvirt.open_auth does not exist"
119
- rescue => e
120
- puts_fail "Libvirt.open_auth uri, creds, userdata, auth block expected to succeed, threw #{e.class.to_s}: #{e.to_s}"
121
- end
128
+ # equivalent to "expect_success"
129
+ begin
130
+ conn = Libvirt::open_auth(URI) do |cred|
131
+ end
122
132
 
123
- # equivalent to "expect_success"
124
- begin
125
- conn = Libvirt::open_auth(URI) do |cred|
133
+ puts_ok "Libvirt.open_auth uri, succeeded"
134
+ conn.close
135
+ rescue NoMethodError
136
+ puts_skipped "Libvirt.open_auth does not exist"
137
+ rescue => e
138
+ puts_fail "Libvirt.open_auth uri expected to succeed, threw #{e.class.to_s}: #{e.to_s}"
126
139
  end
127
140
 
128
- puts_ok "Libvirt.open_auth uri, succeeded"
129
- conn.close
130
- rescue NoMethodError
131
- puts_skipped "Libvirt.open_auth does not exist"
132
- rescue => e
133
- puts_fail "Libvirt.open_auth uri expected to succeed, threw #{e.class.to_s}: #{e.to_s}"
134
- end
135
-
136
- # equivalent to "expect_success"
137
- begin
138
- conn = Libvirt::open_auth(URI, [Libvirt::CRED_AUTHNAME, Libvirt::CRED_PASSPHRASE], "hello", Libvirt::CONNECT_RO) do |cred|
139
- if not cred["userdata"].nil?
140
- puts "userdata is #{cred["userdata"]}"
141
+ # equivalent to "expect_success"
142
+ begin
143
+ conn = Libvirt::open_auth(URI, [Libvirt::CRED_AUTHNAME, Libvirt::CRED_PASSPHRASE], "hello", Libvirt::CONNECT_RO) do |cred|
144
+ if not cred["userdata"].nil?
145
+ puts "userdata is #{cred["userdata"]}"
146
+ end
147
+ if cred["type"] == Libvirt::CRED_AUTHNAME
148
+ print "#{cred['prompt']}: "
149
+ res = gets
150
+ # strip off the \n
151
+ res = res[0..-2]
152
+ elsif cred["type"] == Libvirt::CRED_PASSPHRASE
153
+ print "#{cred['prompt']}: "
154
+ res = gets
155
+ res = res[0..-2]
156
+ else
157
+ raise "Unsupported credential #{cred['type']}"
158
+ end
159
+ res
141
160
  end
142
- if cred["type"] == Libvirt::CRED_AUTHNAME
143
- print "#{cred['prompt']}: "
144
- res = gets
145
- # strip off the \n
146
- res = res[0..-2]
147
- elsif cred["type"] == Libvirt::CRED_PASSPHRASE
148
- print "#{cred['prompt']}: "
149
- res = gets
150
- res = res[0..-2]
151
- else
152
- raise "Unsupported credential #{cred['type']}"
153
- end
154
- res
155
- end
156
161
 
157
- puts_ok "Libvirt.open_auth uri, creds, userdata, R/O flag, auth block succeeded"
158
- conn.close
159
- rescue NoMethodError
160
- puts_skipped "Libvirt.open_auth does not exist"
161
- rescue => e
162
- puts_fail "Libvirt.open_auth uri, creds, userdata, R/O flag, auth block expected to succeed, threw #{e.class.to_s}: #{e.to_s}"
162
+ puts_ok "Libvirt.open_auth uri, creds, userdata, R/O flag, auth block succeeded"
163
+ conn.close
164
+ rescue NoMethodError
165
+ puts_skipped "Libvirt.open_auth does not exist"
166
+ rescue => e
167
+ puts_fail "Libvirt.open_auth uri, creds, userdata, R/O flag, auth block expected to succeed, threw #{e.class.to_s}: #{e.to_s}"
168
+ end
163
169
  end
164
170
 
165
171
  # TESTGROUP: Libvirt::event_invoke_handle_callback
166
- conn = Libvirt::open(URI)
167
-
168
- expect_too_many_args(Libvirt, "event_invoke_handle_callback", 1, 2, 3, 4, 5)
169
- expect_too_few_args(Libvirt, "event_invoke_handle_callback")
170
- expect_too_few_args(Libvirt, "event_invoke_handle_callback", 1)
171
- expect_too_few_args(Libvirt, "event_invoke_handle_callback", 1, 2)
172
- expect_too_few_args(Libvirt, "event_invoke_handle_callback", 1, 2, 3)
173
- expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", "hello", 1, 1, 1)
174
- expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", "hello", 1, 1, [])
175
- expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", "hello", 1, 1, nil)
176
- # this is a bit bizarre; I am constructing a bogus hash to pass as the 4th
177
- # parameter to event_invoke_handle_callback. In a real situation, I would
178
- # have been given this hash from libvirt earlier, and just pass it on. I
179
- # don't want all of that complexity here, though, so I create the bogus hash.
180
- # One caveat; the data inside the hash *must* be of type T_DATA, so I pass in
181
- # a fake conn object just to appease the type checker (so I can test out the
182
- # other arguments properly)
183
- expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", "hello", 1, 1, { "libvirt_cb" => conn, "opaque" => conn })
184
- expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", 1, "hello", 1, { "libvirt_cb" => conn, "opaque" => conn })
185
- expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", 1, 1, "hello", { "libvirt_cb" => conn, "opaque" => conn })
186
- expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", 1, 1, 1, { "libvirt_cb" => "hello", "opaque" => conn })
187
- expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", 1, 1, 1, { "libvirt_cb" => conn, "opaque" => "hello" })
188
- conn.close
172
+ if !test_default_uri?
173
+ conn = Libvirt::open(URI)
174
+
175
+ expect_too_many_args(Libvirt, "event_invoke_handle_callback", 1, 2, 3, 4, 5)
176
+ expect_too_few_args(Libvirt, "event_invoke_handle_callback")
177
+ expect_too_few_args(Libvirt, "event_invoke_handle_callback", 1)
178
+ expect_too_few_args(Libvirt, "event_invoke_handle_callback", 1, 2)
179
+ expect_too_few_args(Libvirt, "event_invoke_handle_callback", 1, 2, 3)
180
+ expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", "hello", 1, 1, 1)
181
+ expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", "hello", 1, 1, [])
182
+ expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", "hello", 1, 1, nil)
183
+ # this is a bit bizarre; I am constructing a bogus hash to pass as the 4th
184
+ # parameter to event_invoke_handle_callback. In a real situation, I would
185
+ # have been given this hash from libvirt earlier, and just pass it on. I
186
+ # don't want all of that complexity here, though, so I create the bogus hash.
187
+ # One caveat; the data inside the hash *must* be of type T_DATA, so I pass in
188
+ # a fake conn object just to appease the type checker (so I can test out the
189
+ # other arguments properly)
190
+ expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", "hello", 1, 1, { "libvirt_cb" => conn, "opaque" => conn })
191
+ expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", 1, "hello", 1, { "libvirt_cb" => conn, "opaque" => conn })
192
+ expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", 1, 1, "hello", { "libvirt_cb" => conn, "opaque" => conn })
193
+ expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", 1, 1, 1, { "libvirt_cb" => "hello", "opaque" => conn })
194
+ expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", 1, 1, 1, { "libvirt_cb" => conn, "opaque" => "hello" })
195
+ conn.close
196
+ end
189
197
 
190
198
  # TESTGROUP: Libvirt::event_invoke_timeout_callback
191
- conn = Libvirt::open(URI)
192
-
193
- expect_too_many_args(Libvirt, "event_invoke_timeout_callback", 1, 2, 3)
194
- expect_too_few_args(Libvirt, "event_invoke_timeout_callback")
195
- expect_too_few_args(Libvirt, "event_invoke_timeout_callback", 1)
196
- expect_invalid_arg_type(Libvirt, "event_invoke_timeout_callback", "hello", 1)
197
- expect_invalid_arg_type(Libvirt, "event_invoke_timeout_callback", "hello", [])
198
- expect_invalid_arg_type(Libvirt, "event_invoke_timeout_callback", "hello", nil)
199
- # this is a bit bizarre; I am constructing a bogus hash to pass as the 4th
200
- # parameter to event_invoke_handle_callback. In a real situation, I would
201
- # have been given this hash from libvirt earlier, and just pass it on. I
202
- # don't want all of that complexity here, though, so I create the bogus hash.
203
- # One caveat; the data inside the hash *must* be of type T_DATA, so I pass in
204
- # a fake conn object just to appease the type checker (so I can test out the
205
- # other arguments properly)
206
- expect_invalid_arg_type(Libvirt, "event_invoke_timeout_callback", "hello", { "libvirt_cb" => conn, "opaque" => conn })
207
- expect_invalid_arg_type(Libvirt, "event_invoke_timeout_callback", 1, { "libvirt_cb" => "hello", "opaque" => conn })
208
- expect_invalid_arg_type(Libvirt, "event_invoke_timeout_callback", 1, { "libvirt_cb" => conn, "opaque" => "hello" })
209
- conn.close
199
+ if !test_default_uri?
200
+ conn = Libvirt::open(URI)
201
+
202
+ expect_too_many_args(Libvirt, "event_invoke_timeout_callback", 1, 2, 3)
203
+ expect_too_few_args(Libvirt, "event_invoke_timeout_callback")
204
+ expect_too_few_args(Libvirt, "event_invoke_timeout_callback", 1)
205
+ expect_invalid_arg_type(Libvirt, "event_invoke_timeout_callback", "hello", 1)
206
+ expect_invalid_arg_type(Libvirt, "event_invoke_timeout_callback", "hello", [])
207
+ expect_invalid_arg_type(Libvirt, "event_invoke_timeout_callback", "hello", nil)
208
+ # this is a bit bizarre; I am constructing a bogus hash to pass as the 4th
209
+ # parameter to event_invoke_handle_callback. In a real situation, I would
210
+ # have been given this hash from libvirt earlier, and just pass it on. I
211
+ # don't want all of that complexity here, though, so I create the bogus hash.
212
+ # One caveat; the data inside the hash *must* be of type T_DATA, so I pass in
213
+ # a fake conn object just to appease the type checker (so I can test out the
214
+ # other arguments properly)
215
+ expect_invalid_arg_type(Libvirt, "event_invoke_timeout_callback", "hello", { "libvirt_cb" => conn, "opaque" => conn })
216
+ expect_invalid_arg_type(Libvirt, "event_invoke_timeout_callback", 1, { "libvirt_cb" => "hello", "opaque" => conn })
217
+ expect_invalid_arg_type(Libvirt, "event_invoke_timeout_callback", 1, { "libvirt_cb" => conn, "opaque" => "hello" })
218
+ conn.close
219
+ end
210
220
 
211
221
  # TESTGROUP: Libvirt::event_register_impl
212
- expect_too_many_args(Libvirt, "event_register_impl", 1, 2, 3, 4, 5, 6, 7)
213
- expect_invalid_arg_type(Libvirt, "event_register_impl", 1)
222
+ if !test_default_uri?
223
+ expect_too_many_args(Libvirt, "event_register_impl", 1, 2, 3, 4, 5, 6, 7)
224
+ expect_invalid_arg_type(Libvirt, "event_register_impl", 1)
214
225
 
215
- # symbol callbacks
216
- def virEventAddHandleImpl(fd, events, opaque)
217
- end
218
- def virEventUpdateHandleImpl(watch, event)
219
- end
220
- def virEventRemoveHandleImpl(handleID)
221
- end
222
- def virEventAddTimerImpl(interval, opaque)
223
- end
224
- def virEventUpdateTimerImpl(timer, timeout)
225
- end
226
- def virEventRemoveTimerImpl(timerID)
227
- end
226
+ # symbol callbacks
227
+ def virEventAddHandleImpl(fd, events, opaque)
228
+ end
229
+ def virEventUpdateHandleImpl(watch, event)
230
+ end
231
+ def virEventRemoveHandleImpl(handleID)
232
+ end
233
+ def virEventAddTimerImpl(interval, opaque)
234
+ end
235
+ def virEventUpdateTimerImpl(timer, timeout)
236
+ end
237
+ def virEventRemoveTimerImpl(timerID)
238
+ end
228
239
 
229
- # proc callbacks
230
- virEventAddHandleProc = lambda {|fd, events, opaque|
231
- }
232
- virEventUpdateHandleProc = lambda {|watch, event|
233
- }
234
- virEventRemoveHandleProc = lambda {|handleID|
235
- }
236
- virEventAddTimerProc = lambda {|interval, opaque|
237
- }
238
- virEventUpdateTimerProc = lambda {|timer, timeout|
239
- }
240
- virEventRemoveTimerProc = lambda {|timerID|
241
- }
242
-
243
- expect_success(Libvirt, "all Symbol callbacks", "event_register_impl", :virEventAddHandleImpl, :virEventUpdateHandleImpl, :virEventRemoveHandleImpl, :virEventAddTimerImpl, :virEventUpdateTimerImpl, :virEventRemoveTimerImpl)
244
- expect_success(Libvirt, "unregister all callbacks", "event_register_impl", nil, nil, nil, nil, nil, nil)
245
- expect_success(Libvirt, "all Proc callbacks", "event_register_impl", virEventAddHandleProc, virEventUpdateHandleProc, virEventRemoveHandleProc, virEventAddTimerProc, virEventUpdateTimerProc, virEventRemoveTimerProc)
246
- expect_success(Libvirt, "unregister all callbacks", "event_register_impl")
240
+ # proc callbacks
241
+ virEventAddHandleProc = lambda {|fd, events, opaque|
242
+ }
243
+ virEventUpdateHandleProc = lambda {|watch, event|
244
+ }
245
+ virEventRemoveHandleProc = lambda {|handleID|
246
+ }
247
+ virEventAddTimerProc = lambda {|interval, opaque|
248
+ }
249
+ virEventUpdateTimerProc = lambda {|timer, timeout|
250
+ }
251
+ virEventRemoveTimerProc = lambda {|timerID|
252
+ }
253
+
254
+ expect_success(Libvirt, "all Symbol callbacks", "event_register_impl", :virEventAddHandleImpl, :virEventUpdateHandleImpl, :virEventRemoveHandleImpl, :virEventAddTimerImpl, :virEventUpdateTimerImpl, :virEventRemoveTimerImpl)
255
+ expect_success(Libvirt, "unregister all callbacks", "event_register_impl", nil, nil, nil, nil, nil, nil)
256
+ expect_success(Libvirt, "all Proc callbacks", "event_register_impl", virEventAddHandleProc, virEventUpdateHandleProc, virEventRemoveHandleProc, virEventAddTimerProc, virEventUpdateTimerProc, virEventRemoveTimerProc)
257
+ expect_success(Libvirt, "unregister all callbacks", "event_register_impl")
258
+ end
247
259
 
248
260
  # END TESTS
249
261