Skip to content

Commit bbfee59

Browse files
harp-intelclaude
andauthored
refactor: table-driven DIMM format parsing with tests (#654)
* refactor: table-driven DIMM format parsing with tests Replace the cascading if-else in getDIMMParseInfo and switch in getDIMMSocketSlot with a unified dimmFormats table. Each entry holds pre-compiled regexes, match predicates, and extraction functions. - Fix regex bugs: [\d+] matched single char, not multi-digit numbers - Add descriptive dimmType names (dimmTypeInspurICX, dimmTypeQuantaGNR, etc.) - Add 66 characterization tests covering all 17 formats, ordering edge cases, and multi-digit regression cases Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * formatting Signed-off-by: Harper, Jason M <jason.m.harper@intel.com> * chore: use descriptive dimmType names in tests, remove old aliases Update all test references from dimmType0-16 to descriptive names (dimmTypeInspurICX, dimmTypeQuantaGNR, etc.) and remove the backward compatibility aliases from dimm.go. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test: add test case for nil-result path in deriveDIMMInfoOther Exercise the return nil, nil path (line 597) where the first DIMM identifies a format but a subsequent DIMM fails to match it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: prevent nil panic in getDIMMSocketSlot for matchBoth formats For formats requiring both bankLocPat and locPat to match (matchBoth), getDIMMSocketSlot now requires both matches to be non-nil before calling extractFunc. Previously, a partial match (one nil, one non-nil) would pass a nil slice to extractFunc, causing an index-out-of-range panic. This is realistic in deriveDIMMInfoOther where the format is identified from dimms[0] but applied to all subsequent DIMM rows. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Signed-off-by: Harper, Jason M <jason.m.harper@intel.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a96c172 commit bbfee59

2 files changed

Lines changed: 901 additions & 302 deletions

File tree

0 commit comments

Comments
 (0)