summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/ruby/core/process/clock_getres_spec.rb30
-rw-r--r--spec/ruby/core/process/fixtures/clocks.rb42
2 files changed, 0 insertions, 72 deletions
diff --git a/spec/ruby/core/process/clock_getres_spec.rb b/spec/ruby/core/process/clock_getres_spec.rb
index 797824f77d..90f775e764 100644
--- a/spec/ruby/core/process/clock_getres_spec.rb
+++ b/spec/ruby/core/process/clock_getres_spec.rb
@@ -1,36 +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, :android 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 = 100_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.)
- if times.all? { |t| t % (reported * 10) == 0 }
- times.uniq.should be_empty
- end
- end
- end
- end
-
# These are documented
it "with :GETTIMEOFDAY_BASED_CLOCK_REALTIME reports 1 microsecond" do
diff --git a/spec/ruby/core/process/fixtures/clocks.rb b/spec/ruby/core/process/fixtures/clocks.rb
index 7537cfaba8..f043f6ac1f 100644
--- a/spec/ruby/core/process/fixtures/clocks.rb
+++ b/spec/ruby/core/process/fixtures/clocks.rb
@@ -15,46 +15,4 @@ module ProcessSpecs
[c, Process.const_get(c)]
}
end
-
- def self.clock_constants_for_resolution_checks
- clocks = clock_constants
-
- # These clocks in practice on Linux do not seem to match their reported resolution.
- platform_is :linux do
- clocks = clocks.reject { |clock, value|
- [:CLOCK_REALTIME_COARSE, :CLOCK_MONOTONIC_COARSE].include?(clock)
- }
- end
-
- # These clocks in practice on macOS seem to be less precise than advertised by clock_getres
- platform_is :darwin do
- clocks = clocks.reject { |clock, value|
- [:CLOCK_UPTIME_RAW_APPROX, :CLOCK_MONOTONIC_RAW_APPROX].include?(clock)
- }
- end
-
- # These clocks in practice on ARM on Linux do not seem to match their reported resolution.
- platform_is :armv7, :armv8, :aarch64 do
- clocks = clocks.reject { |clock, value|
- [:CLOCK_PROCESS_CPUTIME_ID, :CLOCK_THREAD_CPUTIME_ID, :CLOCK_MONOTONIC_RAW].include?(clock)
- }
- end
-
- # These clocks in practice on AIX seem to be more precise than their reported resolution.
- platform_is :aix do
- clocks = clocks.reject { |clock, value|
- [:CLOCK_REALTIME, :CLOCK_MONOTONIC].include?(clock)
- }
- end
-
- # On a Hyper-V Linux guest machine, these clocks in practice
- # seem to be less precise than advertised by clock_getres
- platform_is :linux do
- clocks = clocks.reject { |clock, value|
- clock == :CLOCK_MONOTONIC_RAW
- }
- end
-
- clocks
- end
end