opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

[bazel] Refactor FPGA test_cmd setup/cleanup boilerplate

Open sasdf opened this issue 3 months ago • 1 comments

[WIP]

This PR refactors FPGA test_cmd by separating common setup (initialization, bitstream loading, bootstrapping) and cleanup logic from the core test command. Previously, modifying the test command required repeating these boilerplate steps. Now, these steps are removed from the test_cmd but can still be controlled via a set oftestopt flags in fpga_params.

  • bool testopt_clear_before_test: Call clear-bitstream before loading bitstream.
  • bool testopt_bootstrap: Bootstrap firmware before test.
  • bool testopt_clear_after_test: Call clear-bitstream after test or failure.

This PR also updates the semantic of param field in exec env rules to partially override the param from base exec env.


In addition to the improved code maintainability, this patch enables more flexible test setups, such as for ROM coverage tests where extra steps are required between bitstream loading and bootstrapping, which can now be easily configured using testopt in the execution environment.

sasdf avatar Oct 23 '25 11:10 sasdf

@cfrantz @pamaury Could you please provide a brief review of the proposed approach? I'll continue migrating the remaining tests if this method is acceptable.

sasdf avatar Oct 23 '25 11:10 sasdf

Rebased to resolve merge conflict with 28bfbc1

sasdf avatar Nov 18 '25 08:11 sasdf