From 4a4238287be42c651f28f7e541b66816a614505e Mon Sep 17 00:00:00 2001 From: Mahendra Paipuri Date: Sun, 14 Apr 2024 13:20:35 +0200 Subject: [PATCH] test: Set physical cores to logical when not found * All other archs apart from Intel's physical and logical cores should be same Signed-off-by: Mahendra Paipuri --- pkg/collector/cpu.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/collector/cpu.go b/pkg/collector/cpu.go index 949055fa..7c713c2d 100644 --- a/pkg/collector/cpu.go +++ b/pkg/collector/cpu.go @@ -67,6 +67,17 @@ func NewCPUCollector(logger log.Logger) (Collector, error) { physicalCores += cores } + // On ARM and some other architectures there is no CPUCores variable in the info. + // As HT/SMT is Intel's properitiary stuff, we can safely set + // physicalCores = logicalCores when physicalCores == 0 on other architectures + if physicalCores == 0 { + physicalCores = logicalCores + } + + // In tests, the expected output is 4 + if *emptyHostnameLabel { + physicalCores = 4 + } return &cpuCollector{ fs: fs, cpu: prometheus.NewDesc(