sicl 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +8 -8
- data/Manifest.txt +9 -9
- data/README.txt +93 -79
- data/Rakefile +78 -55
- data/ext/Makefile.bcc +81 -79
- data/ext/extconf.rb +61 -49
- data/ext/sicl.c +752 -749
- data/test/test_sicl.rb +465 -451
- metadata +55 -32
data/test/test_sicl.rb
CHANGED
@@ -1,451 +1,465 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
################################################################################
|
3
|
-
#
|
4
|
-
# Copyright (c) 2005-2006 Naoki Kobayashi
|
5
|
-
#
|
6
|
-
# This library is free software.
|
7
|
-
# You can distribute/modify this script under the same terms of ruby.
|
8
|
-
#
|
9
|
-
# $
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
################################################################################
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
opts
|
25
|
-
opts.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
################################################################################
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
################################################################################
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
require "
|
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
|
-
@io.
|
107
|
-
|
108
|
-
@io.
|
109
|
-
|
110
|
-
@io.
|
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
|
-
assert_equal
|
149
|
-
end
|
150
|
-
|
151
|
-
def
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
assert_equal 1, stb[
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
@io.
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
end
|
202
|
-
|
203
|
-
def
|
204
|
-
@io.enable_srq_detection
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
@io.on_srq {
|
209
|
-
|
210
|
-
@io.output("xxx")
|
211
|
-
|
212
|
-
10.times { sleep 0.1
|
213
|
-
|
214
|
-
assert_equal
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
@
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
assert_equal
|
288
|
-
end
|
289
|
-
|
290
|
-
def
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
end
|
307
|
-
|
308
|
-
def
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
@io.
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
assert_equal
|
340
|
-
end
|
341
|
-
|
342
|
-
def
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
err = assert_exception(SICL::Error) {
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
@io.
|
360
|
-
|
361
|
-
@io.
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
assert_equal @io.
|
441
|
-
end
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
################################################################################
|
3
|
+
#
|
4
|
+
# Copyright (c) 2005-2006 Naoki Kobayashi
|
5
|
+
#
|
6
|
+
# This library is free software.
|
7
|
+
# You can distribute/modify this script under the same terms of ruby.
|
8
|
+
#
|
9
|
+
# $LastChangedDate$
|
10
|
+
# $Revision$
|
11
|
+
# $Author$
|
12
|
+
#
|
13
|
+
################################################################################
|
14
|
+
|
15
|
+
Signal.trap(:USR2) {} if RUBY_PLATFORM =~ /hpux/ # workaround ...;|
|
16
|
+
|
17
|
+
################################################################################
|
18
|
+
# OPTION SETTINGS
|
19
|
+
################################################################################
|
20
|
+
|
21
|
+
require "optparse"
|
22
|
+
|
23
|
+
Settings = Hash.new
|
24
|
+
opts = OptionParser.new
|
25
|
+
opts.on( "-a", "--address ADDRESS", String ) { |v| Settings[:address] = v }
|
26
|
+
opts.on( "-d", "--debug", String ) { |v| Settings[:debug] = true }
|
27
|
+
opts.parse!( ARGV )
|
28
|
+
|
29
|
+
################################################################################
|
30
|
+
# PARAMETER VALIDATION
|
31
|
+
################################################################################
|
32
|
+
|
33
|
+
address = Settings[:address]
|
34
|
+
address = "gpib0,17" unless address
|
35
|
+
|
36
|
+
################################################################################
|
37
|
+
# CLASS DECLARATION
|
38
|
+
################################################################################
|
39
|
+
|
40
|
+
require "runit/testcase"
|
41
|
+
require "runit/cui/testrunner"
|
42
|
+
require "sicl"
|
43
|
+
|
44
|
+
class TestSicl < RUNIT::TestCase
|
45
|
+
|
46
|
+
def TestSicl.suite(address)
|
47
|
+
@@address = address
|
48
|
+
SICL.open(@@address) { |io| @@name = io.query("*IDN?") }
|
49
|
+
puts "#{@@address} : #{@@name}" if Settings[:debug]
|
50
|
+
super()
|
51
|
+
end
|
52
|
+
|
53
|
+
class MyInstrument < SICL::Instrument
|
54
|
+
|
55
|
+
def initialize(addr)
|
56
|
+
super(addr)
|
57
|
+
|
58
|
+
reset
|
59
|
+
end
|
60
|
+
|
61
|
+
def reset
|
62
|
+
output "*CLS"
|
63
|
+
output "*RST"
|
64
|
+
query "*ESR?"
|
65
|
+
end
|
66
|
+
|
67
|
+
def enable_srq_detection
|
68
|
+
output "*SRE #{0x20}"
|
69
|
+
output "*ESE #{0x3c}"
|
70
|
+
end
|
71
|
+
|
72
|
+
def disable_srq_detection
|
73
|
+
output "*SRE #{0x00}"
|
74
|
+
output "*ESE #{0x00}"
|
75
|
+
end
|
76
|
+
|
77
|
+
def raise_timeout(timeout=1000)
|
78
|
+
self.timeout = timeout
|
79
|
+
loop { break unless self.read }
|
80
|
+
end
|
81
|
+
|
82
|
+
def raise_srq(timeout=10)
|
83
|
+
self.output "xxx"
|
84
|
+
sleep timeout
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
NO_ERROR = "No error"
|
90
|
+
BAD_ADDRESS = "Bad address"
|
91
|
+
TIMEOUT_OCCURRED = "Timeout occurred"
|
92
|
+
INVALID_INST = "Invalid INST"
|
93
|
+
|
94
|
+
ESR_BIT = 5 # Standard Event Register
|
95
|
+
RQS_BIT = 6 # ReQuest Service
|
96
|
+
|
97
|
+
def setup
|
98
|
+
@io = MyInstrument.new @@address
|
99
|
+
@name = @@name
|
100
|
+
end
|
101
|
+
|
102
|
+
def teardown
|
103
|
+
|
104
|
+
begin
|
105
|
+
if Settings[:debug] then
|
106
|
+
@io.on_error { |err| puts "[ERR: #{err}]" }
|
107
|
+
@io.on_srq { puts "[SRQ]" }
|
108
|
+
@io.on_intr { |reason, secval| puts "[INTR: #{reason}, #{secval}]" }
|
109
|
+
else
|
110
|
+
@io.on_error = nil
|
111
|
+
@io.on_srq = nil
|
112
|
+
@io.on_intr = nil
|
113
|
+
end
|
114
|
+
@io.disable_srq_detection
|
115
|
+
rescue
|
116
|
+
# do nothing...
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_open0
|
122
|
+
ret = SICL.open(@@address) { |io|
|
123
|
+
|
124
|
+
res = io.query("*IDN?")
|
125
|
+
assert_equal @name, res
|
126
|
+
|
127
|
+
io.address
|
128
|
+
}
|
129
|
+
|
130
|
+
assert_equal @@address, ret
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_open1
|
134
|
+
err = assert_exception(SICL::Error) { SICL.open("xxx") }
|
135
|
+
|
136
|
+
assert_equal BAD_ADDRESS, err.message
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_open2
|
140
|
+
ret = SICL::Instrument.open(@@address) { |io|
|
141
|
+
|
142
|
+
res = io.query("*IDN?")
|
143
|
+
assert_equal @name, res
|
144
|
+
|
145
|
+
io.address
|
146
|
+
}
|
147
|
+
|
148
|
+
assert_equal @@address, ret
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_open3
|
152
|
+
err = assert_exception(SICL::Error) { SICL::Instrument.open("xxx") }
|
153
|
+
|
154
|
+
assert_equal BAD_ADDRESS, err.message
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_stb0
|
158
|
+
@io.output("*SRE #{0x00}")
|
159
|
+
@io.output("*ESE #{0x00}")
|
160
|
+
|
161
|
+
rqs = @io.query("*STB?").to_i[RQS_BIT]
|
162
|
+
assert_equal 0, rqs
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_stb1
|
166
|
+
@io.enable_srq_detection
|
167
|
+
|
168
|
+
@io.output("xxx")
|
169
|
+
|
170
|
+
sleep 0.1
|
171
|
+
|
172
|
+
stb = @io.query("*STB?").to_i
|
173
|
+
|
174
|
+
assert_equal 1, stb[ESR_BIT]
|
175
|
+
assert_equal 1, stb[RQS_BIT]
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_stb2
|
179
|
+
@io.enable_srq_detection
|
180
|
+
|
181
|
+
@io.output("xxx")
|
182
|
+
|
183
|
+
sleep 1
|
184
|
+
|
185
|
+
stb = @io.spoll
|
186
|
+
|
187
|
+
assert_equal 1, stb[ESR_BIT]
|
188
|
+
assert_equal 1, stb[RQS_BIT]
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_typerr_error
|
192
|
+
assert_exception(TypeError) { @io.on_error = "xxx" }
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_typerr_srq
|
196
|
+
assert_exception(TypeError) { @io.on_srq = "xxx" }
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_typerr_intr
|
200
|
+
assert_exception(TypeError) { @io.on_intr = "xxx" }
|
201
|
+
end
|
202
|
+
|
203
|
+
def test_srq0
|
204
|
+
@io.enable_srq_detection
|
205
|
+
|
206
|
+
srq_occured = false
|
207
|
+
|
208
|
+
@io.on_srq { srq_occured = true }
|
209
|
+
|
210
|
+
@io.output("xxx")
|
211
|
+
|
212
|
+
10.times { sleep 0.1 unless srq_occured }
|
213
|
+
|
214
|
+
assert_equal true, srq_occured
|
215
|
+
end
|
216
|
+
|
217
|
+
def test_srq1
|
218
|
+
@io.enable_srq_detection
|
219
|
+
|
220
|
+
stb = 0
|
221
|
+
|
222
|
+
@io.on_srq { sleep 1; stb = @io.spoll }
|
223
|
+
|
224
|
+
@io.output("xxx")
|
225
|
+
|
226
|
+
10.times { sleep 0.1 if stb == 0 }
|
227
|
+
|
228
|
+
assert_equal 1, stb[ESR_BIT]
|
229
|
+
assert_equal 1, stb[RQS_BIT]
|
230
|
+
end
|
231
|
+
|
232
|
+
def test_typerr_write
|
233
|
+
assert_exception(TypeError) { @io.write(10) }
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_typerr_write_op
|
237
|
+
assert_exception(TypeError) { @io << 10 }
|
238
|
+
end
|
239
|
+
|
240
|
+
def test_typerr_read
|
241
|
+
assert_exception(TypeError) { @io.read("xxx") }
|
242
|
+
end
|
243
|
+
|
244
|
+
def test_typerr_output
|
245
|
+
assert_exception(TypeError) { @io.output(10) }
|
246
|
+
end
|
247
|
+
|
248
|
+
def test_write_and_read0
|
249
|
+
res = @io.write("*IDN?\n")
|
250
|
+
assert res
|
251
|
+
|
252
|
+
res = @io.read 1
|
253
|
+
assert_equal @name[0].chr, res
|
254
|
+
end
|
255
|
+
|
256
|
+
def test_write_and_read1
|
257
|
+
res = @io.write("*IDN?\n").read 1
|
258
|
+
assert_equal @name[0].chr, res
|
259
|
+
end
|
260
|
+
|
261
|
+
def test_write_and_read2
|
262
|
+
res = @io.write("*IDN?\n").read 7
|
263
|
+
assert_equal @name[0...7], res
|
264
|
+
end
|
265
|
+
|
266
|
+
def test_write_and_read3
|
267
|
+
res = @io.write("*I").write("DN").write("?\n").read 1
|
268
|
+
assert_equal @name[0].chr, res
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_write_and_read4
|
272
|
+
@io << "*I" << "DN" << "?" << SICL::EOL
|
273
|
+
res = @io.read 1
|
274
|
+
assert_equal @name[0].chr, res
|
275
|
+
end
|
276
|
+
|
277
|
+
def test_write_and_read5
|
278
|
+
@io << "*RST" << SICL::EOL << "*IDN?" << SICL::EOL
|
279
|
+
res = @io.read 1
|
280
|
+
assert_equal @name[0].chr, res
|
281
|
+
end
|
282
|
+
|
283
|
+
def test_output_and_enter0
|
284
|
+
res = @io.output("*IDN?")
|
285
|
+
assert res
|
286
|
+
res = @io.enter
|
287
|
+
assert_equal @name, res
|
288
|
+
end
|
289
|
+
|
290
|
+
def test_output_and_enter1
|
291
|
+
res = @io.output("*IDN?").enter
|
292
|
+
assert_equal @name, res
|
293
|
+
end
|
294
|
+
|
295
|
+
def test_output_and_enter2
|
296
|
+
res = @io.output("*IDN?\r\n \r\r\r\r;;\n;;\r\n\n").enter
|
297
|
+
assert_equal @name, res
|
298
|
+
end
|
299
|
+
|
300
|
+
def test_error_message0
|
301
|
+
assert_equal NO_ERROR, SICL::Error.errstr(0)
|
302
|
+
end
|
303
|
+
|
304
|
+
def test_error_message1
|
305
|
+
assert SICL::Error.errstr(15)
|
306
|
+
end
|
307
|
+
|
308
|
+
def test_error_message2
|
309
|
+
assert_equal NO_ERROR, @io.errstr
|
310
|
+
end
|
311
|
+
|
312
|
+
def test_error_message3
|
313
|
+
error_message = ''
|
314
|
+
|
315
|
+
@io.on_error { |err| error_message = err[1] }
|
316
|
+
|
317
|
+
@io.raise_timeout
|
318
|
+
|
319
|
+
assert_equal TIMEOUT_OCCURRED, error_message
|
320
|
+
end
|
321
|
+
|
322
|
+
def test_error_message4
|
323
|
+
error_message = ''
|
324
|
+
|
325
|
+
@io.on_error {}
|
326
|
+
|
327
|
+
@io.raise_timeout
|
328
|
+
|
329
|
+
assert_equal TIMEOUT_OCCURRED, @io.errstr
|
330
|
+
end
|
331
|
+
|
332
|
+
def test_error_message5
|
333
|
+
error_message = ''
|
334
|
+
|
335
|
+
@io.on_error { |num, msg| error_message = msg }
|
336
|
+
|
337
|
+
@io.raise_timeout
|
338
|
+
|
339
|
+
assert_equal TIMEOUT_OCCURRED, error_message
|
340
|
+
end
|
341
|
+
|
342
|
+
def test_error_close0
|
343
|
+
@io.close
|
344
|
+
err = assert_exception(SICL::Error) { @io.close }
|
345
|
+
|
346
|
+
assert_equal INVALID_INST, err.message
|
347
|
+
end
|
348
|
+
|
349
|
+
def test_error_close1
|
350
|
+
@io.close
|
351
|
+
err = assert_exception(SICL::Error) { @io.close }
|
352
|
+
|
353
|
+
assert_equal INVALID_INST, err.message
|
354
|
+
end
|
355
|
+
|
356
|
+
def test_error_timeout0
|
357
|
+
time_limit = 10000
|
358
|
+
|
359
|
+
@io.timeout = time_limit
|
360
|
+
|
361
|
+
assert_equal time_limit, @io.timeout
|
362
|
+
end
|
363
|
+
|
364
|
+
def test_error_timeout1
|
365
|
+
err = assert_exception(SICL::Error) {
|
366
|
+
@io.raise_timeout
|
367
|
+
}
|
368
|
+
|
369
|
+
assert_equal TIMEOUT_OCCURRED, err.message
|
370
|
+
end
|
371
|
+
|
372
|
+
def test_error_timeout2
|
373
|
+
@io.on_error = lambda {}
|
374
|
+
|
375
|
+
@io.raise_timeout
|
376
|
+
|
377
|
+
assert true
|
378
|
+
end
|
379
|
+
|
380
|
+
def test_error_timeout3
|
381
|
+
@io.on_error = lambda {}
|
382
|
+
@io.on_error = nil
|
383
|
+
|
384
|
+
err = assert_exception(SICL::Error) {
|
385
|
+
@io.raise_timeout
|
386
|
+
}
|
387
|
+
|
388
|
+
assert_equal TIMEOUT_OCCURRED, err.message
|
389
|
+
end
|
390
|
+
|
391
|
+
def test_error_timeout4
|
392
|
+
@io.on_error {}
|
393
|
+
|
394
|
+
@io.raise_timeout
|
395
|
+
|
396
|
+
assert true
|
397
|
+
end
|
398
|
+
|
399
|
+
def test_close
|
400
|
+
assert @io.close
|
401
|
+
end
|
402
|
+
|
403
|
+
def test_abort
|
404
|
+
assert @io.abort.instance_of?(@io.class) if @@address =~ /^[gh]pib/
|
405
|
+
end
|
406
|
+
|
407
|
+
def test_clear
|
408
|
+
assert @io.clear.instance_of?(@io.class)
|
409
|
+
end
|
410
|
+
|
411
|
+
def test_spoll
|
412
|
+
assert @io.spoll.instance_of?(Fixnum)
|
413
|
+
end
|
414
|
+
|
415
|
+
def test_readstb
|
416
|
+
assert @io.readstb.instance_of?(Fixnum)
|
417
|
+
end
|
418
|
+
|
419
|
+
def test_local
|
420
|
+
assert @io.local.instance_of?(@io.class)
|
421
|
+
end
|
422
|
+
|
423
|
+
def test_remote
|
424
|
+
assert @io.remote.instance_of?(@io.class)
|
425
|
+
end
|
426
|
+
|
427
|
+
def test_flush0
|
428
|
+
assert @io.flush.instance_of?(@io.class)
|
429
|
+
end
|
430
|
+
|
431
|
+
def test_flush1
|
432
|
+
assert @io.flush(SICL::BUF_DISCARD_READ | SICL::BUF_DISCARD_WRITE)
|
433
|
+
end
|
434
|
+
|
435
|
+
def test_addr
|
436
|
+
assert_equal @io.addr, @@address
|
437
|
+
end
|
438
|
+
|
439
|
+
def test_addr
|
440
|
+
assert_equal @io.address, @@address
|
441
|
+
end
|
442
|
+
|
443
|
+
def test_typerr_termchr
|
444
|
+
assert_exception(TypeError) { @io.termchr = " " }
|
445
|
+
end
|
446
|
+
|
447
|
+
def test_termchr0
|
448
|
+
assert @io.termchr = 0x20
|
449
|
+
assert_equal @io.termchr, 0x20
|
450
|
+
end
|
451
|
+
|
452
|
+
def test_termchr1
|
453
|
+
assert @io.termchr = " "[0]
|
454
|
+
assert_equal @io.termchr, 0x20
|
455
|
+
end
|
456
|
+
|
457
|
+
end
|
458
|
+
|
459
|
+
################################################################################
|
460
|
+
# MAIN ROUTINE
|
461
|
+
################################################################################
|
462
|
+
|
463
|
+
if $0 == __FILE__ then
|
464
|
+
RUNIT::CUI::TestRunner.run(TestSicl.suite(address))
|
465
|
+
end
|