mbox series

[0/3] Better support for Rust integration tests

Message ID 20251112155730.646159-1-andreas.stergiopoulos@smile.fr
Headers show
Series Better support for Rust integration tests | expand

Message

Andreas STERGIOPOULOS Nov. 12, 2025, 3:57 p.m. UTC
When executing integration tests generated by cargo test, every test that needs
to somehow interact with the generated binary executables fails. This is due
to the fact that most projects in Rust either use static methods to find the
generated executable (such as going up and down the build directories) or use
the "CARGO_BIN_EXE_<package-name>" environment variable, which is exported by
cargo during compilation.

Until now, ptest-cargo copies all the binary executables produced (unit and
integration tests and binary executables) to the /usr/lib/<package>/ptest
directory, where the run-ptest script executes the tests. Unit tests succeed
but integration tests almost always fail. A side-effect of that is that the
same binary is duplicated, as it can be found both in the package installation
directory and in the corresponding ptest directory.

This patch series improves the support of said integration tests by exporting
the appropriate  environment variables during test runtime as well, so that
integration tests can access the binary executables they neeed irregardless of
the configuration of their environment.

The method proposed here is a powerful tool for Rust integration for Yocto, as
it allows the ptest-cargo framework to execute the actual installed binary
packages while at the same time it also reduces image size, by avoiding the
deduplication of the binary executables.

Andreas Stergiopoulos (3):
  ptest-cargo.bbclass: Collect only test binaries and not executables
  cargo.bbclass: Collect installation paths of executable binaries
  ptest-cargo.bbclass: Add support for CARGO_BIN_EXE_<name> environment
    variables

 meta/classes-recipe/cargo.bbclass       |  3 ++
 meta/classes-recipe/ptest-cargo.bbclass | 43 +++++++++++++++++++++++--
 2 files changed, 43 insertions(+), 3 deletions(-)