|
61 | 61 | allow(File).to receive(:exist?) |
62 | 62 | .with('/sys/devices/system/cpu/cpu1/topology/physical_package_id') |
63 | 63 | .and_return(true) |
| 64 | + |
| 65 | + allow(Facter::Util::FileHelper).to receive(:safe_read) |
| 66 | + .with('/sys/devices/system/cpu/cpu0/topology/physical_package_id') |
| 67 | + .and_return('0') |
| 68 | + |
| 69 | + allow(Facter::Util::FileHelper).to receive(:safe_read) |
| 70 | + .with('/sys/devices/system/cpu/cpu1/topology/physical_package_id') |
| 71 | + .and_return('1') |
64 | 72 | end |
65 | 73 |
|
66 | 74 | after do |
|
112 | 120 | allow(Dir).to receive(:entries).with('/sys/devices/system/cpu').and_return(%w[cpu0 cpu1 cpuindex]) |
113 | 121 | allow(File).to receive(:exist?).with('/sys/devices/system/cpu/cpu0/topology/physical_package_id').and_return(true) |
114 | 122 | allow(File).to receive(:exist?).with('/sys/devices/system/cpu/cpu1/topology/physical_package_id').and_return(true) |
| 123 | + allow(Facter::Util::FileHelper).to receive(:safe_read) |
| 124 | + .with('/sys/devices/system/cpu/cpu0/topology/physical_package_id') |
| 125 | + .and_return('0') |
| 126 | + |
| 127 | + allow(Facter::Util::FileHelper).to receive(:safe_read) |
| 128 | + .with('/sys/devices/system/cpu/cpu1/topology/physical_package_id') |
| 129 | + .and_return('1') |
115 | 130 | end |
116 | 131 |
|
117 | 132 | let(:speed) { 2_926_000_000 } |
|
142 | 157 | expect(result).to eq(speed) |
143 | 158 | end |
144 | 159 | end |
| 160 | + |
| 161 | + context 'when on arm64 architecture' do |
| 162 | + before do |
| 163 | + allow(Facter::Util::FileHelper).to receive(:safe_readlines) |
| 164 | + .with('/proc/cpuinfo') |
| 165 | + .and_return(load_fixture('cpuinfo_arm64').readlines) |
| 166 | + |
| 167 | + allow(Dir).to receive(:entries).with('/sys/devices/system/cpu').and_return(%w[cpu0 cpu1 cpuindex]) |
| 168 | + allow(File).to receive(:exist?).with('/sys/devices/system/cpu/cpu0/topology/physical_package_id').and_return(true) |
| 169 | + allow(File).to receive(:exist?).with('/sys/devices/system/cpu/cpu1/topology/physical_package_id').and_return(true) |
| 170 | + allow(Facter::Util::FileHelper).to receive(:safe_read) |
| 171 | + .with('/sys/devices/system/cpu/cpu0/topology/physical_package_id') |
| 172 | + .and_return('0') |
| 173 | + |
| 174 | + allow(Facter::Util::FileHelper).to receive(:safe_read) |
| 175 | + .with('/sys/devices/system/cpu/cpu1/topology/physical_package_id') |
| 176 | + .and_return('0') |
| 177 | + end |
| 178 | + |
| 179 | + let(:physical_processors) { 1 } |
| 180 | + |
| 181 | + it 'returns physical_devices_count' do |
| 182 | + result = Facter::Resolvers::Linux::Processors.resolve(:physical_count) |
| 183 | + |
| 184 | + expect(result).to eq(physical_processors) |
| 185 | + end |
| 186 | + end |
145 | 187 | end |
0 commit comments