10000 test_function.rb: fix messages · github/ruby@440f442 · GitHub
[go: up one dir, main page]

Skip to content

Commit 440f442

Browse files
committed
test_function.rb: fix messages
* test/fiddle/test_function.rb (test_nogvl_poll): fix messages as failed conditions, with errno description. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent d383426 commit 440f442

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

test/fiddle/test_function.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,26 @@ def test_nogvl_poll
8686
n1 = f.call(nil, 0, msec)
8787
n2 = th.value
8888
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
89-
assert_in_delta(msec, t1 - t0, 100, 'slept correct amount of time')
90-
assert_equal(0, n1, 'poll(2) called correctly main-thread')
91-
assert_equal(0, n2, 'poll(2) called correctly in sub-thread')
89+
assert_in_delta(msec, t1 - t0, 100, 'slept amount of time')
90+
assert_equal(0, n1, perror("poll(2) in main-thread"))
91+
assert_equal(0, n2, perror("poll(2) in sub-thread"))
9292
end
9393

9494
def test_no_memory_leak
9595
prep = 'r = Fiddle::Function.new(Fiddle.dlopen(nil)["rb_obj_tainted"], [Fiddle::TYPE_UINTPTR_T], Fiddle::TYPE_UINTPTR_T); a = "a"'
9696
code = 'begin r.call(a); rescue TypeError; end'
9797
assert_no_memory_leak(%w[-W0 -rfiddle], "#{prep}\n1000.times{#{code}}", "10_000.times {#{code}}", limit: 1.2)
9898
end
99+
100+
private
101+
102+
def perror(m)
103+
proc do
104+
if e = Fiddle.last_error
105+
m = "#{m}: #{SystemCallError.new(e).message}"
106+
end
107+
m
108+
end
109+
end
99110
end
100111
end if defined?(Fiddle)

0 commit comments

Comments
 (0)
0