matchesGPUVendor (sat_overlay.go) matched any PCIe DeviceClass containing the substring "Controller" instead of the actual GPU classes, so a same-vendor non-GPU device (e.g. an NVIDIA-branded NIC/storage controller) with a degraded PCIe link surfaced as a pcie:gpu:<vendor> alarm on the Hardware Summary/webui. isGPUDevice (app_format.go) had the same bug via a different path: an "any NVIDIA-vendor device is a GPU" fallback that could inflate the "GPU: N x <model>" audit summary line with non-GPU companion devices (NVSwitch/NVLink bridges, etc). Both now defer to collector.IsGPUClass (exported from the previously unexported isGPUClass), the canonical exact-match classifier already used by amdgpu.go — removing the duplicated/incorrect class checks instead of reimplementing them. Also dedup two more locally-duplicated classifiers within webui (which doesn't import collector by convention): NIC-class matching (pages.go/page_topo.go) and GPU-class matching in page_validate.go now share one copy per package instead of being reimplemented per file. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
33 lines
1.0 KiB
Go
33 lines
1.0 KiB
Go
package app
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"bee/audit/internal/schema"
|
|
)
|
|
|
|
// TestFormatGPULineIgnoresNonGPUSameVendorDevice guards the bug where
|
|
// isGPUDevice treated any NVIDIA-vendor PCIe device as a GPU regardless of
|
|
// class (a fallback for "NVIDIA devices sometimes expose class values
|
|
// outside the standard GPU set"). That fallback misclassified same-vendor
|
|
// companion devices — e.g. NVSwitch/NVLink bridges, or an NVIDIA-branded NIC
|
|
// — as compute GPUs, inflating the "GPU: N x <model>" audit summary line.
|
|
func TestFormatGPULineIgnoresNonGPUSameVendorDevice(t *testing.T) {
|
|
vendor := 0x10de // collector.NvidiaVendorID
|
|
bridgeClass := "Bridge"
|
|
bridgeModel := "NVSwitch"
|
|
gpuClass := "VideoController"
|
|
gpuModel := "H100"
|
|
|
|
devices := []schema.HardwarePCIeDevice{
|
|
{DeviceClass: &bridgeClass, VendorID: &vendor, Model: &bridgeModel},
|
|
{DeviceClass: &gpuClass, VendorID: &vendor, Model: &gpuModel},
|
|
}
|
|
|
|
got := formatGPULine(devices)
|
|
want := "GPU: 1 x H100"
|
|
if got != want {
|
|
t.Fatalf("formatGPULine() = %q, want %q", got, want)
|
|
}
|
|
}
|