summaryrefslogtreecommitdiff
path: root/spec/ruby/core/process/clock_gettime_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/process/clock_gettime_spec.rb')
-rw-r--r--spec/ruby/core/process/clock_gettime_spec.rb22
1 files changed, 8 insertions, 14 deletions
diff --git a/spec/ruby/core/process/clock_gettime_spec.rb b/spec/ruby/core/process/clock_gettime_spec.rb
index a7b6bd2b02..4cd13857ea 100644
--- a/spec/ruby/core/process/clock_gettime_spec.rb
+++ b/spec/ruby/core/process/clock_gettime_spec.rb
@@ -1,18 +1,10 @@
require_relative '../../spec_helper'
+require_relative 'fixtures/clocks'
describe "Process.clock_gettime" do
- platform_is_not :windows, :solaris do
- Process.constants.select { |c|
- c.to_s.start_with?('CLOCK_') &&
- # These require CAP_WAKE_ALARM and are not documented in clock_gettime(),
- # they return EINVAL if the permission is not granted.
- c != :CLOCK_BOOTTIME_ALARM &&
- c != :CLOCK_REALTIME_ALARM
- }.each do |c|
- it "can be called with Process::#{c}" do
- value = Process.const_get(c)
- Process.clock_gettime(value).should be_an_instance_of(Float)
- end
+ ProcessSpecs.clock_constants.each do |name, value|
+ it "can be called with Process::#{name}" do
+ Process.clock_gettime(value).should be_an_instance_of(Float)
end
end
@@ -36,7 +28,8 @@ describe "Process.clock_gettime" do
t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second)
t1.should be_an_instance_of(Float)
- t2.should be_close(t1, 2.0) # 2.0 is chosen arbitrarily to allow for time skew without admitting failure cases, which would be off by an order of magnitude.
+ t2.should be_an_instance_of(Float)
+ t2.should be_close(t1, TIME_TOLERANCE)
end
it 'uses the default time unit (:float_second) when passed nil' do
@@ -44,7 +37,8 @@ describe "Process.clock_gettime" do
t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second)
t1.should be_an_instance_of(Float)
- t2.should be_close(t1, 2.0) # 2.0 is chosen arbitrarily to allow for time skew without admitting failure cases, which would be off by an order of magnitude.
+ t2.should be_an_instance_of(Float)
+ t2.should be_close(t1, TIME_TOLERANCE)
end
end
end