summaryrefslogtreecommitdiff
path: root/spec/ruby/core/process/fixtures/clocks.rb
blob: f043f6ac1ff49d022185696537a4740a5a37500f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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]
    end

    clocks.sort.map { |c|
      [c, Process.const_get(c)]
    }
  end
end