Fix tests

This commit is contained in:
Douglas Eichelberger 2024-09-22 11:10:40 -07:00
parent eed660e784
commit 0d5b56aa6a
4 changed files with 133 additions and 142 deletions

View File

@ -1,5 +0,0 @@
# typed: strict
# module OS::Linux::Cleanup
# include Kernel
# end

View File

@ -12,7 +12,7 @@ module OS
# These methods use info spewed out by sysctl. # These methods use info spewed out by sysctl.
# Look in <mach/machine.h> for decoding info. # Look in <mach/machine.h> for decoding info.
def type def type
case sysctl_int("hw.cputype") case ::Hardware::CPU.sysctl_int("hw.cputype")
when MachO::Headers::CPU_TYPE_I386 when MachO::Headers::CPU_TYPE_I386
:intel :intel
when MachO::Headers::CPU_TYPE_ARM64 when MachO::Headers::CPU_TYPE_ARM64
@ -24,9 +24,9 @@ module OS
def family def family
if ::Hardware::CPU.arm? if ::Hardware::CPU.arm?
arm_family ::Hardware::CPU.arm_family
elsif ::Hardware::CPU.intel? elsif ::Hardware::CPU.intel?
intel_family ::Hardware::CPU.intel_family
else else
:dunno :dunno
end end
@ -37,11 +37,11 @@ module OS
# conflict between what `uname` reports and the underlying `sysctl` flags, # conflict between what `uname` reports and the underlying `sysctl` flags,
# since the `sysctl` flags don't change behaviour under Rosetta 2. # since the `sysctl` flags don't change behaviour under Rosetta 2.
def in_rosetta2? def in_rosetta2?
sysctl_bool("sysctl.proc_translated") ::Hardware::CPU.sysctl_bool("sysctl.proc_translated")
end end
def features def features
@features ||= sysctl_n( @features ||= ::Hardware::CPU.sysctl_n(
"machdep.cpu.features", "machdep.cpu.features",
"machdep.cpu.extfeatures", "machdep.cpu.extfeatures",
"machdep.cpu.leaf7_features", "machdep.cpu.leaf7_features",
@ -49,9 +49,18 @@ module OS
end end
def sse4? def sse4?
sysctl_bool("hw.optional.sse4_1") ::Hardware::CPU.sysctl_bool("hw.optional.sse4_1")
end
end
end
end
end end
Hardware::CPU.singleton_class.prepend(OS::Mac::Hardware::CPU)
module Hardware
class CPU
class << self
def extmodel def extmodel
sysctl_int("machdep.cpu.extmodel") sysctl_int("machdep.cpu.extmodel")
end end
@ -94,8 +103,6 @@ module OS
sysctl_bool("kern.hv_vmm_present") sysctl_bool("kern.hv_vmm_present")
end end
private
def arm_family def arm_family
case sysctl_int("hw.cpufamily") case sysctl_int("hw.cpufamily")
when 0x2c91a47e # ARMv8.0-A (Typhoon) when 0x2c91a47e # ARMv8.0-A (Typhoon)
@ -176,6 +183,3 @@ module OS
end end
end end
end end
end
Hardware::CPU.singleton_class.prepend(OS::Mac::Hardware::CPU)

View File

@ -1,9 +0,0 @@
# typed: strict
module Hardware
class CPU
class << self
include OS::Mac::Hardware::CPU
end
end
end

View File

@ -1,5 +1,6 @@
# typed: strict # typed: strict
class Keg class Keg
# This is only true under MacOS, so can lead to true negative type errors
include OS::Mac::Keg include OS::Mac::Keg
end end