Skip to content

[AutoTuner] Add unit tests for parse_flow_variables() and parse_tunable_variables() #3964

@harsh-kumar-patwa

Description

@harsh-kumar-patwa

Summary

parse_flow_variables() and parse_tunable_variables() in tools/AutoTuner/src/autotuner/utils.py have explicit TODO: Tests. comments but currently lack any unit test coverage.

These are core parsing functions in the AutoTuner pipeline:

  • parse_flow_variables() — Invokes make vars, then extracts environment variable names from env() patterns across Tcl scripts and vars.tcl. Used to determine the set of valid flow variables.
  • parse_tunable_variables() — Reads variables.yaml and returns the set of variables marked with tunable: 1. Used to validate which variables the AutoTuner is allowed to tune.

Proposed Test Coverage

parse_tunable_variables() (7 tests)

  • Returns a non-empty set
  • Known tunable variables (e.g., CORE_UTILIZATION, CORE_AREA) are present
  • Non-tunable variables (e.g., EQUIVALENCE_CHECK, DETAILED_METRICS) are excluded
  • Correctly filters on tunable: 1 flag (with mock YAML)
  • Handles empty YAML and YAML with no tunable variables

parse_flow_variables() (6 tests)

  • Exits on Makefile failure (non-zero return code)
  • Exits when vars.tcl is not generated
  • Passes correct platform argument to make
  • Extracts env() patterns from Tcl files
  • Uppercases all variable names
  • Deduplicates variables (returns a set)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions