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
| | # Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
require_relative 'helper'
require 'timeout'
class TestStreamFile < Testcase
parallelize_me!
DevFD = Struct.new(:to_path)
def test_stream_file
fp = File.open("COPYING")
sf = Yahns::StreamFile.new(fp, true, 0, fp.stat.size)
refute sf.respond_to?(:close)
sf.wbuf_close(nil)
assert fp.closed?
end
def test_fd
fp = File.open("COPYING")
obj = DevFD.new("/dev/fd/#{fp.fileno}")
sf = Yahns::StreamFile.new(obj, true, 0, fp.stat.size)
io = sf.instance_variable_get :@tmpio
assert_instance_of IO, io.to_io
assert_equal fp.fileno, io.fileno
refute sf.respond_to?(:close)
sf.wbuf_close(nil)
refute fp.closed?
refute io.closed?
end
end
|