summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2020-12-31 09:34:09 (GMT)
committernagachika <nagachika@ruby-lang.org>2020-12-31 09:34:09 (GMT)
commitd0693391103672b7fc3976e5ae8ae414059b3e97 (patch)
tree3b09f1c3edbbaed084fb5d51ccb18a34b808d4bf
parent5cbba4d6005a03914fc47e7a65ae5b6ef76c8e29 (diff)
merge revision(s) ed549f80b645aafd62376f65c3a27b66bafa2a38,eff0c5bf2ad47d10a440c5211be5eddb3bbf4028,f6b6a7ad345c50eeb3f7206ceabdf41ba94b7d85,5b48686691c2443d8d7113e593494c4d9302da0e,2af4c1fc5b19fc96203c2d7e917e689510d3527e,c9213aa864fb8527388679c21f1ea8ce129e2f1a,224f29c8e92094af10bc666c474b81a3545d6adf:ruby_2_7
spec/ruby/core/process/clock_getres_spec.rb: skip on Android in the same way as FreeBSD and OpenBSD. I guess that the spec makes too strong assumption. Try to avoid random failures on clock_getres_spec.rb This spec fails too often https://github.com/ruby/ruby/runs/529546249 https://github.com/ruby/ruby/runs/524933256 Show failed times Remove Process.clock_getres "matches the resolution in practice" specs * Almost all platforms return incorrect values for Process.clock_getres, it should be removed: https://bugs.ruby-lang.org/issues/16740 Skip Process#clock_getres specs on Android ... just like AIX and OpenBSD. Update to ruby/spec@d394dfd spec/ruby/core/process/clock_getres_spec.rb: lax the resolution limit Android is Linux, but the clock resolution is 10 milliseconds. I think that 1 microsecond is too strict for embedded environment. This change laxes the limit to 10 milliseconds.
-rw-r--r--spec/ruby/core/process/clock_getres_spec.rb40
-rw-r--r--spec/ruby/core/process/fixtures/clocks.rb42
-rw-r--r--version.h2
3 files changed, 7 insertions, 77 deletions
diff --git a/spec/ruby/core/process/clock_getres_spec.rb b/spec/ruby/core/process/clock_getres_spec.rb
index f1ecb74..85aa2b2 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
diff --git a/spec/ruby/core/process/fixtures/clocks.rb b/spec/ruby/core/process/fixtures/clocks.rb
index 7537cfa..f043f6a 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
diff --git a/version.h b/version.h
index e852c18..fa6b79c 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 3
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 145
+#define RUBY_PATCHLEVEL 146
#define RUBY_RELEASE_YEAR 2020
#define RUBY_RELEASE_MONTH 12