autotuner: add unit tests for parse_flow_variables and parse_tunable_variables#4148
Open
rohithsiddi wants to merge 1 commit intoThe-OpenROAD-Project:masterfrom
Open
autotuner: add unit tests for parse_flow_variables and parse_tunable_variables#4148rohithsiddi wants to merge 1 commit intoThe-OpenROAD-Project:masterfrom
rohithsiddi wants to merge 1 commit intoThe-OpenROAD-Project:masterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces unit tests for the AutoTuner utility and the rule file generation logic. It adds tools/AutoTuner/test/test_utils.py, which is integrated into the test_autotuner.sh script, and a new test suite flow/test/test_genRuleFile.py. Review feedback highlights that test_genRuleFile.py is currently not invoked by any test scripts and should be integrated into the CI pipeline. Additionally, a workaround in the wildcard matching test points to a logic bug in genRuleFile.py that should be addressed directly.
…variables Signed-off-by: rohithsiddi <rohithsiddi7@gmail.com>
94af63b to
56dff7c
Compare
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.
Problem
Two helper functions in
tools/AutoTuner/src/autotuner/utils.pyhad explicitTODO: Tests.comments with no accompanying tests:parse_flow_variables(line 186) — parses environment variables from Tcl scripts and a generatedvars.tclfileparse_tunable_variables(line 221) — readsvariables.yamland returns the set of variables marked as tunableNote:
parse_flow_variableswas the original validation approach inparse_configbefore being superseded byparse_tunable_variablesin4458cacb. The function remains defined with an explicit TODO and is tested here for completeness.These functions are on the critical path:
parse_tunable_variablesis called byparse_configon every tuning run to validate which variables are allowed.Changes
tools/AutoTuner/test/test_utils.py— new test file covering both functionsflow/test/test_autotuner.sh— invoke the new tests before the smoke testsTest coverage
parse_flow_variablestest_parse_flow_variables_from_scripts_and_vars_tclscripts/*.tclandvars.tcl, extracts env vars via regex, normalises to uppercase, verifiesmake varscall signaturetest_parse_flow_variables_exits_when_make_failsmakereturns non-zero → prints[ERROR TUN-0018]and exitstest_parse_flow_variables_exits_when_vars_tcl_is_missingmakesucceeds butvars.tclis absent → prints[ERROR TUN-0019]and exitsparse_tunable_variablestest_parse_tunable_variables_returns_only_tunable_keystunable=1; excludestunable=0and keys with notunablefieldsubprocess.runandyaml.safe_loadare mocked at the module level so no Makefile or realvariables.yamlis required. A real temporary filesystem is used for the Tcl file parsing to exercise the actual glob/regex/file-read path.