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.
- checksums.yaml +4 -4
- data/NEWS.rst +235 -0
- data/README.rst +45 -0
- data/Rakefile +114 -93
- data/ext/libvirt/common.c +11 -0
- data/ext/libvirt/common.h +2 -0
- data/ext/libvirt/connect.c +3 -0
- data/ext/libvirt/domain.c +7 -0
- data/ext/libvirt/extconf.rb +0 -4
- data/ext/libvirt/interface.c +4 -0
- data/ext/libvirt/network.c +4 -0
- data/ext/libvirt/nodedevice.c +3 -0
- data/ext/libvirt/nwfilter.c +4 -0
- data/ext/libvirt/secret.c +3 -0
- data/ext/libvirt/storage.c +6 -0
- data/ext/libvirt/stream.c +3 -0
- data/tests/test_conn.rb +140 -125
- data/tests/test_domain.rb +279 -270
- data/tests/test_interface.rb +7 -5
- data/tests/test_network.rb +1 -1
- data/tests/test_nwfilter.rb +31 -21
- data/tests/test_open.rb +202 -190
- data/tests/test_secret.rb +75 -57
- data/tests/test_storage.rb +103 -88
- data/tests/test_utils.rb +16 -6
- metadata +17 -12
- data/NEWS +0 -158
- data/README +0 -219
- data/ext/libvirt/extconf.h +0 -3
- /data/{README.rdoc → doc/main.rdoc} +0 -0
data/tests/test_interface.rb
CHANGED
@@ -9,13 +9,15 @@ require 'test_utils.rb'
|
|
9
9
|
|
10
10
|
set_test_object("interface")
|
11
11
|
|
12
|
-
conn = Libvirt::open(
|
12
|
+
conn = Libvirt::open(URI)
|
13
13
|
|
14
14
|
# test setup
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
data/tests/test_network.rb
CHANGED
data/tests/test_nwfilter.rb
CHANGED
@@ -9,49 +9,59 @@ require 'test_utils.rb'
|
|
9
9
|
|
10
10
|
set_test_object("nwfilter")
|
11
11
|
|
12
|
-
conn = Libvirt::open(
|
12
|
+
conn = Libvirt::open(URI)
|
13
13
|
|
14
14
|
# TESTGROUP: nwfilter.undefine
|
15
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
51
|
-
newnw.
|
52
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
conn.
|
28
|
-
conn
|
29
|
-
conn.
|
30
|
-
conn
|
31
|
-
conn.
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
conn.
|
38
|
-
conn
|
39
|
-
conn.
|
40
|
-
conn
|
41
|
-
conn.
|
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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
expect_invalid_arg_type(Libvirt, "open_auth",
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
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
|
-
|
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
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
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
|
-
|
124
|
-
|
125
|
-
|
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
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
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
|
-
|
158
|
-
|
159
|
-
rescue NoMethodError
|
160
|
-
|
161
|
-
rescue => e
|
162
|
-
|
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
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
expect_too_few_args(Libvirt, "event_invoke_handle_callback"
|
171
|
-
expect_too_few_args(Libvirt, "event_invoke_handle_callback", 1
|
172
|
-
expect_too_few_args(Libvirt, "event_invoke_handle_callback", 1, 2
|
173
|
-
|
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,
|
176
|
-
|
177
|
-
#
|
178
|
-
#
|
179
|
-
#
|
180
|
-
#
|
181
|
-
#
|
182
|
-
#
|
183
|
-
|
184
|
-
expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback",
|
185
|
-
expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", 1,
|
186
|
-
expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", 1, 1,
|
187
|
-
expect_invalid_arg_type(Libvirt, "event_invoke_handle_callback", 1, 1, 1, { "libvirt_cb" =>
|
188
|
-
conn
|
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
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
expect_too_few_args(Libvirt, "event_invoke_timeout_callback"
|
196
|
-
|
197
|
-
expect_invalid_arg_type(Libvirt, "event_invoke_timeout_callback", "hello",
|
198
|
-
expect_invalid_arg_type(Libvirt, "event_invoke_timeout_callback", "hello",
|
199
|
-
|
200
|
-
#
|
201
|
-
#
|
202
|
-
#
|
203
|
-
#
|
204
|
-
#
|
205
|
-
#
|
206
|
-
|
207
|
-
expect_invalid_arg_type(Libvirt, "event_invoke_timeout_callback",
|
208
|
-
expect_invalid_arg_type(Libvirt, "event_invoke_timeout_callback", 1, { "libvirt_cb" =>
|
209
|
-
conn
|
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
|
-
|
213
|
-
|
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
|
|