49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package inspur
|
|
|
|
import "testing"
|
|
|
|
func TestParseAssetJSON_NVIDIAGPUModelFromPCIIDs(t *testing.T) {
|
|
raw := []byte(`{
|
|
"VersionInfo": [],
|
|
"CpuInfo": [],
|
|
"MemInfo": {"MemCommonInfo": [], "DimmInfo": []},
|
|
"HddInfo": [],
|
|
"PcieInfo": [{
|
|
"VendorId": 4318,
|
|
"DeviceId": 9019,
|
|
"BusNumber": 12,
|
|
"DeviceNumber": 0,
|
|
"FunctionNumber": 0,
|
|
"MaxLinkWidth": 16,
|
|
"MaxLinkSpeed": 5,
|
|
"NegotiatedLinkWidth": 16,
|
|
"CurrentLinkSpeed": 5,
|
|
"ClassCode": 3,
|
|
"SubClassCode": 2,
|
|
"PcieSlot": 11,
|
|
"LocString": "#CPU0_PCIE2",
|
|
"PartNumber": null,
|
|
"SerialNumber": null,
|
|
"Mac": []
|
|
}]
|
|
}`)
|
|
|
|
hw, err := ParseAssetJSON(raw)
|
|
if err != nil {
|
|
t.Fatalf("ParseAssetJSON failed: %v", err)
|
|
}
|
|
if len(hw.GPUs) != 1 {
|
|
t.Fatalf("expected 1 GPU, got %d", len(hw.GPUs))
|
|
}
|
|
if hw.GPUs[0].Model != "GH100 [H200 NVL]" {
|
|
t.Fatalf("expected model GH100 [H200 NVL], got %q", hw.GPUs[0].Model)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeGPUModel_FallbackToDeviceIDForUnknownNVIDIA(t *testing.T) {
|
|
got := normalizeGPUModel(0x10de, 0xbeef, "0xBEEF\t", 3, 2)
|
|
if got != "0xBEEF" {
|
|
t.Fatalf("expected 0xBEEF, got %q", got)
|
|
}
|
|
}
|