feat: improve inspur parsing and pci.ids integration
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package server
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.mchus.pro/mchus/logpile/internal/models"
|
||||
)
|
||||
|
||||
func TestExtractFirmwareComponentAndModel_GPUUsesPartNumberFromParentheses(t *testing.T) {
|
||||
component, model := extractFirmwareComponentAndModel("GPU GPUSXM3 (692-2G520-0280-501)")
|
||||
@@ -21,3 +25,40 @@ func TestExtractFirmwareComponentAndModel_GPUFallbackWithoutParentheses(t *testi
|
||||
t.Fatalf("expected GPU model 692-2G520-0280-501, got %q", model)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildFirmwareEntries_IncludesGPUFirmwareFallback(t *testing.T) {
|
||||
hw := &models.HardwareConfig{
|
||||
Firmware: []models.FirmwareInfo{
|
||||
{DeviceName: "BIOS", Version: "1.0.0"},
|
||||
},
|
||||
GPUs: []models.GPU{
|
||||
{
|
||||
Slot: "#CPU0_PCIE2",
|
||||
Model: "GH100 [H200 NVL]",
|
||||
PartNumber: "699-2G530-0200-501",
|
||||
Firmware: "96.00.B7.00.02",
|
||||
},
|
||||
{
|
||||
Slot: "#CPU0_PCIE1",
|
||||
Model: "GH100 [H200 NVL]",
|
||||
PartNumber: "699-2G530-0200-501",
|
||||
Firmware: "96.00.B7.00.02",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
entries := buildFirmwareEntries(hw)
|
||||
if len(entries) != 2 {
|
||||
t.Fatalf("expected 2 deduplicated firmware entries, got %d", len(entries))
|
||||
}
|
||||
|
||||
var hasGPU bool
|
||||
for _, e := range entries {
|
||||
if e.Component == "GPU" && e.Version == "96.00.B7.00.02" {
|
||||
hasGPU = true
|
||||
}
|
||||
}
|
||||
if !hasGPU {
|
||||
t.Fatalf("expected GPU firmware entry from hardware.gpus fallback")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user