mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-10-18 10:39:05 +02:00
mscluster: accept short resource class information (#2669)
Co-authored-by: EisenbergD <dominik.eisenberg@beiersdorf.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: EisenbergD <dominik.eisenberg@beiersdorf.com>
This commit is contained in:
co-authored by
EisenbergD
Claude Opus 5.5
parent
4e6cbf864c
commit
adc9183cf6
@@ -269,3 +269,27 @@ func TestUnopenedClusterExpiredBudget(t *testing.T) {
|
||||
t.Fatal("unopened cluster was not closed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseResourceClassInfo(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
data []byte
|
||||
class uint32
|
||||
subclass uint32
|
||||
}{
|
||||
{"complete", []byte{1, 0, 0, 0, 0, 0, 0, 0x80}, 1, 0x80000000},
|
||||
// Captured from the Storage Spaces Direct Health Service resource: only
|
||||
// the class DWORD, without the subclass. WMI reports ResourceClass 0.
|
||||
{"health service", []byte{0, 0, 0, 0}, 0, 0},
|
||||
{"empty", nil, 0, 0},
|
||||
{"class only", []byte{2, 0, 0, 0}, 2, 0},
|
||||
{"truncated class", []byte{1, 0}, 0, 0},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
class, subclass := parseResourceClassInfo(test.data)
|
||||
if class != test.class || subclass != test.subclass {
|
||||
t.Fatalf("class=%#x subclass=%#x, want %#x/%#x", class, subclass, test.class, test.subclass)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user