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:
Dominik Eisenberg
2026-10-11 04:55:40 +02:00
committed by GitHub
co-authored by EisenbergD Claude Opus 5.5
parent 4e6cbf864c
commit adc9183cf6
4 changed files with 49 additions and 17 deletions
+24
View File
@@ -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)
}
})
}
}