* process.c (rb_clock_gettime): Support times() based monotonic clock.

(rb_clock_getres): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-09-03 03:10:41 +00:00
parent c048ad23b6
commit bc3d736f43
3 changed files with 65 additions and 0 deletions

View file

@ -1693,6 +1693,16 @@ EOS
assert_kind_of(Float, t, "Process.clock_gettime(:#{n})")
end
def test_clock_gettime_TIMES_BASED_CLOCK_MONOTONIC
n = :TIMES_BASED_CLOCK_MONOTONIC
begin
t = Process.clock_gettime(n)
rescue Errno::EINVAL
return
end
assert_kind_of(Float, t, "Process.clock_gettime(:#{n})")
end
def test_clock_gettime_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID
n = :GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID
begin
@ -1761,6 +1771,18 @@ EOS
assert_equal(1000000000, Process.clock_getres(n, :nanosecond))
end
def test_clock_getres_TIMES_BASED_CLOCK_MONOTONIC
n = :TIMES_BASED_CLOCK_MONOTONIC
begin
t = Process.clock_getres(n)
rescue Errno::EINVAL
return
end
assert_kind_of(Float, t, "Process.clock_getres(:#{n})")
f = Process.clock_getres(n, :hertz)
assert_equal(0, f - f.floor)
end
def test_clock_getres_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID
n = :GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID
begin