diff options
Diffstat (limited to 'spec/ruby/core/process/clock_getres_spec.rb')
-rw-r--r-- | spec/ruby/core/process/clock_getres_spec.rb | 40 |
1 files changed, 6 insertions, 34 deletions
diff --git a/spec/ruby/core/process/clock_getres_spec.rb b/spec/ruby/core/process/clock_getres_spec.rb index f1ecb74010..85aa2b25f1 100644 --- a/spec/ruby/core/process/clock_getres_spec.rb +++ b/spec/ruby/core/process/clock_getres_spec.rb @@ -1,34 +1,6 @@ require_relative '../../spec_helper' -require_relative 'fixtures/clocks' describe "Process.clock_getres" do - # clock_getres() seems completely buggy on FreeBSD: - # https://rubyci.org/logs/rubyci.s3.amazonaws.com/freebsd11zfs/ruby-trunk/log/20190428T093003Z.fail.html.gz - platform_is_not :freebsd, :openbsd do - # NOTE: Look at fixtures/clocks.rb for clock and OS-specific exclusions - ProcessSpecs.clock_constants_for_resolution_checks.each do |name, value| - it "matches the clock in practice for Process::#{name}" do - times = 10_000.times.map { Process.clock_gettime(value, :nanosecond) } - reported = Process.clock_getres(value, :nanosecond) - - # The clock should not be more accurate than reported (times should be - # a multiple of reported precision.) - times.select { |t| t % reported > 0 }.should be_empty - - # We're assuming precision is a multiple of ten - it may or may not - # be an incompatibility if it isn't but we'd like to notice this, - # and the spec following these wouldn't work if it isn't. - reported.should > 0 - (reported == 1 || reported % 10 == 0).should be_true - - # The clock should not be less accurate than reported (times should - # not all be a multiple of the next precision up, assuming precisions - # are multiples of ten.) - times.select { |t| t % (reported * 10) == 0 }.size.should_not == times.size - end - end - end - # These are documented it "with :GETTIMEOFDAY_BASED_CLOCK_REALTIME reports 1 microsecond" do @@ -47,15 +19,15 @@ describe "Process.clock_getres" do # These are observed - platform_is_not :solaris, :aix, :openbsd do - it "with Process::CLOCK_REALTIME reports at least 1 microsecond" do - Process.clock_getres(Process::CLOCK_REALTIME, :nanosecond).should <= 1_000 + platform_is :linux, :darwin, :windows do + it "with Process::CLOCK_REALTIME reports at least 10 millisecond" do + Process.clock_getres(Process::CLOCK_REALTIME, :nanosecond).should <= 10_000_000 end end - platform_is_not :aix, :openbsd do - it "with Process::CLOCK_MONOTONIC reports at least 1 microsecond" do - Process.clock_getres(Process::CLOCK_MONOTONIC, :nanosecond).should <= 1_000 + platform_is :linux, :darwin, :windows do + it "with Process::CLOCK_MONOTONIC reports at least 10 millisecond" do + Process.clock_getres(Process::CLOCK_MONOTONIC, :nanosecond).should <= 10_000_000 end end end |