sleepy_penguin 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/GIT-VERSION-GEN +1 -1
- data/GNUmakefile +0 -1
- data/Rakefile +0 -37
- data/ext/sleepy_penguin/epoll.c +3 -15
- data/ext/sleepy_penguin/extconf.rb +9 -2
- data/ext/sleepy_penguin/init.c +59 -1
- data/ext/sleepy_penguin/inotify.c +16 -36
- data/ext/sleepy_penguin/kqueue.c +3 -15
- data/ext/sleepy_penguin/missing_clock_gettime.h +36 -0
- data/ext/sleepy_penguin/sleepy_penguin.h +1 -0
- data/ext/sleepy_penguin/util.c +16 -8
- data/ext/sleepy_penguin/value2timespec.h +2 -2
- data/test/helper.rb +17 -0
- data/test/test_constants.rb +2 -2
- data/test/test_epoll.rb +10 -9
- data/test/test_epoll_gc.rb +2 -2
- data/test/test_epoll_io.rb +2 -2
- data/test/test_epoll_optimizations.rb +2 -2
- data/test/test_eventfd.rb +3 -7
- data/test/test_inotify.rb +3 -7
- data/test/test_kqueue.rb +2 -2
- data/test/test_kqueue_io.rb +2 -2
- data/test/test_timerfd.rb +3 -7
- metadata +65 -60
- data/ext/sleepy_penguin/signalfd.c +0 -342
- data/test/test_signalfd.rb +0 -94
- data/test/test_signalfd_siginfo.rb +0 -32
data/test/test_signalfd.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require "dl"
|
3
|
-
begin
|
4
|
-
require "dl/func"
|
5
|
-
rescue LoadError
|
6
|
-
end
|
7
|
-
$-w = true
|
8
|
-
require 'sleepy_penguin'
|
9
|
-
|
10
|
-
class TestSignalFD < Test::Unit::TestCase
|
11
|
-
include SleepyPenguin
|
12
|
-
|
13
|
-
def setup
|
14
|
-
@sfd = nil
|
15
|
-
trap(:USR1, "IGNORE")
|
16
|
-
trap(:USR2, "IGNORE")
|
17
|
-
end
|
18
|
-
|
19
|
-
def teardown
|
20
|
-
@sfd.close if @sfd && ! @sfd.closed?
|
21
|
-
trap(:USR1, "DEFAULT")
|
22
|
-
trap(:USR2, "DEFAULT")
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_rt_constants
|
26
|
-
assert [33,34].include?(SignalFD::RTMIN)
|
27
|
-
assert_equal 64, SignalFD::RTMAX
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_new_with_flags
|
31
|
-
@sfd = SignalFD.new(%w(USR1), [:CLOEXEC,:NONBLOCK])
|
32
|
-
assert_instance_of SignalFD, @sfd
|
33
|
-
end if defined?(SignalFD::CLOEXEC) && defined?(SignalFD::NONBLOCK)
|
34
|
-
|
35
|
-
def test_new_with_sym_flag
|
36
|
-
@sfd = SignalFD.new(%w(USR1), :CLOEXEC)
|
37
|
-
assert_instance_of SignalFD, @sfd
|
38
|
-
end if defined?(SignalFD::CLOEXEC)
|
39
|
-
|
40
|
-
def test_take
|
41
|
-
@sfd = SignalFD.new(%w(USR1), 0)
|
42
|
-
pid = fork { sleep 0.01; Process.kill(:USR1, Process.ppid) }
|
43
|
-
siginfo = @sfd.take
|
44
|
-
assert_equal Signal.list["USR1"], siginfo.signo
|
45
|
-
assert_equal pid, siginfo.pid
|
46
|
-
assert Process.waitpid2(pid)[1].success?
|
47
|
-
end if RUBY_VERSION =~ %r{\A1\.9}
|
48
|
-
|
49
|
-
def test_take_nonblock
|
50
|
-
@sfd = SignalFD.new(%w(USR1), :NONBLOCK)
|
51
|
-
assert_nil @sfd.take(true)
|
52
|
-
assert_nil IO.select [ @sfd ], nil, nil, 0
|
53
|
-
pid = fork { sleep 0.01; Process.kill(:USR1, Process.ppid) }
|
54
|
-
siginfo = @sfd.take(true)
|
55
|
-
if siginfo
|
56
|
-
assert_equal Signal.list["USR1"], siginfo.signo
|
57
|
-
assert_equal pid, siginfo.pid
|
58
|
-
else
|
59
|
-
warn "WARNING: SignalFD#take(nonblock=true) broken"
|
60
|
-
end
|
61
|
-
assert Process.waitpid2(pid)[1].success?
|
62
|
-
end if RUBY_VERSION =~ %r{\A1\.9}
|
63
|
-
|
64
|
-
def test_update
|
65
|
-
assert_nothing_raised do
|
66
|
-
@sfd = SignalFD.new
|
67
|
-
@sfd.update! Signal.list["USR1"]
|
68
|
-
@sfd.update! [ "USR1", Signal.list["USR2"] ]
|
69
|
-
@sfd.update! [ "USR1", :USR2 ]
|
70
|
-
@sfd.update! [ Signal.list["USR1"], Signal.list["USR2"] ]
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_with_sigqueue
|
75
|
-
sig = Signal.list["USR2"]
|
76
|
-
@sfd = SignalFD.new(:USR2)
|
77
|
-
libc = DL::Handle.new("libc.so.6")
|
78
|
-
if defined?(DL::Function)
|
79
|
-
sigqueue = libc["sigqueue"]
|
80
|
-
sigqueue = DL::CFunc.new(sigqueue, DL::TYPE_INT, "sigqueue")
|
81
|
-
args = [DL::TYPE_INT, DL::TYPE_INT,DL::TYPE_INT]
|
82
|
-
sigqueue = DL::Function.new(sigqueue, args, DL::TYPE_INT)
|
83
|
-
else
|
84
|
-
sigqueue = libc["sigqueue", "IIII"]
|
85
|
-
end
|
86
|
-
pid = fork { sleep 0.01; sigqueue.call(Process.ppid, sig, 666) }
|
87
|
-
siginfo = @sfd.take
|
88
|
-
assert_equal sig, siginfo.signo
|
89
|
-
assert_equal pid, siginfo.pid
|
90
|
-
assert Process.waitpid2(pid)[1].success?
|
91
|
-
assert_equal 666, siginfo.ptr
|
92
|
-
assert_equal 666, siginfo.int
|
93
|
-
end if RUBY_VERSION =~ %r{\A1\.9}
|
94
|
-
end if defined?(SleepyPenguin::SignalFD)
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
$-w = true
|
3
|
-
require 'sleepy_penguin'
|
4
|
-
|
5
|
-
class TestSignalFDSigInfo < Test::Unit::TestCase
|
6
|
-
include SleepyPenguin
|
7
|
-
|
8
|
-
def test_members
|
9
|
-
members = SignalFD::SigInfo::MEMBERS
|
10
|
-
assert_equal 16, members.size
|
11
|
-
a = SignalFD::SigInfo.new
|
12
|
-
members.each { |k| assert_equal 0, a.__send__(k) }
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_equality
|
16
|
-
a = SignalFD::SigInfo.new
|
17
|
-
b = SignalFD::SigInfo.new
|
18
|
-
assert_equal a, b
|
19
|
-
|
20
|
-
c = Class.new(SignalFD::SigInfo).new
|
21
|
-
assert_equal a, c
|
22
|
-
assert c != c.to_hash
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_to_hash
|
26
|
-
hash = SignalFD::SigInfo.new.to_hash
|
27
|
-
assert_instance_of Hash, hash
|
28
|
-
members = SignalFD::SigInfo::MEMBERS
|
29
|
-
assert_equal members.size, hash.size
|
30
|
-
members.each { |k| assert_equal 0, hash[k] }
|
31
|
-
end
|
32
|
-
end if defined?(SleepyPenguin::SignalFD)
|