Skip to content

Commit

Permalink
test_function.rb: fix messages
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nobu authored and hsbt committed Aug 6, 2018
1 parent 4edbaa9 commit c820d59
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions test/fiddle/test_function.rb
Expand Up @@ -86,15 +86,26 @@ def test_nogvl_poll
n1 = f.call(nil, 0, msec)
n2 = th.value
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
assert_in_delta(msec, t1 - t0, 100, 'slept correct amount of time')
assert_equal(0, n1, 'poll(2) called correctly main-thread')
assert_equal(0, n2, 'poll(2) called correctly in sub-thread')
assert_in_delta(msec, t1 - t0, 100, 'slept amount of time')
assert_equal(0, n1, perror("poll(2) in main-thread"))
assert_equal(0, n2, perror("poll(2) in sub-thread"))
end

def test_no_memory_leak
prep = 'r = Fiddle::Function.new(Fiddle.dlopen(nil)["rb_obj_tainted"], [Fiddle::TYPE_UINTPTR_T], Fiddle::TYPE_UINTPTR_T); a = "a"'
code = 'begin r.call(a); rescue TypeError; end'
assert_no_memory_leak(%w[-W0 -rfiddle], "#{prep}\n1000.times{#{code}}", "10_000.times {#{code}}", limit: 1.2)
end

private

def perror(m)
proc do
if e = Fiddle.last_error
m = "#{m}: #{SystemCallError.new(e).message}"
end
m
end
end
end
end if defined?(Fiddle)

0 comments on commit c820d59

Please sign in to comment.