aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/process/fixtures/clocks.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/process/fixtures/clocks.rb')
-rw-r--r--spec/ruby/core/process/fixtures/clocks.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/ruby/core/process/fixtures/clocks.rb b/spec/ruby/core/process/fixtures/clocks.rb
new file mode 100644
index 0000000000..5f45e8065b
--- /dev/null
+++ b/spec/ruby/core/process/fixtures/clocks.rb
@@ -0,0 +1,24 @@
+module ProcessSpecs
+ def self.clock_constants
+ clocks = []
+
+ platform_is_not :windows, :solaris do
+ clocks += Process.constants.select { |c| c.to_s.start_with?('CLOCK_') }
+
+ # These require CAP_WAKE_ALARM and are not documented in
+ # Process#clock_gettime they return EINVAL if the permission
+ # is not granted.
+ clocks -= [:CLOCK_BOOTTIME_ALARM, :CLOCK_REALTIME_ALARM]
+
+ # These clocks in practice on Linux do not seem to match
+ # their reported resolution.
+ clocks -= [:CLOCK_REALTIME_COARSE, :CLOCK_MONOTONIC_COARSE]
+
+ clocks.map! { |c|
+ [c, Process.const_get(c)]
+ }
+ end
+
+ clocks
+ end
+end