
According to reports, XNU’s CPU family identifier previously used for the Westmere family (which Homebrew mislabels as the Arrandale family) is now being reused for one of Apple’s M1 SoC models. Resolve the conflict by splitting the list of CPU families and adding a microarchitecture check. Sources for the values: - https://github.com/Homebrew/brew/issues/7857#issuecomment-728739049 - https://en.wikipedia.org/wiki/Comparison_of_ARMv8-A_cores - Direct messages
77 lines
1.7 KiB
Ruby
77 lines
1.7 KiB
Ruby
# typed: false
|
|
# frozen_string_literal: true
|
|
|
|
require "hardware"
|
|
|
|
describe Hardware::CPU do
|
|
describe "::type" do
|
|
let(:cpu_types) {
|
|
[
|
|
:arm,
|
|
:intel,
|
|
:ppc,
|
|
:dunno,
|
|
]
|
|
}
|
|
|
|
it "returns the current CPU's type as a symbol, or :dunno if it cannot be detected" do
|
|
expect(cpu_types).to include(described_class.type)
|
|
end
|
|
end
|
|
|
|
describe "::family" do
|
|
let(:cpu_families) {
|
|
[
|
|
:arm_firestorm_icestorm,
|
|
:arm_vortex_tempest,
|
|
:arrandale,
|
|
:atom,
|
|
:broadwell,
|
|
:core,
|
|
:core2,
|
|
:dothan,
|
|
:haswell,
|
|
:icelake,
|
|
:ivybridge,
|
|
:kabylake,
|
|
:merom,
|
|
:nehalem,
|
|
:penryn,
|
|
:prescott,
|
|
:presler,
|
|
:sandybridge,
|
|
:skylake,
|
|
:westmere,
|
|
:dunno,
|
|
]
|
|
}
|
|
|
|
it "returns the current CPU's family name as a symbol, or :dunno if it cannot be detected" do
|
|
expect(cpu_families).to include described_class.family
|
|
end
|
|
|
|
context "when hw.cpufamily is 0x573b5eec on a Mac", :needs_macos do
|
|
before do
|
|
allow(described_class)
|
|
.to receive(:sysctl_int)
|
|
.with("hw.cpufamily")
|
|
.and_return(0x573b5eec)
|
|
end
|
|
|
|
it "returns :arm_firestorm_icestorm on ARM" do
|
|
allow(described_class).to receive(:arm?).and_return(true)
|
|
allow(described_class).to receive(:intel?).and_return(false)
|
|
|
|
expect(described_class.family).to eq(:arm_firestorm_icestorm)
|
|
end
|
|
|
|
it "returns :westmere on Intel" do
|
|
allow(described_class).to receive(:arm?).and_return(false)
|
|
allow(described_class).to receive(:intel?).and_return(true)
|
|
|
|
expect(described_class.family).to eq(:westmere)
|
|
end
|
|
end
|
|
end
|
|
end
|