test(sysinfo): add unit tests for hardware and pdh_adapters#911
Open
xieofxie wants to merge 1 commit into
Open
test(sysinfo): add unit tests for hardware and pdh_adapters#911xieofxie wants to merge 1 commit into
xieofxie wants to merge 1 commit into
Conversation
Cover the architecture-agnostic, branchy logic in sysinfo/hardware.py and sysinfo/pdh_adapters.py that the hardware-conditional e2e perf tests cannot exercise on a runner lacking the relevant device: - get_vendor_id_device_id_from_pnp_id: PCI hex path plus both Qualcomm byte-packing quirks and all three error paths - CPU/GPU/NPU/RAM field mapping, GPU PCI/ACPI software-adapter filter, architecture-enum UNKNOWN fallback, and to_dict() key contract - AdapterInfo.is_npu fingerprint, _parse_multi_sz, _format_pdh_luid, adapter grouping, and NPU/GPU LUID discovery selection Extract the pure instance-string parsing out of enumerate_adapters into _build_adapters() so it is testable without the PDH ctypes plumbing. Resolves #54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #54.
Adds unit-test coverage for the two
sysinfo/modules that had none:hardware.pyandpdh_adapters.py. Scope is deliberately the architecture-agnostic, branchy logic that the existing e2e perf tests (tests/e2e/test_perf_e2e.py) cannot reach — those tests are hardware-conditional andskipwhen the relevant GPU/NPU isn't on the runner, so vendor quirks (notably the Qualcomm paths) and the NPU fingerprint branch essentially never execute there. These unit tests run deterministically on any host off constructedCimInstance/PnpDeviceobjects.test_hardware.py (18 tests)
get_vendor_id_device_id_from_pnp_id— PCI hex path (NVIDIA/AMD/Intel), both Qualcomm byte-packing quirks (ACPI\QCOM####andVEN_QCOM), and all threeValueErrorpaths. QCOM expectations were derived independently of the implementation, not asserted against it.CPU/GPU/NPU/RAMfield mapping +to_dict()camelCase key contract, the CPU architecture-enumUNKNOWN = -1fallback, the GPU PCI/ACPI software-adapter filter (drops RDP-style adapters), and byte→MiB truncation.test_pdh_adapters.py (27 tests)
AdapterInfo.is_npuengine-type fingerprint,_parse_multi_szbuffer parsing,_format_pdh_luidhi/lo 64-bit split,_build_adaptersgrouping, anddiscover_npu_luid/discover_gpu_luid(s)selection incl. the enumeration-failure →None/[]degradation. Skipped at module level off Windows (the module bindspdh.dllat import).Source change
Extracted the pure GPU-Engine instance-string parsing out of
enumerate_adaptersinto a new_build_adapters(list[str]) -> dicthelper so it is testable without the PDH ctypes sizing plumbing.enumerate_adaptersbehavior is unchanged.The real
PdhEnumObjectItemsWcalls and deep ORT-resolution paths are intentionally left to the e2e suite, which exercises them on hosts that have the device.🤖 Generated with Claude Code