pw_unit_test: Add code coverage awareness This changes `test_runner.py` to be aware of the intention to run a code coverage test (any test that is executed with the automatic runner when `pw_toolchain_SANITIZERS` contains `"coverage"`). This is accomplished by adding an extra `argparse` arg called `--run-for-coverage`. When that flag is set, the test runner will set the `LLVM_PROFILE_FILE` environment variable to generate a `profraw` file next to the test binary. The `pw_test` template is also updated to check for `"coverage"` in `pw_toolchain_SANITIZERS`, and sets `--run-for-coverage` and includes the `profraw` file in outputs when in coverage mode. The `profraw` file path for the test is then propagated through `metadata.profraws` similar to `tests`. This allows a `generated_file` to be used downstream to collect all `profraw` paths. Further work is required to use these `profraw` files to actually generate coverage reports with `llvm-cov` or some other tool, but this is a first step. Tested: `pw presubmit`. Tested: Downstream project continues to build in coverage mode and succesfully outputs `profraw` files. Change-Id: I098ecceae5cba27e8f7e5a129d71f358f301340a Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/116317 Reviewed-by: Alexei Frolov <frolv@google.com> Commit-Queue: Greg Pataky <gregpataky@google.com> Reviewed-by: Ted Pudlik <tpudlik@google.com>
Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.
For more information please see our website: https://pigweed.dev/.