tests(amdsmi): [AILITOOLS-308] Create python mock testing suite - #10555
Open
amd-josnarlo wants to merge 1 commit into
Open
tests(amdsmi): [AILITOOLS-308] Create python mock testing suite#10555amd-josnarlo wants to merge 1 commit into
amd-josnarlo wants to merge 1 commit into
Conversation
Signed-off-by: josnarlo <joseph.narlo@amd.com>
✅ All Policy Checks Passed
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
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.
Motivation
The Python suites that stub the
amdsmipackage installed fake modules intosys.modulesand never restored them, so whichever suite ran next imported the stub and failed withImportError: cannot import name 'AmdSmiRequiredCommandException' from 'amdsmi_cli_exceptions' (unknown location). The failure surfaced in an unrelated file and depended on discovery order, and the ad-hoc fixes applied so far left the same defect in three more classes with nothing to catch the next one. This groups the stubbing suites behind a single isolation contract and adds a guard that fails when any of them leaks.Technical Details
Test harness (
tests/python/common/common.py):ModuleIsolationMixin— snapshots thesys.modulesnames listed inISOLATED_MODULESand thesys.pathentry inISOLATED_PATHduringsetUpClass, restores both intearDownClassREPO_ROOT, resolved by walking up foramdsmi_cli/+CMakeLists.txt; replaces the hard-coded".."chains that needed editing on every directory move and silentlySkipTested when off by onerun_test_dirnow exits 2 when discovery yields zero tests and no-kfilter is set, instead of reporting success on an empty suiteMock tier (
tests/python/unit/mock/{gpu,system}/):sys.modulesentries underunit/mock/; the five that exercise the real library stay atunit/{gpu,system}/ModuleIsolationMixin, removing three per-file constant names, two hand-rolled snapshot/restore shapes, and every localtearDownClassTestCliMetricPartitionClock,TestCliMetricPartitionVirtualOSandTestVcnBusyNaviFallbacknever restored theiramdsmistubs;test_cli_set_clk_limit.pyandtest_output_file_stdin.pynever removed theirsys.pathentryRegression guard (
tests/python/unit/test_module_isolation.py):sys.pathis unchangedDocs (
tests/python/README.md,docs/conceptual/test-design.md,CHANGELOG.md):unit/mock/admission rule and the isolation contract a new suite must followsys.modulesstateIssue Tracking
JIRA ID : AILITOOLS-308
Test Plan
Run unit_tests.py
Test Result
Test results return as expected